[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
coreutils miscellaneous int-related changes in lib subdirectory
From: |
Paul Eggert |
Subject: |
coreutils miscellaneous int-related changes in lib subdirectory |
Date: |
Mon, 02 Aug 2004 16:05:59 -0700 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) |
There's only one very-theoretical fix here: version-etc now supports
more than UINT_MAX authors. Other than that, it's just code cleanup.
2004-08-02 Paul Eggert <address@hidden>
* canonicalize.c (errno): Remove decl; we now assume C89 or better.
* chown.c (errno): Likewise.
* closeout.c (errno): Likewise.
* dup-safer.c (errno): Likewise.
* dup2.c (errno): Likewise.
* exclude.c (errno): Likewise.
* fopen-safer.c (errno): Likewise.
* ftruncate.c (errno): Likewise.
* full-write.c (errno): Likewise.
* getcwd.c (errno): Likewise.
* lchown.c (errno): Likewise.
* memcoll.c (errno): Likewise.
* nanosleep.c (errno): Likewise.
* putenv.c (errno): Likewise.
* rmdir.c (errno): Likewise.
* same.c (errno): Likewise.
* savedir.c (errno): Likewise.
* setenv.c (errno): Likewise.
* stat.c (errno): Likewise.
* utime.c (errno): Likewise.
* xgetcwd.c (errno): Likewise.
* xmemcoll.c (errno): Likewise.
* xreadlink.c (errno): Likewise.
* xstrtol.c (errno): Likewise.
* canonicalize.h (enum canonicalize_mode_t): Reformat comments to
fit in 80 columns.
* fileblocks.c (textutils_fileblocks_unused): Make it a typedef
instead of an int, to save a few bytes in the object file.
* getdate.y (lookup_word): Rewrite to avoid cast.
* getloadavg.c: Include <stdbool.h>.
(getloadavg_initialized): Use bool for booleans.
* hard-locale.c (hard_locale): Return bool, not int.
* hard-locale.h (hard_locale): Likewise. Include <stdbool.h>.
* hash.c (hash_string): Rewrite to avoid cast.
* human.h: Use Autoconf-suggested pattern for inttypes and stdint.
* strtiomax.c: Likewise.
* xstrtol.h: Likewise.
* nanosleep.c: Include stdbool.h.
(rpl_nanosleep): Usee bool for booleans.
* quotearg.c: Include stdbool.h.
(quotearg_buffer_restyled): Use bool for booleans.
* readtokens.c (readtoken): Rewrite to avoid casts.
* same.c (same_name): Return bool, not int.
* same.h (same_name): Likewise. Include <stdbool.h>.
* version-etc.c (version_etc_va): Use size_t for sizes.
* xnanosleep.c: Include limits.h, stdbool.h.
(CHAR_BIT): Remove.
(timespec_subtract, xnanosleep): Use bool for booleans.
* xstrtoimax.c: Just include xstrtol.h rather than rolling our
own include pattern.
* xstrtoumax.c: Likewise.
* xstrtol.c (__xstrtol): Rewrite to avoid casts.
* yesno.c: Include yesno.h first.
(yesno): Return bool, not int.
* yesno.h (yesno): Likewise. Include <stdbool.h>.
Index: lib/canonicalize.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/canonicalize.c,v
retrieving revision 1.17
diff -p -u -r1.17 canonicalize.c
--- lib/canonicalize.c 7 Jul 2004 15:54:51 -0000 1.17
+++ lib/canonicalize.c 13 Jul 2004 22:27:10 -0000
@@ -50,10 +50,6 @@ void free ();
#include "xalloc.h"
#include "xgetcwd.h"
-#ifndef errno
-extern int errno;
-#endif
-
#ifndef __set_errno
# define __set_errno(Val) errno = (Val)
#endif
Index: lib/canonicalize.h
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/canonicalize.h,v
retrieving revision 1.2
diff -p -u -r1.2 canonicalize.h
--- lib/canonicalize.h 6 Jul 2004 16:55:40 -0000 1.2
+++ lib/canonicalize.h 28 Jul 2004 00:10:27 -0000
@@ -3,9 +3,14 @@
enum canonicalize_mode_t
{
- CAN_EXISTING = 0, /* All path components must exist. */
- CAN_ALL_BUT_LAST = 1, /* All path components exluding last one must
exist. */
- CAN_MISSING = 2, /* No requirements on components existence. */
+ /* All path components must exist. */
+ CAN_EXISTING = 0,
+
+ /* All path components excluding last one must exist. */
+ CAN_ALL_BUT_LAST = 1,
+
+ /* No requirements on components existence. */
+ CAN_MISSING = 2
};
typedef enum canonicalize_mode_t canonicalize_mode_t;
Index: lib/chown.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/chown.c,v
retrieving revision 1.9
diff -p -u -r1.9 chown.c
--- lib/chown.c 1 May 2004 14:36:29 -0000 1.9
+++ lib/chown.c 13 Jul 2004 23:53:10 -0000
@@ -36,9 +36,6 @@
# include <sys/file.h>
#endif
#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
/* Provide a more-closely POSIX-conforming version of chown on
systems with one or both of the following problems:
Index: lib/closeout.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/closeout.c,v
retrieving revision 1.12
diff -p -u -r1.12 closeout.c
--- lib/closeout.c 19 Jul 2003 08:08:56 -0000 1.12
+++ lib/closeout.c 13 Jul 2004 23:53:59 -0000
@@ -22,11 +22,7 @@
#include "closeout.h"
#include <stdio.h>
-
#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
#include "gettext.h"
#define _(msgid) gettext (msgid)
Index: lib/dup-safer.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/dup-safer.c,v
retrieving revision 1.1
diff -p -u -r1.1 dup-safer.c
--- lib/dup-safer.c 3 Mar 2001 19:05:36 -0000 1.1
+++ lib/dup-safer.c 14 Jul 2004 00:12:45 -0000
@@ -22,9 +22,6 @@
#endif
#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
#if HAVE_FCNTL_H
# include <fcntl.h>
Index: lib/dup2.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/dup2.c,v
retrieving revision 1.3
diff -p -u -r1.3 dup2.c
--- lib/dup2.c 7 Aug 2000 15:48:18 -0000 1.3
+++ lib/dup2.c 14 Jul 2004 00:12:01 -0000
@@ -22,9 +22,6 @@
#endif
#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
#if HAVE_FCNTL_H
# include <fcntl.h>
Index: lib/exclude.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/exclude.c,v
retrieving revision 1.20
diff -p -u -r1.20 exclude.c
--- lib/exclude.c 31 Oct 2003 13:43:55 -0000 1.20
+++ lib/exclude.c 14 Jul 2004 07:11:26 -0000
@@ -28,9 +28,6 @@
#include <ctype.h>
#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
Index: lib/fileblocks.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/fileblocks.c,v
retrieving revision 1.16
diff -p -u -r1.16 fileblocks.c
--- lib/fileblocks.c 7 Aug 2000 15:48:18 -0000 1.16
+++ lib/fileblocks.c 14 Jul 2004 07:13:24 -0000
@@ -73,5 +73,5 @@ st_blocks (off_t size)
#else
/* This declaration is solely to ensure that after preprocessing
this file is never empty. */
-extern int textutils_fileblocks_unused;
+typedef int textutils_fileblocks_unused;
#endif
Index: lib/fopen-safer.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/fopen-safer.c,v
retrieving revision 1.1
diff -p -u -r1.1 fopen-safer.c
--- lib/fopen-safer.c 3 Mar 2001 19:05:51 -0000 1.1
+++ lib/fopen-safer.c 14 Jul 2004 07:30:00 -0000
@@ -31,10 +31,6 @@
#endif
#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
-
#include <stdio.h>
#include <stdio-safer.h>
Index: lib/ftruncate.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/ftruncate.c,v
retrieving revision 1.7
diff -p -u -r1.7 ftruncate.c
--- lib/ftruncate.c 7 Dec 1998 03:12:10 -0000 1.7
+++ lib/ftruncate.c 14 Jul 2004 07:36:42 -0000
@@ -79,9 +79,6 @@ ftruncate (int fd, off_t length)
# else /* not F_CHSIZE nor F_FREESP nor HAVE_CHSIZE */
# include <errno.h>
-# ifndef errno
-extern int errno;
-# endif
int
ftruncate (int fd, off_t length)
Index: lib/full-write.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/full-write.c,v
retrieving revision 1.18
diff -p -u -r1.18 full-write.c
--- lib/full-write.c 18 Aug 2003 09:44:49 -0000 1.18
+++ lib/full-write.c 14 Jul 2004 20:14:26 -0000
@@ -28,9 +28,6 @@
#endif
#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
#ifdef FULL_READ
# include "safe-read.h"
Index: lib/getcwd.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/getcwd.c,v
retrieving revision 1.5
diff -p -u -r1.5 getcwd.c
--- lib/getcwd.c 7 Mar 2003 10:13:55 -0000 1.5
+++ lib/getcwd.c 14 Jul 2004 20:14:41 -0000
@@ -21,12 +21,7 @@
#include <stdlib.h>
#include <string.h>
-
#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
-
#include <sys/types.h>
#include "pathmax.h"
Index: lib/getdate.y
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/getdate.y,v
retrieving revision 1.83
diff -p -u -r1.83 getdate.y
--- lib/getdate.y 6 Jun 2004 19:03:01 -0000 1.83
+++ lib/getdate.y 24 Jul 2004 22:44:37 -0000
@@ -768,8 +768,11 @@ lookup_word (parser_control const *pc, c
/* Make it uppercase. */
for (p = word; *p; p++)
- if (ISLOWER ((unsigned char) *p))
- *p = toupper ((unsigned char) *p);
+ {
+ unsigned char ch = *p;
+ if (ISLOWER (ch))
+ *p = toupper (ch);
+ }
for (tp = meridian_table; tp->name; tp++)
if (strcmp (word, tp->name) == 0)
Index: lib/getloadavg.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/getloadavg.c,v
retrieving revision 1.25
diff -p -u -r1.25 getloadavg.c
--- lib/getloadavg.c 12 Jul 2004 18:19:38 -0000 1.25
+++ lib/getloadavg.c 20 Jul 2004 04:33:51 -0000
@@ -84,6 +84,7 @@
#endif
#include <errno.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
@@ -457,7 +458,7 @@
# ifdef NeXT
static processor_set_t default_set;
-static int getloadavg_initialized;
+static bool getloadavg_initialized;
# endif /* NeXT */
# ifdef UMAX
@@ -472,8 +473,8 @@ static struct dg_sys_info_load_info load
# if !defined (HAVE_LIBKSTAT) && defined (LOAD_AVE_TYPE)
/* File descriptor open to /dev/kmem or VMS load ave driver. */
static int channel;
-/* Nonzero iff channel is valid. */
-static int getloadavg_initialized;
+/* True iff channel is valid. */
+static bool getloadavg_initialized;
/* Offset in kmem to seek to read load average, or 0 means invalid. */
static long offset;
@@ -648,7 +649,7 @@ getloadavg (double loadavg[], int nelem)
host_t host;
struct processor_set_basic_info info;
- unsigned info_count;
+ unsigned int info_count;
/* We only know how to get the 1-minute average for this system,
so even if the caller asks for more than 1, we only return 1. */
@@ -656,7 +657,7 @@ getloadavg (double loadavg[], int nelem)
if (!getloadavg_initialized)
{
if (processor_set_default (host_self (), &default_set) == KERN_SUCCESS)
- getloadavg_initialized = 1;
+ getloadavg_initialized = true;
}
if (getloadavg_initialized)
@@ -665,7 +666,7 @@ getloadavg (double loadavg[], int nelem)
if (processor_set_info (default_set, PROCESSOR_SET_BASIC_INFO, &host,
(processor_set_info_t) &info, &info_count)
!= KERN_SUCCESS)
- getloadavg_initialized = 0;
+ getloadavg_initialized = false;
else
{
if (nelem > 0)
@@ -826,7 +827,7 @@ getloadavg (double loadavg[], int nelem)
/* VMS specific code -- read from the Load Ave driver. */
LOAD_AVE_TYPE load_ave[3];
- static int getloadavg_initialized = 0;
+ static bool getloadavg_initialized;
# ifdef eunice
struct
{
@@ -846,7 +847,7 @@ getloadavg (double loadavg[], int nelem)
$DESCRIPTOR (descriptor, "LAV0:");
# endif
if (sys$assign (&descriptor, &channel, 0, 0) & 1)
- getloadavg_initialized = 1;
+ getloadavg_initialized = true;
}
/* Read the load average vector. */
@@ -855,7 +856,7 @@ getloadavg (double loadavg[], int nelem)
load_ave, 12, 0, 0, 0, 0) & 1))
{
sys$dassgn (channel);
- getloadavg_initialized = 0;
+ getloadavg_initialized = false;
}
if (!getloadavg_initialized)
@@ -908,7 +909,7 @@ getloadavg (double loadavg[], int nelem)
ldav_off = sysmp (MP_KERNADDR, MPKA_AVENRUN);
if (ldav_off != -1)
- offset = (long) ldav_off & 0x7fffffff;
+ offset = (long int) ldav_off & 0x7fffffff;
# endif /* sgi */
}
@@ -922,7 +923,7 @@ getloadavg (double loadavg[], int nelem)
/* Set the channel to close on exec, so it does not
litter any child's descriptor table. */
set_cloexec_flag (channel, true);
- getloadavg_initialized = 1;
+ getloadavg_initialized = true;
}
# else /* SUNOS_5 */
/* We pass 0 for the kernel, corefile, and swapfile names
@@ -933,7 +934,7 @@ getloadavg (double loadavg[], int nelem)
/* nlist the currently running kernel. */
kvm_nlist (kd, nl);
offset = nl[0].n_value;
- getloadavg_initialized = 1;
+ getloadavg_initialized = true;
}
# endif /* SUNOS_5 */
}
@@ -948,14 +949,14 @@ getloadavg (double loadavg[], int nelem)
!= sizeof (load_ave))
{
close (channel);
- getloadavg_initialized = 0;
+ getloadavg_initialized = false;
}
# else /* SUNOS_5 */
if (kvm_read (kd, offset, (char *) load_ave, sizeof (load_ave))
!= sizeof (load_ave))
{
kvm_close (kd);
- getloadavg_initialized = 0;
+ getloadavg_initialized = false;
}
# endif /* SUNOS_5 */
}
Index: lib/hard-locale.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/hard-locale.c,v
retrieving revision 1.8
diff -p -u -r1.8 hard-locale.c
--- lib/hard-locale.c 10 Sep 2003 08:48:30 -0000 1.8
+++ lib/hard-locale.c 13 Jul 2004 06:51:41 -0000
@@ -29,23 +29,23 @@
#include <stdlib.h>
#include <string.h>
-/* Return nonzero if the current CATEGORY locale is hard, i.e. if you
+/* Return true if the current CATEGORY locale is hard, i.e. if you
can't get away with assuming traditional C or POSIX behavior. */
-int
+bool
hard_locale (int category)
{
#if ! HAVE_SETLOCALE
- return 0;
+ return false;
#else
- int hard = 1;
- char const *p = setlocale (category, 0);
+ bool hard = true;
+ char const *p = setlocale (category, NULL);
if (p)
{
# if defined __GLIBC__ && 2 <= __GLIBC__
if (strcmp (p, "C") == 0 || strcmp (p, "POSIX") == 0)
- hard = 0;
+ hard = false;
# else
char *locale = malloc (strlen (p) + 1);
if (locale)
@@ -59,7 +59,7 @@ hard_locale (int category)
&& strcmp (p, locale) == 0)
|| ((p = setlocale (category, "POSIX"))
&& strcmp (p, locale) == 0))
- hard = 0;
+ hard = false;
/* Restore the caller's locale. */
setlocale (category, locale);
Index: lib/hard-locale.h
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/hard-locale.h,v
retrieving revision 1.3
diff -p -u -r1.3 hard-locale.h
--- lib/hard-locale.h 18 Aug 2003 09:44:49 -0000 1.3
+++ lib/hard-locale.h 13 Jul 2004 06:50:51 -0000
@@ -1,6 +1,6 @@
/* Determine whether a locale is hard.
- Copyright (C) 1999, 2003 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2003, 2004 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,6 +19,8 @@
#ifndef HARD_LOCALE_H_
# define HARD_LOCALE_H_ 1
-int hard_locale (int);
+# include <stdbool.h>
+
+bool hard_locale (int);
#endif /* HARD_LOCALE_H_ */
Index: lib/hash.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/hash.c,v
retrieving revision 1.34
diff -p -u -r1.34 hash.c
--- lib/hash.c 31 Oct 2003 14:05:55 -0000 1.34
+++ lib/hash.c 24 Jul 2004 22:46:15 -0000
@@ -400,9 +400,10 @@ hash_string (const char *string, size_t
((Byte) + ROTATE_LEFT (Value, 7))
size_t value = 0;
+ unsigned char ch;
- for (; *string; string++)
- value = HASH_ONE_CHAR (value, (unsigned char) *string);
+ for (; (ch = *string); string++)
+ value = HASH_ONE_CHAR (value, ch);
return value % n_buckets;
# undef ROTATE_LEFT
@@ -420,9 +421,10 @@ size_t
hash_string (const char *string, size_t n_buckets)
{
size_t value = 0;
+ unsigned char ch;
- while (*string)
- value = (value * 31 + (unsigned char) *string++) % n_buckets;
+ for (; (ch = *string); string++)
+ value = (value * 31 + ch) % n_buckets;
return value;
}
Index: lib/human.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/human.c,v
retrieving revision 1.26
diff -p -u -r1.26 human.c
--- lib/human.c 4 Apr 2004 06:51:11 -0000 1.26
+++ lib/human.c 2 Aug 2004 17:20:57 -0000
@@ -300,8 +300,8 @@ human_readable (uintmax_t n, char *buf,
{
do
{
- unsigned r10 = (amt % base) * 10 + tenths;
- unsigned r2 = (r10 % base) * 2 + (rounding >> 1);
+ unsigned int r10 = (amt % base) * 10 + tenths;
+ unsigned int r2 = (r10 % base) * 2 + (rounding >> 1);
amt /= base;
tenths = r10 / base;
rounding = (r2 < base
Index: lib/human.h
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/human.h,v
retrieving revision 1.8
diff -p -u -r1.8 human.h
--- lib/human.h 6 Jun 2003 19:16:17 -0000 1.8
+++ lib/human.h 13 Jul 2004 23:35:14 -0000
@@ -29,12 +29,11 @@
# include <limits.h>
# include <stdbool.h>
-# if HAVE_INTTYPES_H
-# include <inttypes.h>
-# else
-# if HAVE_STDINT_H
-# include <stdint.h>
-# endif
+# if HAVE_STDINT_H
+# include <stdint.h>
+# endif
+# if HAVE_UNISTD_H
+# include <unistd.h>
# endif
/* A conservative bound on the maximum length of a human-readable string.
Index: lib/lchown.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/lchown.c,v
retrieving revision 1.15
diff -p -u -r1.15 lchown.c
--- lib/lchown.c 19 Jun 2004 12:27:23 -0000 1.15
+++ lib/lchown.c 14 Jul 2004 20:39:57 -0000
@@ -22,9 +22,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
+
#include "lchown.h"
#include "stat-macros.h"
Index: lib/memcoll.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/memcoll.c,v
retrieving revision 1.9
diff -p -u -r1.9 memcoll.c
--- lib/memcoll.c 10 Sep 2003 08:56:48 -0000 1.9
+++ lib/memcoll.c 14 Jul 2004 22:04:49 -0000
@@ -24,10 +24,6 @@
#include "memcoll.h"
#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
-
#include <string.h>
/* Compare S1 (with length S1LEN) and S2 (with length S2LEN) according
Index: lib/modechange.h
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/modechange.h,v
retrieving revision 1.13
diff -p -u -r1.13 modechange.h
--- lib/modechange.h 18 Aug 2003 09:44:49 -0000 1.13
+++ lib/modechange.h 20 Jul 2004 04:02:54 -0000
@@ -51,7 +51,7 @@ struct mode_change
# define MODE_MEMORY_EXHAUSTED (struct mode_change *) 1
# define MODE_BAD_REFERENCE (struct mode_change *) 2
-struct mode_change *mode_compile (const char *, unsigned);
+struct mode_change *mode_compile (const char *, unsigned int);
struct mode_change *mode_create_from_ref (const char *);
mode_t mode_adjust (mode_t, const struct mode_change *);
void mode_free (struct mode_change *);
Index: lib/nanosleep.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/nanosleep.c,v
retrieving revision 1.12
diff -p -u -r1.12 nanosleep.c
--- lib/nanosleep.c 20 Apr 2004 10:41:36 -0000 1.12
+++ lib/nanosleep.c 14 Jul 2004 23:31:21 -0000
@@ -23,14 +23,12 @@
prototype for rpl_nanosleep. (they'd conflict e.g., on alpha-dec-osf3.2) */
#undef nanosleep
+#include <stdbool.h>
#include <stdio.h>
#include <sys/types.h>
#include <signal.h>
#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
#if HAVE_UNISTD_H
# include <unistd.h>
@@ -77,7 +75,7 @@ int
rpl_nanosleep (const struct timespec *requested_delay,
struct timespec *remaining_delay)
{
- static int initialized;
+ static bool initialized;
#ifdef SA_NOCLDSTOP
struct sigaction oldact, newact;
@@ -100,7 +98,7 @@ rpl_nanosleep (const struct timespec *re
if (signal (SIGCONT, SIG_IGN) != SIG_IGN)
signal (SIGCONT, sighandler);
#endif
- initialized = 1;
+ initialized = true;
}
my_usleep (requested_delay);
Index: lib/putenv.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/putenv.c,v
retrieving revision 1.29
diff -p -u -r1.29 putenv.c
--- lib/putenv.c 10 Sep 2003 09:07:43 -0000 1.29
+++ lib/putenv.c 15 Jul 2004 03:42:11 -0000
@@ -26,10 +26,7 @@
/* Include errno.h *after* sys/types.h to work around header problems
on AIX 3.2.5. */
#include <errno.h>
-#if !_LIBC
-# if !defined errno
-extern int errno;
-# endif
+#ifndef __set_errno
# define __set_errno(ev) ((errno) = (ev))
#endif
Index: lib/quotearg.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/quotearg.c,v
retrieving revision 1.42
diff -p -u -r1.42 quotearg.c
--- lib/quotearg.c 13 Apr 2004 09:04:58 -0000 1.42
+++ lib/quotearg.c 14 Jul 2004 23:42:58 -0000
@@ -30,6 +30,7 @@
#include <ctype.h>
#include <errno.h>
#include <limits.h>
+#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
@@ -192,8 +193,8 @@ quotearg_buffer_restyled (char *buffer,
size_t len = 0;
char const *quote_string = 0;
size_t quote_string_len = 0;
- int backslash_escapes = 0;
- int unibyte_locale = MB_CUR_MAX == 1;
+ bool backslash_escapes = false;
+ bool unibyte_locale = MB_CUR_MAX == 1;
#define STORE(c) \
do \
@@ -208,13 +209,13 @@ quotearg_buffer_restyled (char *buffer,
{
case c_quoting_style:
STORE ('"');
- backslash_escapes = 1;
+ backslash_escapes = true;
quote_string = "\"";
quote_string_len = 1;
break;
case escape_quoting_style:
- backslash_escapes = 1;
+ backslash_escapes = true;
break;
case locale_quoting_style:
@@ -239,7 +240,7 @@ quotearg_buffer_restyled (char *buffer,
char const *right = gettext_quote (N_("'"), quoting_style);
for (quote_string = left; *quote_string; quote_string++)
STORE (*quote_string);
- backslash_escapes = 1;
+ backslash_escapes = true;
quote_string = right;
quote_string_len = strlen (quote_string);
}
@@ -396,12 +397,12 @@ quotearg_buffer_restyled (char *buffer,
/* Length of multibyte sequence found so far. */
size_t m;
- int printable;
+ bool printable;
if (unibyte_locale)
{
m = 1;
- printable = isprint (c);
+ printable = isprint (c) != 0;
}
else
{
@@ -409,7 +410,7 @@ quotearg_buffer_restyled (char *buffer,
memset (&mbstate, 0, sizeof mbstate);
m = 0;
- printable = 1;
+ printable = true;
if (argsize == SIZE_MAX)
argsize = strlen (arg);
@@ -422,12 +423,12 @@ quotearg_buffer_restyled (char *buffer,
break;
else if (bytes == (size_t) -1)
{
- printable = 0;
+ printable = false;
break;
}
else if (bytes == (size_t) -2)
{
- printable = 0;
+ printable = false;
while (i + m < argsize && arg[i + m])
m++;
break;
@@ -451,7 +452,7 @@ quotearg_buffer_restyled (char *buffer,
}
if (! iswprint (w))
- printable = 0;
+ printable = false;
m += bytes;
}
}
Index: lib/readtokens.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/readtokens.c,v
retrieving revision 1.16
diff -p -u -r1.16 readtokens.c
--- lib/readtokens.c 21 Mar 2004 19:50:17 -0000 1.16
+++ lib/readtokens.c 24 Jul 2004 22:48:08 -0000
@@ -96,7 +96,10 @@ readtoken (FILE *stream,
saved_delim = delim;
memset (isdelim, 0, sizeof isdelim);
for (j = 0; j < n_delim; j++)
- isdelim[(unsigned char) delim[j]] = 1;
+ {
+ unsigned char ch = delim[j];
+ isdelim[ch] = 1;
+ }
}
/* FIXME: don't fool with this caching. Use strchr instead. */
Index: lib/rmdir.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/rmdir.c,v
retrieving revision 1.12
diff -p -u -r1.12 rmdir.c
--- lib/rmdir.c 19 Jun 2004 12:25:31 -0000 1.12
+++ lib/rmdir.c 14 Jul 2004 23:57:30 -0000
@@ -22,11 +22,7 @@
#include <sys/types.h>
#include <sys/stat.h>
-
#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
#include "stat-macros.h"
Index: lib/same.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/same.c,v
retrieving revision 1.12
diff -p -u -r1.12 same.c
--- lib/same.c 19 Aug 2003 10:02:53 -0000 1.12
+++ lib/same.c 14 Jul 2004 23:50:17 -0000
@@ -31,9 +31,6 @@
#include <sys/stat.h>
#include <ctype.h>
#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
#include <string.h>
@@ -56,7 +53,7 @@ extern int errno;
/* Return nonzero if SOURCE and DEST point to the same name in the same
directory. */
-int
+bool
same_name (const char *source, const char *dest)
{
/* Compare the basenames. */
Index: lib/same.h
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/same.h,v
retrieving revision 1.4
diff -p -u -r1.4 same.h
--- lib/same.h 18 Jun 2003 06:53:26 -0000 1.4
+++ lib/same.h 14 Jul 2004 23:50:30 -0000
@@ -20,6 +20,8 @@
#ifndef SAME_H_
# define SAME_H_ 1
-int same_name (const char *source, const char *dest);
+# include <stdbool.h>
+
+bool same_name (const char *source, const char *dest);
#endif /* SAME_H_ */
Index: lib/savedir.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/savedir.c,v
retrieving revision 1.23
diff -p -u -r1.23 savedir.c
--- lib/savedir.c 30 Jun 2004 22:40:20 -0000 1.23
+++ lib/savedir.c 15 Jul 2004 03:36:28 -0000
@@ -28,9 +28,6 @@
#include <sys/types.h>
#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
#if HAVE_DIRENT_H
# include <dirent.h>
Index: lib/setenv.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/setenv.c,v
retrieving revision 1.9
diff -p -u -r1.9 setenv.c
--- lib/setenv.c 4 Apr 2004 06:51:11 -0000 1.9
+++ lib/setenv.c 15 Jul 2004 03:42:21 -0000
@@ -21,10 +21,7 @@
#include <alloca.h>
#include <errno.h>
-#if !_LIBC
-# if !defined errno && !defined HAVE_ERRNO_DECL
-extern int errno;
-# endif
+#ifndef __set_errno
# define __set_errno(ev) ((errno) = (ev))
#endif
Index: lib/sig2str.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/sig2str.c,v
retrieving revision 1.5
diff -p -u -r1.5 sig2str.c
--- lib/sig2str.c 21 Nov 2002 13:17:47 -0000 1.5
+++ lib/sig2str.c 20 Jul 2004 04:03:11 -0000
@@ -253,7 +253,7 @@ static struct numname { int num; char co
POSIX says that only '0' through '9' are digits. Prefer ISDIGIT to
ISDIGIT_LOCALE 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) (c) - '0' <= 9)
+#define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9)
/* Convert the signal name SIGNAME to a signal number. Return the
signal number if successful, -1 otherwise. */
@@ -270,7 +270,7 @@ str2signum (char const *signame)
}
else
{
- unsigned i;
+ unsigned int i;
for (i = 0; i < NUMNAME_ENTRIES; i++)
if (strcmp (numname_table[i].name, signame) == 0)
return numname_table[i].num;
@@ -315,7 +315,7 @@ str2sig (char const *signame, int *signu
int
sig2str (int signum, char *signame)
{
- unsigned i;
+ unsigned int i;
for (i = 0; i < NUMNAME_ENTRIES; i++)
if (numname_table[i].num == signum)
{
Index: lib/stat.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/stat.c,v
retrieving revision 1.10
diff -p -u -r1.10 stat.c
--- lib/stat.c 19 Jun 2004 12:25:04 -0000 1.10
+++ lib/stat.c 15 Jul 2004 04:03:59 -0000
@@ -27,9 +27,6 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
#if defined LSTAT && ! LSTAT_FOLLOWS_SLASHED_SYMLINK
# include <stdlib.h>
# include <string.h>
Index: lib/strtoimax.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/strtoimax.c,v
retrieving revision 1.9
diff -p -u -r1.9 strtoimax.c
--- lib/strtoimax.c 13 Sep 2003 22:01:20 -0000 1.9
+++ lib/strtoimax.c 20 Jul 2004 04:38:20 -0000
@@ -23,7 +23,8 @@
#if HAVE_INTTYPES_H
# include <inttypes.h>
-#elif HAVE_STDINT_H
+#endif
+#if HAVE_STDINT_H
# include <stdint.h>
#endif
@@ -66,14 +67,14 @@ strtoimax (char const *ptr, char **endpt
{
#if HAVE_LONG_LONG
verify (size_is_that_of_long_or_long_long,
- (sizeof (INT) == sizeof (long)
- || sizeof (INT) == sizeof (long long)));
+ (sizeof (INT) == sizeof (long int)
+ || sizeof (INT) == sizeof (long long int)));
- if (sizeof (INT) != sizeof (long))
+ if (sizeof (INT) != sizeof (long int))
return strtoll (ptr, endptr, base);
#else
verify (size_is_that_of_long,
- sizeof (INT) == sizeof (long));
+ sizeof (INT) == sizeof (long int));
#endif
return strtol (ptr, endptr, base);
Index: lib/strverscmp.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/strverscmp.c,v
retrieving revision 1.13
diff -p -u -r1.13 strverscmp.c
--- lib/strverscmp.c 10 Jul 2003 07:06:25 -0000 1.13
+++ lib/strverscmp.c 20 Jul 2004 04:03:15 -0000
@@ -43,7 +43,7 @@
POSIX says that only '0' through '9' are digits. Prefer ISDIGIT to
ISDIGIT_LOCALE 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) (c) - '0' <= 9)
+#define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9)
#undef __strverscmp
#undef strverscmp
Index: lib/utime.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/utime.c,v
retrieving revision 1.10
diff -p -u -r1.10 utime.c
--- lib/utime.c 17 Nov 2003 16:13:04 -0000 1.10
+++ lib/utime.c 15 Jul 2004 04:56:32 -0000
@@ -34,9 +34,6 @@
#include <unistd.h>
#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
#include "full-write.h"
#include "safe-read.h"
Index: lib/version-etc.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/version-etc.c,v
retrieving revision 1.17
diff -p -u -r1.17 version-etc.c
--- lib/version-etc.c 10 Jan 2004 16:59:17 -0000 1.17
+++ lib/version-etc.c 15 Jul 2004 04:58:33 -0000
@@ -46,7 +46,7 @@ version_etc_va (FILE *stream,
const char *command_name, const char *package,
const char *version, va_list authors)
{
- unsigned int n_authors;
+ size_t n_authors;
/* Count the number of authors. */
{
Index: lib/xgetcwd.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/xgetcwd.c,v
retrieving revision 1.16
diff -p -u -r1.16 xgetcwd.c
--- lib/xgetcwd.c 11 Sep 2003 09:07:42 -0000 1.16
+++ lib/xgetcwd.c 15 Jul 2004 04:59:31 -0000
@@ -23,10 +23,6 @@
#include <stdio.h>
#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
-
#include <sys/types.h>
#include <stdlib.h>
Index: lib/xmemcoll.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/xmemcoll.c,v
retrieving revision 1.4
diff -p -u -r1.4 xmemcoll.c
--- lib/xmemcoll.c 18 Aug 2003 09:44:49 -0000 1.4
+++ lib/xmemcoll.c 15 Jul 2004 05:01:01 -0000
@@ -22,10 +22,6 @@
#endif
#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
-
#include <stdlib.h>
#include "gettext.h"
Index: lib/xnanosleep.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/xnanosleep.c,v
retrieving revision 1.8
diff -p -u -r1.8 xnanosleep.c
--- lib/xnanosleep.c 27 Nov 2003 07:42:03 -0000 1.8
+++ lib/xnanosleep.c 22 Jul 2004 22:55:40 -0000
@@ -22,16 +22,14 @@
# include <config.h>
#endif
+#include <limits.h>
+#include <stdbool.h>
#include <stdio.h>
#include <assert.h>
#include <errno.h>
#include <sys/types.h>
#include <time.h>
-#ifndef CHAR_BIT
-# define CHAR_BIT 8
-#endif
-
/* The extra casts work around common compiler bugs. */
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
/* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
@@ -49,12 +47,12 @@
#include "xnanosleep.h"
/* Subtract the `struct timespec' values X and Y by computing X - Y.
- If the difference is negative or zero, return 0.
- Otherwise, return 1 and store the difference in DIFF.
+ If the difference is negative or zero, return false.
+ Otherwise, return true and store the difference in DIFF.
X and Y must have valid ts_nsec values, in the range 0 to 999999999.
If the difference would overflow, store the maximum possible difference. */
-static int
+static bool
timespec_subtract (struct timespec *diff,
struct timespec const *x, struct timespec const *y)
{
@@ -62,7 +60,7 @@ timespec_subtract (struct timespec *diff
long int nsec = x->tv_nsec - y->tv_nsec;
if (x->tv_sec < y->tv_sec)
- return 0;
+ return false;
if (sec < 0)
{
@@ -71,7 +69,7 @@ timespec_subtract (struct timespec *diff
nsec = 999999999;
}
else if (sec == 0 && nsec <= 0)
- return 0;
+ return false;
if (nsec < 0)
{
@@ -81,7 +79,7 @@ timespec_subtract (struct timespec *diff
diff->tv_sec = sec;
diff->tv_nsec = nsec;
- return 1;
+ return true;
}
/* Sleep until the time (call it WAKE_UP_TIME) specified as
@@ -94,7 +92,7 @@ timespec_subtract (struct timespec *diff
int
xnanosleep (double seconds)
{
- int overflow;
+ bool overflow;
double ns;
struct timespec ts_start;
struct timespec ts_sleep;
Index: lib/xreadlink.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/xreadlink.c,v
retrieving revision 1.13
diff -p -u -r1.13 xreadlink.c
--- lib/xreadlink.c 1 Jun 2004 13:20:50 -0000 1.13
+++ lib/xreadlink.c 15 Jul 2004 05:02:58 -0000
@@ -27,10 +27,6 @@
#include <stdio.h>
#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
-
#include <limits.h>
#include <sys/types.h>
#include <stdlib.h>
Index: lib/xstrtoimax.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/xstrtoimax.c,v
retrieving revision 1.4
diff -p -u -r1.4 xstrtoimax.c
--- lib/xstrtoimax.c 15 Oct 2003 07:26:10 -0000 1.4
+++ lib/xstrtoimax.c 13 Jul 2004 23:38:38 -0000
@@ -21,11 +21,7 @@
# include <config.h>
#endif
-#if HAVE_INTTYPES_H
-# include <inttypes.h>
-#elif HAVE_STDINT_H
-# include <stdint.h>
-#endif
+#include "xstrtol.h"
#define __strtol strtoimax
#define __strtol_t intmax_t
Index: lib/xstrtol.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/xstrtol.c,v
retrieving revision 1.34
diff -p -u -r1.34 xstrtol.c
--- lib/xstrtol.c 13 Nov 2003 07:45:00 -0000 1.34
+++ lib/xstrtol.c 24 Jul 2004 22:49:40 -0000
@@ -37,15 +37,10 @@
#include <assert.h>
#include <ctype.h>
-#include <stdlib.h>
-#include <string.h>
-
#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
-
#include <limits.h>
+#include <stdlib.h>
+#include <string.h>
/* The extra casts work around common compiler bugs. */
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
@@ -121,9 +116,10 @@ __xstrtol (const char *s, char **ptr, in
if (! TYPE_SIGNED (__strtol_t))
{
const char *q = s;
- while (ISSPACE ((unsigned char) *q))
- ++q;
- if (*q == '-')
+ unsigned char ch = *q;
+ while (ISSPACE (ch))
+ ch = *++q;
+ if (ch == '-')
return LONGINT_INVALID;
}
Index: lib/xstrtol.h
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/xstrtol.h,v
retrieving revision 1.18
diff -p -u -r1.18 xstrtol.h
--- lib/xstrtol.h 21 Jan 2004 22:37:21 -0000 1.18
+++ lib/xstrtol.h 13 Jul 2004 23:36:46 -0000
@@ -22,13 +22,11 @@
# include "exitfail.h"
-/* Get uintmax_t. */
# if HAVE_INTTYPES_H
# include <inttypes.h>
-# else
-# if HAVE_STDINT_H
-# include <stdint.h>
-# endif
+# endif
+# if HAVE_STDINT_H
+# include <stdint.h>
# endif
# ifndef _STRTOL_ERROR
Index: lib/xstrtoumax.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/xstrtoumax.c,v
retrieving revision 1.8
diff -p -u -r1.8 xstrtoumax.c
--- lib/xstrtoumax.c 15 Oct 2003 07:26:36 -0000 1.8
+++ lib/xstrtoumax.c 13 Jul 2004 23:38:12 -0000
@@ -21,11 +21,7 @@
# include <config.h>
#endif
-#if HAVE_INTTYPES_H
-# include <inttypes.h>
-#elif HAVE_STDINT_H
-# include <stdint.h>
-#endif
+#include "xstrtol.h"
#define __strtol strtoumax
#define __strtol_t uintmax_t
Index: lib/yesno.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/yesno.c,v
retrieving revision 1.10
diff -p -u -r1.10 yesno.c
--- lib/yesno.c 20 Jun 2004 13:42:11 -0000 1.10
+++ lib/yesno.c 15 Jul 2004 05:13:02 -0000
@@ -19,11 +19,12 @@
# include <config.h>
#endif
+#include "yesno.h"
+
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include "unlocked-io.h"
-#include "yesno.h"
/* Read one line from standard input
and return nonzero if that line begins with y or Y,
@@ -31,7 +32,7 @@
extern int rpmatch (char const *response);
-int
+bool
yesno (void)
{
/* We make some assumptions here:
Index: lib/yesno.h
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/yesno.h,v
retrieving revision 1.1
diff -p -u -r1.1 yesno.h
--- lib/yesno.h 20 Jun 2004 13:41:24 -0000 1.1
+++ lib/yesno.h 15 Jul 2004 05:13:44 -0000
@@ -19,6 +19,8 @@
#ifndef YESNO_H_
# define YESNO_H_
-int yesno (void);
+# include <stdbool.h>
+
+bool yesno (void);
#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- coreutils miscellaneous int-related changes in lib subdirectory,
Paul Eggert <=