maint: avoid \] in REs
[coreutils.git] / src / system.h
blob0c5c9b9009abf3a30201b7f136fc0f14d25239a1
1 /* system-dependent definitions for coreutils
2 Copyright (C) 1989-2022 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 /* Include this file _after_ system headers if possible. */
19 #include <attribute.h>
21 #include <alloca.h>
23 #include <sys/stat.h>
25 /* Commonly used file permission combination. */
26 #define MODE_RW_UGO (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
28 #if HAVE_SYS_PARAM_H
29 # include <sys/param.h>
30 #endif
32 #include <unistd.h>
34 #include <limits.h>
36 #include "pathmax.h"
37 #ifndef PATH_MAX
38 # define PATH_MAX 8192
39 #endif
41 #include "configmake.h"
43 #include <sys/time.h>
44 #include <time.h>
46 /* Since major is a function on SVR4, we can't use 'ifndef major'. */
47 #if MAJOR_IN_MKDEV
48 # include <sys/mkdev.h>
49 # define HAVE_MAJOR
50 #endif
51 #if MAJOR_IN_SYSMACROS
52 # include <sys/sysmacros.h>
53 # define HAVE_MAJOR
54 #endif
55 #ifdef major /* Might be defined in sys/types.h. */
56 # define HAVE_MAJOR
57 #endif
59 #ifndef HAVE_MAJOR
60 # define major(dev) (((dev) >> 8) & 0xff)
61 # define minor(dev) ((dev) & 0xff)
62 # define makedev(maj, min) (((maj) << 8) | (min))
63 #endif
64 #undef HAVE_MAJOR
66 #if ! defined makedev && defined mkdev
67 # define makedev(maj, min) mkdev (maj, min)
68 #endif
70 #include <string.h>
71 #include <errno.h>
73 /* Some systems don't define this; POSIX mentions it but says it is
74 obsolete. gnulib defines it, but only on native Windows systems,
75 and there only because MSVC 10 does. */
76 #ifndef ENODATA
77 # define ENODATA (-1)
78 #endif
80 #include <stdbool.h>
81 #include <stdlib.h>
82 #include "version.h"
84 /* Exit statuses for programs like 'env' that exec other programs. */
85 enum
87 EXIT_TIMEDOUT = 124, /* Time expired before child completed. */
88 EXIT_CANCELED = 125, /* Internal error prior to exec attempt. */
89 EXIT_CANNOT_INVOKE = 126, /* Program located, but not usable. */
90 EXIT_ENOENT = 127 /* Could not find program to exec. */
93 #include "exitfail.h"
95 /* Set exit_failure to STATUS if that's not the default already. */
96 static inline void
97 initialize_exit_failure (int status)
99 if (status != EXIT_FAILURE)
100 exit_failure = status;
103 #include <fcntl.h>
104 #ifdef O_PATH
105 enum { O_PATHSEARCH = O_PATH };
106 #else
107 enum { O_PATHSEARCH = O_SEARCH };
108 #endif
110 #include <dirent.h>
111 #ifndef _D_EXACT_NAMLEN
112 # define _D_EXACT_NAMLEN(dp) strlen ((dp)->d_name)
113 #endif
115 enum
117 NOT_AN_INODE_NUMBER = 0
120 #ifdef D_INO_IN_DIRENT
121 # define D_INO(dp) (dp)->d_ino
122 #else
123 /* Some systems don't have inodes, so fake them to avoid lots of ifdefs. */
124 # define D_INO(dp) NOT_AN_INODE_NUMBER
125 #endif
127 /* include here for SIZE_MAX. */
128 #include <inttypes.h>
130 /* Redirection and wildcarding when done by the utility itself.
131 Generally a noop, but used in particular for OS/2. */
132 #ifndef initialize_main
133 # ifndef __OS2__
134 # define initialize_main(ac, av)
135 # else
136 # define initialize_main(ac, av) \
137 do { _wildcard (ac, av); _response (ac, av); } while (0)
138 # endif
139 #endif
141 #include "stat-macros.h"
143 #include "timespec.h"
145 #include <ctype.h>
147 /* ISDIGIT differs from isdigit, as follows:
148 - Its arg may be any int or unsigned int; it need not be an unsigned char
149 or EOF.
150 - It's typically faster.
151 POSIX says that only '0' through '9' are digits. Prefer ISDIGIT to
152 isdigit unless it's important to use the locale's definition
153 of 'digit' even when the host does not conform to POSIX. */
154 #define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9)
156 /* Convert a possibly-signed character to an unsigned character. This is
157 a bit safer than casting to unsigned char, since it catches some type
158 errors that the cast doesn't. */
159 static inline unsigned char to_uchar (char ch) { return ch; }
161 /* '\n' is considered a field separator with --zero-terminated. */
162 static inline bool
163 field_sep (unsigned char ch)
165 return isblank (ch) || ch == '\n';
168 #include <locale.h>
170 /* Take care of NLS matters. */
172 #include "gettext.h"
173 #if ! ENABLE_NLS
174 # undef textdomain
175 # define textdomain(Domainname) /* empty */
176 # undef bindtextdomain
177 # define bindtextdomain(Domainname, Dirname) /* empty */
178 #endif
180 #define _(msgid) gettext (msgid)
181 #define N_(msgid) msgid
183 /* Return a value that pluralizes the same way that N does, in all
184 languages we know of. */
185 static inline unsigned long int
186 select_plural (uintmax_t n)
188 /* Reduce by a power of ten, but keep it away from zero. The
189 gettext manual says 1000000 should be safe. */
190 enum { PLURAL_REDUCER = 1000000 };
191 return (n <= ULONG_MAX ? n : n % PLURAL_REDUCER + PLURAL_REDUCER);
194 #define STREQ(a, b) (strcmp (a, b) == 0)
195 #define STREQ_LEN(a, b, n) (strncmp (a, b, n) == 0)
196 #define STRPREFIX(a, b) (strncmp (a, b, strlen (b)) == 0)
198 /* Just like strncmp, but the second argument must be a literal string
199 and you don't specify the length; that comes from the literal. */
200 #define STRNCMP_LIT(s, lit) strncmp (s, "" lit "", sizeof (lit) - 1)
202 #if !HAVE_DECL_GETLOGIN
203 char *getlogin (void);
204 #endif
206 #if !HAVE_DECL_TTYNAME
207 char *ttyname (int);
208 #endif
210 #if !HAVE_DECL_GETEUID
211 uid_t geteuid (void);
212 #endif
214 #if !HAVE_DECL_GETPWUID
215 struct passwd *getpwuid (uid_t);
216 #endif
218 #if !HAVE_DECL_GETGRGID
219 struct group *getgrgid (gid_t);
220 #endif
222 /* Interix has replacements for getgr{gid,nam,ent}, that don't
223 query the domain controller for group members when not required.
224 This speeds up the calls tremendously (<1 ms vs. >3 s). */
225 /* To protect any system that could provide _nomembers functions
226 other than interix, check for HAVE_SETGROUPS, as interix is
227 one of the very few (the only?) platform that lacks it */
228 #if ! HAVE_SETGROUPS
229 # if HAVE_GETGRGID_NOMEMBERS
230 # define getgrgid(gid) getgrgid_nomembers(gid)
231 # endif
232 # if HAVE_GETGRNAM_NOMEMBERS
233 # define getgrnam(nam) getgrnam_nomembers(nam)
234 # endif
235 # if HAVE_GETGRENT_NOMEMBERS
236 # define getgrent() getgrent_nomembers()
237 # endif
238 #endif
240 #if !HAVE_DECL_GETUID
241 uid_t getuid (void);
242 #endif
244 #include "xalloc.h"
245 #include "verify.h"
247 /* This is simply a shorthand for the common case in which
248 the third argument to x2nrealloc would be 'sizeof *(P)'.
249 Ensure that sizeof *(P) is *not* 1. In that case, it'd be
250 better to use X2REALLOC, although not strictly necessary. */
251 #define X2NREALLOC(P, PN) verify_expr (sizeof *(P) != 1, \
252 x2nrealloc (P, PN, sizeof *(P)))
254 /* Using x2realloc (when appropriate) usually makes your code more
255 readable than using x2nrealloc, but it also makes it so your
256 code will malfunction if sizeof *(P) ever becomes 2 or greater.
257 So use this macro instead of using x2realloc directly. */
258 #define X2REALLOC(P, PN) verify_expr (sizeof *(P) == 1, \
259 x2realloc (P, PN))
261 #include "unlocked-io.h"
262 #include "same-inode.h"
264 #include "dirname.h"
265 #include "openat.h"
267 static inline bool
268 dot_or_dotdot (char const *file_name)
270 if (file_name[0] == '.')
272 char sep = file_name[(file_name[1] == '.') + 1];
273 return (! sep || ISSLASH (sep));
275 else
276 return false;
279 /* A wrapper for readdir so that callers don't see entries for '.' or '..'. */
280 static inline struct dirent const *
281 readdir_ignoring_dot_and_dotdot (DIR *dirp)
283 while (true)
285 struct dirent const *dp = readdir (dirp);
286 if (dp == NULL || ! dot_or_dotdot (dp->d_name))
287 return dp;
291 /* Return true if DIR is determined to be an empty directory.
292 Return false with ERRNO==0 if DIR is a non empty directory.
293 Return false if not able to determine if directory empty. */
294 static inline bool
295 is_empty_dir (int fd_cwd, char const *dir)
297 DIR *dirp;
298 struct dirent const *dp;
299 int saved_errno;
300 int fd = openat (fd_cwd, dir,
301 (O_RDONLY | O_DIRECTORY
302 | O_NOCTTY | O_NOFOLLOW | O_NONBLOCK));
304 if (fd < 0)
305 return false;
307 dirp = fdopendir (fd);
308 if (dirp == NULL)
310 close (fd);
311 return false;
314 errno = 0;
315 dp = readdir_ignoring_dot_and_dotdot (dirp);
316 saved_errno = errno;
317 closedir (dirp);
318 errno = saved_errno;
319 if (dp != NULL)
320 return false;
321 return saved_errno == 0 ? true : false;
324 /* Factor out some of the common --help and --version processing code. */
326 /* These enum values cannot possibly conflict with the option values
327 ordinarily used by commands, including CHAR_MAX + 1, etc. Avoid
328 CHAR_MIN - 1, as it may equal -1, the getopt end-of-options value. */
329 enum
331 GETOPT_HELP_CHAR = (CHAR_MIN - 2),
332 GETOPT_VERSION_CHAR = (CHAR_MIN - 3)
335 #define GETOPT_HELP_OPTION_DECL \
336 "help", no_argument, NULL, GETOPT_HELP_CHAR
337 #define GETOPT_VERSION_OPTION_DECL \
338 "version", no_argument, NULL, GETOPT_VERSION_CHAR
339 #define GETOPT_SELINUX_CONTEXT_OPTION_DECL \
340 "context", optional_argument, NULL, 'Z'
342 #define case_GETOPT_HELP_CHAR \
343 case GETOPT_HELP_CHAR: \
344 usage (EXIT_SUCCESS); \
345 break;
347 /* Program_name must be a literal string.
348 Usually it is just PROGRAM_NAME. */
349 #define USAGE_BUILTIN_WARNING \
350 _("\n" \
351 "NOTE: your shell may have its own version of %s, which usually supersedes\n" \
352 "the version described here. Please refer to your shell's documentation\n" \
353 "for details about the options it supports.\n")
355 #define HELP_OPTION_DESCRIPTION \
356 _(" --help display this help and exit\n")
357 #define VERSION_OPTION_DESCRIPTION \
358 _(" --version output version information and exit\n")
360 #include "closein.h"
361 #include "closeout.h"
363 #define emit_bug_reporting_address unused__emit_bug_reporting_address
364 #include "version-etc.h"
365 #undef emit_bug_reporting_address
367 #include "propername.h"
368 /* Define away proper_name (leaving proper_name_utf8, which affects far
369 fewer programs), since it's not worth the cost of adding ~17KB to
370 the x86_64 text size of every single program. This avoids a 40%
371 (almost ~2MB) increase in the file system space utilization for the set
372 of the 100 binaries. */
373 #define proper_name(x) (x)
375 #include "progname.h"
377 #define case_GETOPT_VERSION_CHAR(Program_name, Authors) \
378 case GETOPT_VERSION_CHAR: \
379 version_etc (stdout, Program_name, PACKAGE_NAME, Version, Authors, \
380 (char *) NULL); \
381 exit (EXIT_SUCCESS); \
382 break;
384 #include "minmax.h"
385 #include "intprops.h"
387 #ifndef SSIZE_MAX
388 # define SSIZE_MAX TYPE_MAXIMUM (ssize_t)
389 #endif
391 #ifndef OFF_T_MIN
392 # define OFF_T_MIN TYPE_MINIMUM (off_t)
393 #endif
395 #ifndef OFF_T_MAX
396 # define OFF_T_MAX TYPE_MAXIMUM (off_t)
397 #endif
399 #ifndef UID_T_MAX
400 # define UID_T_MAX TYPE_MAXIMUM (uid_t)
401 #endif
403 #ifndef GID_T_MAX
404 # define GID_T_MAX TYPE_MAXIMUM (gid_t)
405 #endif
407 #ifndef PID_T_MAX
408 # define PID_T_MAX TYPE_MAXIMUM (pid_t)
409 #endif
411 /* Use this to suppress gcc warnings. */
412 #ifdef lint
413 # define IF_LINT(Code) Code
414 #else
415 # define IF_LINT(Code) /* empty */
416 #endif
418 /* main_exit should be called only from the main function. It is
419 equivalent to 'exit'. When checking for lint it calls 'exit', to
420 pacify gcc -fsanitize=lint which would otherwise have false alarms
421 for pointers in the main function's activation record. Otherwise
422 it simply returns from 'main'; this used to be what gcc's static
423 checking preferred and may yet be again. */
424 #ifdef lint
425 # define main_exit(status) exit (status)
426 #else
427 # define main_exit(status) return status
428 #endif
430 #ifdef __GNUC__
431 # define LIKELY(cond) __builtin_expect ((cond), 1)
432 # define UNLIKELY(cond) __builtin_expect ((cond), 0)
433 #else
434 # define LIKELY(cond) (cond)
435 # define UNLIKELY(cond) (cond)
436 #endif
439 #if defined strdupa
440 # define ASSIGN_STRDUPA(DEST, S) \
441 do { DEST = strdupa (S); } while (0)
442 #else
443 # define ASSIGN_STRDUPA(DEST, S) \
444 do \
446 char const *s_ = (S); \
447 size_t len_ = strlen (s_) + 1; \
448 char *tmp_dest_ = alloca (len_); \
449 DEST = memcpy (tmp_dest_, s_, len_); \
451 while (0)
452 #endif
454 #if ! HAVE_SYNC
455 # define sync() /* empty */
456 #endif
458 /* Compute the greatest common divisor of U and V using Euclid's
459 algorithm. U and V must be nonzero. */
461 ATTRIBUTE_CONST
462 static inline size_t
463 gcd (size_t u, size_t v)
467 size_t t = u % v;
468 u = v;
469 v = t;
471 while (v);
473 return u;
476 /* Compute the least common multiple of U and V. U and V must be
477 nonzero. There is no overflow checking, so callers should not
478 specify outlandish sizes. */
480 ATTRIBUTE_CONST
481 static inline size_t
482 lcm (size_t u, size_t v)
484 return u * (v / gcd (u, v));
487 /* Return PTR, aligned upward to the next multiple of ALIGNMENT.
488 ALIGNMENT must be nonzero. The caller must arrange for ((char *)
489 PTR) through ((char *) PTR + ALIGNMENT - 1) to be addressable
490 locations. */
492 static inline void *
493 ptr_align (void const *ptr, size_t alignment)
495 char const *p0 = ptr;
496 char const *p1 = p0 + alignment - 1;
497 return (void *) (p1 - (size_t) p1 % alignment);
500 /* Return whether the buffer consists entirely of NULs.
501 Based on memeqzero in CCAN by Rusty Russell under CC0 (Public domain). */
503 ATTRIBUTE_PURE
504 static inline bool
505 is_nul (void const *buf, size_t length)
507 const unsigned char *p = buf;
508 /* Using possibly unaligned access for the first 16 bytes
509 saves about 30-40 cycles, though it is strictly undefined behavior
510 and so would need __attribute__ ((__no_sanitize_undefined__))
511 to avoid -fsanitize=undefined warnings.
512 Considering coreutils is mainly concerned with relatively
513 large buffers, we'll just use the defined behavior. */
514 #if 0 && (_STRING_ARCH_unaligned || _STRING_INLINE_unaligned)
515 unsigned long word;
516 #else
517 unsigned char word;
518 #endif
520 if (! length)
521 return true;
523 /* Check len bytes not aligned on a word. */
524 while (UNLIKELY (length & (sizeof word - 1)))
526 if (*p)
527 return false;
528 p++;
529 length--;
530 if (! length)
531 return true;
534 /* Check up to 16 bytes a word at a time. */
535 for (;;)
537 memcpy (&word, p, sizeof word);
538 if (word)
539 return false;
540 p += sizeof word;
541 length -= sizeof word;
542 if (! length)
543 return true;
544 if (UNLIKELY (length & 15) == 0)
545 break;
548 /* Now we know first 16 bytes are NUL, memcmp with self. */
549 return memcmp (buf, p, length) == 0;
552 /* If 10*Accum + Digit_val is larger than the maximum value for Type,
553 then don't update Accum and return false to indicate it would
554 overflow. Otherwise, set Accum to that new value and return true.
555 Verify at compile-time that Type is Accum's type, and that Type is
556 unsigned. Accum must be an object, so that we can take its
557 address. Accum and Digit_val may be evaluated multiple times.
559 The "Added check" below is not strictly required, but it causes GCC
560 to return a nonzero exit status instead of merely a warning
561 diagnostic, and that is more useful. */
563 #define DECIMAL_DIGIT_ACCUMULATE(Accum, Digit_val, Type) \
565 (void) (&(Accum) == (Type *) NULL), /* The type matches. */ \
566 verify_expr (! TYPE_SIGNED (Type), /* The type is unsigned. */ \
567 (((Type) -1 / 10 < (Accum) \
568 || (Type) ((Accum) * 10 + (Digit_val)) < (Accum)) \
569 ? false \
570 : (((Accum) = (Accum) * 10 + (Digit_val)), true))) \
573 static inline void
574 emit_stdin_note (void)
576 fputs (_("\n\
577 With no FILE, or when FILE is -, read standard input.\n\
578 "), stdout);
580 static inline void
581 emit_mandatory_arg_note (void)
583 fputs (_("\n\
584 Mandatory arguments to long options are mandatory for short options too.\n\
585 "), stdout);
588 static inline void
589 emit_size_note (void)
591 fputs (_("\n\
592 The SIZE argument is an integer and optional unit (example: 10K is 10*1024).\n\
593 Units are K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,... (powers of 1000).\n\
594 Binary prefixes can be used, too: KiB=K, MiB=M, and so on.\n\
595 "), stdout);
598 static inline void
599 emit_blocksize_note (char const *program)
601 printf (_("\n\
602 Display values are in units of the first available SIZE from --block-size,\n\
603 and the %s_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables.\n\
604 Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set).\n\
605 "), program);
608 static inline void
609 emit_backup_suffix_note (void)
611 fputs (_("\
613 The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.\n\
614 The version control method may be selected via the --backup option or through\n\
615 the VERSION_CONTROL environment variable. Here are the values:\n\
617 "), stdout);
618 fputs (_("\
619 none, off never make backups (even if --backup is given)\n\
620 numbered, t make numbered backups\n\
621 existing, nil numbered if numbered backups exist, simple otherwise\n\
622 simple, never always make simple backups\n\
623 "), stdout);
626 static inline void
627 emit_ancillary_info (char const *program)
629 struct infomap { char const *program; char const *node; } const infomap[] = {
630 { "[", "test invocation" },
631 { "coreutils", "Multi-call invocation" },
632 { "sha224sum", "sha2 utilities" },
633 { "sha256sum", "sha2 utilities" },
634 { "sha384sum", "sha2 utilities" },
635 { "sha512sum", "sha2 utilities" },
636 { NULL, NULL }
639 char const *node = program;
640 struct infomap const *map_prog = infomap;
642 while (map_prog->program && ! STREQ (program, map_prog->program))
643 map_prog++;
645 if (map_prog->node)
646 node = map_prog->node;
648 printf (_("\n%s online help: <%s>\n"), PACKAGE_NAME, PACKAGE_URL);
650 /* Don't output this redundant message for English locales.
651 Note we still output for 'C' so that it gets included in the man page. */
652 char const *lc_messages = setlocale (LC_MESSAGES, NULL);
653 if (lc_messages && STRNCMP_LIT (lc_messages, "en_"))
655 /* TRANSLATORS: Replace LANG_CODE in this URL with your language code
656 <https://translationproject.org/team/LANG_CODE.html> to form one of
657 the URLs at https://translationproject.org/team/. Otherwise, replace
658 the entire URL with your translation team's email address. */
659 fputs (_("Report any translation bugs to "
660 "<https://translationproject.org/team/>\n"), stdout);
662 /* .htaccess on the coreutils web site maps programs to the appropriate page,
663 however we explicitly handle "[" -> "test" here as the "[" is not
664 recognized as part of a URL by default in terminals. */
665 char const *url_program = STREQ (program, "[") ? "test" : program;
666 printf (_("Full documentation <%s%s>\n"),
667 PACKAGE_URL, url_program);
668 printf (_("or available locally via: info '(coreutils) %s%s'\n"),
669 node, node == program ? " invocation" : "");
672 /* Use a macro rather than an inline function, as this references
673 the global program_name, which causes dynamic linking issues
674 in libstdbuf.so on some systems where unused functions
675 are not removed by the linker. */
676 #define emit_try_help() \
677 do \
679 fprintf (stderr, _("Try '%s --help' for more information.\n"), \
680 program_name); \
682 while (0)
684 #include "inttostr.h"
686 static inline char *
687 timetostr (time_t t, char *buf)
689 return (TYPE_SIGNED (time_t)
690 ? imaxtostr (t, buf)
691 : umaxtostr (t, buf));
694 static inline char *
695 bad_cast (char const *s)
697 return (char *) s;
700 /* Return a boolean indicating whether SB->st_size is defined. */
701 static inline bool
702 usable_st_size (struct stat const *sb)
704 return (S_ISREG (sb->st_mode) || S_ISLNK (sb->st_mode)
705 || S_TYPEISSHM (sb) || S_TYPEISTMO (sb));
708 _Noreturn void usage (int status);
710 /* Like error(0, 0, ...), but without an implicit newline.
711 Also a noop unless the global DEV_DEBUG is set. */
712 #define devmsg(...) \
713 do \
715 if (dev_debug) \
716 fprintf (stderr, __VA_ARGS__); \
718 while (0)
720 #define emit_cycle_warning(file_name) \
721 do \
723 error (0, 0, _("\
724 WARNING: Circular directory structure.\n\
725 This almost certainly means that you have a corrupted file system.\n\
726 NOTIFY YOUR SYSTEM MANAGER.\n\
727 The following directory is part of the cycle:\n %s\n"), \
728 quotef (file_name)); \
730 while (0)
732 /* Like stpncpy, but do ensure that the result is NUL-terminated,
733 and do not NUL-pad out to LEN. I.e., when strnlen (src, len) == len,
734 this function writes a NUL byte into dest[len]. Thus, the length
735 of the destination buffer must be at least LEN + 1.
736 The DEST and SRC buffers must not overlap. */
737 static inline char *
738 stzncpy (char *restrict dest, char const *restrict src, size_t len)
740 char const *src_end = src + len;
741 while (src < src_end && *src)
742 *dest++ = *src++;
743 *dest = 0;
744 return dest;
747 #ifndef ARRAY_CARDINALITY
748 # define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array))
749 #endif
751 /* Return true if ERR is ENOTSUP or EOPNOTSUPP, otherwise false.
752 This wrapper function avoids the redundant 'or'd comparison on
753 systems like Linux for which they have the same value. It also
754 avoids the gcc warning to that effect. */
755 static inline bool
756 is_ENOTSUP (int err)
758 return err == EOPNOTSUPP || (ENOTSUP != EOPNOTSUPP && err == ENOTSUP);
762 /* How coreutils quotes filenames, to minimize use of outer quotes,
763 but also provide better support for copy and paste when used. */
764 #include "quotearg.h"
766 /* Use these to shell quote only when necessary,
767 when the quoted item is already delimited with colons. */
768 #define quotef(arg) \
769 quotearg_n_style_colon (0, shell_escape_quoting_style, arg)
770 #define quotef_n(n, arg) \
771 quotearg_n_style_colon (n, shell_escape_quoting_style, arg)
773 /* Use these when there are spaces around the file name,
774 in the error message. */
775 #define quoteaf(arg) \
776 quotearg_style (shell_escape_always_quoting_style, arg)
777 #define quoteaf_n(n, arg) \
778 quotearg_n_style (n, shell_escape_always_quoting_style, arg)