Compare commits
9
Commits
master
...
1_34_stable
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0cf9e105e6 | ||
|
|
0e0dd21497 | ||
|
|
118baea06e | ||
|
|
5ec12fa657 | ||
|
|
150986c922 | ||
|
|
3c9f559a41 | ||
|
|
9ea17d5a0a | ||
|
|
76ef439154 | ||
|
|
00adcdb64a |
No files matched your search
@@ -1,6 +1,6 @@
|
||||
VERSION = 1
|
||||
PATCHLEVEL = 34
|
||||
SUBLEVEL = 0
|
||||
SUBLEVEL = 1
|
||||
EXTRAVERSION =
|
||||
NAME = Unnamed
|
||||
|
||||
|
||||
+36
-16
@@ -2338,36 +2338,55 @@ static char *awk_printf(node *n, size_t *len)
|
||||
|
||||
b = NULL;
|
||||
i = 0;
|
||||
while (*f) { /* "print one format spec" loop */
|
||||
while (1) { /* "print one format spec" loop */
|
||||
char *s;
|
||||
char c;
|
||||
char sv;
|
||||
var *arg;
|
||||
size_t slen;
|
||||
|
||||
/* Find end of the next format spec, or end of line */
|
||||
s = f;
|
||||
while (*f && (*f != '%' || *++f == '%'))
|
||||
f++;
|
||||
while (*f && !isalpha(*f)) {
|
||||
if (*f == '*')
|
||||
syntax_error("%*x formats are not supported");
|
||||
while (1) {
|
||||
c = *f;
|
||||
if (!c) /* no percent chars found at all */
|
||||
goto nul;
|
||||
f++;
|
||||
if (c == '%')
|
||||
break;
|
||||
}
|
||||
/* we are past % in "....%..." */
|
||||
c = *f;
|
||||
if (!c) {
|
||||
/* Tail of fmt with no percent chars,
|
||||
* or "....%" (percent seen, but no format specifier char found)
|
||||
*/
|
||||
slen = strlen(s);
|
||||
goto tail;
|
||||
if (!c) /* "....%" */
|
||||
goto nul;
|
||||
if (c == '%') { /* "....%%...." */
|
||||
slen = f - s;
|
||||
s = xstrndup(s, slen);
|
||||
f++;
|
||||
goto append; /* print "....%" part verbatim */
|
||||
}
|
||||
sv = *++f;
|
||||
*f = '\0';
|
||||
while (1) {
|
||||
if (isalpha(c))
|
||||
break;
|
||||
if (c == '*')
|
||||
syntax_error("%*x formats are not supported");
|
||||
c = *++f;
|
||||
if (!c) { /* "....%...." and no letter found after % */
|
||||
/* Example: awk 'BEGIN { printf "^^^%^^^\n"; }' */
|
||||
nul:
|
||||
slen = f - s;
|
||||
goto tail; /* print remaining string, exit loop */
|
||||
}
|
||||
}
|
||||
/* we are at A in "....%...A..." */
|
||||
|
||||
arg = evaluate(nextarg(&n), TMPVAR);
|
||||
|
||||
/* Result can be arbitrarily long. Example:
|
||||
* printf "%99999s", "BOOM"
|
||||
*/
|
||||
sv = *++f;
|
||||
*f = '\0';
|
||||
if (c == 'c') {
|
||||
char cc = is_numeric(arg) ? getvar_i(arg) : *getvar_s(arg);
|
||||
char *r = xasprintf(s, cc ? cc : '^' /* else strlen will be wrong */);
|
||||
@@ -2386,13 +2405,14 @@ static char *awk_printf(node *n, size_t *len)
|
||||
} else if (strchr("eEfFgGaA", c)) {
|
||||
s = xasprintf(s, d);
|
||||
} else {
|
||||
//TODO: GNU Awk 5.0.1: printf "%W" prints "%W", does not error out
|
||||
syntax_error(EMSG_INV_FMT);
|
||||
}
|
||||
}
|
||||
slen = strlen(s);
|
||||
}
|
||||
*f = sv;
|
||||
|
||||
append:
|
||||
if (i == 0) {
|
||||
b = s;
|
||||
i = slen;
|
||||
@@ -2402,7 +2422,7 @@ static char *awk_printf(node *n, size_t *len)
|
||||
b = xrealloc(b, i + slen + 1);
|
||||
strcpy(b + i, s);
|
||||
i += slen;
|
||||
if (!c) /* tail? */
|
||||
if (!c) /* s is NOT allocated and this is the last part of string? */
|
||||
break;
|
||||
free(s);
|
||||
}
|
||||
|
||||
+34
-30
@@ -201,6 +201,9 @@ int chat_main(int argc UNUSED_PARAM, char **argv)
|
||||
DIR_RECORD,
|
||||
};
|
||||
|
||||
#define inbuf bb_common_bufsiz1
|
||||
setup_common_bufsiz();
|
||||
|
||||
// make x* functions fail with correct exitcode
|
||||
xfunc_error_retval = ERR_IO;
|
||||
|
||||
@@ -361,35 +364,36 @@ int chat_main(int argc UNUSED_PARAM, char **argv)
|
||||
// get reply
|
||||
pfd.fd = STDIN_FILENO;
|
||||
pfd.events = POLLIN;
|
||||
while (!exitcode
|
||||
while (exitcode == ERR_OK
|
||||
&& poll(&pfd, 1, timeout) > 0
|
||||
&& (pfd.revents & POLLIN)
|
||||
/* && (pfd.revents & POLLIN) - may be untrue (e.g. only POLLERR set) */
|
||||
) {
|
||||
llist_t *l;
|
||||
ssize_t delta;
|
||||
#define buf bb_common_bufsiz1
|
||||
setup_common_bufsiz();
|
||||
|
||||
// read next char from device
|
||||
if (safe_read(STDIN_FILENO, buf+buf_len, 1) > 0) {
|
||||
// dump device input if RECORD fname
|
||||
if (record_fd > 0) {
|
||||
full_write(record_fd, buf+buf_len, 1);
|
||||
}
|
||||
// dump device input if ECHO ON
|
||||
if (echo) {
|
||||
// if (buf[buf_len] < ' ') {
|
||||
// full_write2_str("^");
|
||||
// buf[buf_len] += '@';
|
||||
// }
|
||||
full_write(STDERR_FILENO, buf+buf_len, 1);
|
||||
}
|
||||
buf_len++;
|
||||
// move input frame if we've reached higher bound
|
||||
if (buf_len > COMMON_BUFSIZE) {
|
||||
memmove(buf, buf+buf_len-max_len, max_len);
|
||||
buf_len = max_len;
|
||||
}
|
||||
if (safe_read(STDIN_FILENO, inbuf + buf_len, 1) <= 0) {
|
||||
exitcode = ERR_IO;
|
||||
goto expect_done;
|
||||
}
|
||||
|
||||
// dump device input if RECORD fname
|
||||
if (record_fd > 0) {
|
||||
full_write(record_fd, inbuf + buf_len, 1);
|
||||
}
|
||||
// dump device input if ECHO ON
|
||||
if (echo) {
|
||||
// if (inbuf[buf_len] < ' ') {
|
||||
// full_write2_str("^");
|
||||
// inbuf[buf_len] += '@';
|
||||
// }
|
||||
full_write(STDERR_FILENO, inbuf + buf_len, 1);
|
||||
}
|
||||
buf_len++;
|
||||
// move input frame if we've reached higher bound
|
||||
if (buf_len > COMMON_BUFSIZE) {
|
||||
memmove(inbuf, inbuf + buf_len - max_len, max_len);
|
||||
buf_len = max_len;
|
||||
}
|
||||
// N.B. rule of thumb: values being looked for can
|
||||
// be found only at the end of input buffer
|
||||
@@ -399,20 +403,20 @@ int chat_main(int argc UNUSED_PARAM, char **argv)
|
||||
// abort condition is met? -> bail out
|
||||
for (l = aborts, exitcode = ERR_ABORT; l; l = l->link, ++exitcode) {
|
||||
size_t len = strlen(l->data);
|
||||
delta = buf_len-len;
|
||||
if (delta >= 0 && !memcmp(buf+delta, l->data, len))
|
||||
delta = buf_len - len;
|
||||
if (delta >= 0 && !memcmp(inbuf + delta, l->data, len))
|
||||
goto expect_done;
|
||||
}
|
||||
exitcode = ERR_OK;
|
||||
|
||||
// expected reply received? -> goto next command
|
||||
delta = buf_len - expect_len;
|
||||
if (delta >= 0 && !memcmp(buf+delta, expect, expect_len))
|
||||
if (delta >= 0 && memcmp(inbuf + delta, expect, expect_len) == 0)
|
||||
goto expect_done;
|
||||
#undef buf
|
||||
} /* while (have data) */
|
||||
|
||||
// device timed out or unexpected reply received
|
||||
// device timed out, or unexpected reply received,
|
||||
// or we got a signal (poll() returned -1 with EINTR).
|
||||
exitcode = ERR_TIMEOUT;
|
||||
expect_done:
|
||||
#if ENABLE_FEATURE_CHAT_NOFAIL
|
||||
@@ -434,7 +438,7 @@ int chat_main(int argc UNUSED_PARAM, char **argv)
|
||||
}
|
||||
#endif
|
||||
// bail out unless we expected successfully
|
||||
if (exitcode)
|
||||
if (exitcode != ERR_OK)
|
||||
break;
|
||||
|
||||
//-----------------------
|
||||
@@ -478,7 +482,7 @@ int chat_main(int argc UNUSED_PARAM, char **argv)
|
||||
continue;
|
||||
}
|
||||
if ('p' == c) {
|
||||
usleep(10000);
|
||||
msleep(10);
|
||||
len--;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -304,18 +304,6 @@ void udhcp_dump_packet(struct dhcp_packet *packet) FAST_FUNC;
|
||||
# define log3s(msg) ((void)0)
|
||||
#endif
|
||||
|
||||
#if defined(__mips__)
|
||||
/*
|
||||
* The 'simple' message functions have a negative impact on the size of the
|
||||
* DHCP code when compiled for MIPS, so don't use them in this case.
|
||||
*/
|
||||
#define bb_simple_info_msg bb_info_msg
|
||||
#define bb_simple_error_msg bb_error_msg
|
||||
#define bb_simple_perror_msg_and_die bb_perror_msg_and_die
|
||||
#undef log1s
|
||||
#define log1s log1
|
||||
#endif
|
||||
|
||||
/*** Other shared functions ***/
|
||||
|
||||
/* 2nd param is "uint32_t*" */
|
||||
|
||||
+7
-3
@@ -10278,6 +10278,9 @@ evalcommand(union node *cmd, int flags)
|
||||
|
||||
/* First expand the arguments. */
|
||||
TRACE(("evalcommand(0x%lx, %d) called\n", (long)cmd, flags));
|
||||
#if BASH_PROCESS_SUBST
|
||||
redir_stop = redirlist;
|
||||
#endif
|
||||
file_stop = g_parsefile;
|
||||
back_exitstatus = 0;
|
||||
|
||||
@@ -10356,7 +10359,11 @@ evalcommand(union node *cmd, int flags)
|
||||
lastarg = nargv[-1];
|
||||
|
||||
expredir(cmd->ncmd.redirect);
|
||||
#if !BASH_PROCESS_SUBST
|
||||
redir_stop = pushredir(cmd->ncmd.redirect);
|
||||
#else
|
||||
pushredir(cmd->ncmd.redirect);
|
||||
#endif
|
||||
preverrout_fd = 2;
|
||||
if (BASH_XTRACEFD && xflag) {
|
||||
/* NB: bash closes fd == $BASH_XTRACEFD when it is changed.
|
||||
@@ -13476,9 +13483,6 @@ cmdloop(int top)
|
||||
#if JOBS
|
||||
if (doing_jobctl)
|
||||
showjobs(SHOW_CHANGED|SHOW_STDERR);
|
||||
#endif
|
||||
#if BASH_PROCESS_SUBST
|
||||
unwindredir(NULL);
|
||||
#endif
|
||||
inter = 0;
|
||||
if (iflag && top) {
|
||||
|
||||
@@ -463,4 +463,10 @@ testing "awk \"cmd\" | getline" \
|
||||
"HELLO\n" \
|
||||
'' ''
|
||||
|
||||
# printf %% should print one % (had a bug where it didn't)
|
||||
testing 'awk printf %% prints one %' \
|
||||
"awk 'BEGIN { printf \"%%\n\" }'" \
|
||||
"%\n" \
|
||||
'' ''
|
||||
|
||||
exit $FAILCOUNT
|
||||
@@ -79,6 +79,11 @@ testing "printf understands %Ld" \
|
||||
"-5\n""0\n" \
|
||||
"" ""
|
||||
|
||||
testing "printf understands %%" \
|
||||
"${bb}printf '%%\n' 2>&1; echo \$?" \
|
||||
"%\n""0\n" \
|
||||
"" ""
|
||||
|
||||
testing "printf handles positive numbers for %d" \
|
||||
"${bb}printf '%d\n' 3 +3 ' 3' ' +3' 2>&1; echo \$?" \
|
||||
"3\n"\
|
||||
|
||||
Reference in new issue
Block a user