Mercurial > hg > octave-nkf > gnulib-hg
annotate lib/human.h @ 17587:344018b6e5d7
maint: update copyright
I ran 'make update-copyright'.
Signed-off-by: Eric Blake <eblake@redhat.com>
author | Eric Blake <eblake@redhat.com> |
---|---|
date | Wed, 01 Jan 2014 00:04:40 -0700 |
parents | e542fd46ad6f |
children | ab58d4870664 |
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 |
17587 | 3 Copyright (C) 1996-2007, 2009-2014 Free Software Foundation, Inc. |
4351
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
4 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
9137
diff
changeset
|
5 This program is free software: you can redistribute it and/or modify |
4351
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
6 it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
9137
diff
changeset
|
7 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
9137
diff
changeset
|
8 (at your option) any later version. |
4351
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
9 |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
10 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
|
11 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
|
12 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
|
13 GNU General Public License for more details. |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
14 |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
15 You should have received a copy of the GNU General Public License |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
9137
diff
changeset
|
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
4351
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
17 |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
18 /* Written by Paul Eggert and Larry McVoy. */ |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
19 |
1137
2c9059ccc457
New file. The interface is inspired
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
20 #ifndef HUMAN_H_ |
2c9059ccc457
New file. The interface is inspired
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
21 # define HUMAN_H_ 1 |
2c9059ccc457
New file. The interface is inspired
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
22 |
4351
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
23 # include <limits.h> |
d0d257fdad20
Merge human.c changes from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
24 # 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
|
25 # include <stdint.h> |
6275 | 26 # include <unistd.h> |
1813
9e16d9bc8891
<inttypes.h>: Include it here instead.
Jim Meyering <jim@meyering.net>
parents:
1392
diff
changeset
|
27 |
9137
629a6928f108
* NEWS: Describe interface changes to human, xstrtol.
Paul Eggert <eggert@cs.ucla.edu>
parents:
9127
diff
changeset
|
28 # include <xstrtol.h> |
629a6928f108
* NEWS: Describe interface changes to human, xstrtol.
Paul Eggert <eggert@cs.ucla.edu>
parents:
9127
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 |
16235
18a38c9615f0
In commentary, do not use ` to quote.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
55 /* Group digits together, e.g. "1,000,000". This uses the |
4351
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 |
9137
629a6928f108
* NEWS: Describe interface changes to human, xstrtol.
Paul Eggert <eggert@cs.ucla.edu>
parents:
9127
diff
changeset
|
81 enum strtol_error human_options (char const *, int *, 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_ */ |