1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-05 22:20:24 -08:00

Update from Gnulib by running admin/merge-gnulib

This commit is contained in:
Paul Eggert 2025-11-20 08:46:44 -08:00
parent cada1c3192
commit 2cc6c81278
27 changed files with 249 additions and 269 deletions

View file

@ -161,9 +161,7 @@ acl_default_nontrivial (acl_t acl)
int
acl_nontrivial (int count, aclent_t *entries)
{
int i;
for (i = 0; i < count; i++)
for (int i = 0; i < count; i++)
{
aclent_t *ace = &entries[i];
@ -192,8 +190,6 @@ acl_nontrivial (int count, aclent_t *entries)
int
acl_ace_nontrivial (int count, ace_t *entries)
{
int i;
/* The flags in the ace_t structure changed in a binary incompatible way
when ACL_NO_TRIVIAL etc. were introduced in <sys/acl.h> version 1.15.
How to distinguish the two conventions at runtime?
@ -202,7 +198,7 @@ acl_ace_nontrivial (int count, ace_t *entries)
convention, these values are not used. */
int old_convention = 0;
for (i = 0; i < count; i++)
for (int i = 0; i < count; i++)
if (entries[i].a_flags & (OLD_ACE_OWNER | OLD_ACE_GROUP | OLD_ACE_OTHER))
{
old_convention = 1;
@ -211,7 +207,7 @@ acl_ace_nontrivial (int count, ace_t *entries)
if (old_convention)
/* Running on Solaris 10. */
for (i = 0; i < count; i++)
for (int i = 0; i < count; i++)
{
ace_t *ace = &entries[i];
@ -238,7 +234,7 @@ acl_ace_nontrivial (int count, ace_t *entries)
0 /* everyone@ allow */
};
for (i = 0; i < count; i++)
for (int i = 0; i < count; i++)
{
ace_t *ace = &entries[i];
unsigned int index1;
@ -374,12 +370,10 @@ acl_ace_nontrivial (int count, ace_t *entries)
int
acl_nontrivial (int count, struct acl_entry *entries)
{
int i;
if (count > 3)
return 1;
for (i = 0; i < count; i++)
for (int i = 0; i < count; i++)
{
struct acl_entry *ace = &entries[i];
@ -396,9 +390,7 @@ acl_nontrivial (int count, struct acl_entry *entries)
int
aclv_nontrivial (int count, struct acl *entries)
{
int i;
for (i = 0; i < count; i++)
for (int i = 0; i < count; i++)
{
struct acl *ace = &entries[i];
@ -424,10 +416,8 @@ int
acl_nontrivial (struct acl *a)
{
/* The normal way to iterate through an ACL is like this:
struct acl_entry *ace;
for (ace = a->acl_ext; ace != acl_last (a); ace = acl_nxt (ace))
for (struct acl_entry *ace = a->acl_ext; ace != acl_last (a); ace = acl_nxt (ace))
{
struct ace_id *aei;
switch (ace->ace_type)
{
case ACC_PERMIT:
@ -435,7 +425,7 @@ acl_nontrivial (struct acl *a)
case ACC_SPECIFY:
...;
}
for (aei = ace->ace_id; aei != id_last (ace); aei = id_nxt (aei))
for (struct ace_id *aei = ace->ace_id; aei != id_last (ace); aei = id_nxt (aei))
...
}
*/
@ -453,9 +443,8 @@ acl_nfs4_nontrivial (nfs4_acl_int_t *a)
return (a->aclEntryN > 0 ? 1 : 0);
# else
int count = a->aclEntryN;
int i;
for (i = 0; i < count; i++)
for (int i = 0; i < count; i++)
{
nfs4_ace_int_t *ace = &a->aclEntry[i];
@ -484,9 +473,7 @@ acl_nfs4_nontrivial (nfs4_acl_int_t *a)
int
acl_nontrivial (int count, struct acl *entries)
{
int i;
for (i = 0; i < count; i++)
for (int i = 0; i < count; i++)
{
struct acl *ace = &entries[i];

View file

@ -286,160 +286,156 @@ diag (OFFSET xoff, OFFSET xlim, OFFSET yoff, OFFSET ylim, bool find_minimal,
}
}
if (find_minimal)
continue;
if (!find_minimal)
{
#ifdef USE_HEURISTIC
bool heuristic = ctxt->heuristic;
bool heuristic = ctxt->heuristic;
#else
bool heuristic = false;
bool heuristic = false;
#endif
/* Heuristic: check occasionally for a diagonal that has made lots
of progress compared with the edit distance. If we have any
such, find the one that has made the most progress and return it
as if it had succeeded.
/* Heuristic: check occasionally for a diagonal that has made lots
of progress compared with the edit distance. If we have any
such, find the one that has made the most progress and return it
as if it had succeeded.
With this heuristic, for vectors with a constant small density
of changes, the algorithm is linear in the vector size. */
With this heuristic, for vectors with a constant small density
of changes, the algorithm is linear in the vector size. */
if (200 < c && big_snake && heuristic)
{
{
OFFSET best = 0;
for (d = fmax; d >= fmin; d -= 2)
if (200 < c && big_snake && heuristic)
{
{
OFFSET dd = d - fmid;
OFFSET x = fd[d];
OFFSET y = x - d;
OFFSET v = (x - xoff) * 2 - dd;
OFFSET best = 0;
if (v > 12 * (c + (dd < 0 ? -dd : dd)))
for (d = fmax; d >= fmin; d -= 2)
{
if (v > best
&& xoff + SNAKE_LIMIT <= x && x < xlim
&& yoff + SNAKE_LIMIT <= y && y < ylim)
{
/* We have a good enough best diagonal; now insist
that it end with a significant snake. */
int k;
OFFSET dd = d - fmid;
OFFSET x = fd[d];
OFFSET y = x - d;
OFFSET v = (x - xoff) * 2 - dd;
for (k = 1; XREF_YREF_EQUAL (x - k, y - k); k++)
if (k == SNAKE_LIMIT)
{
best = v;
part->xmid = x;
part->ymid = y;
break;
}
if (v > 12 * (c + (dd < 0 ? -dd : dd)))
{
if (v > best
&& xoff + SNAKE_LIMIT <= x && x < xlim
&& yoff + SNAKE_LIMIT <= y && y < ylim)
{
/* We have a good enough best diagonal; now insist
that it end with a significant snake. */
for (int k = 1; XREF_YREF_EQUAL (x - k, y - k); k++)
if (k == SNAKE_LIMIT)
{
best = v;
part->xmid = x;
part->ymid = y;
break;
}
}
}
}
}
if (best > 0)
{
part->lo_minimal = true;
part->hi_minimal = false;
return;
}
}
{
OFFSET best = 0;
for (d = bmax; d >= bmin; d -= 2)
{
OFFSET dd = d - bmid;
OFFSET x = bd[d];
OFFSET y = x - d;
OFFSET v = (xlim - x) * 2 + dd;
if (v > 12 * (c + (dd < 0 ? -dd : dd)))
if (best > 0)
{
if (v > best
&& xoff < x && x <= xlim - SNAKE_LIMIT
&& yoff < y && y <= ylim - SNAKE_LIMIT)
{
/* We have a good enough best diagonal; now insist
that it end with a significant snake. */
int k;
for (k = 0; XREF_YREF_EQUAL (x + k, y + k); k++)
if (k == SNAKE_LIMIT - 1)
{
best = v;
part->xmid = x;
part->ymid = y;
break;
}
}
part->lo_minimal = true;
part->hi_minimal = false;
return;
}
}
if (best > 0)
{
part->lo_minimal = false;
part->hi_minimal = true;
return;
OFFSET best = 0;
for (d = bmax; d >= bmin; d -= 2)
{
OFFSET dd = d - bmid;
OFFSET x = bd[d];
OFFSET y = x - d;
OFFSET v = (xlim - x) * 2 + dd;
if (v > 12 * (c + (dd < 0 ? -dd : dd)))
{
if (v > best
&& xoff < x && x <= xlim - SNAKE_LIMIT
&& yoff < y && y <= ylim - SNAKE_LIMIT)
{
/* We have a good enough best diagonal; now insist
that it end with a significant snake. */
for (int k = 0; XREF_YREF_EQUAL (x + k, y + k); k++)
if (k == SNAKE_LIMIT - 1)
{
best = v;
part->xmid = x;
part->ymid = y;
break;
}
}
}
}
if (best > 0)
{
part->lo_minimal = false;
part->hi_minimal = true;
return;
}
}
}
}
/* Heuristic: if we've gone well beyond the call of duty, give up
and report halfway between our best results so far. */
if (c >= ctxt->too_expensive)
{
/* Find forward diagonal that maximizes X + Y. */
OFFSET fxybest = -1, fxbest;
for (d = fmax; d >= fmin; d -= 2)
{
OFFSET x = MIN (fd[d], xlim);
OFFSET y = x - d;
if (ylim < y)
{
x = ylim + d;
y = ylim;
}
if (fxybest < x + y)
{
fxybest = x + y;
fxbest = x;
}
}
/* Find backward diagonal that minimizes X + Y. */
OFFSET bxybest = OFFSET_MAX, bxbest;
for (d = bmax; d >= bmin; d -= 2)
/* Heuristic: if we've gone well beyond the call of duty, give up
and report halfway between our best results so far. */
if (c >= ctxt->too_expensive)
{
OFFSET x = MAX (xoff, bd[d]);
OFFSET y = x - d;
if (y < yoff)
/* Find forward diagonal that maximizes X + Y. */
OFFSET fxybest = -1, fxbest;
for (d = fmax; d >= fmin; d -= 2)
{
x = yoff + d;
y = yoff;
OFFSET x = MIN (fd[d], xlim);
OFFSET y = x - d;
if (ylim < y)
{
x = ylim + d;
y = ylim;
}
if (fxybest < x + y)
{
fxybest = x + y;
fxbest = x;
}
}
if (x + y < bxybest)
{
bxybest = x + y;
bxbest = x;
}
}
/* Use the better of the two diagonals. */
if ((xlim + ylim) - bxybest < fxybest - (xoff + yoff))
{
part->xmid = fxbest;
part->ymid = fxybest - fxbest;
part->lo_minimal = true;
part->hi_minimal = false;
/* Find backward diagonal that minimizes X + Y. */
OFFSET bxybest = OFFSET_MAX, bxbest;
for (d = bmax; d >= bmin; d -= 2)
{
OFFSET x = MAX (xoff, bd[d]);
OFFSET y = x - d;
if (y < yoff)
{
x = yoff + d;
y = yoff;
}
if (x + y < bxybest)
{
bxybest = x + y;
bxbest = x;
}
}
/* Use the better of the two diagonals. */
if ((xlim + ylim) - bxybest < fxybest - (xoff + yoff))
{
part->xmid = fxbest;
part->ymid = fxybest - fxbest;
part->lo_minimal = true;
part->hi_minimal = false;
}
else
{
part->xmid = bxbest;
part->ymid = bxybest - bxbest;
part->lo_minimal = false;
part->hi_minimal = true;
}
return;
}
else
{
part->xmid = bxbest;
part->ymid = bxybest - bxbest;
part->lo_minimal = false;
part->hi_minimal = true;
}
return;
}
}
#undef XREF_YREF_EQUAL

View file

@ -146,9 +146,8 @@ dupfd (int oldfd, int newfd, int flags)
/* Close the previous fds that turned out to be too small. */
{
int saved_errno = errno;
unsigned int duplicated_fd;
for (duplicated_fd = 0;
for (unsigned int duplicated_fd = 0;
duplicated_fd < fds_to_close_bound * CHAR_BIT;
duplicated_fd++)
if ((fds_to_close[duplicated_fd / CHAR_BIT]

View file

@ -495,6 +495,15 @@ _GL_WARN_ON_USE (openat2, "openat2 is not portable - "
# define AT_NO_AUTOMOUNT 0
#endif
/* errno when openat+O_NOFOLLOW fails because the file is a symlink. */
#if defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__
# define _GL_OPENAT_ESYMLINK EMLINK
#elif defined __NetBSD__
# define _GL_OPENAT_ESYMLINK EFTYPE
#else
# define _GL_OPENAT_ESYMLINK ELOOP
#endif
#endif /* _@GUARD_PREFIX@_FCNTL_H */
#endif /* _@GUARD_PREFIX@_FCNTL_H */
#endif

View file

@ -660,9 +660,9 @@ fdfile_has_aclinfo (MAYBE_UNUSED int fd,
(aclent_t *) malloc (alloc * sizeof (aclent_t));
if (entries == NULL)
return -1;
continue;
}
break;
else
break;
}
if (count < 0)
{
@ -732,9 +732,9 @@ fdfile_has_aclinfo (MAYBE_UNUSED int fd,
entries = malloced = (ace_t *) malloc (alloc * sizeof (ace_t));
if (entries == NULL)
return -1;
continue;
}
break;
else
break;
}
if (count < 0)
{

View file

@ -124,7 +124,6 @@ FTOASTR (char *buf, size_t bufsize, int flags, int width, FLOAT x)
PROMOTED_FLOAT promoted_x = x;
char format[sizeof "%-+ 0*.*Lg"];
FLOAT abs_x = x < 0 ? -x : x;
int prec;
char *p = format;
*p++ = '%';
@ -142,7 +141,7 @@ FTOASTR (char *buf, size_t bufsize, int flags, int width, FLOAT x)
*p++ = flags & FTOASTR_UPPER_E ? 'G' : 'g';
*p = '\0';
for (prec = abs_x < FLOAT_MIN ? 1 : FLOAT_DIG; ; prec++)
for (int prec = abs_x < FLOAT_MIN ? 1 : FLOAT_DIG; ; prec++)
{
int n = snprintf (buf, bufsize, format, width, prec, promoted_x);
if (n < 0

View file

@ -61,13 +61,10 @@ getdtablesize (void)
{
/* We are looking for the number N such that the valid file descriptors
are 0..N-1. It can be obtained through a loop as follows:
{
int fd;
for (fd = 3; fd < 65536; fd++)
if (dup2 (0, fd) == -1)
break;
return fd;
}
for (int fd = 3; fd < 65536; fd++)
if (dup2 (0, fd) == -1)
break;
return fd;
On Windows XP, the result is 2048.
The drawback of this loop is that it allocates memory for a libc
internal array that is never freed.

View file

@ -623,11 +623,11 @@ getloadavg (double loadavg[], int nelem)
struct proc_summary proc_sum_data;
struct stat_descr proc_info;
double load;
register unsigned int i, j;
register unsigned int j;
if (cpus == 0)
{
register unsigned int c, i;
register unsigned int c;
struct cpu_config conf;
struct stat_descr desc;
@ -641,7 +641,7 @@ getloadavg (double loadavg[], int nelem)
return -1;
c = 0;
for (i = 0; i < conf.config_maxclass; ++i)
for (unsigned int i = 0; i < conf.config_maxclass; ++i)
{
struct class_stats stats;
memset (&stats, 0, sizeof stats);
@ -672,7 +672,7 @@ getloadavg (double loadavg[], int nelem)
load = proc_sum_data.ps_nrunnable;
j = 0;
for (i = samples - 1; i > 0; --i)
for (unsigned int i = samples - 1; i > 0; --i)
{
load += proc_sum_data.ps_nrun[j];
if (j++ == PS_NRUNSIZE)

View file

@ -73,14 +73,13 @@ get_group_info (struct group_info *gi)
int
group_member (gid_t gid)
{
int i;
int found;
struct group_info gi;
int n_groups = get_group_info (&gi);
/* Search through the list looking for GID. */
found = 0;
for (i = 0; i < n_groups; i++)
for (int i = 0; i < n_groups; i++)
{
if (gid == gi.group[i])
{
@ -99,9 +98,7 @@ group_member (gid_t gid)
int
main (int argc, char **argv)
{
int i;
for (i = 1; i < argc; i++)
for (int i = 1; i < argc; i++)
{
gid_t gid;

View file

@ -116,8 +116,8 @@
#endif
/* True if __builtin_mul_overflow (A, B, P) works when P is non-null. */
#if defined __clang_major__ && __clang_major__ < 14
/* Work around Clang bug <https://bugs.llvm.org/show_bug.cgi?id=16404>. */
#if defined __clang_major__ && __clang_major__ < 21
/* Work around Clang bug <https://github.com/llvm/llvm-project/issues/16778>. */
# define _GL_HAS_BUILTIN_MUL_OVERFLOW 0
#else
# define _GL_HAS_BUILTIN_MUL_OVERFLOW _GL_HAS_BUILTIN_ADD_OVERFLOW
@ -179,9 +179,9 @@
_GL_INT_OP_WRAPV (a, b, r, *, _GL_INT_MULTIPLY_RANGE_OVERFLOW)
#endif
/* Nonzero if this compiler has GCC bug 68193 or Clang bug 25390. See:
/* Nonzero if this compiler has GCC bug 68193 or Clang bug 25764. See:
https://gcc.gnu.org/PR68193
https://llvm.org/bugs/show_bug.cgi?id=25390
https://github.com/llvm/llvm-project/issues/25764
For now, assume GCC < 14 and all Clang versions generate bogus
warnings for _Generic. This matters only for compilers that
lack relevant builtins. */

View file

@ -84,15 +84,11 @@ __memrchr (void const *s, int c_in, size_t n)
repeated_one |= repeated_one << 31 << 1;
repeated_c |= repeated_c << 31 << 1;
if (8 < sizeof (longword))
{
size_t i;
for (i = 64; i < sizeof (longword) * 8; i *= 2)
{
repeated_one |= repeated_one << i;
repeated_c |= repeated_c << i;
}
}
for (size_t i = 64; i < sizeof (longword) * 8; i *= 2)
{
repeated_one |= repeated_one << i;
repeated_c |= repeated_c << i;
}
}
/* Instead of the traditional loop which tests each byte, we will test a

View file

@ -468,11 +468,9 @@ __mktime_internal (struct tm *tp, bool local, mktime_offset_t *offset)
int year_seconds_bound = 366 * 24 * 60 * 60 + 1;
int delta_bound = year_seconds_bound + stride;
int delta, direction;
/* Search in both directions, closest first. */
for (delta = stride; delta < delta_bound; delta += stride)
for (direction = -1; direction <= 1; direction += 2)
for (int delta = stride; delta < delta_bound; delta += stride)
for (int direction = -1; direction <= 1; direction += 2)
{
long_int ot;
if (! ckd_add (&ot, t, delta * direction))

View file

@ -89,10 +89,8 @@ num_processors_via_affinity_mask (void)
/* glibc >= 2.6 has the CPU_COUNT macro. */
count = CPU_COUNT (&set);
# else
size_t i;
count = 0;
for (i = 0; i < CPU_SETSIZE; i++)
for (size_t i = 0; i < CPU_SETSIZE; i++)
if (CPU_ISSET (i, &set))
count++;
# endif
@ -112,9 +110,7 @@ num_processors_via_affinity_mask (void)
if (pthread_getaffinity_np (pthread_self (), cpuset_size (set), set)
== 0)
{
cpuid_t i;
for (i = 0;; i++)
for (cpuid_t i = 0;; i++)
{
int ret = cpuset_isset (i, set);
if (ret < 0)
@ -180,10 +176,8 @@ num_processors_via_affinity_mask (void)
/* glibc >= 2.6 has the CPU_COUNT macro. */
count = CPU_COUNT (&set);
# else
size_t i;
count = 0;
for (i = 0; i < CPU_SETSIZE; i++)
for (size_t i = 0; i < CPU_SETSIZE; i++)
if (CPU_ISSET (i, &set))
count++;
# endif
@ -202,9 +196,7 @@ num_processors_via_affinity_mask (void)
if (sched_getaffinity_np (getpid (), cpuset_size (set), set) == 0)
{
cpuid_t i;
for (i = 0;; i++)
for (cpuid_t i = 0;; i++)
{
int ret = cpuset_isset (i, set);
if (ret < 0)

View file

@ -95,15 +95,13 @@ rpl_pselect (int nfds, fd_set *restrict rfds,
struct timespec const *restrict timeout,
sigset_t const *restrict sigmask)
{
int i;
/* FreeBSD 8.2 has a bug: it does not always detect invalid fds. */
if (nfds < 0 || nfds > FD_SETSIZE)
{
errno = EINVAL;
return -1;
}
for (i = 0; i < nfds; i++)
for (int i = 0; i < nfds; i++)
{
if (((rfds && FD_ISSET (i, rfds))
|| (wfds && FD_ISSET (i, wfds))

View file

@ -99,19 +99,17 @@ set_acls_from_mode (const char *name, int desc, mode_t mode, bool *must_chmod)
errno = ENOMEM;
return -1;
}
continue;
}
break;
else
break;
}
if (count <= 0)
convention = -1;
else
{
int i;
convention = 0;
for (i = 0; i < count; i++)
for (int i = 0; i < count; i++)
if (entries[i].a_flags & (OLD_ACE_OWNER | OLD_ACE_GROUP | OLD_ACE_OTHER))
{
convention = 1;

View file

@ -254,8 +254,7 @@ sha1_process_block (const void *buffer, size_t len, struct sha1_ctx *ctx)
while (words < endp)
{
uint32_t tm;
int t;
for (t = 0; t < 16; t++)
for (int t = 0; t < 16; t++)
{
x[t] = SWAP (*words);
words++;

View file

@ -96,10 +96,9 @@ set_uint32 (char *cp, uint32_t v)
void *
sha256_read_ctx (const struct sha256_ctx *ctx, void *resbuf)
{
int i;
char *r = resbuf;
for (i = 0; i < 8; i++)
for (int i = 0; i < 8; i++)
set_uint32 (r + i * sizeof ctx->state[0], SWAP (ctx->state[i]));
return resbuf;
@ -108,10 +107,9 @@ sha256_read_ctx (const struct sha256_ctx *ctx, void *resbuf)
void *
sha224_read_ctx (const struct sha256_ctx *ctx, void *resbuf)
{
int i;
char *r = resbuf;
for (i = 0; i < 7; i++)
for (int i = 0; i < 7; i++)
set_uint32 (r + i * sizeof ctx->state[0], SWAP (ctx->state[i]));
return resbuf;
@ -338,9 +336,8 @@ sha256_process_block (const void *buffer, size_t len, struct sha256_ctx *ctx)
{
uint32_t tm;
uint32_t t0, t1;
int t;
/* FIXME: see sha1.c for a better implementation. */
for (t = 0; t < 16; t++)
for (int t = 0; t < 16; t++)
{
x[t] = SWAP (*words);
words++;

View file

@ -96,10 +96,9 @@ set_uint64 (char *cp, u64 v)
void *
sha512_read_ctx (const struct sha512_ctx *ctx, void *resbuf)
{
int i;
char *r = resbuf;
for (i = 0; i < 8; i++)
for (int i = 0; i < 8; i++)
set_uint64 (r + i * sizeof ctx->state[0], SWAP (ctx->state[i]));
return resbuf;
@ -108,10 +107,9 @@ sha512_read_ctx (const struct sha512_ctx *ctx, void *resbuf)
void *
sha384_read_ctx (const struct sha512_ctx *ctx, void *resbuf)
{
int i;
char *r = resbuf;
for (i = 0; i < 6; i++)
for (int i = 0; i < 6; i++)
set_uint64 (r + i * sizeof ctx->state[0], SWAP (ctx->state[i]));
return resbuf;
@ -367,9 +365,8 @@ sha512_process_block (const void *buffer, size_t len, struct sha512_ctx *ctx)
while (words < endp)
{
int t;
/* FIXME: see sha1.c for a better implementation. */
for (t = 0; t < 16; t++)
for (int t = 0; t < 16; t++)
{
x[t] = SWAP (*words);
words++;

View file

@ -286,8 +286,7 @@ str2signum (char const *signame)
}
else
{
unsigned int i;
for (i = 0; i < NUMNAME_ENTRIES; i++)
for (unsigned int i = 0; i < NUMNAME_ENTRIES; i++)
if (streq (numname_table[i].name, signame))
return numname_table[i].num;
@ -331,8 +330,7 @@ str2sig (char const *signame, int *signum)
int
sig2str (int signum, char *signame)
{
unsigned int i;
for (i = 0; i < NUMNAME_ENTRIES; i++)
for (unsigned int i = 0; i < NUMNAME_ENTRIES; i++)
if (numname_table[i].num == signum)
{
strcpy (signame, numname_table[i].name);

View file

@ -232,8 +232,7 @@ stat_time_normalize (int result, _GL_UNUSED struct stat *st)
short int const ts_off[] = { STAT_TIMESPEC_OFFSETOF (st_atim),
STAT_TIMESPEC_OFFSETOF (st_mtim),
STAT_TIMESPEC_OFFSETOF (st_ctim) };
int i;
for (i = 0; i < sizeof ts_off / sizeof *ts_off; i++)
for (int i = 0; i < sizeof ts_off / sizeof *ts_off; i++)
{
struct timespec *ts = (struct timespec *) ((char *) st + ts_off[i]);
long int q = ts->tv_nsec / timespec_hz;

View file

@ -329,7 +329,6 @@ static RETURN_TYPE _GL_ATTRIBUTE_PURE
two_way_long_needle (const unsigned char *haystack, size_t haystack_len,
const unsigned char *needle, size_t needle_len)
{
size_t i; /* Index into current byte of NEEDLE. */
size_t j; /* Index into current window of HAYSTACK. */
size_t period; /* The period of the right half of needle. */
size_t suffix; /* The index of the right half of needle. */
@ -344,9 +343,9 @@ two_way_long_needle (const unsigned char *haystack, size_t haystack_len,
shift_table[c] is the distance from the last occurrence of c to
the end of NEEDLE, or NEEDLE_LEN if c is absent from the NEEDLE.
shift_table[NEEDLE[NEEDLE_LEN - 1]] contains the only 0. */
for (i = 0; i < 1U << CHAR_BIT; i++)
for (size_t i = 0; i < 1U << CHAR_BIT; i++)
shift_table[i] = needle_len;
for (i = 0; i < needle_len; i++)
for (size_t i = 0; i < needle_len; i++)
shift_table[CANON_ELEMENT (needle[i])] = needle_len - i - 1;
/* Perform the search. Each iteration compares the right half
@ -379,7 +378,7 @@ two_way_long_needle (const unsigned char *haystack, size_t haystack_len,
}
/* Scan for matches in right half. The last byte has
already been matched, by virtue of the shift table. */
i = MAX (suffix, memory);
size_t i = MAX (suffix, memory);
while (i < needle_len - 1 && (CANON_ELEMENT (needle[i])
== CANON_ELEMENT (haystack[i + j])))
++i;
@ -423,7 +422,7 @@ two_way_long_needle (const unsigned char *haystack, size_t haystack_len,
}
/* Scan for matches in right half. The last byte has
already been matched, by virtue of the shift table. */
i = suffix;
size_t i = suffix;
while (i < needle_len - 1 && (CANON_ELEMENT (needle[i])
== CANON_ELEMENT (haystack[i + j])))
++i;

View file

@ -181,7 +181,9 @@ enum pad_style
#if SUPPORT_NON_GREG_CALENDARS_IN_STRFTIME
/* Support for non-Gregorian calendars. */
# include "localcharset.h"
# include "localename.h"
# if !(defined __APPLE__ && defined __MACH__)
# include "localename.h"
# endif
# include "calendars.h"
# define CAL_ARGS(x,y) x, y,
#else
@ -1020,8 +1022,7 @@ underlying_strftime (timezone_t tz, char *ubuf, size_t ubufsize,
{
/* The last word has length >= 3. */
bool found_letter = false;
const char *p;
for (p = space + 1; *p != '\0'; p++)
for (const char *p = space + 1; *p != '\0'; p++)
if ((*p >= 'A' && *p <= 'Z')
|| (*p >= 'a' && *p <= 'z'))
{
@ -1138,9 +1139,9 @@ my_strftime (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
#if SUPPORT_NON_GREG_CALENDARS_IN_STRFTIME
/* Recognize whether to use a non-Gregorian calendar. */
const struct calendar *cal = NULL;
struct calendar_date caldate;
if (strcmp (locale_charset (), "UTF-8") == 0)
{
# if !(defined __APPLE__ && defined __MACH__)
const char *loc = gl_locale_name_unsafe (LC_TIME, "LC_TIME");
if (strlen (loc) >= 5 && !(loc[5] >= 'A' && loc[5] <= 'Z'))
{
@ -1150,15 +1151,45 @@ my_strftime (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
cal = &persian_calendar;
else if (memcmp (loc, "am_ET", 5) == 0)
cal = &ethiopian_calendar;
if (cal != NULL)
{
if (cal->from_gregorian (&caldate,
tp->tm_year + 1900,
tp->tm_mon,
tp->tm_mday) < 0)
cal = NULL;
}
}
# else /* defined __APPLE__ && defined __MACH__ */
/* Nearly equivalent code for macOS, that avoids the need to link with
CoreFoundation.
It's not entirely equivalent, because it tests only for the language
(Thai, Farsi, Amharic) instead of also for the territory (Thailand,
Iran, Ethiopia). */
/* Get the translation of "Monday" in the LC_TIME locale, by calling
the underlying strftime function. */
struct tm some_monday; /* 2024-01-01 12:00:00 */
memset (&some_monday, '\0', sizeof (struct tm));
some_monday.tm_year = 2024 - 1900;
some_monday.tm_mon = 1 - 1;
some_monday.tm_mday = 1;
some_monday.tm_wday = 1; /* Monday */
some_monday.tm_hour = 12;
some_monday.tm_min = 0;
some_monday.tm_sec = 0;
char weekday_buf[32];
if (strftime (weekday_buf, sizeof (weekday_buf), "%A", &some_monday) > 0)
{
/* Test for the Thai / Farsi / Amharic translation of "Monday". */
if (streq (weekday_buf, "จันทร์") || streq (weekday_buf, "วันจันทร์"))
cal = &thai_calendar;
else if (streq (weekday_buf, "ﺩﻮﺸﻨﺒﻫ") || streq (weekday_buf, "دوشنبه"))
cal = &persian_calendar;
else if (streq (weekday_buf, "ሰኞ"))
cal = &ethiopian_calendar;
}
# endif
}
struct calendar_date caldate;
if (cal != NULL)
{
if (cal->from_gregorian (&caldate,
tp->tm_year + 1900,
tp->tm_mon,
tp->tm_mday) < 0)
cal = NULL;
}
#endif
bool tzset_called = false;
@ -1248,7 +1279,6 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
#endif
retval_t i = 0;
STREAM_OR_CHAR_T *p = s;
const CHAR_T *f;
#if DO_MULTIBYTE && !defined COMPILE_WIDE
const char *format_end = NULL;
#endif
@ -1260,7 +1290,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
if (hour12 == 0)
hour12 = 12;
for (f = format; *f != '\0'; width = -1, f++)
for (const CHAR_T *f = format; *f != '\0'; width = -1, f++)
{
enum pad_style pad = ZERO_PAD;
int modifier; /* Field modifier ('E', 'O', or 0). */
@ -1659,10 +1689,9 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
{
/* The last word has length >= 3. */
bool found_letter = false;
const char *p;
for (p = space + 1; *p != '\0'; p++)
if ((*p >= 'A' && *p <= 'Z')
|| (*p >= 'a' && *p <= 'z'))
for (const char *wp = space + 1; *wp != '\0'; wp++)
if ((*wp >= 'A' && *wp <= 'Z')
|| (*wp >= 'a' && *wp <= 'z'))
{
found_letter = true;
break;

View file

@ -27,8 +27,7 @@ strnlen (const char *s, size_t maxlen)
{
/* Do not use memchr, because on some platforms memchr has
undefined behavior if MAXLEN exceeds the number of bytes in S. */
size_t i;
for (i = 0; i < maxlen && s[i]; i++)
for (size_t i = 0; i < maxlen && s[i]; i++)
continue;
return i;
}

View file

@ -217,7 +217,6 @@ INTERNAL (strtol) (const STRING_TYPE *nptr, STRING_TYPE **endptr,
register unsigned int cutlim;
register unsigned LONG int i;
register const STRING_TYPE *s;
register UCHAR_TYPE c;
const STRING_TYPE *save, *end;
int overflow;
@ -307,7 +306,7 @@ INTERNAL (strtol) (const STRING_TYPE *nptr, STRING_TYPE **endptr,
{
/* Find the end of the digit string and check its grouping. */
end = s;
for (c = *end; c != L_('\0'); c = *++end)
for (UCHAR_TYPE c = *end; c != L_('\0'); c = *++end)
if ((wchar_t) c != thousands
&& ((wchar_t) c < L_('0') || (wchar_t) c > L_('9'))
&& (!ISALPHA (c) || (int) (TOUPPER (c) - L_('A') + 10) >= base))
@ -326,7 +325,7 @@ INTERNAL (strtol) (const STRING_TYPE *nptr, STRING_TYPE **endptr,
overflow = 0;
i = 0;
for (c = *s; c != L_('\0'); c = *++s)
for (UCHAR_TYPE c = *s; c != L_('\0'); c = *++s)
{
if (s == end)
break;

View file

@ -152,11 +152,10 @@ typedef int suseconds_t;
static int
rpl_fd_isset (SOCKET fd, const fd_set * set)
{
u_int i;
if (set == NULL)
return 0;
for (i = 0; i < set->fd_count; i++)
for (u_int i = 0; i < set->fd_count; i++)
if (set->fd_array[i] == fd)
return 1;

View file

@ -191,7 +191,6 @@ try_tempname_len (char *tmpl, int suffixlen, void *args,
{
size_t len;
char *XXXXXX;
unsigned int count;
int fd = -1;
int saved_errno = errno;
@ -236,7 +235,7 @@ try_tempname_len (char *tmpl, int suffixlen, void *args,
/* This is where the Xs start. */
XXXXXX = &tmpl[len - x_suffix_len - suffixlen];
for (count = 0; count < attempts; ++count)
for (unsigned int count = 0; count < attempts; ++count)
{
for (size_t i = 0; i < x_suffix_len; i++)
{

View file

@ -1,5 +1,5 @@
# gnulib-common.m4
# serial 113
# serial 114
dnl Copyright (C) 2007-2025 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@ -1406,7 +1406,7 @@ AC_DEFUN([gl_CC_GNULIB_WARNINGS],
dnl -Wno-type-limits >= 4.3 >= 3.9
dnl -Wno-undef >= 3 >= 3.9
dnl -Wno-unsuffixed-float-constants >= 4.5
dnl -Wno-unused-const-variable >= 4.4 >= 3.9
dnl -Wno-unused-const-variable >= 6.1 >= 3.9
dnl -Wno-unused-function >= 3 >= 3.9
dnl -Wno-unused-parameter >= 3 >= 3.9
dnl
@ -1436,7 +1436,7 @@ AC_DEFUN([gl_CC_GNULIB_WARNINGS],
-Wno-sign-conversion
-Wno-type-limits
#endif
#if (__GNUC__ + (__GNUC_MINOR__ >= 4) > 4 && !defined __clang__) || (__clang_major__ + (__clang_minor__ >= 9) > 3)
#if (__GNUC__ + (__GNUC_MINOR__ >= 1) > 6 && !defined __clang__) || (__clang_major__ + (__clang_minor__ >= 9) > 3)
-Wno-unused-const-variable
#endif
#if (__GNUC__ + (__GNUC_MINOR__ >= 5) > 4 && !defined __clang__)