Mercurial > hg > octave-shane > gnulib-hg
comparison lib/inttostr.h @ 5691:ec62790f0938
Factor int-properties macros into a single file, except for
glibc-related files.
* lib/intprops.h: New file.
* lib/getloadavg.c: Include it instead of limits.h.
(INT_STRLEN_BOUND): Remove.
* lib/human.c: Include intprops.h.
(group_number): Use INT_STRLEN_BOUND instead of rolling it ourself.
* lib/human.h (LONGEST_HUMAN_READABLE): Use 146/485 rather than 302/1000.
* lib/inttostr.h: Include intprops.h instead of limits.h.
(INT_STRLEN_BOUND, INT_BUFSIZE_BOUND): Remove.
* lib/mktime.c (TYPE_IS_INTEGER, TYPE_TWOS_COMPLEMENT): New macros,
for consistency with intprops.h.
(time_t_is_integer, twos_complement_arithmetic): Use them.
* lib/sig2str.h: Include <signal.h>, intprops.h.
(INT_STRLEN_BOUND): Remove.
* lib/strftime.c (TYPE_SIGNED): Remove.
(INT_STRLEN_BOUND): Switch to same implementation as intprops.h.
* lib/strtol.c: Adjust comments to match intprops.h.
* lib/userspec.c: Include intprops.h.
(TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM): Remove.
* lib/utimecmp.c, lib/xnanosleep.c, lib/xstrtol.c: Likewise.
* lib/utimecmp.c (utimecmp): Use TYPE_IS_INTEGER, TYPE_TWOS_COMPLEMENT
instead of rolling our own expressions.
* lib/xstrtol.c: Include xstrtol.h first, to test interface.
* modules/getloadavg (Files): Add lib/intprops.h.
* modules/human (Files): Likewise.
* modules/inttostr (Files): Likewise.
* modules/sig2str (Files): Likewise.
* modules/userspec (Files): Likewise.
* modules/utimecmp (Files): Likewise.
* modules/xnanosleep (Files): Likewise.
* modules/xstrtol (Files): Likewise.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Wed, 09 Mar 2005 19:11:23 +0000 |
parents | d3dbed4f82b1 |
children | a48fb0e98c8c |
comparison
equal
deleted
inserted
replaced
5690:e44b4f85ad9b | 5691:ec62790f0938 |
---|---|
1 /* inttostr.h -- convert integers to printable strings | 1 /* inttostr.h -- convert integers to printable strings |
2 | 2 |
3 Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. | 3 Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. |
4 | 4 |
5 This program is free software; you can redistribute it and/or modify | 5 This program is free software; you can redistribute it and/or modify |
6 it under the terms of the GNU General Public License as published by | 6 it under the terms of the GNU General Public License as published by |
7 the Free Software Foundation; either version 2, or (at your option) | 7 the Free Software Foundation; either version 2, or (at your option) |
8 any later version. | 8 any later version. |
27 #endif | 27 #endif |
28 #if HAVE_STDINT_H | 28 #if HAVE_STDINT_H |
29 # include <stdint.h> | 29 # include <stdint.h> |
30 #endif | 30 #endif |
31 | 31 |
32 #include <limits.h> | |
33 | |
34 #if HAVE_SYS_TYPES_H | 32 #if HAVE_SYS_TYPES_H |
35 # include <sys/types.h> | 33 # include <sys/types.h> |
36 #endif | 34 #endif |
37 | 35 |
38 /* Upper bound on the string length of an integer converted to string. | 36 #include "intprops.h" |
39 302 / 1000 is ceil (log10 (2.0)). Subtract 1 for the sign bit; | |
40 add 1 for integer division truncation; add 1 more for a minus sign. */ | |
41 #define INT_STRLEN_BOUND(t) ((sizeof (t) * CHAR_BIT - 1) * 302 / 1000 + 2) | |
42 | |
43 #define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1) | |
44 | 37 |
45 char *offtostr (off_t, char *); | 38 char *offtostr (off_t, char *); |
46 char *imaxtostr (intmax_t, char *); | 39 char *imaxtostr (intmax_t, char *); |
47 char *umaxtostr (uintmax_t, char *); | 40 char *umaxtostr (uintmax_t, char *); |