Bash-4.4 distribution sources and documentation
This commit is contained in:
parent
30a978b7d8
commit
a0c0a00fc4
588 changed files with 130746 additions and 80164 deletions
|
|
@ -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-2010 Free Software Foundation, Inc.
|
||||
Copyright (C) 1997-2016 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -40,8 +40,8 @@ printf interprets:
|
|||
|
||||
%b expand backslash escape sequences in the corresponding argument
|
||||
%q quote the argument in a way that can be reused as shell input
|
||||
%(fmt)T output the date-time string resulting from using FMT as a format
|
||||
string for strftime(3)
|
||||
%(fmt)T output the date-time string resulting from using FMT as a format
|
||||
string for strftime(3)
|
||||
|
||||
The format is re-used as necessary to consume all of the arguments. If
|
||||
there are fewer arguments than the format requires, extra format
|
||||
|
|
@ -116,6 +116,7 @@ extern int errno;
|
|||
vbadd (b, 1); \
|
||||
else \
|
||||
putchar (c); \
|
||||
QUIT; \
|
||||
} while (0)
|
||||
|
||||
#define PF(f, func) \
|
||||
|
|
@ -131,6 +132,7 @@ extern int errno;
|
|||
else \
|
||||
nw = vflag ? vbprintf (f, func) : printf (f, func); \
|
||||
tw += nw; \
|
||||
QUIT; \
|
||||
if (ferror (stdout)) \
|
||||
{ \
|
||||
sh_wrerror (); \
|
||||
|
|
@ -143,6 +145,7 @@ extern int errno;
|
|||
#define PRETURN(value) \
|
||||
do \
|
||||
{ \
|
||||
QUIT; \
|
||||
if (vflag) \
|
||||
{ \
|
||||
bind_printf_variable (vname, vbuf, 0); \
|
||||
|
|
@ -162,9 +165,9 @@ extern int errno;
|
|||
} \
|
||||
else if (vbuf) \
|
||||
vbuf[0] = 0; \
|
||||
terminate_immediately--; \
|
||||
if (ferror (stdout) == 0) \
|
||||
fflush (stdout); \
|
||||
QUIT; \
|
||||
if (ferror (stdout)) \
|
||||
{ \
|
||||
sh_wrerror (); \
|
||||
|
|
@ -255,7 +258,7 @@ printf_builtin (list)
|
|||
case 'v':
|
||||
vname = list_optarg;
|
||||
#if defined (ARRAY_VARS)
|
||||
if (legal_identifier (vname) || valid_array_reference (vname))
|
||||
if (legal_identifier (vname) || valid_array_reference (vname, 0))
|
||||
#else
|
||||
if (legal_identifier (vname))
|
||||
#endif
|
||||
|
|
@ -273,6 +276,7 @@ printf_builtin (list)
|
|||
return (EX_USAGE);
|
||||
}
|
||||
break;
|
||||
CASE_HELPOPT;
|
||||
default:
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
|
|
@ -286,6 +290,14 @@ printf_builtin (list)
|
|||
return (EX_USAGE);
|
||||
}
|
||||
|
||||
/* Allow printf -v var "" to act like var="" */
|
||||
if (vflag && list->word->word && list->word->word[0] == '\0')
|
||||
{
|
||||
bind_printf_variable (vname, "", 0);
|
||||
stupidly_hack_special_variables (vname);
|
||||
return (EXECUTION_SUCCESS);
|
||||
}
|
||||
|
||||
if (list->word->word == 0 || list->word->word[0] == '\0')
|
||||
return (EXECUTION_SUCCESS);
|
||||
|
||||
|
|
@ -298,8 +310,6 @@ printf_builtin (list)
|
|||
if (format == 0 || *format == 0)
|
||||
return (EXECUTION_SUCCESS);
|
||||
|
||||
terminate_immediately++;
|
||||
|
||||
/* Basic algorithm is to scan the format string for conversion
|
||||
specifications -- once one is found, find out if the field
|
||||
width or precision is a '*'; if it is, gather up value. Note,
|
||||
|
|
@ -409,6 +419,7 @@ printf_builtin (list)
|
|||
modstart[0] = convch;
|
||||
modstart[1] = '\0';
|
||||
|
||||
QUIT;
|
||||
switch(convch)
|
||||
{
|
||||
case 'c':
|
||||
|
|
@ -759,6 +770,8 @@ printstr (fmt, string, len, fieldwidth, precision)
|
|||
/* Error if precision > INT_MAX here? */
|
||||
pr = (mpr < 0 || mpr > INT_MAX) ? INT_MAX : mpr;
|
||||
}
|
||||
else
|
||||
pr = 0; /* "a null digit string is treated as zero" */
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
|
@ -1045,7 +1058,7 @@ vbprintf (format, va_alist)
|
|||
|
||||
#ifdef DEBUG
|
||||
if (strlen (vbuf) != vblen)
|
||||
internal_error ("printf:vbadd: vblen (%d) != strlen (vbuf) (%d)", vblen, (int)strlen (vbuf));
|
||||
internal_error ("printf:vbprintf: vblen (%d) != strlen (vbuf) (%d)", vblen, (int)strlen (vbuf));
|
||||
#endif
|
||||
|
||||
return (blen);
|
||||
|
|
@ -1255,7 +1268,7 @@ bind_printf_variable (name, value, flags)
|
|||
SHELL_VAR *v;
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
if (valid_array_reference (name) == 0)
|
||||
if (valid_array_reference (name, 0) == 0)
|
||||
v = bind_variable (name, value, flags);
|
||||
else
|
||||
v = assign_array_element (name, value, flags);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue