bash-5.0 distribution sources and documentation

This commit is contained in:
Chet Ramey
2019-01-07 09:27:52 -05:00
parent 6444760999
commit d233b485e8
528 changed files with 84836 additions and 67099 deletions
+31 -18
View File
@@ -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-2016 Free Software Foundation, Inc.
Copyright (C) 1997-2017 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -148,8 +148,11 @@ extern int errno;
QUIT; \
if (vflag) \
{ \
bind_printf_variable (vname, vbuf, 0); \
SHELL_VAR *v; \
v = bind_printf_variable (vname, vbuf, 0); \
stupidly_hack_special_variables (vname); \
if (v == 0 || readonly_p (v) || noassign_p (v)) \
return (EXECUTION_FAILURE); \
} \
if (conv_bufsize > 4096 ) \
{ \
@@ -244,6 +247,9 @@ printf_builtin (list)
char mbch[25]; /* 25 > MB_LEN_MAX, plus can handle 4-byte UTF-8 and large Unicode characters*/
int mbind, mblen;
#endif
#if defined (ARRAY_VARS)
int arrayflags;
#endif
conversion_error = 0;
retval = EXECUTION_SUCCESS;
@@ -258,7 +264,8 @@ printf_builtin (list)
case 'v':
vname = list_optarg;
#if defined (ARRAY_VARS)
if (legal_identifier (vname) || valid_array_reference (vname, 0))
arrayflags = assoc_expand_once ? (VA_NOEXPAND|VA_ONEWORD) : 0;
if (legal_identifier (vname) || valid_array_reference (vname, arrayflags))
#else
if (legal_identifier (vname))
#endif
@@ -293,9 +300,10 @@ printf_builtin (list)
/* Allow printf -v var "" to act like var="" */
if (vflag && list->word->word && list->word->word[0] == '\0')
{
bind_printf_variable (vname, "", 0);
SHELL_VAR *v;
v = bind_printf_variable (vname, "", 0);
stupidly_hack_special_variables (vname);
return (EXECUTION_SUCCESS);
return ((v == 0 || readonly_p (v) || noassign_p (v)) ? EXECUTION_FAILURE : EXECUTION_SUCCESS);
}
if (list->word->word == 0 || list->word->word[0] == '\0')
@@ -577,7 +585,7 @@ printf_builtin (list)
else if (ansic_shouldquote (p))
xp = ansic_quote (p, 0, (int *)0);
else
xp = sh_backslash_quote (p, 0, 1);
xp = sh_backslash_quote (p, 0, 3);
if (xp)
{
/* Use printstr to get fieldwidth and precision right. */
@@ -711,8 +719,8 @@ printstr (fmt, string, len, fieldwidth, precision)
int fw, pr; /* fieldwidth and precision */
intmax_t mfw, mpr;
if (string == 0 || len == 0)
return 0;
if (string == 0)
string = "";
#if 0
s = fmt;
@@ -955,7 +963,9 @@ bexpand (string, len, sawc, lenp)
*sawc = 0;
if (lenp)
*lenp = 0;
return ((char *)NULL);
ret = (char *)xmalloc (1);
ret[0] = '\0';
return (ret);
}
ret = (char *)xmalloc (len + 1);
@@ -1192,8 +1202,10 @@ getuintmax ()
if (*ep)
{
sh_invalidnum (garglist->word->word);
#if 0
/* Same POSIX.2 conversion error requirements as getintmax(). */
ret = 0;
#endif
conversion_error = 1;
}
else if (errno == ERANGE)
@@ -1221,8 +1233,10 @@ getfloatmax ()
if (*ep)
{
sh_invalidnum (garglist->word->word);
#if 0
/* Same thing about POSIX.2 conversion error requirements. */
ret = 0;
#endif
conversion_error = 1;
}
else if (errno == ERANGE)
@@ -1239,18 +1253,17 @@ asciicode ()
register intmax_t ch;
#if defined (HANDLE_MULTIBYTE)
wchar_t wc;
size_t mblength, slen;
size_t slen;
int mblength;
#endif
DECLARE_MBSTATE;
#if defined (HANDLE_MULTIBYTE)
slen = strlen (garglist->word->word+1);
mblength = MBLEN (garglist->word->word+1, slen);
if (mblength > 1)
{
mblength = mbtowc (&wc, garglist->word->word+1, slen);
ch = wc; /* XXX */
}
wc = 0;
mblength = mbtowc (&wc, garglist->word->word+1, slen);
if (mblength > 0)
ch = wc; /* XXX */
else
#endif
ch = (unsigned char)garglist->word->word[1];
@@ -1268,10 +1281,10 @@ bind_printf_variable (name, value, flags)
SHELL_VAR *v;
#if defined (ARRAY_VARS)
if (valid_array_reference (name, 0) == 0)
if (valid_array_reference (name, assoc_expand_once ? (VA_NOEXPAND|VA_ONEWORD) : 0) == 0)
v = bind_variable (name, value, flags);
else
v = assign_array_element (name, value, flags);
v = assign_array_element (name, value, flags | (assoc_expand_once ? ASS_NOEXPAND : 0));
#else /* !ARRAY_VARS */
v = bind_variable (name, value, flags);
#endif /* !ARRAY_VARS */