[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bash 2.05 support for arithmetic on file sizes wider than 'long'
From: |
Paul Eggert |
Subject: |
Bash 2.05 support for arithmetic on file sizes wider than 'long' |
Date: |
Mon, 19 Nov 2001 00:05:22 -0800 (PST) |
Configuration Information [Automatically generated, do not change]:
Machine: sparc
OS: solaris2.8
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='sparc'
-DCONF_OSTYPE='solaris2.8' -DCONF_MACHTYPE='sparc-sun-solaris2.8'
-DCONF_VENDOR='sun' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -g
-O2 -Wall -W -Wno-sign-compare -Wpointer-arith -Wstrict-prototypes
-Wmissing-prototypes -Wmissing-noreturn -Wmissing-format-attribute
uname output: SunOS sic.twinsun.com 5.8 Generic_108528-12 sun4u sparc
SUNW,UltraSPARC-IIi-Engine
Machine Type: sparc-sun-solaris2.8
Bash Version: 2.05a
Patch Level: 0
Release Status: release
Description:
[This is a followup to my May 1 message to bug-bash on the
same subject:
http://groups.google.com/groups?selm=200105011955.MAA15487%40shade.twinsun.com
Much of that patch was incorporated into Bash 2.05a, but some
crucial parts are missing. This message proposes a fix for
the biggest part of the problem. I plan to follow up this
message with further patches for more parts of the problem.]
Bash 2.05 uses 'long' for most of its internal arithmetic.
Unfortunately, this doesn't work on hosts like recent versions
of GNU/Linux x86 and 32-bit Solaris, which support "large files"
whose sizes are wider than 'long'. On these hosts, Bash mishandles
calculations involving sizes of large files.
The latest POSIX draft (1003.1-200x draft 7 rationale section
C.2.6.4) says that shell implementations "are encouraged to
support signed integer values at least as large as the size of
the largest file allowed on the implementation".
Repeat-By:
$ filesize=2147483654
$ ((halfsize=$filesize/2))
$ echo $halfsize
-1073741821
The correct answer is 1073741827.
Fix:
2001-11-19 Paul Eggert <eggert@twinsun.com>
Use 'intmax_t', not 'long', for arithmetic calculations.
POSIX 1003.1-200x draft 7 recommends that we use an integer as
least as wide as off_t, and off_t is longer than 'long' on
"large-file" hosts.
* array.c (print_element): Do not assume that the array index
fits in 'long'.
* array.h (arrayind_t): long -> intmax_t
* bashtypes.h: [HAVE_INTTYPES_H]: Include <inttypes.h>.
* builtins/bashgetopt.c (internal_getopt): long -> intmax_t
* builtins/break.def (break_builtin, continue_builtin): Likewise.
* builtins/common.c (get_numeric_arg, get_exitstat,
display_signal_list): Likewise.
(display_signal_list): Rework slightly to
avoid the need for %ld, as intmax_t might be wider than long.
* builtins/common.h (get_numeric_arg, get_dirstack_element,
set_dirstack_element): long -> intmax_t
* builtins/fc.def (fc_number): Likewise.
* builtins/history.def (history_builtin, display_history): Likewise.
* builtins/jobs.def (disown_builtin): Likewise.
* builtins/kill.def (kill_builtin): Likewise.
* builtins/let.def (let_builtin, exp_builtin): Likewise.
* builtins/printf.def (NEED_STRTOIMAX_DECL): Remove; no longer needed.
(INTMAX_CONV): Remove; replacing with...
(PRIdMAX): Define if not already defined.
(mklong): New size_t arg mlen. All callers changed.
(printf_builtin): long -> intmax_t.
Use PRIdMAX instead of INTMAX_CONV.
* builtins/pushd.def (get_dirstack_index, pushd_builtin,
popd_builtin, dirs_builtin, add_dirstack_element,
get_dirstack_from_string, get_dirstack_element,
set_dirstack_element): long -> intmax_t
* builtins/read.def (read_builtin): Likewise.
* builtins/shift.def (shift_builtin): Likewise.
* builtins/wait.def (wait_builtin): Likewise.
* doc/bashref.texi (Shell Arithmetic): Evaluation is done with
fixed-width integers, which may be wider than long.
* execute_cmd.c (eval_arith_for_expr,
execute_arith_for_command, select_query,
execute_arith_command): long -> intmax_t
* expr.c (tokval, strlong, subexpr, expcomma, expassign,
expcond, explor, expland, expbor, expbxor, expband, exp5,
exp4, expshift, exp3, exp2, exppower, exp1, exp0,
EXPR_CONTENT, evalexp, main, itos): Likewise.
* externs.h (evalexp, inttostr, itos, uinttostr, uitos): Likewise.
(fmtumax): New decl.
(strtoimax, strtoumax): Always declare, regardless of
NEED_STRTOIMAX_DECL.
* general.c (legal_number): long -> intmax_t
* general.h (pointer_to_int, legal_number): Likewise.
* lib/malloc/stats.c (inttostr): Remove decl; no longer used.
(trace_malloc_stats): Revamp to avoid inttostr, so that we don't
need to worry about configuring intmax_t.
Do not assume that a printed pid_t fits in 39 bytes.
* lib/sh/Makefile.in (CSOURCES): Add fmtumax.c.
(OBJECTS): Add fmtumax.o.
(fmtumax.o): New rule.
* lib/sh/fmtullong.c (QUAD): Remove.
(LONG, UNSIGNED_LONG, fmtulong): New macros.
* lib/sh/fmtulong.c (LONG):
Remove special case for QUAD; now defined by includer.
(FMTUL_LONG_MAX, FMTUL_ULONG_MAX): Remove: no longer needed.
(UNSIGNED_LONG): New macro.
(fmtulong): unsigned LONG -> unsigned_LONG.
Rewrite to avoid the need for FMTUL_LONG_MAX.
* lib/sh/itos.c (<chartypes.h>): Remove include; no longer needed.
(inttostr, itos, uinttostr, uitos): long -> intmax_t,
unsigned long -> uintmax_t.
* lib/sh/netopen.c (_getserv): long -> intmax_t
* mailcheck.c (time_to_check_mail): Likewise.
* parse.y (read_token_word): Likewise.
* redir.c (redir_special_open, do_redirection_internal): Likewise.
* subst.c (parameter_brace_expand_length,
verify_substring_values, sub_append_number,
get_dollar_var_value, parameter_brace_expand_word,
parameter_brace_substring, parameter_brace_expand,
param_expand): Likewise.
* subst.h (sub_append_number, get_dollar_var_value): Likewise.
* test.c (test_stat, arithcomp, unary_operator, unary_test): Likewise.
* trap.c (decode_signal): Likewise.
* variables.c (adjust_shell_level, seconds_value_assigned,
assign_lines, make_variable_value, bind_var_to_int, sv_histsize):
Likewise.
* variables.h (bind_var_to_int, put_gnu_argv_flags_into_env):
Likewise.
* lib/sh/fmtumax.c: New file.
* Makefile.in (SHLIB_SOURCE): Add fmtumax.c.
* MANIFEST: Add lib/sh/fmtumax.c.
===================================================================
RCS file: array.c,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- array.c 2001/10/29 18:09:42 2.5.1.4
+++ array.c 2001/11/19 06:00:59 2.5.1.4.0.1
@@ -9,7 +9,7 @@
* chet@ins.cwru.edu
*/
-/* Copyright (C) 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 2001 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -578,7 +578,11 @@ int mflags;
print_element(ae)
ARRAY_ELEMENT *ae;
{
- printf("array[%ld] = %s\n", element_index(ae), element_value(ae));
+ char lbuf[INT_STRLEN_BOUND (intmax_t) + 1];
+
+ printf ("array[%s] = %s\n",
+ inttostr (element_index (ae), lbuf, sizeof lbuf),
+ element_value (ae));
}
print_array(a)
===================================================================
RCS file: array.h,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- array.h 2001/09/10 16:32:13 2.5.1.4
+++ array.h 2001/11/19 06:00:59 2.5.1.4.0.1
@@ -1,7 +1,7 @@
/* array.h -- definitions for the interface exported by array.c that allows
the rest of the shell to manipulate array variables. */
-/* Copyright (C) 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 2001 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -24,7 +24,7 @@
#include "stdc.h"
-typedef long arrayind_t;
+typedef intmax_t arrayind_t;
enum atype {array_indexed, array_assoc};
===================================================================
RCS file: bashtypes.h,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- bashtypes.h 1999/08/05 11:02:34 2.5.1.4
+++ bashtypes.h 2001/11/19 06:00:59 2.5.1.4.0.1
@@ -1,6 +1,6 @@
-/* bashtypes.h -- <sys/types.h> with special handling for crays. */
+/* bashtypes.h -- Bash system types. */
-/* Copyright (C) 1993 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 2001 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -31,4 +31,8 @@
# undef word
#endif
+#if defined (HAVE_INTTYPES_H)
+# include <inttypes.h>
+#endif
+
#endif /* _BASHTYPES_H_ */
===================================================================
RCS file: builtins/bashgetopt.c,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- builtins/bashgetopt.c 2001/09/12 15:56:33 2.5.1.4
+++ builtins/bashgetopt.c 2001/11/19 06:00:59 2.5.1.4.0.1
@@ -1,6 +1,6 @@
/* bashgetopt.c -- `getopt' for use by the builtins. */
-/* Copyright (C) 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1992, 2001 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -131,7 +131,7 @@ char *opts;
} else
list_optarg = (char *)NULL;
} else {
- if (lcurrent->next &&
legal_number(lcurrent->next->word->word, (long *)0)) {
+ if (lcurrent->next && legal_number
(lcurrent->next->word->word, (intmax_t *)0)) {
lcurrent = lcurrent->next;
list_optarg = lcurrent->word->word;
lcurrent = lcurrent->next;
===================================================================
RCS file: builtins/break.def,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- builtins/break.def 2001/05/21 19:26:47 2.5.1.4
+++ builtins/break.def 2001/11/19 06:00:59 2.5.1.4.0.1
@@ -1,7 +1,7 @@
This file is break.def, from which is created break.c.
It implements the builtins "break" and "continue" in Bash.
-Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
+Copyright (C) 1987, 1989, 1991, 2001 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -59,7 +59,7 @@ int
break_builtin (list)
WORD_LIST *list;
{
- long newbreak;
+ intmax_t newbreak;
if (check_loop_level () == 0)
return (EXECUTION_SUCCESS);
@@ -94,7 +94,7 @@ int
continue_builtin (list)
WORD_LIST *list;
{
- long newcont;
+ intmax_t newcont;
if (check_loop_level () == 0)
return (EXECUTION_SUCCESS);
===================================================================
RCS file: builtins/common.c,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- builtins/common.c 2001/10/29 18:14:49 2.5.1.4
+++ builtins/common.c 2001/11/19 06:00:59 2.5.1.4.0.1
@@ -1,4 +1,4 @@
-/* Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
+/* Copyright (C) 1987, 1989, 1991, 2001 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -330,12 +330,12 @@ set_dollar_vars_changed ()
follow. If FATAL is true, call throw_to_top_level, which exits the
shell; if not, call jump_to_top_level (DISCARD), which aborts the
current command. */
-long
+intmax_t
get_numeric_arg (list, fatal)
WORD_LIST *list;
int fatal;
{
- long count = 1;
+ intmax_t count = 1;
if (list)
{
@@ -362,7 +362,7 @@ get_exitstat (list)
WORD_LIST *list;
{
int status;
- long sval;
+ intmax_t sval;
char *arg;
arg = list->word->word;
@@ -546,7 +546,8 @@ display_signal_list (list, forcecols)
register int i, column;
char *name;
int result;
- long signum;
+ intmax_t lsignum;
+ int signum;
result = EXECUTION_SUCCESS;
if (!list)
@@ -581,13 +582,13 @@ display_signal_list (list, forcecols)
/* List individual signal names or numbers. */
while (list)
{
- if (legal_number (list->word->word, &signum))
+ if (legal_number (list->word->word, &lsignum))
{
/* This is specified by Posix.2 so that exit statuses can be
mapped into signal numbers. */
- if (signum > 128)
- signum -= 128;
- if (signum < 0 || signum >= NSIG)
+ if (lsignum > 128)
+ lsignum -= 128;
+ if (lsignum < 0 || lsignum >= NSIG)
{
builtin_error ("bad signal number: %s", list->word->word);
result = EXECUTION_FAILURE;
@@ -595,6 +596,7 @@ display_signal_list (list, forcecols)
continue;
}
+ signum = lsignum;
name = signal_name (signum);
if (STREQN (name, "SIGJUNK", 7) || STREQN (name, "Unknown", 7))
{
@@ -619,7 +621,7 @@ display_signal_list (list, forcecols)
list = list->next;
continue;
}
- printf ("%ld\n", signum);
+ printf ("%d\n", signum);
}
list = list->next;
}
===================================================================
RCS file: builtins/common.h,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- builtins/common.h 2001/09/12 14:01:40 2.5.1.4
+++ builtins/common.h 2001/11/19 06:00:59 2.5.1.4.0.1
@@ -1,6 +1,6 @@
/* common.h -- extern declarations for functions defined in common.c. */
-/* Copyright (C) 1993 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 2001 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -49,7 +49,7 @@ extern int dollar_vars_changed __P((void
extern void set_dollar_vars_unchanged __P((void));
extern void set_dollar_vars_changed __P((void));
-extern long get_numeric_arg __P((WORD_LIST *, int));
+extern intmax_t get_numeric_arg __P((WORD_LIST *, int));
extern int get_exitstat __P((WORD_LIST *));
extern int read_octal __P((char *));
@@ -106,8 +106,8 @@ extern void set_var_attribute __P((char
/* Functions from pushd.def */
extern char *get_dirstack_from_string __P((char *));
-extern char *get_dirstack_element __P((long, int));
-extern void set_dirstack_element __P((long, int, char *));
+extern char *get_dirstack_element __P((intmax_t, int));
+extern void set_dirstack_element __P((intmax_t, int, char *));
extern WORD_LIST *get_directory_stack __P((void));
/* Functions from evalstring.c */
===================================================================
RCS file: builtins/fc.def,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- builtins/fc.def 2001/09/12 15:57:25 2.5.1.4
+++ builtins/fc.def 2001/11/19 06:00:59 2.5.1.4.0.1
@@ -1,7 +1,7 @@
This file is fc.def, from which is created fc.c.
It implements the builtin "fc" in Bash.
-Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
+Copyright (C) 1987, 1989, 1991, 2001 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -410,7 +410,7 @@ fc_number (list)
s = list->word->word;
if (*s == '-')
s++;
- return (legal_number (s, (long *)NULL));
+ return (legal_number (s, (intmax_t *)NULL));
}
/* Return an absolute index into HLIST which corresponds to COMMAND. If
===================================================================
RCS file: builtins/history.def,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- builtins/history.def 2001/05/21 19:32:57 2.5.1.4
+++ builtins/history.def 2001/11/19 06:00:59 2.5.1.4.0.1
@@ -1,7 +1,7 @@
This file is history.def, from which is created history.c.
It implements the builtin "history" in Bash.
-Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
+Copyright (C) 1987, 1989, 1991, 2001 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -91,7 +91,7 @@ history_builtin (list)
{
int flags, opt, result;
char *filename, *delete_arg;
- long delete_offset;
+ intmax_t delete_offset;
flags = 0;
reset_internal_getopt ();
@@ -215,7 +215,7 @@ display_history (list)
WORD_LIST *list;
{
register int i;
- long limit;
+ intmax_t limit;
HIST_ENTRY **hlist;
if (list)
===================================================================
RCS file: builtins/jobs.def,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- builtins/jobs.def 2001/09/11 19:38:49 2.5.1.4
+++ builtins/jobs.def 2001/11/19 06:00:59 2.5.1.4.0.1
@@ -1,7 +1,7 @@
This file is jobs.def, from which is created jobs.c.
It implements the builtins "jobs" and "disown" in Bash.
-Copyright (C) 1987, 1989, 1991, 1992 Free Software Foundation, Inc.
+Copyright (C) 1987, 1989, 1991, 1992, 2001 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -219,7 +219,7 @@ disown_builtin (list)
{
int opt, job, retval, nohup_only, running_jobs, all_jobs;
sigset_t set, oset;
- long pid_value;
+ intmax_t pid_value;
nohup_only = running_jobs = all_jobs = 0;
reset_internal_getopt ();
===================================================================
RCS file: builtins/kill.def,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- builtins/kill.def 2001/10/15 17:23:32 2.5.1.4
+++ builtins/kill.def 2001/11/19 06:00:59 2.5.1.4.0.1
@@ -1,7 +1,7 @@
This file is kill.def, from which is created kill.c.
It implements the builtin "kill" in Bash.
-Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
+Copyright (C) 1987, 1989, 1991, 2001 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -76,7 +76,7 @@ kill_builtin (list)
int signal, any_succeeded, listing, saw_signal;
char *sigspec, *word;
pid_t pid;
- long pid_value;
+ intmax_t pid_value;
if (list == 0)
{
===================================================================
RCS file: builtins/let.def,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- builtins/let.def 2001/09/17 17:51:02 2.5.1.4
+++ builtins/let.def 2001/11/19 06:00:59 2.5.1.4.0.1
@@ -1,7 +1,7 @@
This file is let.def, from which is created let.c.
It implements the builtin "let" in Bash.
-Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
+Copyright (C) 1987, 1989, 1991, 2001 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -24,7 +24,7 @@ $FUNCTION let_builtin
$PRODUCES let.c
$SHORT_DOC let arg [arg ...]
Each ARG is an arithmetic expression to be evaluated. Evaluation
-is done in long integers with no check for overflow, though division
+is done in fixed-width integers with no check for overflow, though division
by 0 is trapped and flagged as an error. The following list of
operators is grouped into levels of equal-precedence operators.
The levels are listed in order of decreasing precedence.
@@ -48,7 +48,7 @@ The levels are listed in order of decrea
&=, ^=, |= assignment
Shell variables are allowed as operands. The name of the variable
-is replaced by its value (coerced to a long integer) within
+is replaced by its value (coerced to a fixed-width integer) within
an expression. The variable need not have its integer attribute
turned on to be used in an expression.
@@ -77,7 +77,7 @@ int
let_builtin (list)
WORD_LIST *list;
{
- long ret;
+ intmax_t ret;
int expok;
if (list == 0)
@@ -102,7 +102,8 @@ exp_builtin (list)
WORD_LIST *list;
{
char *exp;
- int ret, expok;
+ intmax_t ret;
+ int expok;
if (list == 0)
{
===================================================================
RCS file: builtins/printf.def,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- builtins/printf.def 2001/11/01 17:37:49 2.5.1.4
+++ builtins/printf.def 2001/11/19 06:00:59 2.5.1.4.0.1
@@ -1,7 +1,7 @@
This file is printf.def, from which is created printf.c.
It implements the builtin "printf" in Bash.
-Copyright (C) 1997 Free Software Foundation, Inc.
+Copyright (C) 1997, 2001 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -56,18 +56,17 @@ $END
#include "../bashansi.h"
-#define NEED_STRTOIMAX_DECL
-
#include "../shell.h"
#include "stdc.h"
#include "bashgetopt.h"
#include "common.h"
-/* This should use the ISO C constant format strings; I'll do that later. */
-#if SIZEOF_LONG < SIZEOF_LONG_LONG
-# define INTMAX_CONV "ll"
-#else
-# define INTMAX_CONV "l"
+#if !defined (PRIdMAX)
+# if HAVE_LONG_LONG
+# define PRIdMAX "lld"
+# else
+# define PRIdMAX "ld"
+# endif
#endif
#if !defined (errno)
@@ -107,7 +106,7 @@ extern int errno;
static void printstr __P((char *, char *, int, int, int));
static int tescape __P((char *, int, char *, int *));
static char *bexpand __P((char *, int, int *, int *));
-static char *mklong __P((char *, char *));
+static char *mklong __P((char *, char *, size_t));
static int getchr __P((void));
static char *getstr __P((void));
static int getint __P((void));
@@ -138,7 +137,7 @@ printf_builtin (list)
{
int ch, fieldwidth, precision;
int have_fieldwidth, have_precision;
- long tw;
+ intmax_t tw;
char convch, thisch, nextch, *format, *modstart, *fmt, *start;
conversion_error = 0;
@@ -342,7 +341,7 @@ printf_builtin (list)
long long p;
p = getllong ();
- f = mklong (start, "ll");
+ f = mklong (start, "ll", 2);
PF(f, p);
}
else
@@ -352,7 +351,7 @@ printf_builtin (list)
intmax_t p;
p = getintmax ();
- f = mklong (start, INTMAX_CONV);
+ f = mklong (start, PRIdMAX, sizeof PRIdMAX - 2);
PF(f, p);
}
else
@@ -360,7 +359,7 @@ printf_builtin (list)
long p;
p = getlong ();
- f = mklong (start, "l");
+ f = mklong (start, "l", 1);
PF(f, p);
}
break;
@@ -378,7 +377,7 @@ printf_builtin (list)
unsigned long long p;
p = getullong ();
- f = mklong (start, "ll");
+ f = mklong (start, "ll", 2);
PF(f, p);
}
else
@@ -388,7 +387,7 @@ printf_builtin (list)
uintmax_t p;
p = getuintmax ();
- f = mklong (start, INTMAX_CONV);
+ f = mklong (start, PRIdMAX, sizeof PRIdMAX - 2);
PF(f, p);
}
else
@@ -396,7 +395,7 @@ printf_builtin (list)
unsigned long p;
p = getulong ();
- f = mklong (start, "l");
+ f = mklong (start, "l", 1);
PF (f, p);
}
break;
@@ -420,7 +419,7 @@ printf_builtin (list)
long double p;
p = getldouble ();
- f = mklong (start, "L");
+ f = mklong (start, "L", 1);
PF (f, p);
}
else
@@ -429,7 +428,7 @@ printf_builtin (list)
double p;
p = getdouble ();
- f = mklong (start, "");
+ f = mklong (start, "", 0);
PF (f, p);
}
break;
@@ -706,14 +705,14 @@ bexpand (string, len, sawc, lenp)
}
static char *
-mklong (str, modifiers)
+mklong (str, modifiers, mlen)
char *str;
char *modifiers;
+ size_t mlen;
{
- size_t len, slen, mlen;
+ size_t len, slen;
slen = strlen (str);
- mlen = strlen (modifiers);
len = slen + mlen + 1;
if (len > conv_bufsize)
===================================================================
RCS file: builtins/pushd.def,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- builtins/pushd.def 2001/09/17 17:46:28 2.5.1.4
+++ builtins/pushd.def 2001/11/19 06:00:59 2.5.1.4.0.1
@@ -1,7 +1,7 @@
This file is pushd.def, from which is created pushd.c. It implements the
builtins "pushd", "popd", and "dirs" in Bash.
-Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
+Copyright (C) 1987, 1989, 1991, 2001 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -141,7 +141,7 @@ static void clear_directory_stack __P((v
static int cd_to_string __P((char *));
static int change_to_temp __P((char *));
static void add_dirstack_element __P((char *));
-static int get_dirstack_index __P((long, int, int *));
+static int get_dirstack_index __P((intmax_t, int, int *));
#define NOCD 0x01
#define ROTATE 0x02
@@ -154,7 +154,7 @@ pushd_builtin (list)
{
char *temp, *current_directory, *top;
int j, flags;
- long num;
+ intmax_t num;
char direction;
/* If there is no argument list then switch current and
@@ -287,7 +287,7 @@ popd_builtin (list)
WORD_LIST *list;
{
register int i;
- long which;
+ intmax_t which;
int flags;
char direction;
char *which_word;
@@ -364,7 +364,7 @@ dirs_builtin (list)
WORD_LIST *list;
{
int flags, desired_index, index_flag, vflag;
- long i;
+ intmax_t i;
char *temp, *w;
for (flags = vflag = index_flag = 0, desired_index = -1, w = ""; list; list
= list->next)
@@ -537,7 +537,7 @@ add_dirstack_element (dir)
static int
get_dirstack_index (ind, sign, indexp)
- long ind;
+ intmax_t ind;
int sign, *indexp;
{
if (indexp)
@@ -565,7 +565,7 @@ get_dirstack_from_string (string)
char *string;
{
int ind, sign, index_flag;
- long i;
+ intmax_t i;
sign = 1;
if (*string == '-' || *string == '+')
@@ -589,7 +589,7 @@ get_dirstack_from_string (string)
#ifdef INCLUDE_UNUSED
char *
get_dirstack_element (ind, sign)
- long ind;
+ intmax_t ind;
int sign;
{
int i;
@@ -602,7 +602,7 @@ get_dirstack_element (ind, sign)
void
set_dirstack_element (ind, sign, value)
- long ind;
+ intmax_t ind;
int sign;
char *value;
{
===================================================================
RCS file: builtins/read.def,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- builtins/read.def 2001/10/31 15:31:52 2.5.1.4
+++ builtins/read.def 2001/11/19 06:00:59 2.5.1.4.0.1
@@ -1,7 +1,7 @@
This file is read.def, from which is created read.c.
It implements the builtin "read" in Bash.
-Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
+Copyright (C) 1987, 1989, 1991, 2001 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -125,7 +125,7 @@ read_builtin (list)
int input_is_tty, input_is_pipe, unbuffered_read;
int raw, edit, nchars, silent, have_timeout;
unsigned int tmout;
- long timeoutval, ncharsval;
+ intmax_t timeoutval, ncharsval;
char c;
char *input_string, *orig_input_string, *ifs_chars, *prompt, *arrayname;
char *e, *t, *t1;
===================================================================
RCS file: builtins/shift.def,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- builtins/shift.def 2001/05/21 19:26:12 2.5.1.4
+++ builtins/shift.def 2001/11/19 06:00:59 2.5.1.4.0.1
@@ -1,7 +1,7 @@
This file is shift.def, from which is created shift.c.
It implements the builtin "shift" in Bash.
-Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
+Copyright (C) 1987, 1989, 1991, 2001 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -52,7 +52,7 @@ int
shift_builtin (list)
WORD_LIST *list;
{
- long times;
+ intmax_t times;
register int count;
WORD_LIST *temp;
===================================================================
RCS file: builtins/wait.def,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- builtins/wait.def 2001/10/29 18:45:52 2.5.1.4
+++ builtins/wait.def 2001/11/19 06:00:59 2.5.1.4.0.1
@@ -1,7 +1,7 @@
This file is wait.def, from which is created wait.c.
It implements the builtin "wait" in Bash.
-Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
+Copyright (C) 1987, 1989, 1991, 2001 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -124,7 +124,7 @@ wait_builtin (list)
{
pid_t pid;
char *w;
- long pid_value;
+ intmax_t pid_value;
w = list->word->word;
if (DIGIT (*w))
===================================================================
RCS file: doc/bashref.texi,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- doc/bashref.texi 2001/11/13 17:55:03 2.5.1.4
+++ doc/bashref.texi 2001/11/19 06:00:59 2.5.1.4.0.1
@@ -4919,7 +4919,7 @@ may be positive or negative integers.
The shell allows arithmetic expressions to be evaluated, as one of
the shell expansions or by the @code{let} builtin.
-Evaluation is done in long integers with no check for overflow,
+Evaluation is done in fixed-width integers with no check for overflow,
though division by 0 is trapped and flagged as an error.
The operators and their precedence and associativity are the same
as in the C language.
===================================================================
RCS file: execute_cmd.c,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- execute_cmd.c 2001/10/29 19:03:18 2.5.1.4
+++ execute_cmd.c 2001/11/19 06:00:59 2.5.1.4.0.1
@@ -1,6 +1,6 @@
/* execute_command.c -- Execute a COMMAND structure. */
-/* Copyright (C) 1987,1991 Free Software Foundation, Inc.
+/* Copyright (C) 1987, 1991, 2001 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -151,7 +151,7 @@ static void print_formatted_time __P((FI
static int time_command __P((COMMAND *, int, int, int, struct fd_bitmap *));
#endif
#if defined (ARITH_FOR_COMMAND)
-static long eval_arith_for_expr __P((WORD_LIST *, int *));
+static intmax_t eval_arith_for_expr __P((WORD_LIST *, int *));
static int execute_arith_for_command __P((ARITH_FOR_COM *));
#endif
static int execute_case_command __P((CASE_COM *));
@@ -1661,13 +1661,13 @@ execute_for_command (for_command)
eval \(\( step \)\)
done
*/
-static long
+static intmax_t
eval_arith_for_expr (l, okp)
WORD_LIST *l;
int *okp;
{
WORD_LIST *new;
- long expresult;
+ intmax_t expresult;
new = expand_words_no_vars (l);
if (new)
@@ -1690,7 +1690,7 @@ static int
execute_arith_for_command (arith_for_command)
ARITH_FOR_COM *arith_for_command;
{
- long expresult;
+ intmax_t expresult;
int expok, body_status;
body_status = EXECUTION_SUCCESS;
@@ -1865,7 +1865,7 @@ select_query (list, list_len, prompt)
char *prompt;
{
int max_elem_len, indices_len, len;
- long reply;
+ intmax_t reply;
WORD_LIST *l;
char *repl_string, *t;
@@ -2217,7 +2217,7 @@ execute_arith_command (arith_command)
ARITH_COM *arith_command;
{
int expok;
- long expresult;
+ intmax_t expresult;
WORD_LIST *new;
expresult = 0;
===================================================================
RCS file: expr.c,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- expr.c 2001/10/15 18:19:21 2.5.1.4
+++ expr.c 2001/11/19 06:22:20 2.5.1.4.0.1
@@ -1,6 +1,6 @@
/* expr.c -- arithmetic expression evaluation. */
-/* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
+/* Copyright (C) 1990, 1991, 2001 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -19,7 +19,7 @@
Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/*
- All arithmetic is done as long integers with no checking for overflow
+ All arithmetic is done as intmax_t integers with no checking for overflow
(though division by 0 is caught and flagged as an error).
The following operators are handled, grouped into a set of levels in
@@ -142,41 +142,41 @@ static int curtok; /* the current token
static int lasttok; /* the previous token */
static int assigntok; /* the OP in OP= */
static char *tokstr; /* current token string */
-static long tokval; /* current token value */
+static intmax_t tokval; /* current token value */
static int noeval; /* set to 1 if no assignment to be done */
static procenv_t evalbuf;
static void readtok __P((void)); /* lexical analyzer */
-static long strlong __P((char *));
+static intmax_t strlong __P((char *));
static void evalerror __P((char *));
static void pushexp __P((void));
static void popexp __P((void));
-static long subexpr __P((char *));
+static intmax_t subexpr __P((char *));
-static long expcomma __P((void));
-static long expassign __P((void));
-static long expcond __P((void));
-static long explor __P((void));
-static long expland __P((void));
-static long expbor __P((void));
-static long expbxor __P((void));
-static long expband __P((void));
-static long exp5 __P((void));
-static long exp4 __P((void));
-static long expshift __P((void));
-static long exp3 __P((void));
-static long exp2 __P((void));
-static long exppower __P((void));
-static long exp1 __P((void));
-static long exp0 __P((void));
+static intmax_t expcomma __P((void));
+static intmax_t expassign __P((void));
+static intmax_t expcond __P((void));
+static intmax_t explor __P((void));
+static intmax_t expland __P((void));
+static intmax_t expbor __P((void));
+static intmax_t expbxor __P((void));
+static intmax_t expband __P((void));
+static intmax_t exp5 __P((void));
+static intmax_t exp4 __P((void));
+static intmax_t expshift __P((void));
+static intmax_t exp3 __P((void));
+static intmax_t exp2 __P((void));
+static intmax_t exppower __P((void));
+static intmax_t exp1 __P((void));
+static intmax_t exp0 __P((void));
/* A structure defining a single expression context. */
typedef struct {
int curtok, lasttok;
char *expression, *tp, *lasttp;
- long tokval;
+ intmax_t tokval;
char *tokstr;
int noeval;
} EXPR_CONTEXT;
@@ -185,7 +185,7 @@ typedef struct {
/* Not used yet. */
typedef struct {
char *tokstr;
- long tokval;
+ intmax_t tokval;
} LVALUE;
#endif
@@ -273,12 +273,12 @@ popexp ()
were assigned at program startup or by the compiler. Therefore, it is
safe to let the loop terminate when expr_depth == 0, without freeing up
any of the expr_depth[0] stuff. */
-long
+intmax_t
evalexp (expr, validp)
char *expr;
int *validp;
{
- long val;
+ intmax_t val;
#if 0
procenv_t old_evalbuf;
#endif
@@ -328,11 +328,11 @@ evalexp (expr, validp)
return (val);
}
-static long
+static intmax_t
subexpr (expr)
char *expr;
{
- long val;
+ intmax_t val;
char *p;
for (p = expr; p && *p && cr_whitespace (*p); p++)
@@ -364,10 +364,10 @@ subexpr (expr)
return val;
}
-static long
+static intmax_t
expcomma ()
{
- register long value;
+ register intmax_t value;
value = expassign ();
while (curtok == COMMA)
@@ -379,17 +379,17 @@ expcomma ()
return value;
}
-static long
+static intmax_t
expassign ()
{
- register long value;
+ register intmax_t value;
char *lhs, *rhs;
value = expcond ();
if (curtok == EQ || curtok == OP_ASSIGN)
{
int special, op;
- long lvalue;
+ intmax_t lvalue;
special = curtok == OP_ASSIGN;
@@ -460,10 +460,10 @@ expassign ()
}
/* Conditional expression (expr?expr:expr) */
-static long
+static intmax_t
expcond ()
{
- long cval, val1, val2, rval;
+ intmax_t cval, val1, val2, rval;
int set_noeval;
set_noeval = 0;
@@ -504,10 +504,10 @@ expcond ()
}
/* Logical OR. */
-static long
+static intmax_t
explor ()
{
- register long val1, val2;
+ register intmax_t val1, val2;
int set_noeval;
val1 = expland ();
@@ -532,10 +532,10 @@ explor ()
}
/* Logical AND. */
-static long
+static intmax_t
expland ()
{
- register long val1, val2;
+ register intmax_t val1, val2;
int set_noeval;
val1 = expbor ();
@@ -560,10 +560,10 @@ expland ()
}
/* Bitwise OR. */
-static long
+static intmax_t
expbor ()
{
- register long val1, val2;
+ register intmax_t val1, val2;
val1 = expbxor ();
@@ -578,10 +578,10 @@ expbor ()
}
/* Bitwise XOR. */
-static long
+static intmax_t
expbxor ()
{
- register long val1, val2;
+ register intmax_t val1, val2;
val1 = expband ();
@@ -596,10 +596,10 @@ expbxor ()
}
/* Bitwise AND. */
-static long
+static intmax_t
expband ()
{
- register long val1, val2;
+ register intmax_t val1, val2;
val1 = exp5 ();
@@ -613,10 +613,10 @@ expband ()
return (val1);
}
-static long
+static intmax_t
exp5 ()
{
- register long val1, val2;
+ register intmax_t val1, val2;
val1 = exp4 ();
@@ -634,10 +634,10 @@ exp5 ()
return (val1);
}
-static long
+static intmax_t
exp4 ()
{
- register long val1, val2;
+ register intmax_t val1, val2;
val1 = expshift ();
while ((curtok == LEQ) ||
@@ -663,10 +663,10 @@ exp4 ()
}
/* Left and right shifts. */
-static long
+static intmax_t
expshift ()
{
- register long val1, val2;
+ register intmax_t val1, val2;
val1 = exp3 ();
@@ -686,10 +686,10 @@ expshift ()
return (val1);
}
-static long
+static intmax_t
exp3 ()
{
- register long val1, val2;
+ register intmax_t val1, val2;
val1 = exp2 ();
@@ -708,10 +708,10 @@ exp3 ()
return (val1);
}
-static long
+static intmax_t
exp2 ()
{
- register long val1, val2;
+ register intmax_t val1, val2;
val1 = exppower ();
@@ -738,10 +738,10 @@ exp2 ()
return (val1);
}
-static long
+static intmax_t
exppower ()
{
- register long val1, val2, c;
+ register intmax_t val1, val2, c;
val1 = exp1 ();
if (curtok == POWER)
@@ -759,10 +759,10 @@ exppower ()
return (val1);
}
-static long
+static intmax_t
exp1 ()
{
- register long val;
+ register intmax_t val;
if (curtok == NOT)
{
@@ -780,10 +780,10 @@ exp1 ()
return (val);
}
-static long
+static intmax_t
exp0 ()
{
- register long val = 0, v2;
+ register intmax_t val = 0, v2;
char *vincdec;
int stok;
@@ -1032,7 +1032,7 @@ evalerror (msg)
longjmp (evalbuf, 1);
}
-/* Convert a string to a long integer, with an arbitrary base.
+/* Convert a string to an intmax_t, with an arbitrary base.
0nnn -> base 8
0[Xx]nn -> base 16
Anything else: [base#]number (this is implemented to match ksh93)
@@ -1043,14 +1043,14 @@ evalerror (msg)
from [0-9][a-z][A-Z]_@ (a = 10, z = 35, A = 36, Z = 61, _ = 62, @ = 63 --
you get the picture). */
-static long
+static intmax_t
strlong (num)
char *num;
{
register char *s;
register unsigned char c;
int base, foundbase;
- long val;
+ intmax_t val;
s = num;
@@ -1142,7 +1142,7 @@ main (argc, argv)
char **argv;
{
register int i;
- long v;
+ intmax_t v;
int expok;
if (setjmp (top_level))
@@ -1171,7 +1171,7 @@ builtin_error (format, arg1, arg2, arg3,
char *
itos (n)
- long n;
+ intmax_t n;
{
return ("42");
}
===================================================================
RCS file: externs.h,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- externs.h 2001/10/31 20:46:51 2.5.1.4
+++ externs.h 2001/11/19 06:22:20 2.5.1.4.0.1
@@ -1,7 +1,7 @@
/* externs.h -- extern function declarations which do not appear in their
own header file. */
-/* Copyright (C) 1993 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 2001 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -27,7 +27,7 @@
#include "stdc.h"
/* Functions from expr.c. */
-extern long evalexp __P((char *, int *));
+extern intmax_t evalexp __P((char *, int *));
/* Functions from print_cmd.c. */
extern char *make_command_string __P((COMMAND *));
@@ -130,16 +130,19 @@ extern char *fmtulong __P((unsigned long
extern char *fmtullong __P((unsigned long long int, int, char *, size_t, int));
#endif
+/* Declarations for functions defined in lib/sh/fmtumax.c */
+extern char *fmtumax __P((uintmax_t, int, char *, size_t, int));
+
/* Declarations for functions defined in lib/sh/getcwd.c */
#if !defined (HAVE_GETCWD)
extern char *getcwd __P((char *, size_t));
#endif
/* Declarations for functions defined in lib/sh/itos.c */
-extern char *inttostr __P((long, char *, size_t));
-extern char *itos __P((long));
-extern char *uinttostr __P((unsigned long, char *, size_t));
-extern char *uitos __P((unsigned long));
+extern char *inttostr __P((intmax_t, char *, size_t));
+extern char *itos __P((intmax_t));
+extern char *uinttostr __P((uintmax_t, char *, size_t));
+extern char *uitos __P((uintmax_t));
/* declarations for functions defined in lib/sh/makepath.c */
#define MP_DOTILDE 0x01
@@ -261,8 +264,6 @@ extern unsigned long long strtoull __P((
#endif
/* declarations for functions defined in lib/sh/strimax.c */
-#ifdef NEED_STRTOIMAX_DECL
-
#if !HAVE_DECL_STRTOIMAX
extern intmax_t strtoimax __P((const char *, char **, int));
#endif
@@ -272,8 +273,6 @@ extern intmax_t strtoimax __P((const cha
extern uintmax_t strtoumax __P((const char *, char **, int));
#endif
-#endif /* NEED_STRTOIMAX_DECL */
-
/* declarations for functions defined in lib/sh/strtrans.c */
extern char *ansicstr __P((char *, int, int, int *, int *));
extern char *ansic_quote __P((char *, int, int *));
===================================================================
RCS file: general.c,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- general.c 2001/11/05 22:14:19 2.5.1.4
+++ general.c 2001/11/19 06:22:20 2.5.1.4.0.1
@@ -1,6 +1,6 @@
/* general.c -- Stuff that is used by all files. */
-/* Copyright (C) 1987-1999 Free Software Foundation, Inc.
+/* Copyright (C) 1987-1999, 2001 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -155,20 +155,20 @@ all_digits (string)
int
legal_number (string, result)
char *string;
- long *result;
+ intmax_t *result;
{
- long value;
+ intmax_t value;
char *ep;
if (result)
*result = 0;
errno = 0;
- value = strtol (string, &ep, 10);
+ value = strtoimax (string, &ep, 10);
if (errno)
return 0; /* errno is set on overflow or underflow */
- /* Skip any trailing whitespace, since strtol does not. */
+ /* Skip any trailing whitespace, since strtoimax does not. */
while (whitespace (*ep))
ep++;
===================================================================
RCS file: general.h,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- general.h 2001/10/15 17:52:31 2.5.1.4
+++ general.h 2001/11/19 06:22:20 2.5.1.4.0.1
@@ -1,6 +1,6 @@
/* general.h -- defines that everybody likes to use. */
-/* Copyright (C) 1993 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 2001 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -53,7 +53,7 @@
# endif /* !__STDC__ */
#endif /* !NULL */
-#define pointer_to_int(x) (int)((long)(x))
+#define pointer_to_int(x) (int)((intmax_t)(x))
#if defined (alpha) && defined (__GNUC__) && !defined (strchr) && !defined
(__STDC__)
extern char *strchr (), *strrchr ();
@@ -270,7 +270,7 @@ extern void print_rlimtype __P((RLIMTYPE
#endif
extern int all_digits __P((char *));
-extern int legal_number __P((char *, long *));
+extern int legal_number __P((char *, intmax_t *));
extern int legal_identifier __P((char *));
extern int check_identifier __P((WORD_DESC *, int));
===================================================================
RCS file: lib/malloc/stats.c,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- lib/malloc/stats.c 2001/10/15 13:36:26 2.5.1.4
+++ lib/malloc/stats.c 2001/11/19 06:25:18 2.5.1.4.0.1
@@ -120,21 +120,15 @@ fprint_malloc_stats (s, fp)
}
#define TRACEROOT "/var/tmp/maltrace/trace."
-extern char *inttostr ();
void
trace_malloc_stats (s)
char *s;
{
- char ibuf[32], *ip;
- char fname[64];
- long p;
+ char fname[sizeof TRACEROOT + INT_STRLEN_BOUND (pid_t)];
FILE *fp;
- p = getpid();
- ip = inttostr(p, ibuf, sizeof(ibuf));
- strcpy (fname, TRACEROOT);
- strcat (fname, ip);
+ sprintf (fname, "%s%ld", TRACEROOT, (long) getpid ());
fp = fopen(fname, "w");
if (fp)
{
===================================================================
RCS file: lib/sh/Makefile.in,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- lib/sh/Makefile.in 2001/10/23 18:32:08 2.5.1.4
+++ lib/sh/Makefile.in 2001/11/19 06:25:18 2.5.1.4.0.1
@@ -2,7 +2,7 @@
# Makefile for the Bash library
#
#
-# Copyright (C) 1998 Free Software Foundation, Inc.
+# Copyright (C) 1998, 2001 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
@@ -71,7 +71,7 @@ CSOURCES = clktck.c clock.c getcwd.c get
inet_aton.c netopen.c strpbrk.c timeval.c makepath.c pathcanon.c \
pathphys.c tmpfile.c stringlist.c stringvec.c spell.c \
shquote.c strtrans.c strindex.c snprintf.c mailstat.c fmtulong.c \
- fmtullong.c strtoll.c strtoull.c strtoimax.c strtoumax.c
+ fmtullong.c fmtumax.c strtoll.c strtoull.c strtoimax.c strtoumax.c
# The header files for this library.
HSOURCES =
@@ -83,7 +83,7 @@ OBJECTS = clktck.o clock.o getenv.o osli
netopen.o timeval.o makepath.o pathcanon.o \
pathphys.o tmpfile.o stringlist.o stringvec.o spell.o shquote.o \
strtrans.o strindex.o snprintf.o mailstat.o fmtulong.o \
- fmtullong.o ${LIBOBJS}
+ fmtullong.o fmtumax.o ${LIBOBJS}
SUPPORT = Makefile
@@ -116,6 +116,7 @@ clktck.o: clktck.c
clock.o: clock.c
fmtullong.o: fmtullong.c
fmtulong.o: fmtulong.c
+fmtumax.o: fmtumax.c
getcwd.o: getcwd.c
getenv.o: getenv.c
inet_aton.o: inet_aton.c
@@ -155,6 +156,7 @@ zwrite.o: zwrite.c
# dependencies for c files that include other c files
fmtullong.o: fmtulong.c
+fmtumax.o: fmtulong.c
strtoll.o: strtol.c
strtoul.o: strtol.c
strtoull.o: strtol.c
@@ -164,6 +166,7 @@ clktck.o: ${BUILD_DIR}/config.h
clock.o: ${BUILD_DIR}/config.h
fmtullong.o: ${BUILD_DIR}/config.h
fmtulong.o: ${BUILD_DIR}/config.h
+fmtumax.o: ${BUILD_DIR}/config.h
getcwd.o: ${BUILD_DIR}/config.h
getenv.o: ${BUILD_DIR}/config.h
inet_aton.o: ${BUILD_DIR}/config.h
@@ -395,3 +398,9 @@ fmtullong.o: ${BASHINCDIR}/ansi_stdlib.h
fmtullong.o: ${BASHINCDIR}/chartypes.h
fmtullong.o: ${BASHINCDIR}/stdc.h
fmtullong.o: ${BASHINCDIR}/typemax.h
+
+fmtumax.o: ${topdir}/bashansi.h
+fmtumax.o: ${BASHINCDIR}/ansi_stdlib.h
+fmtumax.o: ${BASHINCDIR}/chartypes.h
+fmtumax.o: ${BASHINCDIR}/stdc.h
+fmtumax.o: ${BASHINCDIR}/typemax.h
===================================================================
RCS file: lib/sh/fmtullong.c,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- lib/sh/fmtullong.c 2001/10/12 18:41:07 2.5.1.4
+++ lib/sh/fmtullong.c 2001/11/19 06:25:18 2.5.1.4.0.1
@@ -18,7 +18,9 @@ Inc., 59 Temple Place - Suite 330, Bosto
#ifdef HAVE_LONG_LONG
-#define QUAD 1
+#define LONG long long
+#define UNSIGNED_LONG unsigned long long
+#define fmtulong fmtullong
#include "fmtulong.c"
#endif
===================================================================
RCS file: lib/sh/fmtulong.c,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- lib/sh/fmtulong.c 2001/10/18 20:17:53 2.5.1.4
+++ lib/sh/fmtulong.c 2001/11/19 06:25:18 2.5.1.4.0.1
@@ -1,6 +1,6 @@
/* fmtulong.c -- Convert unsigned long int to string. */
-/* Copyright (C) 1998, Free Software Foundation, Inc.
+/* Copyright (C) 1998, 2001 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -67,28 +67,17 @@ extern int errno;
# define FL_UNSIGNED 0x08 /* don't add any sign */
#endif
-#ifdef QUAD
- /* fmtullong */
-# define LONG long long
-# define FMTUL_LONG_MAX LLONG_MAX
-# define FMTUL_ULONG_MAX ULLONG_MAX
-#else
+#ifndef LONG
# define LONG long
-# define FMTUL_LONG_MAX LONG_MAX
-# define FMTUL_ULONG_MAX ULONG_MAX
-#endif
-
-/* Set the name */
-#ifdef QUAD
-# define fmtulong fmtullong
+# define UNSIGNED_LONG unsigned long
#endif
-/* `unsigned long' (or unsigned long long) to string conversion for a given
+/* UNSIGNED_LONG to string conversion for a given
base. The caller passes the output buffer and the size. This should
check for buffer underflow, but currently does not. */
char *
fmtulong (ui, base, buf, len, flags)
- unsigned LONG ui;
+ UNSIGNED_LONG ui;
int base;
char *buf;
size_t len;
@@ -134,7 +123,7 @@ fmtulong (ui, base, buf, len, flags)
}
/* Favor signed arithmetic over unsigned arithmetic; it is faster on
many machines. */
- if (ui > FMTUL_LONG_MAX)
+ if ((LONG)ui < 0)
{
*p-- = TOCHAR (ui % 10);
si = ui / 10;
===================================================================
RCS file: lib/sh/itos.c,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- lib/sh/itos.c 2001/10/15 20:10:57 2.5.1.4
+++ lib/sh/itos.c 2001/11/19 06:25:18 2.5.1.4.0.1
@@ -1,6 +1,6 @@
/* itos.c -- Convert integer to string. */
-/* Copyright (C) 1998, Free Software Foundation, Inc.
+/* Copyright (C) 1998, 2001 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -27,47 +27,46 @@
#endif
#include <bashansi.h>
-#include <chartypes.h>
#include "shell.h"
char *
inttostr (i, buf, len)
- long i;
+ intmax_t i;
char *buf;
size_t len;
{
- return (fmtulong (i, 10, buf, len, 0));
+ return (fmtumax (i, 10, buf, len, 0));
}
/* Integer to string conversion. This conses the string; the
caller should free it. */
char *
itos (i)
- long i;
+ intmax_t i;
{
- char *p, lbuf[INT_STRLEN_BOUND(long) + 1];
+ char *p, lbuf[INT_STRLEN_BOUND(intmax_t) + 1];
- p = fmtulong (i, 10, lbuf, sizeof(lbuf), 0);
+ p = fmtumax (i, 10, lbuf, sizeof(lbuf), 0);
return (savestring (p));
}
char *
uinttostr (i, buf, len)
- unsigned long i;
+ uintmax_t i;
char *buf;
size_t len;
{
- return (fmtulong (i, 10, buf, len, FL_UNSIGNED));
+ return (fmtumax (i, 10, buf, len, FL_UNSIGNED));
}
/* Integer to string conversion. This conses the string; the
caller should free it. */
char *
uitos (i)
- unsigned long i;
+ uintmax_t i;
{
- char *p, lbuf[INT_STRLEN_BOUND(long) + 1];
+ char *p, lbuf[INT_STRLEN_BOUND(uintmax_t) + 1];
- p = fmtulong (i, 10, lbuf, sizeof(lbuf), FL_UNSIGNED);
+ p = fmtumax (i, 10, lbuf, sizeof(lbuf), FL_UNSIGNED);
return (savestring (p));
}
===================================================================
RCS file: lib/sh/netopen.c,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- lib/sh/netopen.c 2001/10/23 18:30:25 2.5.1.4
+++ lib/sh/netopen.c 2001/11/19 06:25:18 2.5.1.4.0.1
@@ -5,7 +5,7 @@
* chet@ins.CWRU.Edu
*/
-/* Copyright (C) 1987,1991 Free Software Foundation, Inc.
+/* Copyright (C) 1987, 1991, 2001 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -107,7 +107,7 @@ _getserv (serv, proto, pp)
int proto;
unsigned short *pp;
{
- long l;
+ intmax_t l;
unsigned short s;
if (legal_number (serv, &l))
===================================================================
RCS file: mailcheck.c,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- mailcheck.c 2001/10/29 18:03:30 2.5.1.4
+++ mailcheck.c 2001/11/19 06:25:18 2.5.1.4.0.1
@@ -1,6 +1,6 @@
/* mailcheck.c -- The check is in the mail... */
-/* Copyright (C) 1987,1989 Free Software Foundation, Inc.
+/* Copyright (C) 1987, 1989, 2001 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -75,7 +75,7 @@ time_to_check_mail ()
{
char *temp;
time_t now;
- long seconds;
+ intmax_t seconds;
temp = get_string_value ("MAILCHECK");
===================================================================
RCS file: parse.y,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- parse.y 2001/10/30 16:23:35 2.5.1.4
+++ parse.y 2001/11/19 06:25:18 2.5.1.4.0.1
@@ -1,6 +1,6 @@
/* Yacc grammar for bash. */
-/* Copyright (C) 1989 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 2001 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -2933,7 +2933,7 @@ read_token_word (character)
int result, peek_char;
char *ttok, *ttrans;
int ttoklen, ttranslen;
- long lvalue;
+ intmax_t lvalue;
if (token_buffer_size < TOKEN_DEFAULT_INITIAL_SIZE)
token = (char *)xrealloc (token, token_buffer_size =
TOKEN_DEFAULT_INITIAL_SIZE);
===================================================================
RCS file: redir.c,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- redir.c 2001/10/02 19:02:00 2.5.1.4
+++ redir.c 2001/11/19 06:25:18 2.5.1.4.0.1
@@ -1,6 +1,6 @@
/* redir.c -- Functions to perform input and output redirection. */
-/* Copyright (C) 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 2001 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -416,7 +416,7 @@ redir_special_open (spec, filename, flag
{
int fd;
#if !defined (HAVE_DEV_FD)
- long lfd;
+ intmax_t lfd;
#endif
fd = -1;
@@ -562,7 +562,7 @@ do_redirection_internal (redirect, for_r
{
WORD_DESC *redirectee;
int redir_fd, fd, redirector, r, oflags;
- long lfd;
+ intmax_t lfd;
char *redirectee_word;
enum r_instruction ri;
REDIRECT *new_redirect;
===================================================================
RCS file: subst.c,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- subst.c 2001/11/05 19:19:49 2.5.1.4
+++ subst.c 2001/11/19 06:25:18 2.5.1.4.0.1
@@ -4,7 +4,7 @@
/* ``Have a little faith, there's magic in the night. You ain't a
beauty, but, hey, you're alright.'' */
-/* Copyright (C) 1987,1989 Free Software Foundation, Inc.
+/* Copyright (C) 1987, 1989, 2001 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -211,10 +211,10 @@ static char *parameter_brace_expand_rhs
static void parameter_brace_expand_error __P((char *, char *));
static int valid_length_expression __P((char *));
-static long parameter_brace_expand_length __P((char *));
+static intmax_t parameter_brace_expand_length __P((char *));
static char *skiparith __P((char *, int));
-static int verify_substring_values __P((char *, char *, int, long *, long *));
+static int verify_substring_values __P((char *, char *, int, intmax_t *,
intmax_t *));
static int get_var_and_type __P((char *, char *, SHELL_VAR **, char **));
static char *parameter_brace_substring __P((char *, char *, char *, int));
@@ -451,7 +451,7 @@ sub_append_string (source, target, indx,
INDX and SIZE are as in SUB_APPEND_STRING. */
char *
sub_append_number (number, target, indx, size)
- long number;
+ intmax_t number;
int *indx, *size;
char *target;
{
@@ -1935,7 +1935,7 @@ number_of_args ()
/* Return the value of a positional parameter. This handles values > 10. */
char *
get_dollar_var_value (ind)
- long ind;
+ intmax_t ind;
{
char *temp;
WORD_LIST *p;
@@ -3787,7 +3787,7 @@ parameter_brace_expand_word (name, var_i
int var_is_special, quoted;
{
char *temp, *tt;
- long arg_index;
+ intmax_t arg_index;
SHELL_VAR *var;
#if 0
WORD_LIST *l;
@@ -3987,12 +3987,12 @@ valid_length_expression (name)
/* Handle the parameter brace expansion that requires us to return the
length of a parameter. */
-static long
+static intmax_t
parameter_brace_expand_length (name)
char *name;
{
char *t, *newname;
- long number, arg_index;
+ intmax_t number, arg_index;
WORD_LIST *list;
#if defined (ARRAY_VARS)
SHELL_VAR *var;
@@ -4126,7 +4126,7 @@ static int
verify_substring_values (value, substr, vtype, e1p, e2p)
char *value, *substr;
int vtype;
- long *e1p, *e2p;
+ intmax_t *e1p, *e2p;
{
char *t, *temp1, *temp2;
arrayind_t len;
@@ -4268,7 +4268,7 @@ parameter_brace_substring (varname, valu
char *varname, *value, *substr;
int quoted;
{
- long e1, e2;
+ intmax_t e1, e2;
int vtype, r;
char *temp, *val;
SHELL_VAR *v;
@@ -4547,7 +4547,7 @@ parameter_brace_expand (string, indexp,
int want_substring, want_indir, want_patsub;
char *name, *value, *temp, *temp1;
int t_index, sindex, c;
- long number;
+ intmax_t number;
value = (char *)NULL;
var_is_set = var_is_null = var_is_special = check_nullness = 0;
@@ -4907,7 +4907,7 @@ param_expand (string, sindex, quoted, ex
char *temp, *temp1;
int zindex, t_index, expok;
unsigned char c;
- long number;
+ intmax_t number;
SHELL_VAR *var;
WORD_LIST *list;
===================================================================
RCS file: subst.h,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- subst.h 2001/09/19 13:46:26 2.5.1.4
+++ subst.h 2001/11/19 06:25:18 2.5.1.4.0.1
@@ -1,6 +1,6 @@
/* subst.h -- Names of externally visible functions in subst.c. */
-/* Copyright (C) 1993 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 2001 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -105,7 +105,7 @@ extern char *sub_append_string __P((char
/* Append the textual representation of NUMBER to TARGET.
INDEX and SIZE are as in SUB_APPEND_STRING. */
-extern char *sub_append_number __P((long, char *, int *, int *));
+extern char *sub_append_number __P((intmax_t, char *, int *, int *));
/* Return the word list that corresponds to `$*'. */
extern WORD_LIST *list_rest_of_args __P((void));
@@ -155,7 +155,7 @@ extern WORD_LIST *expand_word_unsplit __
extern WORD_LIST *expand_word_leave_quoted __P((WORD_DESC *, int));
/* Return the value of a positional parameter. This handles values > 10. */
-extern char *get_dollar_var_value __P((long));
+extern char *get_dollar_var_value __P((intmax_t));
/* Quote a string to protect it from word splitting. */
extern char *quote_string __P((char *));
===================================================================
RCS file: test.c,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- test.c 2001/10/30 17:37:48 2.5.1.4
+++ test.c 2001/11/19 06:25:18 2.5.1.4.0.1
@@ -2,7 +2,8 @@
/* Modified to run with the GNU shell Apr 25, 1988 by bfox. */
-/* Copyright (C) 1987, 1988, 1989, 1990, 1991 Free Software Foundation, Inc.
+/* Copyright (C) 1987, 1988, 1989, 1990, 1991, 2001 Free Software Foundation,
+ Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -181,7 +182,7 @@ test_stat (path, finfo)
if (path[0] == '/' && path[1] == 'd' && strncmp (path, "/dev/fd/", 8) == 0)
{
#if !defined (HAVE_DEV_FD)
- long fd;
+ intmax_t fd;
int r;
if (legal_number (path + 8, &fd) && fd == (int)fd)
@@ -423,7 +424,7 @@ arithcomp (s, t, op, flags)
char *s, *t;
int op, flags;
{
- long l, r;
+ intmax_t l, r;
int expok;
if (flags & TEST_ARITHEXP)
@@ -558,7 +559,7 @@ static int
unary_operator ()
{
char *op;
- long r;
+ intmax_t r;
op = argv[pos];
if (test_unop (op) == 0)
@@ -594,7 +595,7 @@ int
unary_test (op, arg)
char *op, *arg;
{
- long r;
+ intmax_t r;
struct stat stat_buf;
switch (op[1])
===================================================================
RCS file: trap.c,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- trap.c 2001/09/10 19:10:22 2.5.1.4
+++ trap.c 2001/11/19 06:25:18 2.5.1.4.0.1
@@ -1,7 +1,7 @@
/* trap.c -- Not the trap command, but useful functions for manipulating
those objects. The trap command is in builtins/trap.def. */
-/* Copyright (C) 1987, 1991 Free Software Foundation, Inc.
+/* Copyright (C) 1987, 1991, 2001 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -192,7 +192,7 @@ int
decode_signal (string)
char *string;
{
- long sig;
+ intmax_t sig;
if (legal_number (string, &sig))
return ((sig >= 0 && sig < NSIG) ? (int)sig : NO_SIG);
===================================================================
RCS file: variables.c,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- variables.c 2001/11/05 14:55:34 2.5.1.4
+++ variables.c 2001/11/19 06:39:51 2.5.1.4.0.1
@@ -1,6 +1,6 @@
/* variables.c -- Functions for hacking shell variables. */
-/* Copyright (C) 1987,1989 Free Software Foundation, Inc.
+/* Copyright (C) 1987, 1989, 2001 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -570,7 +570,7 @@ adjust_shell_level (change)
int change;
{
char new_level[5], *old_SHLVL;
- long old_level;
+ intmax_t old_level;
SHELL_VAR *temp_var;
old_SHLVL = get_string_value ("SHLVL");
@@ -1033,7 +1033,7 @@ null_array_assign (self, ind, value)
/* The value of $SECONDS. This is the number of seconds since shell
invocation, or, the number of seconds since the last assignment + the
value of the last assignment. */
-static long seconds_value_assigned;
+static intmax_t seconds_value_assigned;
static SHELL_VAR *
assign_seconds (self, value)
@@ -1165,7 +1165,7 @@ assign_lineno (var, value)
SHELL_VAR *var;
char *value;
{
- long new_value;
+ intmax_t new_value;
if (value == 0 || *value == '\0' || legal_number (value, &new_value) == 0)
new_value = 0;
@@ -1575,7 +1575,7 @@ make_variable_value (var, value)
char *value;
{
char *retval;
- long lval;
+ intmax_t lval;
int expok;
/* If this variable has had its type set to integer (via `declare -i'),
@@ -1754,9 +1754,9 @@ bind_int_variable (lhs, rhs)
SHELL_VAR *
bind_var_to_int (var, val)
char *var;
- long val;
+ intmax_t val;
{
- char ibuf[INT_STRLEN_BOUND (long) + 1], *p;
+ char ibuf[INT_STRLEN_BOUND (intmax_t) + 1], *p;
p = fmtulong (val, 10, ibuf, sizeof (ibuf), 0);
return (bind_int_variable (var, p));
@@ -2865,7 +2865,7 @@ put_command_name_into_env (command_name)
#if 0 /* UNUSED -- it caused too many problems */
void
put_gnu_argv_flags_into_env (pid, flags_string)
- long pid;
+ intmax_t pid;
char *flags_string;
{
char *dummy, *pbuf;
@@ -3084,7 +3084,7 @@ sv_histsize (name)
char *name;
{
char *temp;
- long num;
+ intmax_t num;
temp = get_string_value (name);
===================================================================
RCS file: variables.h,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- variables.h 2001/10/23 12:47:46 2.5.1.4
+++ variables.h 2001/11/19 06:39:51 2.5.1.4.0.1
@@ -1,6 +1,6 @@
/* variables.h -- data structures for shell variables. */
-/* Copyright (C) 1987,1991 Free Software Foundation, Inc.
+/* Copyright (C) 1987, 1991, 2001 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -179,7 +179,7 @@ extern char *make_variable_value __P((SH
extern SHELL_VAR *bind_variable_value __P((SHELL_VAR *, char *));
extern SHELL_VAR *bind_int_variable __P((char *, char *));
-extern SHELL_VAR *bind_var_to_int __P((char *, long));
+extern SHELL_VAR *bind_var_to_int __P((char *, intmax_t));
extern int assignment __P((const char *));
extern int variable_in_context __P((SHELL_VAR *));
@@ -207,7 +207,7 @@ extern void sort_variables __P((SHELL_VA
extern void maybe_make_export_env __P((void));
extern void update_export_env_inplace __P((char *, int, char *));
extern void put_command_name_into_env __P((char *));
-extern void put_gnu_argv_flags_into_env __P((long, char *));
+extern void put_gnu_argv_flags_into_env __P((intmax_t, char *));
extern void print_var_list __P((SHELL_VAR **));
extern void print_func_list __P((SHELL_VAR **));
extern void print_assignment __P((SHELL_VAR *));
--- /dev/null Mon Nov 19 07:01:03 2001
+++ lib/sh/fmtumax.c Mon Nov 19 06:43:47 2001
@@ -0,0 +1,24 @@
+/* fmtumax.c -- Convert uintmax_t to string. */
+
+/* Copyright (C) 2001 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 the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software Foundation,
+Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include <config.h>
+
+#define LONG intmax_t
+#define UNSIGNED_LONG uintmax_t
+#define fmtulong fmtumax
+#include "fmtulong.c"
===================================================================
RCS file: RCS/MANIFEST,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- MANIFEST 2001/10/18 20:15:35 2.5.1.4
+++ MANIFEST 2001/11/19 07:51:54 2.5.1.4.0.1
@@ -319,6 +319,7 @@ lib/sh/clktck.c f
lib/sh/clock.c f
lib/sh/fmtullong.c f
lib/sh/fmtulong.c f
+lib/sh/fmtumax.c f
lib/sh/getcwd.c f
lib/sh/getenv.c f
lib/sh/inet_aton.c f
===================================================================
RCS file: RCS/Makefile.in,v
retrieving revision 2.5.1.4
retrieving revision 2.5.1.4.0.1
diff -pu -r2.5.1.4 -r2.5.1.4.0.1
--- Makefile.in 2001/11/12 16:42:45 2.5.1.4
+++ Makefile.in 2001/11/19 07:51:54 2.5.1.4.0.1
@@ -168,6 +168,7 @@ SHLIB_SOURCE = ${SH_LIBSRC}/clktck.c ${S
${SH_LIBSRC}/strindex.c ${SH_LIBSRC}/shquote.c \
${SH_LIBSRC}/snprintf.c ${SH_LIBSRC}/mailstat.c \
${SH_LIBSRC}/fmtulong.c ${SH_LIBSRC}/fmtullong.c \
+ ${SH_LIBSRC}/fmtumax.c \
${SH_LIBSRC}/strtoll.c ${SH_LIBSRC}/strtoull.c \
${SH_LIBSRC}/strtoimax.c ${SH_LIBSRC}/strtoumax.c
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Bash 2.05 support for arithmetic on file sizes wider than 'long',
Paul Eggert <=