]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
maint: prefer attribute.h in .c files
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 1 Nov 2021 05:30:38 +0000 (22:30 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 1 Nov 2021 05:36:46 +0000 (22:36 -0700)
This will help us make the transition to C2x, where some
attributes must come at the start of function decls.
Leave the attributes alone in .h files for now,
as the Gnulib tradition is to not expose attribute.h to users.
* bootstrap.conf (gnulib_modules): Add ‘attribute’.
* gl/lib/randperm.c, src/make-prime-list.c, src/system.h:
Include attribute.h.
* gl/lib/strnumcmp.c (strnumcmp): Remove _GL_ATTRIBUTE_PURE here,
as this belongs in the .h file.
* gl/lib/strnumcmp.h (strnumcmp): Add _GL_ATTRIBUTE_PURE here.
* src/sort.c (human_numcompare, numcompare): Now ATTRIBUTE_PURE;
discovered due to strnumcmp.h change.
* gl/lib/randperm.c, src/copy.c, src/dd.c, src/df.c, src/digest.c:
* src/env.c, src/expr.c, src/factor.c, src/ls.c:
* src/make-prime-list.c, src/numfmt.c, src/od.c, src/pathchk.c:
* src/pinky.c, src/pr.c, src/ptx.c, src/realpath.c, src/relpath.c:
* src/seq.c, src/sort.c, src/stat.c, src/stty.c, src/system.h:
* src/tr.c, src/uniq.c, src/wc.c:
In .c files, crefer ATTRIBUTE_CONST to _GL_ATTRIBUTE_CONST, and
similarly for ATTRIBUTE_FORMAT and ATTRIBUTE_PURE.
* src/system.h (FALLTHROUGH): Remove; attribute.h defines it.

29 files changed:
bootstrap.conf
gl/lib/randperm.c
gl/lib/strnumcmp.c
gl/lib/strnumcmp.h
src/copy.c
src/dd.c
src/df.c
src/digest.c
src/env.c
src/expr.c
src/factor.c
src/ls.c
src/make-prime-list.c
src/numfmt.c
src/od.c
src/pathchk.c
src/pinky.c
src/pr.c
src/ptx.c
src/realpath.c
src/relpath.c
src/seq.c
src/sort.c
src/stat.c
src/stty.c
src/system.h
src/tr.c
src/uniq.c
src/wc.c

index aef9ec7ded827be818e13a897590f1539728ea94..2b66bc42d7d5786a08144eabed57d4907114bb48 100644 (file)
@@ -33,6 +33,7 @@ gnulib_modules="
   argmatch
   argv-iter
   assert
+  attribute
   autobuild
   backupfile
   backup-rename
index c01c2960822eb33691eb2aa71f264bee0e83fa19..bce7a2daf53c2e2df26df678c8fe0f0c10966c98 100644 (file)
@@ -25,6 +25,7 @@
 #include <stdint.h>
 #include <stdlib.h>
 
+#include "attribute.h"
 #include "count-leading-zeros.h"
 #include "hash.h"
 #include "verify.h"
@@ -32,7 +33,7 @@
 
 /* Return the floor of the log base 2 of N.  If N is zero, return -1.  */
 
-static int _GL_ATTRIBUTE_CONST
+ATTRIBUTE_CONST static int
 floor_lg (size_t n)
 {
   verify (SIZE_WIDTH <= ULLONG_WIDTH);
index 4af160b3358f2c48439cdf62deeb8fc2da21329a..36f7332b7d09e0e300819f0255ae5ed5302f518d 100644 (file)
@@ -23,7 +23,7 @@
 
 /* Externally-visible name for numcompare.  */
 
-int _GL_ATTRIBUTE_PURE
+int
 strnumcmp (char const *a, char const *b,
            int decimal_point, int thousands_sep)
 {
index 4deef82bde46dc3ffa61e7f04e2eb68ab9c08aad..d7f273326140307a09adcf9e9e1e9505ef1435b4 100644 (file)
@@ -1,2 +1,2 @@
 int strintcmp (char const *, char const *) _GL_ATTRIBUTE_PURE;
-int strnumcmp (char const *, char const *, int, int);
+int strnumcmp (char const *, char const *, int, int) _GL_ATTRIBUTE_PURE;
index a6523ed975d49c3ddf64d7bd13b0028a55439f48..8c69400ec76ac16d27c4ac42af0d77431d02728b 100644 (file)
@@ -648,7 +648,8 @@ lseek_copy (int src_fd, int dest_fd, char *buf, size_t buf_size,
    performance hit that's probably noticeable only on trees deeper
    than a few hundred levels.  See use of active_dir_map in remove.c  */
 
-static bool _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static bool
 is_ancestor (const struct stat *sb, const struct dir_list *ancestors)
 {
   while (ancestors != 0)
@@ -1912,7 +1913,8 @@ create_hard_link (char const *src_name, char const *dst_name,
 /* Return true if the current file should be (tried to be) dereferenced:
    either for DEREF_ALWAYS or for DEREF_COMMAND_LINE_ARGUMENTS in the case
    where the current file is a COMMAND_LINE_ARG; otherwise return false.  */
-static inline bool _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static inline bool
 should_dereference (const struct cp_options *x, bool command_line_arg)
 {
   return x->dereference == DEREF_ALWAYS
@@ -3057,7 +3059,8 @@ un_backup:
   return false;
 }
 
-static bool _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static bool
 valid_options (const struct cp_options *co)
 {
   assert (co != NULL);
index ab9ac677d9cbba743bad62845352fa49623a66f3..7ed1c828a56a07cf25273e92ed64d11ef4163593 100644 (file)
--- a/src/dd.c
+++ b/src/dd.c
@@ -535,7 +535,8 @@ maybe_close_stdout (void)
 
 /* Like the 'error' function but handle any pending newline.  */
 
-static void _GL_ATTRIBUTE_FORMAT ((__printf__, 3, 4))
+ATTRIBUTE_FORMAT ((__printf__, 3, 4))
+static void
 nl_error (int status, int errnum, char const *fmt, ...)
 {
   if (0 < progress_len)
@@ -1390,7 +1391,8 @@ iftruncate (int fd, off_t length)
 
 /* Return true if STR is of the form "PATTERN" or "PATTERNDELIM...".  */
 
-static bool _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static bool
 operand_matches (char const *str, char const *pattern, char delim)
 {
   while (*pattern)
@@ -1480,7 +1482,8 @@ parse_integer (char const *str, strtol_error *invalid)
 
 /* OPERAND is of the form "X=...".  Return true if X is NAME.  */
 
-static bool _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static bool
 operand_is (char const *operand, char const *name)
 {
   return operand_matches (operand, name, '=');
index 48025b9fcac3b3f2992e35f25b97dae595cc6272..4689493821bb553dfa5d0cd0f6a094bbb37b1a02 100644 (file)
--- a/src/df.c
+++ b/src/df.c
@@ -654,7 +654,8 @@ get_header (void)
 
 /* Is FSTYPE a type of file system that should be listed?  */
 
-static bool _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static bool
 selected_fstype (char const *fstype)
 {
   const struct fs_type_list *fsp;
@@ -669,7 +670,8 @@ selected_fstype (char const *fstype)
 
 /* Is FSTYPE a type of file system that should be omitted?  */
 
-static bool _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static bool
 excluded_fstype (char const *fstype)
 {
   const struct fs_type_list *fsp;
@@ -860,7 +862,8 @@ filter_mount_list (bool devices_only)
 /* Search a mount entry list for device id DEV.
    Return the corresponding mount entry if found or NULL if not.  */
 
-static struct mount_entry const * _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static struct mount_entry const *
 me_for_dev (dev_t dev)
 {
   struct devlist *dl = devlist_for_dev (dev);
@@ -941,7 +944,8 @@ add_uint_with_neg_flag (uintmax_t *dest, bool *dest_neg,
 /* Return true if S ends in a string that may be a 36-byte UUID,
    i.e., of the form HHHHHHHH-HHHH-HHHH-HHHH-HHHHHHHHHHHH, where
    each H is an upper or lower case hexadecimal digit.  */
-static bool _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static bool
 has_uuid_suffix (char const *s)
 {
   size_t len = strlen (s);
index 2dfc87791c06f3039f1948af239086f630898d41..62ed795c18f060717f4504b9b703174a68eccab0 100644 (file)
@@ -603,7 +603,8 @@ filename_unescape (char *s, size_t s_len)
 
 /* Return true if S is a NUL-terminated string of DIGEST_HEX_BYTES hex digits.
    Otherwise, return false.  */
-static bool _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static bool
 hex_digits (unsigned char const *s)
 {
   for (unsigned int i = 0; i < digest_hex_bytes; i++)
index 685c24adb6d878ec63ba3f63f190ce05bf46c8ec..98382a4396ae767fabd33192dc47533bfc0fae9b 100644 (file)
--- a/src/env.c
+++ b/src/env.c
@@ -197,7 +197,8 @@ unset_envvars (void)
    First letter in VARNAME must be alpha or underscore,
    rest of letters are alnum or underscore.
    Any other character is an error.  */
-static char const * _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static char const *
 scan_varname (char const *str)
 {
   if (str[1] == '{' && (c_isalpha (str[2]) || str[2] == '_'))
index 41185a8f876fefaf03d0d1ba3ed301944b909626..e60fb70dc10ac2aa7a6f53f0c7a06242eb90fa34 100644 (file)
@@ -415,7 +415,8 @@ printv (VALUE *v)
 
 /* Return true if V is a null-string or zero-number.  */
 
-static bool _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static bool
 null (VALUE *v)
 {
   switch (v->type)
@@ -446,7 +447,8 @@ null (VALUE *v)
 
 /* Return true if CP takes the form of an integer.  */
 
-static bool _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static bool
 looks_like_integer (char const *cp)
 {
   cp += (*cp == '-');
index c2bf05526d7746e73ad24839e0c0af80b3cb72b3..6586ec7571c9b003f152485bfd8235f5012463cd 100644 (file)
@@ -431,7 +431,8 @@ mod2 (uintmax_t *r1, uintmax_t a1, uintmax_t a0, uintmax_t d1, uintmax_t d0)
   return a0;
 }
 
-static uintmax_t _GL_ATTRIBUTE_CONST
+ATTRIBUTE_CONST
+static uintmax_t
 gcd_odd (uintmax_t a, uintmax_t b)
 {
   if ((b & 1) == 0)
@@ -1046,7 +1047,8 @@ mulredc2 (uintmax_t *r1p,
   return r0;
 }
 
-static uintmax_t _GL_ATTRIBUTE_CONST
+ATTRIBUTE_CONST
+static uintmax_t
 powm (uintmax_t b, uintmax_t e, uintmax_t n, uintmax_t ni, uintmax_t one)
 {
   uintmax_t y = one;
@@ -1107,7 +1109,8 @@ powm2 (uintmax_t *r1m,
   return r0;
 }
 
-static bool _GL_ATTRIBUTE_CONST
+ATTRIBUTE_CONST
+static bool
 millerrabin (uintmax_t n, uintmax_t ni, uintmax_t b, uintmax_t q,
              unsigned int k, uintmax_t one)
 {
@@ -1752,7 +1755,8 @@ mp_factor_using_pollard_rho (mpz_t n, unsigned long int a,
 #if USE_SQUFOF
 /* FIXME: Maybe better to use an iteration converging to 1/sqrt(n)?  If
    algorithm is replaced, consider also returning the remainder.  */
-static uintmax_t _GL_ATTRIBUTE_CONST
+ATTRIBUTE_CONST
+static uintmax_t
 isqrt (uintmax_t n)
 {
   uintmax_t x;
@@ -1775,7 +1779,8 @@ isqrt (uintmax_t n)
     }
 }
 
-static uintmax_t _GL_ATTRIBUTE_CONST
+ATTRIBUTE_CONST
+static uintmax_t
 isqrt2 (uintmax_t nh, uintmax_t nl)
 {
   unsigned int shift;
@@ -1827,7 +1832,8 @@ isqrt2 (uintmax_t nh, uintmax_t nl)
 # define MAGIC11 0x23b
 
 /* Return the square root if the input is a square, otherwise 0.  */
-static uintmax_t _GL_ATTRIBUTE_CONST
+ATTRIBUTE_CONST
+static uintmax_t
 is_square (uintmax_t x)
 {
   /* Uses the tests suggested by Cohen.  Excludes 99% of the non-squares before
index 322affef4a4953efb14ae03a843fa42fecea7352..992f604f451891c09752f98c24adcddfc113e9d8 100644 (file)
--- a/src/ls.c
+++ b/src/ls.c
@@ -1110,7 +1110,8 @@ get_stat_btime (struct stat const *st)
 }
 
 #if HAVE_STATX && defined STATX_INO
-static unsigned int _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static unsigned int
 time_type_to_statx (void)
 {
   switch (time_type)
@@ -1129,7 +1130,8 @@ time_type_to_statx (void)
     return 0;
 }
 
-static unsigned int _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static unsigned int
 calc_req_mask (void)
 {
   unsigned int mask = STATX_MODE;
@@ -1259,7 +1261,8 @@ fstat_for_ino (int fd, struct stat *st)
    there is no such spec.  %5b etc. do not match, so that user
    widths/flags are honored.  */
 
-static char const * _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static char const *
 first_percent_b (char const *fmt)
 {
   for (; *fmt; fmt++)
@@ -3818,25 +3821,25 @@ dirfirst_check (struct fileinfo const *a, struct fileinfo const *b,
   /* direct, non-dirfirst versions */                                  \
   static int xstrcoll_##key_name (V a, V b)                            \
   { return key_cmp_func (a, b, xstrcoll); }                            \
-  static int _GL_ATTRIBUTE_PURE strcmp_##key_name (V a, V b)           \
+  ATTRIBUTE_PURE static int strcmp_##key_name (V a, V b)               \
   { return key_cmp_func (a, b, strcmp); }                              \
                                                                         \
   /* reverse, non-dirfirst versions */                                 \
   static int rev_xstrcoll_##key_name (V a, V b)                                \
   { return key_cmp_func (b, a, xstrcoll); }                            \
-  static int _GL_ATTRIBUTE_PURE rev_strcmp_##key_name (V a, V b)       \
+  ATTRIBUTE_PURE static int rev_strcmp_##key_name (V a, V b)   \
   { return key_cmp_func (b, a, strcmp); }                              \
                                                                         \
   /* direct, dirfirst versions */                                      \
   static int xstrcoll_df_##key_name (V a, V b)                         \
   { return dirfirst_check (a, b, xstrcoll_##key_name); }               \
-  static int _GL_ATTRIBUTE_PURE strcmp_df_##key_name (V a, V b)                \
+  ATTRIBUTE_PURE static int strcmp_df_##key_name (V a, V b)            \
   { return dirfirst_check (a, b, strcmp_##key_name); }                 \
                                                                         \
   /* reverse, dirfirst versions */                                     \
   static int rev_xstrcoll_df_##key_name (V a, V b)                     \
   { return dirfirst_check (a, b, rev_xstrcoll_##key_name); }           \
-  static int _GL_ATTRIBUTE_PURE rev_strcmp_df_##key_name (V a, V b)    \
+  ATTRIBUTE_PURE static int rev_strcmp_df_##key_name (V a, V b)        \
   { return dirfirst_check (a, b, rev_strcmp_##key_name); }
 
 static int
@@ -4942,7 +4945,8 @@ print_color_indicator (const struct bin_str *ind)
 }
 
 /* Returns color indicator or NULL if none.  */
-static const struct bin_str* _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static const struct bin_str*
 get_color_indicator (const struct fileinfo *f, bool symlink_target)
 {
   enum indicator_no type;
index ef9392f222ab2b971a711b0344750aea29b5618a..579d3d89e8257f7a91bcfbc6d33ef82da14cb218 100644 (file)
@@ -19,9 +19,11 @@ this program.  If not, see https://www.gnu.org/licenses/.  */
 
 #include <config.h>
 
+#include <attribute.h>
+#include <inttypes.h>
+
 #include <limits.h>
 #include <stdint.h>
-#include <inttypes.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
@@ -54,7 +56,8 @@ struct prime
   wide_uint lim; /* floor ((wide_uint) -1 / p) */
 };
 
-static wide_uint _GL_ATTRIBUTE_CONST
+ATTRIBUTE_CONST
+static wide_uint
 binvert (wide_uint a)
 {
   wide_uint x = 0xf5397db1 >> (4*((a/2) & 0x7));
@@ -158,7 +161,8 @@ output_primes (const struct prime *primes, unsigned nprimes)
   printf ("#define FIRST_OMITTED_PRIME %u\n", p);
 }
 
-static void * _GL_ATTRIBUTE_MALLOC
+ATTRIBUTE_MALLOC
+static void *
 xalloc (size_t s)
 {
   void *p = malloc (s);
index 35209591a7a8b13a739f76a677080ee659784ead..259298546218a75d66b705ebc16d76d39c721527 100644 (file)
@@ -395,7 +395,8 @@ simple_round_nearest (long double val)
   return val < 0 ? val - 0.5 : val + 0.5;
 }
 
-static inline long double _GL_ATTRIBUTE_CONST
+ATTRIBUTE_CONST
+static inline long double
 simple_round (long double val, enum round_type t)
 {
   intmax_t rval;
@@ -1349,7 +1350,8 @@ next_field (char **line)
   return field_start;
 }
 
-static bool _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static bool
 include_field (uintmax_t field)
 {
   struct field_range_pair *p = frp;
index 111c94935c2cd9d61296149bb270364178eff008..b4ae8490f243449912c5bcf2842fe7da3e2ec8f5 100644 (file)
--- a/src/od.c
+++ b/src/od.c
@@ -1317,7 +1317,8 @@ read_block (size_t n, char *block, size_t *n_bytes_in_buffer)
 /* Return the least common multiple of the sizes associated
    with the format specs.  */
 
-static int _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static int
 get_lcm (void)
 {
   int l_c_m = 1;
index 22edc5fe3da6969fed59ea453c2986a08507b149..f74c2479e5eb362ce3b0d1d5fdbf9f52f4cfbfe2 100644 (file)
@@ -204,7 +204,8 @@ portable_chars_only (char const *file, size_t filelen)
 
 /* Return the address of the start of the next file name component in F.  */
 
-static char * _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static char *
 component_start (char *f)
 {
   while (*f == '/')
@@ -214,7 +215,8 @@ component_start (char *f)
 
 /* Return the size of the file name component F.  F must be nonempty.  */
 
-static size_t _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static size_t
 component_len (char const *f)
 {
   size_t len;
index 6fea94923c54c787763157ef638d618a23aee4f1..a36836a3361fd7065e31b87e9e93181bb2bc3384 100644 (file)
@@ -81,7 +81,8 @@ static struct option const longopts[] =
 
 /* Count and return the number of ampersands in STR.  */
 
-static size_t _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static size_t
 count_ampersands (char const *str)
 {
   size_t count = 0;
index 8f84d0f594d494f3dac64b2ce6853129f90029ae..667e62c161c3b4ef202b916413de17576d0cf543 100644 (file)
--- a/src/pr.c
+++ b/src/pr.c
@@ -781,7 +781,8 @@ integer_overflow (void)
 /* Return the number of columns that have either an open file or
    stored lines. */
 
-static unsigned int _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static unsigned int
 cols_ready_to_print (void)
 {
   COLUMN *q;
index 60dedb99cd0d1029dfefb10063917807e0ac6d67..497767fd5a34dfcaefd4c881da51e460b8c028c0 100644 (file)
--- a/src/ptx.c
+++ b/src/ptx.c
@@ -602,7 +602,8 @@ compare_occurs (const void *void_first, const void *void_second)
 
 /* True if WORD appears in TABLE.  Uses a binary search.  */
 
-static bool _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static bool
 search_table (WORD *word, WORD_TABLE *table)
 {
   ptrdiff_t lowest;            /* current lowest possible index */
index 8e4aabfdf14ecbd760f282c2462c841a9ebc86a1..0b37935fac2b1ec218a7e3838f63a54d4b6a4a1b 100644 (file)
@@ -110,7 +110,8 @@ realpath_canon (char const *fname, int can_mode)
 }
 
 /* Test whether canonical prefix is parent or match of path.  */
-static bool _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static bool
 path_prefix (char const *prefix, char const *path)
 {
   /* We already know prefix[0] and path[0] are '/'.  */
index a1ec5737eeb0f3a7a1a227ccfcb36a24092fac63..6a5275f78d5b6034307bde507a86431a0667dd3e 100644 (file)
@@ -26,7 +26,8 @@
 /* Return the length of the longest common prefix
    of canonical PATH1 and PATH2, ensuring only full path components
    are matched.  Return 0 on no match.  */
-static int _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static int
 path_common_prefix (char const *path1, char const *path2)
 {
   int i = 0;
index 5025fac9297c5c56a1fc3156237bc7b6b34f635a..1032b548b6d1e7d1fa4973343a1ac917474d17bb 100644 (file)
--- a/src/seq.c
+++ b/src/seq.c
@@ -441,7 +441,8 @@ cmp (char const *a, size_t a_len, char const *b, size_t b_len)
 
 /* Trim leading 0's from S, but if S is all 0's, leave one.
    Return a pointer to the trimmed string.  */
-static char const * _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static char const *
 trim_leading_zeros (char const *s)
 {
   char const *p = s;
@@ -558,7 +559,8 @@ seq_fast (char const *a, char const *b, uintmax_t step)
 }
 
 /* Return true if S consists of at least one digit and no non-digits.  */
-static bool _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static bool
 all_digits_p (char const *s)
 {
   size_t n = strlen (s);
index 2024502ee680ea25d06b97591723e6ccb0d14c2b..6ac232ce28c5cdae6cad2511996264a69b26cb55 100644 (file)
@@ -1653,7 +1653,8 @@ begfield (struct line const *line, struct keyfield const *key)
 /* Return the limit of (a pointer to the first character after) the field
    in LINE specified by KEY. */
 
-static char * _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static char *
 limfield (struct line const *line, struct keyfield const *key)
 {
   char *ptr = line->text, *lim = ptr + line->length - 1;
@@ -1953,7 +1954,8 @@ traverse_raw_number (char const **number)
    separators and a decimal point, but it may not contain leading blanks.
    Negative numbers get negative orders; zero numbers have a zero order.  */
 
-static int _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static int
 find_unit_order (char const *number)
 {
   bool minus_sign = (*number == '-');
@@ -1972,6 +1974,7 @@ find_unit_order (char const *number)
 /* Compare numbers A and B ending in units with SI or IEC prefixes
        <none/unknown> < K/k < M < G < T < P < E < Z < Y  */
 
+ATTRIBUTE_PURE
 static int
 human_numcompare (char const *a, char const *b)
 {
@@ -1988,6 +1991,7 @@ human_numcompare (char const *a, char const *b)
    machine numbers.  Comparatively slow for short strings, but asymptotically
    hideously fast. */
 
+ATTRIBUTE_PURE
 static int
 numcompare (char const *a, char const *b)
 {
index 0c34501e34410b9096edf377654b9ff27fe9fa24..f4fdc99845e34223aad8ce19459effb37d23f687 100644 (file)
@@ -1105,7 +1105,8 @@ print_esc_char (char c)
   putchar (c);
 }
 
-static size_t _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static size_t
 format_code_offset (char const* directive)
 {
   size_t len = strspn (directive + 1, printf_flags);
@@ -1334,7 +1335,8 @@ fmt_to_mask (char fmt)
   return 0;
 }
 
-static unsigned int _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static unsigned int
 format_to_mask (char const *format)
 {
   unsigned int mask = 0;
index 1bf7f6328d431f620acb8c41e2ea74ca82d0caf0..ac38dbb16eead4392ced2d01bd7d38db96462100 100644 (file)
@@ -1830,7 +1830,8 @@ screen_columns (void)
   }
 }
 
-static tcflag_t * _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static tcflag_t *
 mode_type_flag (enum mode_type type, struct termios *mode)
 {
   switch (type)
@@ -2207,7 +2208,8 @@ static struct speed_map const speeds[] =
   {NULL, 0, 0}
 };
 
-static speed_t _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static speed_t
 string_to_baud (char const *arg)
 {
   for (int i = 0; speeds[i].string != NULL; ++i)
@@ -2216,7 +2218,8 @@ string_to_baud (char const *arg)
   return (speed_t) -1;
 }
 
-static unsigned long int _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static unsigned long int
 baud_to_value (speed_t speed)
 {
   for (int i = 0; speeds[i].string != NULL; ++i)
index 411dc8b46c7f6c13d9ebde60af4ea432d507b776..8fc13bff0f4180d22c0cee9194eceff6325f129d 100644 (file)
@@ -16,6 +16,8 @@
 
 /* Include this file _after_ system headers if possible.  */
 
+#include <attribute.h>
+
 #include <alloca.h>
 
 #include <sys/stat.h>
@@ -464,7 +466,8 @@ enum
 /* Compute the greatest common divisor of U and V using Euclid's
    algorithm.  U and V must be nonzero.  */
 
-static inline size_t _GL_ATTRIBUTE_CONST
+ATTRIBUTE_CONST
+static inline size_t
 gcd (size_t u, size_t v)
 {
   do
@@ -482,7 +485,8 @@ gcd (size_t u, size_t v)
    nonzero.  There is no overflow checking, so callers should not
    specify outlandish sizes.  */
 
-static inline size_t _GL_ATTRIBUTE_CONST
+ATTRIBUTE_CONST
+static inline size_t
 lcm (size_t u, size_t v)
 {
   return u * (v / gcd (u, v));
@@ -504,7 +508,8 @@ ptr_align (void const *ptr, size_t alignment)
 /* Return whether the buffer consists entirely of NULs.
    Based on memeqzero in CCAN by Rusty Russell under CC0 (Public domain).  */
 
-static inline bool _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static inline bool
 is_nul (void const *buf, size_t length)
 {
   const unsigned char *p = buf;
@@ -775,11 +780,3 @@ is_ENOTSUP (int err)
   quotearg_style (shell_escape_always_quoting_style, arg)
 #define quoteaf_n(n, arg) \
   quotearg_n_style (n, shell_escape_always_quoting_style, arg)
-
-#ifndef FALLTHROUGH
-# if __GNUC__ < 7
-#  define FALLTHROUGH ((void) 0)
-# else
-#  define FALLTHROUGH __attribute__ ((__fallthrough__))
-# endif
-#endif
index 801942203bed2cad30ba663e098705632c65d9cf..09e9aa45af8a5851caffb996928b446841d3ce0a 100644 (file)
--- a/src/tr.c
+++ b/src/tr.c
@@ -363,7 +363,8 @@ is_equiv_class_member (unsigned char equiv_class, unsigned char c)
 /* Return true if the character C is a member of the
    character class CHAR_CLASS.  */
 
-static bool _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static bool
 is_char_class_member (enum Char_class char_class, unsigned char c)
 {
   int result;
@@ -539,7 +540,8 @@ unquote (char const *s, struct E_string *es)
 /* If CLASS_STR is a valid character class string, return its index
    in the global char_class_name array.  Otherwise, return CC_NO_CLASS.  */
 
-static enum Char_class _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static enum Char_class
 look_up_char_class (char const *class_str, size_t len)
 {
   enum Char_class i;
@@ -826,7 +828,8 @@ find_bracketed_repeat (const struct E_string *es, size_t start_idx,
    expression '\*[0-9]*\]', false otherwise.  The string does not
    match if any of its characters are escaped.  */
 
-static bool _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static bool
 star_digits_closebracket (const struct E_string *es, size_t idx)
 {
   if (!es_match (es, idx, '*'))
index 8f6e97352ee553f49773562d00e228c0a4516340..f88a2a28b51049c38db902eb44c89c8dfae06e6d 100644 (file)
@@ -252,7 +252,8 @@ size_opt (char const *opt, char const *msgid)
 /* Given a linebuffer LINE,
    return a pointer to the beginning of the line's field to be compared. */
 
-static char * _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static char *
 find_field (struct linebuffer const *line)
 {
   size_t count;
index ec2a4e18416ad92c1d116caa254c6664c6a34957..cea6f294e4e5d54560c1b4a1c3504a8329cc90d2 100644 (file)
--- a/src/wc.c
+++ b/src/wc.c
@@ -224,7 +224,8 @@ the following order: newline, word, character, byte, maximum line length.\n\
 }
 
 /* Return non zero if a non breaking space.  */
-static int _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static int
 iswnbspace (wint_t wc)
 {
   return ! posixly_correct
@@ -748,7 +749,8 @@ get_input_fstatus (size_t nfiles, char *const *file)
    recorded in FSTATUS.  Optimize the same special case that
    get_input_fstatus optimizes.  */
 
-static int _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static int
 compute_number_width (size_t nfiles, struct fstatus const *fstatus)
 {
   int width = 1;