From 389e7663671e6dbd5644f6381d23f46f6d341339 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 31 Oct 2021 22:30:38 -0700 Subject: [PATCH] maint: prefer attribute.h in .c files MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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. --- bootstrap.conf | 1 + gl/lib/randperm.c | 3 ++- gl/lib/strnumcmp.c | 2 +- gl/lib/strnumcmp.h | 2 +- src/copy.c | 9 ++++++--- src/dd.c | 9 ++++++--- src/df.c | 12 ++++++++---- src/digest.c | 3 ++- src/env.c | 3 ++- src/expr.c | 6 ++++-- src/factor.c | 18 ++++++++++++------ src/ls.c | 20 ++++++++++++-------- src/make-prime-list.c | 10 +++++++--- src/numfmt.c | 6 ++++-- src/od.c | 3 ++- src/pathchk.c | 6 ++++-- src/pinky.c | 3 ++- src/pr.c | 3 ++- src/ptx.c | 3 ++- src/realpath.c | 3 ++- src/relpath.c | 3 ++- src/seq.c | 6 ++++-- src/sort.c | 8 ++++++-- src/stat.c | 6 ++++-- src/stty.c | 9 ++++++--- src/system.h | 19 ++++++++----------- src/tr.c | 9 ++++++--- src/uniq.c | 3 ++- src/wc.c | 6 ++++-- 29 files changed, 124 insertions(+), 70 deletions(-) diff --git a/bootstrap.conf b/bootstrap.conf index aef9ec7ded..2b66bc42d7 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -33,6 +33,7 @@ gnulib_modules=" argmatch argv-iter assert + attribute autobuild backupfile backup-rename diff --git a/gl/lib/randperm.c b/gl/lib/randperm.c index c01c296082..bce7a2daf5 100644 --- a/gl/lib/randperm.c +++ b/gl/lib/randperm.c @@ -25,6 +25,7 @@ #include #include +#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); diff --git a/gl/lib/strnumcmp.c b/gl/lib/strnumcmp.c index 4af160b335..36f7332b7d 100644 --- a/gl/lib/strnumcmp.c +++ b/gl/lib/strnumcmp.c @@ -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) { diff --git a/gl/lib/strnumcmp.h b/gl/lib/strnumcmp.h index 4deef82bde..d7f2733261 100644 --- a/gl/lib/strnumcmp.h +++ b/gl/lib/strnumcmp.h @@ -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; diff --git a/src/copy.c b/src/copy.c index a6523ed975..8c69400ec7 100644 --- a/src/copy.c +++ b/src/copy.c @@ -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); diff --git a/src/dd.c b/src/dd.c index ab9ac677d9..7ed1c828a5 100644 --- 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, '='); diff --git a/src/df.c b/src/df.c index 48025b9fca..4689493821 100644 --- 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); diff --git a/src/digest.c b/src/digest.c index 2dfc87791c..62ed795c18 100644 --- a/src/digest.c +++ b/src/digest.c @@ -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++) diff --git a/src/env.c b/src/env.c index 685c24adb6..98382a4396 100644 --- 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] == '_')) diff --git a/src/expr.c b/src/expr.c index 41185a8f87..e60fb70dc1 100644 --- a/src/expr.c +++ b/src/expr.c @@ -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 == '-'); diff --git a/src/factor.c b/src/factor.c index c2bf05526d..6586ec7571 100644 --- a/src/factor.c +++ b/src/factor.c @@ -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 diff --git a/src/ls.c b/src/ls.c index 322affef4a..992f604f45 100644 --- 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; diff --git a/src/make-prime-list.c b/src/make-prime-list.c index ef9392f222..579d3d89e8 100644 --- a/src/make-prime-list.c +++ b/src/make-prime-list.c @@ -19,9 +19,11 @@ this program. If not, see https://www.gnu.org/licenses/. */ #include +#include +#include + #include #include -#include #include #include #include @@ -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); diff --git a/src/numfmt.c b/src/numfmt.c index 35209591a7..2592985462 100644 --- a/src/numfmt.c +++ b/src/numfmt.c @@ -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; diff --git a/src/od.c b/src/od.c index 111c94935c..b4ae8490f2 100644 --- 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; diff --git a/src/pathchk.c b/src/pathchk.c index 22edc5fe3d..f74c2479e5 100644 --- a/src/pathchk.c +++ b/src/pathchk.c @@ -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; diff --git a/src/pinky.c b/src/pinky.c index 6fea94923c..a36836a336 100644 --- a/src/pinky.c +++ b/src/pinky.c @@ -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; diff --git a/src/pr.c b/src/pr.c index 8f84d0f594..667e62c161 100644 --- 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; diff --git a/src/ptx.c b/src/ptx.c index 60dedb99cd..497767fd5a 100644 --- 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 */ diff --git a/src/realpath.c b/src/realpath.c index 8e4aabfdf1..0b37935fac 100644 --- a/src/realpath.c +++ b/src/realpath.c @@ -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 '/'. */ diff --git a/src/relpath.c b/src/relpath.c index a1ec5737ee..6a5275f78d 100644 --- a/src/relpath.c +++ b/src/relpath.c @@ -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; diff --git a/src/seq.c b/src/seq.c index 5025fac929..1032b548b6 100644 --- 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); diff --git a/src/sort.c b/src/sort.c index 2024502ee6..6ac232ce28 100644 --- a/src/sort.c +++ b/src/sort.c @@ -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 < 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) { diff --git a/src/stat.c b/src/stat.c index 0c34501e34..f4fdc99845 100644 --- a/src/stat.c +++ b/src/stat.c @@ -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; diff --git a/src/stty.c b/src/stty.c index 1bf7f6328d..ac38dbb16e 100644 --- a/src/stty.c +++ b/src/stty.c @@ -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) diff --git a/src/system.h b/src/system.h index 411dc8b46c..8fc13bff0f 100644 --- a/src/system.h +++ b/src/system.h @@ -16,6 +16,8 @@ /* Include this file _after_ system headers if possible. */ +#include + #include #include @@ -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 diff --git a/src/tr.c b/src/tr.c index 801942203b..09e9aa45af 100644 --- 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, '*')) diff --git a/src/uniq.c b/src/uniq.c index 8f6e97352e..f88a2a28b5 100644 --- a/src/uniq.c +++ b/src/uniq.c @@ -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; diff --git a/src/wc.c b/src/wc.c index ec2a4e1841..cea6f294e4 100644 --- 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; -- 2.47.2