# include "strnumcmp.h"
+# include "c-ctype.h"
# include <stddef.h>
# define NEGATION_SIGN '-'
# define NUMERIC_ZERO '0'
-/* ISDIGIT differs from isdigit, as follows:
- - Its arg may be any int or unsigned int; it need not be an unsigned char
- or EOF.
- - It's typically faster.
- POSIX says that only '0' through '9' are digits. Prefer ISDIGIT to
- isdigit unless it's important to use the locale's definition
- of 'digit' even when the host does not conform to POSIX. */
-# define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9)
-
-
/* Compare strings A and B containing decimal fractions < 1.
DECIMAL_POINT is the decimal point. Each string
should begin with a decimal point followed immediately by the digits
if (*a == decimal_point && *b == decimal_point)
{
while (*++a == *++b)
- if (! ISDIGIT (*a))
+ if (! c_isdigit (*a))
return 0;
- if (ISDIGIT (*a) && ISDIGIT (*b))
+ if (c_isdigit (*a) && c_isdigit (*b))
return *a - *b;
- if (ISDIGIT (*a))
+ if (c_isdigit (*a))
goto a_trailing_nonzero;
- if (ISDIGIT (*b))
+ if (c_isdigit (*b))
goto b_trailing_nonzero;
return 0;
}
a_trailing_nonzero:
while (*a == NUMERIC_ZERO)
a++;
- return ISDIGIT (*a);
+ return c_isdigit (*a);
}
else if (*b++ == decimal_point)
{
b_trailing_nonzero:
while (*b == NUMERIC_ZERO)
b++;
- return - ISDIGIT (*b);
+ return - c_isdigit (*b);
}
return 0;
}
do
tmpa = *++a;
while (tmpa == NUMERIC_ZERO);
- if (ISDIGIT (tmpa))
+ if (c_isdigit (tmpa))
return -1;
while (tmpb == NUMERIC_ZERO || tmpb == thousands_sep)
tmpb = *++b;
do
tmpb = *++b;
while (tmpb == NUMERIC_ZERO);
- return - ISDIGIT (tmpb);
+ return - c_isdigit (tmpb);
}
do
tmpb = *++b;
while (tmpb == NUMERIC_ZERO || tmpb == thousands_sep);
- while (tmpa == tmpb && ISDIGIT (tmpa))
+ while (tmpa == tmpb && c_isdigit (tmpa))
{
do
tmpa = *++a;
while (tmpb == thousands_sep);
}
- if ((tmpa == decimal_point && !ISDIGIT (tmpb))
- || (tmpb == decimal_point && !ISDIGIT (tmpa)))
+ if ((tmpa == decimal_point && !c_isdigit (tmpb))
+ || (tmpb == decimal_point && !c_isdigit (tmpa)))
return fraccompare (b, a, decimal_point);
tmp = tmpb - tmpa;
- for (log_a = 0; ISDIGIT (tmpa); ++log_a)
+ for (log_a = 0; c_isdigit (tmpa); ++log_a)
do
tmpa = *++a;
while (tmpa == thousands_sep);
- for (log_b = 0; ISDIGIT (tmpb); ++log_b)
+ for (log_b = 0; c_isdigit (tmpb); ++log_b)
do
tmpb = *++b;
while (tmpb == thousands_sep);
do
tmpb = *++b;
while (tmpb == NUMERIC_ZERO);
- if (ISDIGIT (tmpb))
+ if (c_isdigit (tmpb))
return 1;
while (tmpa == NUMERIC_ZERO || tmpa == thousands_sep)
tmpa = *++a;
do
tmpa = *++a;
while (tmpa == NUMERIC_ZERO);
- return ISDIGIT (tmpa);
+ return c_isdigit (tmpa);
}
else
{
while (tmpb == NUMERIC_ZERO || tmpb == thousands_sep)
tmpb = *++b;
- while (tmpa == tmpb && ISDIGIT (tmpa))
+ while (tmpa == tmpb && c_isdigit (tmpa))
{
do
tmpa = *++a;
while (tmpb == thousands_sep);
}
- if ((tmpa == decimal_point && !ISDIGIT (tmpb))
- || (tmpb == decimal_point && !ISDIGIT (tmpa)))
+ if ((tmpa == decimal_point && !c_isdigit (tmpb))
+ || (tmpb == decimal_point && !c_isdigit (tmpa)))
return fraccompare (a, b, decimal_point);
tmp = tmpa - tmpb;
- for (log_a = 0; ISDIGIT (tmpa); ++log_a)
+ for (log_a = 0; c_isdigit (tmpa); ++log_a)
do
tmpa = *++a;
while (tmpa == thousands_sep);
- for (log_b = 0; ISDIGIT (tmpb); ++log_b)
+ for (log_b = 0; c_isdigit (tmpb); ++log_b)
do
tmpb = *++b;
while (tmpb == thousands_sep);
lib/strnumcmp-in.h
Depends-on:
+c-ctype
inline
stddef
#include <regex.h>
+#include "c-ctype.h"
#include "fd-reopen.h"
#include "quote.h"
#include "safe-read.h"
percent = true;
int flags;
f += get_format_flags (f, &flags);
- while (ISDIGIT (*f))
+ while (c_isdigit (*f))
f++;
if (*f == '.')
- while (ISDIGIT (*++f))
+ while (c_isdigit (*++f))
continue;
check_format_conv_type (f, flags);
}
#include <stdio.h>
#include <sys/types.h>
#include "system.h"
+#include "c-ctype.h"
#include "fadvise.h"
#include "quote.h"
increment_tabval = true;
extend_tabval = false;
}
- else if (ISDIGIT (*stops))
+ else if (c_isdigit (*stops))
{
if (!have_tabval)
{
#include <gmp.h>
#include <regex.h>
+#include "c-ctype.h"
#include "long-options.h"
#include "mcel.h"
#include "strnumcmp.h"
cp += (*cp == '-');
do
- if (! ISDIGIT (*cp))
+ if (! c_isdigit (*cp))
return false;
while (*++cp);
#include "system.h"
#include "assure.h"
+#include "c-ctype.h"
#include "full-write.h"
#include "quote.h"
#include "readtokens.h"
if (c == 0)
break;
- if (UNLIKELY (!ISDIGIT (c)))
+ if (UNLIKELY (!c_isdigit (c)))
{
err = LONGINT_INVALID;
break;
prefix = "";
prefix_length = prefix_lead_space = prefix_full_length = 0;
- if (argc > 1 && argv[1][0] == '-' && ISDIGIT (argv[1][1]))
+ if (argc > 1 && argv[1][0] == '-' && c_isdigit (argv[1][1]))
{
/* Old option syntax; a dash followed by one or more digits. */
max_width_option = argv[1] + 1;
switch (optchar)
{
default:
- if (ISDIGIT (optchar))
+ if (c_isdigit (optchar))
error (0, 0, _("invalid option -- %c; -WIDTH is recognized\
only when it is the first\noption; use -w N instead"),
optchar);
#include "system.h"
#include "assure.h"
+#include "c-ctype.h"
#include "full-read.h"
#include "safe-read.h"
#include "stat-size.h"
line_end = '\n';
- if (1 < argc && argv[1][0] == '-' && ISDIGIT (argv[1][1]))
+ if (1 < argc && argv[1][0] == '-' && c_isdigit (argv[1][1]))
{
char *a = argv[1];
char *n_string = ++a;
/* Old option syntax; a dash, one or more digits, and one or
more option letters. Move past the number. */
do ++a;
- while (ISDIGIT (*a));
+ while (c_isdigit (*a));
/* Pointer to the byte after the last digit. */
end_n_string = a;
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
default:
- if (ISDIGIT (c))
+ if (c_isdigit (c))
error (0, 0, _("invalid trailing option -- %c"), c);
usage (EXIT_FAILURE);
}
#include <signal.h>
#include "system.h"
+#include "c-ctype.h"
#include "sig2str.h"
#include "operand2sig.h"
#include "quote.h"
signum = operand2sig (*argv);
if (signum < 0)
status = EXIT_FAILURE;
- else if (ISDIGIT (**argv))
+ else if (c_isdigit (**argv))
{
if (sig2str (signum, signame) == 0)
puts (signame);
int fill = max_mon_width - mon_width[i];
if (ABFORMAT_SIZE - mon_len[i] <= fill)
return false;
- bool align_left = !isdigit (to_uchar (abmon[i][0]));
+ bool align_left = !c_isdigit (abmon[i][0]);
int fill_offset;
if (align_left)
fill_offset = mon_len[i];
# include <sys/resource.h>
#endif
+#include "c-ctype.h"
#include "quote.h"
#include "xstrtol.h"
{
char const *s = argv[i];
- if (s[0] == '-' && ISDIGIT (s[1 + (s[1] == '-' || s[1] == '+')]))
+ if (s[0] == '-' && c_isdigit (s[1 + (s[1] == '-' || s[1] == '+')]))
{
adjustment_given = s + 1;
++i;
#include "system.h"
#include "argmatch.h"
#include "assure.h"
+#include "c-ctype.h"
#include "ftoastr.h"
#include "quote.h"
#include "stat-size.h"
{
int sum;
- for (sum = 0; ISDIGIT (*s); s++)
+ for (sum = 0; c_isdigit (*s); s++)
if (ckd_mul (&sum, sum, 10) || ckd_add (&sum, sum, *s - '0'))
return false;
*p = s;
case 2:
if ((traditional || argv[optind + 1][0] == '+'
- || ISDIGIT (argv[optind + 1][0]))
+ || c_isdigit (argv[optind + 1][0]))
&& parse_old_offset (argv[optind + 1], &o2))
{
if (traditional && parse_old_offset (argv[optind], &o1))
#include <sys/wait.h>
#include "system.h"
+#include "c-ctype.h"
#include "quote.h"
#include "sig2str.h"
#include "operand2sig.h"
{
int signum;
- if (ISDIGIT (*operand))
+ if (c_isdigit (*operand))
{
/* Note we don't put a limit on the maximum value passed,
because we're checking shell $? values here, and ksh for
#include <getopt.h>
#include <sys/types.h>
#include "system.h"
+#include "c-ctype.h"
#include "fadvise.h"
#include "hard-locale.h"
#include "mbswidth.h"
if (c == -1)
break;
- if (ISDIGIT (c))
+ if (c_isdigit (c))
{
/* Accumulate column-count digits specified via old-style options. */
if (n_digits + 1 >= n_alloc)
usage (EXIT_FAILURE);
}
- if (!ISDIGIT (*arg))
+ if (!c_isdigit (*arg))
*character = *arg++;
if (*arg)
{
have_field_width = true;
}
else
- while (ISDIGIT (*ac.f))
+ while (c_isdigit (*ac.f))
*pdirec++ = *ac.f++;
if (*ac.f == '.')
{
have_precision = true;
}
else
- while (ISDIGIT (*ac.f))
+ while (c_isdigit (*ac.f))
*pdirec++ = *ac.f++;
}
#include <sys/types.h>
#include "system.h"
+#include "c-ctype.h"
#include "cl-strtod.h"
#include "full-write.h"
#include "quote.h"
ret.width += (fraction_len == 0 /* #. -> # */
? -1
: (decimal_point == arg /* .# -> 0.# */
- || ! ISDIGIT (decimal_point[-1]))); /* -.# -> 0.# */
+ || ! c_isdigit (decimal_point[-1]))); /* -.# -> 0.# */
}
char const *e = strchr (arg, 'e');
if (! e)
all_digits_p (char const *s)
{
size_t n = strlen (s);
- return ISDIGIT (s[0]) && n == strspn (s, "0123456789");
+ return c_isdigit (s[0]) && n == strspn (s, "0123456789");
}
int
while (optind < argc)
{
if (argv[optind][0] == '-'
- && ((optc = argv[optind][1]) == '.' || ISDIGIT (optc)))
+ && ((optc = argv[optind][1]) == '.' || c_isdigit (optc)))
{
/* means negative number */
break;
#include "system.h"
#include <ctype.h>
+#include "c-ctype.h"
#include "quote.h"
#include "set-fields.h"
lhs_specified = false;
rhs_specified = false;
}
- else if (ISDIGIT (*fieldstr))
+ else if (c_isdigit (*fieldstr))
{
/* Record beginning of digit string, in case we have to
complain about it. */
#include "system.h"
#include "argmatch.h"
#include "assure.h"
+#include "c-ctype.h"
#include "fadvise.h"
#include "filevercmp.h"
#include "flexmember.h"
enum strtol_error e = xstrtoumax (s, &suffix, 10, &n, "EgGkKmMPQRtTYZ");
/* The default unit is KiB. */
- if (e == LONGINT_OK && ISDIGIT (suffix[-1]))
+ if (e == LONGINT_OK && c_isdigit (suffix[-1]))
{
if (n <= UINTMAX_MAX / 1024)
n *= 1024;
}
/* A 'b' suffix means bytes; a '%' suffix means percent of memory. */
- if (e == LONGINT_INVALID_SUFFIX_CHAR && ISDIGIT (suffix[-1]) && ! suffix[1])
+ if (e == LONGINT_INVALID_SUFFIX_CHAR && c_isdigit (suffix[-1]) && ! suffix[1])
switch (suffix[0])
{
case 'b':
to be lacking in units.
FIXME: add support for multibyte thousands_sep and decimal_point. */
- while (ISDIGIT (ch = *p++))
+ while (c_isdigit (ch = *p++))
{
if (max_digit < ch)
max_digit = ch;
}
if (ch == decimal_point)
- while (ISDIGIT (ch = *p++))
+ while (c_isdigit (ch = *p++))
if (max_digit < ch)
max_digit = ch;
if (optarg[0] == '+')
{
bool minus_pos_usage = (optind != argc && argv[optind][0] == '-'
- && ISDIGIT (argv[optind][1]));
+ && c_isdigit (argv[optind][1]));
traditional_usage |= minus_pos_usage && !posixly_correct;
if (traditional_usage)
{
if (optarg == argv[optind - 1])
{
char const *p;
- for (p = optarg; ISDIGIT (*p); p++)
+ for (p = optarg; c_isdigit (*p); p++)
continue;
optind -= (*p != '\0');
}
sec_prefix_len = dot - pformat;
pformat[prefix_len] = '\0';
- if (ISDIGIT (dot[1]))
+ if (c_isdigit (dot[1]))
{
long int lprec = strtol (dot + 1, nullptr, 10);
precision = (lprec <= INT_MAX ? lprec : INT_MAX);
precision = 9;
}
- if (precision && ISDIGIT (dot[-1]))
+ if (precision && c_isdigit (dot[-1]))
{
/* If a nontrivial width is given, subtract the width of the
decimal point and PRECISION digits that will be output
do
--p;
- while (ISDIGIT (p[-1]));
+ while (c_isdigit (p[-1]));
long int lwidth = strtol (p, nullptr, 10);
width = (lwidth <= INT_MAX ? lwidth : INT_MAX);
#include "timespec.h"
-/* ISDIGIT differs from isdigit, as follows:
- - Its arg may be any int or unsigned int; it need not be an unsigned char
- or EOF.
- - It's typically faster.
- POSIX says that only '0' through '9' are digits. Prefer ISDIGIT to
- isdigit unless it's important to use the locale's definition
- of 'digit' even when the host does not conform to POSIX. */
-#define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9)
-
/* Convert a possibly-signed character to an unsigned character. This is
a bit safer than casting to unsigned char, since it catches some type
errors that the cast doesn't. */
#include "system.h"
#include "argmatch.h"
#include "assure.h"
+#include "c-ctype.h"
#include "cl-strtod.h"
#include "fcntl--.h"
#include "iopoll.h"
}
n_string = p;
- while (ISDIGIT (*p))
+ while (c_isdigit (*p))
p++;
n_string_end = p;
#include "system.h"
#include "assure.h"
+#include "c-ctype.h"
#include "quote.h"
#include "stat-time.h"
#include "strnumcmp.h"
p += (*p == '-');
}
- if (ISDIGIT (*p++))
+ if (c_isdigit (*p++))
{
- while (ISDIGIT (*p))
+ while (c_isdigit (*p))
p++;
while (isspace (to_uchar (*p)))
p++;
#include "system.h"
#include "assure.h"
+#include "c-ctype.h"
#include "fadvise.h"
#include "quote.h"
#include "safe-read.h"
result = iscntrl (c);
break;
case CC_DIGIT:
- result = isdigit (c);
+ result = c_isdigit (c);
break;
case CC_GRAPH:
result = isgraph (c);
result = isupper (c);
break;
case CC_XDIGIT:
- result = isxdigit (c);
+ result = c_isxdigit (c);
break;
default:
unreachable ();
return false;
for (size_t i = idx + 1; i < es->len; i++)
- if (!ISDIGIT (es->s[i]) || es->escaped[i])
+ if (!c_isdigit (es->s[i]) || es->escaped[i])
return es_match (es, i, ']');
return false;
}