argmatch
argv-iter
assert
+ attribute
autobuild
backupfile
backup-rename
#include <stdint.h>
#include <stdlib.h>
+#include "attribute.h"
#include "count-leading-zeros.h"
#include "hash.h"
#include "verify.h"
/* 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);
/* Externally-visible name for numcompare. */
-int _GL_ATTRIBUTE_PURE
+int
strnumcmp (char const *a, char const *b,
int decimal_point, int thousands_sep)
{
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;
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)
/* 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
return false;
}
-static bool _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static bool
valid_options (const struct cp_options *co)
{
assert (co != NULL);
/* 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)
/* 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)
/* 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, '=');
/* 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;
/* 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;
/* 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);
/* 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);
/* 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++)
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] == '_'))
/* 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)
/* 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 == '-');
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)
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;
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)
{
#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;
}
}
-static uintmax_t _GL_ATTRIBUTE_CONST
+ATTRIBUTE_CONST
+static uintmax_t
isqrt2 (uintmax_t nh, uintmax_t nl)
{
unsigned int shift;
# 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
}
#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)
return 0;
}
-static unsigned int _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static unsigned int
calc_req_mask (void)
{
unsigned int mask = STATX_MODE;
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++)
/* 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
}
/* 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;
#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>
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));
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);
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;
return field_start;
}
-static bool _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static bool
include_field (uintmax_t field)
{
struct field_range_pair *p = frp;
/* 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;
/* 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 == '/')
/* 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;
/* 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;
/* 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;
/* 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 */
}
/* 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 '/'. */
/* 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;
/* 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;
}
/* 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);
/* 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;
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 == '-');
/* 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)
{
machine numbers. Comparatively slow for short strings, but asymptotically
hideously fast. */
+ATTRIBUTE_PURE
static int
numcompare (char const *a, char const *b)
{
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);
return 0;
}
-static unsigned int _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static unsigned int
format_to_mask (char const *format)
{
unsigned int mask = 0;
}
}
-static tcflag_t * _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static tcflag_t *
mode_type_flag (enum mode_type type, struct termios *mode)
{
switch (type)
{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)
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)
/* Include this file _after_ system headers if possible. */
+#include <attribute.h>
+
#include <alloca.h>
#include <sys/stat.h>
/* 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
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));
/* 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;
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
/* 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;
/* 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;
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, '*'))
/* 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;
}
/* Return non zero if a non breaking space. */
-static int _GL_ATTRIBUTE_PURE
+ATTRIBUTE_PURE
+static int
iswnbspace (wint_t wc)
{
return ! posixly_correct
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;