Mercurial > hg > octave-nkf > gnulib-hg
annotate lib/human.h @ 7162:19c2e5121b2f
Add and change modules to make it easier for coreutils to use
gnulib-tool.
* lib/cycle-check.h: Include <stdint.h> unconditionally, since we
now assume the stdint module. Do not include inttypes.h.
* lib/fsusage.h: Likewise.
* lib/getndelim2.c: Likewise.
* lib/human.h: Likewise.
* lib/inttostr.h: Likewise.
* lib/obstack.c: Likewise.
* lib/regex_internal.h: Likewise.
* lib/tempname.c: Likewise.
* lib/utimecmp.c: Likewise.
* lib/xstrtol.h: Likewise.
* lib/stat_.h: Fix typo: HAVE_FUNC_LSTAT -> HAVE_LSTAT.
* lib/strtoimax.c: Adjust to macro name changes in Autoconf,
e.g., HAVE_LONG_LONG -> HAVE_LONG_LONG_INT.
* lib/xtime.h: Likewise.
Remove files that are no longer needed by their respective modules.
* m4/obstack.m4: Remove.
* m4/strerror_r.m4: Remove.
* m4/uint32_t.m4: Remove.
* m4/uintptr_t.m4: Remove.
* m4/ullong_max.m4: Remove.
* m4/xstrtoimax.m4: Remove.
* m4/xstrtoumax.m4: Remove.
* cycle-check.m4 (gl_CYCLE_CHECK): Do not require gl_AC_TYPE_UINTMAX_T,
gl_STRUCT_DEV_INO, or gl_SAME_INODE, since gnulib dependencies now
capture this.
* cycle-check.m4 (gl_CYCLE_CHECK):
Do not use AC_LIBSOURCES, since gnulib modules now do this.
* fsusage.m4 (gl_FSUSAGE): Likewise.
* human.m4 (gl_HUMAN): Likewise.
* inttostr.m4 (gl_INTTOSTR): Likewise.
* xstrtol.m4 (gl_XSTRTOL): Likewise.
* filemode.m4 (gl_FILEMODE): Require AC_STRUCT_ST_DM_MODE.
* filemode.m4 (gl_PREREQ_FSUSAGE_EXTRA): Do not require
gl_AC_TYPE_INTMAX_T or gl_AC_TYPE_UINTMAX_T, since we now require
stdint.
* human.m4 (gl_HUMAN): Likewise.
* inttostr.m4 (gl_PREREQ_INTTOSTR): Likewise.
* mkstemp.m4 (gl_PREREQ_TEMPNAME): Likewise.
* strtoimax.m4 (gl_PREREQ_STRTOIMAX): Likewise.
* strtoumax.m4 (gl_PREREQ_STRTOUMAX): Likewise.
* xstrtol (gl_XSTRTOL): Likewise.
* gethrxtime.m4 (gl_XTIME): gl_AC_TYPE_LONG_LONG ->
AC_TYPE_LONG_LONG_INT.
* strtoimax.m4 (gl_PREREQ_STRTOIMAX): Likewise.
* strtoll.m4 (gl_FUNC_STRTOLL): Likewise.
* strtoull.m4 (gl_FUNC_STRTOULL): Likewise, for unsigned long.
* strtoumax.m4 (gl_PREREQ_STRTOUMAX): Likewise.
* human.m4 (gl_HUMAN): Do not require AM_STDBOOL_H since we depend
on stdbool.
* xstrtol.m4 (gl_PREREQ_XSTRTOL_H, gl_PREREQ_XSTRTOL): Remove.
(gl_PREREQ_XSTRTOUL): Remove.
* ls-mntd-fs.m4 (gl_LIST_MOUNTED_FILE_SYSTEMS): Check for hasmntopt.
* posixver.m4: Fix comment since head -1 now works even in POSIX mode.
* modules/backupfile (Files): Remove m4/d-ino.m4.
(Depends-on): Add d-ino.
* modules/cycle-check (Depends-on): Add stdint.
(lib_SOURCES): Add cycle-check.h.
* modules/d-ino: New module.
* modules/d-type: New module.
* modules/error (Files): Remove m4/strerror_r.m4.
* modules/filemode (Files): Add m4/st_dm_mode.m4.
* modules/fsuage (Files): Remove m4/ulonglong.m4, m4/stdint_h.m4,
m4/inttypes_h.m4, m4/uintmax_t.m4.
(Depends-on): Add stdint.
(lib_SOURCES): Add fsusage.h.
* modules/getcwd (Files): Remove d-ino.m4.
(Depends-on): Add d-ino.
* modules/getndelim2 (Depends-on): Add stdint.
* modules/glob (Files): Remove m4/d-type.m4.
(Depends-on): Add d-type.
* modules/host-os: New module.
* modules/human (Files): Remove m4/ulonglong.m4, m4/stdint_h.m4,
m4/inttypes_h.m4, m4/uintmax_t.m4.
* Depends-on: Add stdint.
(lib_SOURCES): Add human.h.
* modules/inttostr (Files): Remove m4/intmax_t.m4,
m4/inttostr.m4, m4/inttypes_h.m4, m4/longlong.m4, m4/stdint_h.m4,
m4/uintmax_t.m4, m4/ulonglong.m4.
(Depends-on): Add stdint.
(EXTRA_DIST): Add inttostr.h.
* modules/lchmod: New module.
* modules/link-follow: New module.
* modules/mkdir-p (Files): Remove lib/lchmod.h, m4/lchmod.m4.
(Depends-on): Add lchmod.
* modules/mkstemp (Files): Remove m4/ulonglong.m4,
m4/stdint_h.m4, m4/inttypes_h.m4, m4/uintmax_t.m4.
(Depends-on): Add stdint.
* modules/obstack (Files): Remove m4/inttypes_h.m4, m4/obstack.m4,
m4/stdint_h.m4, m4/uintmax_t.m4, m4/ulonglong.m4.
(Depends-on): Add stdint.
(configure.ac): Change gl_OBSTACK to AC_FUNC_OBSTACK.
* modules/perl: New module.
* modules/regex (Depends-on): Add stdint.
* modules/rmdir-errno: New module.
* modules/strtoimax (Files): Remove m4/stdint_h.m4, m4/inttypes_h.m4,
m4/intmax_t.m4.
(Depends-on): Add stdint.
* modules/strtoumax (Files): Remove m4/stdint_h.m4, m4/inttypes_h.m4,
m4/uintmax_t.m4.
(Depends-on): Add stdint.
* modules/unlink-busy: New module.
* modules/utimecmp (Depends-on): Add stdint.
* modules/uptime: New module.
* modules/winsz-ioctl: New module.
* modules/winsz-termios: New module.
* modules/xnanosleep (Depends-on): Add nanosleep.
* modules/ullong_max: Remove.
* modules/xstrtoimax (Files): Remove m4/xstrtoimax.m4.
(configure.ac): Remove gl_XSTRTOIMAX; no action needed now.
* modules/xstrtol (Files): Remove m4/ulonglong.m4, m4/longlong.m4,
m4/stdint_h.m4, m4/inttypes_h.m4, m4/uintmax_t.m4, m4/intmax_t.m4.
(Depends-on): Add inttypes.
(lib_SOURCES): Add xstrtol.h.
* modules/xstrtoumax (Files): Remove m4/xstrtoumax.m4.
(configure.ac): Remove gl_XSTRTOUMAX; no action needed now.
* MODULES.html.sh: Move 'assert' into the assert section.
Move 'dummy' into the linking section.
Remove ullong_max.
Add section for compatibility checks for POSIX:2001 functions,
and put d-ino, d-type, link-follow, rmdir-errno, unlink-busy,
winsz-ioctl, and winsz-termios into it.
Add lchmod.
Add top-level Misc section and put host-os, perl, and uptime
into it.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Mon, 21 Aug 2006 06:11:26 +0000 |
parents | fd0ccce602e4 |
children | e18ac20a0e07 |
rev | line source |
---|---|
4351
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
1 /* human.h -- print human readable file size |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
2 |
7162
19c2e5121b2f
Add and change modules to make it easier for coreutils to use
Paul Eggert <eggert@cs.ucla.edu>
parents:
6275
diff
changeset
|
3 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, |
19c2e5121b2f
Add and change modules to make it easier for coreutils to use
Paul Eggert <eggert@cs.ucla.edu>
parents:
6275
diff
changeset
|
4 2005, 2006 Free Software Foundation, Inc. |
4351
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
5 |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
6 This program is free software; you can redistribute it and/or modify |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
7 it under the terms of the GNU General Public License as published by |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
8 the Free Software Foundation; either version 2, or (at your option) |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
9 any later version. |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
10 |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
11 This program is distributed in the hope that it will be useful, |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
14 GNU General Public License for more details. |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
15 |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
16 You should have received a copy of the GNU General Public License |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
17 along with this program; if not, write to the Free Software Foundation, |
5848
a48fb0e98c8c
*** empty log message ***
Paul Eggert <eggert@cs.ucla.edu>
parents:
5691
diff
changeset
|
18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
4351
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
19 |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
20 /* Written by Paul Eggert and Larry McVoy. */ |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
21 |
1137
2c9059ccc457
New file. The interface is inspired
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
22 #ifndef HUMAN_H_ |
2c9059ccc457
New file. The interface is inspired
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
23 # define HUMAN_H_ 1 |
2c9059ccc457
New file. The interface is inspired
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
24 |
4351
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
25 # include <limits.h> |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
26 # include <stdbool.h> |
7162
19c2e5121b2f
Add and change modules to make it easier for coreutils to use
Paul Eggert <eggert@cs.ucla.edu>
parents:
6275
diff
changeset
|
27 # include <stdint.h> |
6275 | 28 # include <unistd.h> |
1813
9e16d9bc8891
<inttypes.h>: Include it here instead.
Jim Meyering <jim@meyering.net>
parents:
1392
diff
changeset
|
29 |
1137
2c9059ccc457
New file. The interface is inspired
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
30 /* A conservative bound on the maximum length of a human-readable string. |
4351
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
31 The output can be the square of the largest uintmax_t, so double |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
32 its size before converting to a bound. |
5691
ec62790f0938
Factor int-properties macros into a single file, except for
Paul Eggert <eggert@cs.ucla.edu>
parents:
5458
diff
changeset
|
33 log10 (2.0) < 146/485. Add 1 for integer division truncation. |
4351
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
34 Also, the output can have a thousands separator between every digit, |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
35 so multiply by MB_LEN_MAX + 1 and then subtract MB_LEN_MAX. |
5458 | 36 Append 1 for a space before the suffix. |
4351
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
37 Finally, append 3, the maximum length of a suffix. */ |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
38 # define LONGEST_HUMAN_READABLE \ |
5691
ec62790f0938
Factor int-properties macros into a single file, except for
Paul Eggert <eggert@cs.ucla.edu>
parents:
5458
diff
changeset
|
39 ((2 * sizeof (uintmax_t) * CHAR_BIT * 146 / 485 + 1) * (MB_LEN_MAX + 1) \ |
5458 | 40 - MB_LEN_MAX + 1 + 3) |
4351
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
41 |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
42 /* Options for human_readable. */ |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
43 enum |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
44 { |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
45 /* Unless otherwise specified these options may be ORed together. */ |
1137
2c9059ccc457
New file. The interface is inspired
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
46 |
4351
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
47 /* The following three options are mutually exclusive. */ |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
48 /* Round to plus infinity (default). */ |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
49 human_ceiling = 0, |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
50 /* Round to nearest, ties to even. */ |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
51 human_round_to_nearest = 1, |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
52 /* Round to minus infinity. */ |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
53 human_floor = 2, |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
54 |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
55 /* Group digits together, e.g. `1,000,000'. This uses the |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
56 locale-defined grouping; the traditional C locale does not group, |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
57 so this has effect only if some other locale is in use. */ |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
58 human_group_digits = 4, |
1137
2c9059ccc457
New file. The interface is inspired
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
59 |
4351
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
60 /* When autoscaling, suppress ".0" at end. */ |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
61 human_suppress_point_zero = 8, |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
62 |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
63 /* Scale output and use SI-style units, ignoring the output block size. */ |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
64 human_autoscale = 16, |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
65 |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
66 /* Prefer base 1024 to base 1000. */ |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
67 human_base_1024 = 32, |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
68 |
5458 | 69 /* Prepend " " before unit symbol. */ |
70 human_space_before_unit = 64, | |
71 | |
4351
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
72 /* Append SI prefix, e.g. "k" or "M". */ |
5458 | 73 human_SI = 128, |
4351
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
74 |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
75 /* Append "B" (if base 1000) or "iB" (if base 1024) to SI prefix. */ |
5458 | 76 human_B = 256 |
1864
734d9b0f9fce
(enum human_inexact_style): New enum.
Jim Meyering <jim@meyering.net>
parents:
1813
diff
changeset
|
77 }; |
734d9b0f9fce
(enum human_inexact_style): New enum.
Jim Meyering <jim@meyering.net>
parents:
1813
diff
changeset
|
78 |
4351
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
79 char *human_readable (uintmax_t, char *, int, uintmax_t, uintmax_t); |
1392
849f05797f68
(human_readable): Coalesce last two args into one, for convenience.
Jim Meyering <jim@meyering.net>
parents:
1170
diff
changeset
|
80 |
4351
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
81 int human_options (char const *, bool, uintmax_t *); |
1137
2c9059ccc457
New file. The interface is inspired
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
82 |
2c9059ccc457
New file. The interface is inspired
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
83 #endif /* HUMAN_H_ */ |