From 3e97eeb408a1107b0ffacc6ba39682428c4598f1 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sat, 12 Dec 2009 22:17:44 +0100 Subject: [PATCH] apply post-1.15.2 fixes Signed-off-by: Denys Vlasenko --- Makefile | 11 +- coreutils/split.c | 6 +- editors/awk.c | 12 +- findutils/grep.c | 2 + include/platform.h | 2 + libbb/Kbuild | 1 + miscutils/flash_eraseall.c | 47 ++- networking/ping.c | 36 +- scripts/kconfig/Makefile | 23 ++ shell/ash.c | 773 ++++++++++++++++++------------------- testsuite/awk.tests | 17 + testsuite/grep.tests | 5 + util-linux/mount.c | 24 +- 13 files changed, 530 insertions(+), 429 deletions(-) diff --git a/Makefile b/Makefile index 3ab0524dc..7529cd8d8 100644 --- a/Makefile +++ b/Makefile @@ -358,6 +358,15 @@ scripts_basic: # To avoid any implicit rule to kick in, define an empty command. scripts/basic/%: scripts_basic ; +# bbox: we have helpers in applets/ +# we depend on scripts_basic, since scripts/basic/fixdep +# must be built before any other host prog +PHONY += applets_dir +applets_dir: scripts_basic + $(Q)$(MAKE) $(build)=applets + +applets/%: applets_dir ; + PHONY += outputmakefile # outputmakefile generates a Makefile in the output directory, if using a # separate output directory. This allows convenient use of make in the @@ -797,7 +806,7 @@ ifneq ($(KBUILD_MODULES),) $(Q)rm -f $(MODVERDIR)/* endif -archprepare: prepare1 scripts_basic +archprepare: prepare1 scripts_basic applets_dir prepare0: archprepare FORCE $(Q)$(MAKE) $(build)=. diff --git a/coreutils/split.c b/coreutils/split.c index f1ec64be0..55927a491 100644 --- a/coreutils/split.c +++ b/coreutils/split.c @@ -79,9 +79,13 @@ int split_main(int argc UNUSED_PARAM, char **argv) argv += optind; if (argv[0]) { + int fd; if (argv[1]) sfx = argv[1]; - xmove_fd(xopen(argv[0], O_RDONLY), 0); + fd = open_or_warn_stdin(argv[0]); + if (fd == -1) + return EXIT_FAILURE; + xmove_fd(fd, STDIN_FILENO); } else { argv[0] = (char *) bb_msg_standard_input; } diff --git a/editors/awk.c b/editors/awk.c index cef73342c..a8c5476a7 100644 --- a/editors/awk.c +++ b/editors/awk.c @@ -2393,12 +2393,14 @@ static var *evaluate(node *op, var *res) case XC( OC_MOVE ): /* if source is a temporary string, jusk relink it to dest */ - if (R.v == v1+1 && R.v->string) { - res = setvar_p(L.v, R.v->string); - R.v->string = NULL; - } else { +//Disabled: if R.v is numeric but happens to have cached R.v->string, +//then L.v ends up being a string, which is wrong +// if (R.v == v1+1 && R.v->string) { +// res = setvar_p(L.v, R.v->string); +// R.v->string = NULL; +// } else { res = copyvar(L.v, R.v); - } +// } break; case XC( OC_TERNARY ): diff --git a/findutils/grep.c b/findutils/grep.c index 776a629be..dc26b5f07 100644 --- a/findutils/grep.c +++ b/findutils/grep.c @@ -377,6 +377,8 @@ static int grep_file(FILE *file) print_line(line + gl->matched_range.rm_so, end - gl->matched_range.rm_so, linenum, ':'); + if (old == '\0') + break; line[end] = old; #if !ENABLE_EXTRA_COMPAT if (regexec(&gl->compiled_regex, line + end, diff --git a/include/platform.h b/include/platform.h index 7c88d1ba6..b3847f70d 100644 --- a/include/platform.h +++ b/include/platform.h @@ -174,12 +174,14 @@ char *strchrnul(const char *s, int c); * a lvalue. This makes it more likely to not swap them by mistake */ #if defined(i386) || defined(__x86_64__) +# define move_from_unaligned_int(v, intp) ((v) = *(int*)(intp)) # define move_from_unaligned16(v, u16p) ((v) = *(uint16_t*)(u16p)) # define move_from_unaligned32(v, u32p) ((v) = *(uint32_t*)(u32p)) # define move_to_unaligned32(u32p, v) (*(uint32_t*)(u32p) = (v)) /* #elif ... - add your favorite arch today! */ #else /* performs reasonably well (gcc usually inlines memcpy here) */ +# define move_from_unaligned_int(v, intp) (memcpy(&(v), (intp), sizeof(int))) # define move_from_unaligned16(v, u16p) (memcpy(&(v), (u16p), 2)) # define move_from_unaligned32(v, u32p) (memcpy(&(v), (u32p), 4)) # define move_to_unaligned32(u32p, v) do { \ diff --git a/libbb/Kbuild b/libbb/Kbuild index 8c7a189b4..8558e117a 100644 --- a/libbb/Kbuild +++ b/libbb/Kbuild @@ -143,6 +143,7 @@ lib-$(CONFIG_FEATURE_HTTPD_AUTH_MD5) += pw_encrypt.o lib-$(CONFIG_DF) += find_mount_point.o lib-$(CONFIG_MKFS_MINIX) += find_mount_point.o lib-$(CONFIG_FSCK_MINIX) += find_mount_point.o +lib-$(CONFIG_MOUNT) += find_mount_point.o lib-$(CONFIG_HWCLOCK) += rtc.o lib-$(CONFIG_RTCWAKE) += rtc.o diff --git a/miscutils/flash_eraseall.c b/miscutils/flash_eraseall.c index 4f3e94dc1..faed9c345 100644 --- a/miscutils/flash_eraseall.c +++ b/miscutils/flash_eraseall.c @@ -12,22 +12,35 @@ #include "libbb.h" #include -#include +#include #define OPTION_J (1 << 0) #define OPTION_Q (1 << 1) #define IS_NAND (1 << 2) #define BBTEST (1 << 3) -struct globals { - /* This is used in the cpu_to_je/je_to_cpu macros in jffs2_user.h */ - int tgt_endian; -}; -#define G (*(struct globals*)&bb_common_bufsiz1) -#define target_endian (G.tgt_endian) -#define INIT_G() do { \ - target_endian = __BYTE_ORDER; \ -} while (0) +/* mtd/jffs2-user.h used to have this atrocity: +extern int target_endian; + +#define t16(x) ({ __u16 __b = (x); (target_endian==__BYTE_ORDER)?__b:bswap_16(__b); }) +#define t32(x) ({ __u32 __b = (x); (target_endian==__BYTE_ORDER)?__b:bswap_32(__b); }) + +#define cpu_to_je16(x) ((jint16_t){t16(x)}) +#define cpu_to_je32(x) ((jint32_t){t32(x)}) +#define cpu_to_jemode(x) ((jmode_t){t32(x)}) + +#define je16_to_cpu(x) (t16((x).v16)) +#define je32_to_cpu(x) (t32((x).v32)) +#define jemode_to_cpu(x) (t32((x).m)) + +but mtd/jffs2-user.h is gone now (at least 2.6.31.6 does not have it anymore) +*/ + +/* We always use native endianness */ +#undef cpu_to_je16 +#undef cpu_to_je32 +#define cpu_to_je16(v) ((jint16_t){(v)}) +#define cpu_to_je32(v) ((jint32_t){(v)}) static uint32_t crc32(uint32_t val, const void *ss, int len, uint32_t *crc32_table) @@ -40,9 +53,11 @@ static uint32_t crc32(uint32_t val, const void *ss, int len, static void show_progress(mtd_info_t *meminfo, erase_info_t *erase) { - printf("\rErasing %d Kibyte @ %x -- %2llu %% complete.", - (unsigned)meminfo->erasesize / 1024, erase->start, - (unsigned long long) erase->start * 100 / meminfo->size); + printf("\rErasing %u Kibyte @ %x - %2u%% complete.", + (unsigned)meminfo->erasesize / 1024, + erase->start, + (unsigned) ((unsigned long long) erase->start * 100 / meminfo->size) + ); fflush(stdout); } @@ -57,17 +72,15 @@ int flash_eraseall_main(int argc UNUSED_PARAM, char **argv) unsigned int flags; char *mtd_name; - INIT_G(); opt_complementary = "=1"; flags = BBTEST | getopt32(argv, "jq"); mtd_name = argv[optind]; - xstat(mtd_name, &st); + fd = xopen(mtd_name, O_RDWR); + fstat(fd, &st); if (!S_ISCHR(st.st_mode)) bb_error_msg_and_die("%s: not a char device", mtd_name); - fd = xopen(mtd_name, O_RDWR); - xioctl(fd, MEMGETINFO, &meminfo); erase.length = meminfo.erasesize; if (meminfo.type == MTD_NANDFLASH) diff --git a/networking/ping.c b/networking/ping.c index 71b2a4be8..0d89cb6f6 100644 --- a/networking/ping.c +++ b/networking/ping.c @@ -173,13 +173,14 @@ static void ping6(len_and_sockaddr *lsa) } #endif -int ping_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; -int ping_main(int argc UNUSED_PARAM, char **argv) +#if !ENABLE_PING6 +# define common_ping_main(af, argv) common_ping_main(argv) +#endif +static int common_ping_main(sa_family_t af, char **argv) { len_and_sockaddr *lsa; -#if ENABLE_PING6 - sa_family_t af = AF_UNSPEC; +#if ENABLE_PING6 while ((++argv)[0] && argv[0][0] == '-') { if (argv[0][1] == '4') { af = AF_INET; @@ -689,7 +690,8 @@ static void ping6(len_and_sockaddr *lsa) /* don't check len - we trust the kernel: */ /* && mp->cmsg_len >= CMSG_LEN(sizeof(int)) */ ) { - hoplimit = *(int*)CMSG_DATA(mp); + /*hoplimit = *(int*)CMSG_DATA(mp); - unaligned access */ + move_from_unaligned_int(hoplimit, CMSG_DATA(mp)); } } unpack6(packet, c, /*&from,*/ hoplimit); @@ -716,18 +718,16 @@ static void ping(len_and_sockaddr *lsa) ping4(lsa); } -int ping_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; -int ping_main(int argc UNUSED_PARAM, char **argv) +static int common_ping_main(int opt, char **argv) { len_and_sockaddr *lsa; char *str_s; - int opt; INIT_G(); /* exactly one argument needed; -v and -q don't mix; -c NUM, -w NUM, -W NUM */ opt_complementary = "=1:q--v:v--q:c+:w+:W+"; - opt = getopt32(argv, OPT_STRING, &pingcount, &str_s, &deadline, &timeout, &str_I); + opt |= getopt32(argv, OPT_STRING, &pingcount, &str_s, &deadline, &timeout, &str_I); if (opt & OPT_s) datalen = xatou16(str_s); // -s if (opt & OPT_I) { // -I @@ -765,13 +765,25 @@ int ping_main(int argc UNUSED_PARAM, char **argv) #endif /* FEATURE_FANCY_PING */ +int ping_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; +int ping_main(int argc UNUSED_PARAM, char **argv) +{ +#if !ENABLE_FEATURE_FANCY_PING + return common_ping_main(AF_UNSPEC, argv); +#else + return common_ping_main(0, argv); +#endif +} + #if ENABLE_PING6 int ping6_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int ping6_main(int argc UNUSED_PARAM, char **argv) { - argv[0] = (char*)"-6"; - return ping_main(0 /* argc+1 - but it's unused anyway */, - argv - 1); +# if !ENABLE_FEATURE_FANCY_PING + return common_ping_main(AF_INET6, argv); +# else + return common_ping_main(OPT_IPV6, argv); +# endif } #endif diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index f56863f7c..b5708e2e4 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -17,11 +17,28 @@ menuconfig: $(obj)/mconf config: $(obj)/conf $< Config.in +# Mtime granularity problem. +# It was observed that these commands: +# make allnoconfig; sed -i -e '/CONFIG_TRUE/s/.*/CONFIG_TRUE=y/' .config; make +# sometimes produce busybox with "true" applet still disabled. +# This is caused by .config updated by sed having mtime which is still +# equal to (not bigger than) include/autoconf.h's mtime, +# and thus 2nd make does not regenerate include/autoconf.h. +# Waiting for 1 second after non-interactive "make XXXXconfig" +# prevents this from happening. +# +# We'd like to detect whether filesystem we are on has coarse mtimes, +# but can't do it yet, bbox ls hasn't got --full-time. +#MTIME_IS_COARSE:=@ls --full-time -ld | grep -F .000 >/dev/null +MTIME_IS_COARSE:=@true + oldconfig: $(obj)/conf $< -o Config.in + $(MTIME_IS_COARSE) && sleep 1 silentoldconfig: $(obj)/conf $< -s Config.in + $(MTIME_IS_COARSE) && sleep 1 update-po-config: $(obj)/kxgettext xgettext --default-domain=linux \ @@ -46,15 +63,19 @@ PHONY += randconfig allyesconfig allnoconfig allmodconfig defconfig randconfig: $(obj)/conf $< -r Config.in + $(MTIME_IS_COARSE) && sleep 1 allyesconfig: $(obj)/conf $< -y Config.in + $(MTIME_IS_COARSE) && sleep 1 allnoconfig: $(obj)/conf $< -n Config.in + $(MTIME_IS_COARSE) && sleep 1 allmodconfig: $(obj)/conf $< -m Config.in + $(MTIME_IS_COARSE) && sleep 1 defconfig: $(obj)/conf ifeq ($(KBUILD_DEFCONFIG),) @@ -63,9 +84,11 @@ else @echo *** Default configuration is based on '$(KBUILD_DEFCONFIG)' $(Q)$< -D $(KBUILD_DEFCONFIG) Config.in endif + $(MTIME_IS_COARSE) && sleep 1 %_defconfig: $(obj)/conf $(Q)$< -D $@ Config.in + $(MTIME_IS_COARSE) && sleep 1 # Help text used by make help help: diff --git a/shell/ash.c b/shell/ash.c index a9529f86b..3ca7fa376 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -258,9 +258,6 @@ static void trace_vprintf(const char *fmt, va_list va); /* ============ Utility functions */ #define xbarrier() do { __asm__ __volatile__ ("": : :"memory"); } while (0) -/* C99 says: "char" declaration may be signed or unsigned by default */ -#define signed_char2int(sc) ((int)(signed char)(sc)) - static int isdigit_str9(const char *str) { int maxlen = 9 + 1; /* max 9 digits: 999999999 */ @@ -718,17 +715,17 @@ trace_puts_quoted(char *s) return; putc('"', tracefile); for (p = s; *p; p++) { - switch (*p) { - case '\n': c = 'n'; goto backslash; - case '\t': c = 't'; goto backslash; - case '\r': c = 'r'; goto backslash; - case '"': c = '"'; goto backslash; - case '\\': c = '\\'; goto backslash; - case CTLESC: c = 'e'; goto backslash; - case CTLVAR: c = 'v'; goto backslash; - case CTLVAR+CTLQUOTE: c = 'V'; goto backslash; - case CTLBACKQ: c = 'q'; goto backslash; - case CTLBACKQ+CTLQUOTE: c = 'Q'; goto backslash; + switch ((unsigned char)*p) { + case '\n': c = 'n'; goto backslash; + case '\t': c = 't'; goto backslash; + case '\r': c = 'r'; goto backslash; + case '\"': c = '\"'; goto backslash; + case '\\': c = '\\'; goto backslash; + case CTLESC: c = 'e'; goto backslash; + case CTLVAR: c = 'v'; goto backslash; + case CTLVAR+CTLQUOTE: c = 'V'; goto backslash; + case CTLBACKQ: c = 'q'; goto backslash; + case CTLBACKQ+CTLQUOTE: c = 'Q'; goto backslash; backslash: putc('\\', tracefile); putc(c, tracefile); @@ -738,8 +735,8 @@ trace_puts_quoted(char *s) putc(*p, tracefile); else { putc('\\', tracefile); - putc(*p >> 6 & 03, tracefile); - putc(*p >> 3 & 07, tracefile); + putc((*p >> 6) & 03, tracefile); + putc((*p >> 3) & 07, tracefile); putc(*p & 07, tracefile); } break; @@ -823,7 +820,7 @@ sharg(union node *arg, FILE *fp) { char *p; struct nodelist *bqlist; - int subtype; + unsigned char subtype; if (arg->type != NARG) { out1fmt("\n", arg->type); @@ -831,7 +828,7 @@ sharg(union node *arg, FILE *fp) } bqlist = arg->narg.backquote; for (p = arg->narg.text; *p; p++) { - switch (*p) { + switch ((unsigned char)*p) { case CTLESC: putc(*++p, fp); break; @@ -1581,21 +1578,21 @@ single_quote(const char *s) STADJUST(q - p, p); - len = strspn(s, "'"); - if (!len) + if (*s != '\'') break; + len = 0; + do len++; while (*++s == '\''); q = p = makestrspace(len + 3, p); *q++ = '"'; - q = (char *)memcpy(q, s, len) + len; + q = (char *)memcpy(q, s - len, len) + len; *q++ = '"'; - s += len; STADJUST(q - p, p); } while (*s); - USTPUTC(0, p); + USTPUTC('\0', p); return stackblock(); } @@ -2603,14 +2600,10 @@ pwdcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) #define CIGN 14 /* character should be ignored */ #if ENABLE_ASH_ALIAS -#define SYNBASE 130 -#define PEOF -130 -#define PEOA -129 -#define PEOA_OR_PEOF PEOA +# define PEOA 256 +# define PEOF 257 #else -#define SYNBASE 129 -#define PEOF -129 -#define PEOA_OR_PEOF PEOF +# define PEOF 256 #endif /* number syntax index */ @@ -2621,14 +2614,14 @@ pwdcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) #define PSSYNTAX 4 /* prompt */ #if ENABLE_ASH_OPTIMIZE_FOR_SIZE -#define USE_SIT_FUNCTION +# define USE_SIT_FUNCTION #endif #if ENABLE_SH_MATH_SUPPORT -static const char S_I_T[][4] = { -#if ENABLE_ASH_ALIAS +static const uint8_t S_I_T[][4] = { +# if ENABLE_ASH_ALIAS { CSPCL, CIGN, CIGN, CIGN }, /* 0, PEOA */ -#endif +# endif { CSPCL, CWORD, CWORD, CWORD }, /* 1, ' ' */ { CNL, CNL, CNL, CNL }, /* 2, \n */ { CWORD, CCTL, CCTL, CWORD }, /* 3, !*-/:=?[]~ */ @@ -2640,17 +2633,17 @@ static const char S_I_T[][4] = { { CBACK, CBACK, CCTL, CBACK }, /* 9, \ */ { CBQUOTE, CBQUOTE, CWORD, CBQUOTE }, /* 10, ` */ { CENDVAR, CENDVAR, CWORD, CENDVAR }, /* 11, } */ -#ifndef USE_SIT_FUNCTION +# ifndef USE_SIT_FUNCTION { CENDFILE, CENDFILE, CENDFILE, CENDFILE }, /* 12, PEOF */ { CWORD, CWORD, CWORD, CWORD }, /* 13, 0-9A-Za-z */ { CCTL, CCTL, CCTL, CCTL } /* 14, CTLESC ... */ -#endif +# endif }; #else -static const char S_I_T[][3] = { -#if ENABLE_ASH_ALIAS +static const uint8_t S_I_T[][3] = { +# if ENABLE_ASH_ALIAS { CSPCL, CIGN, CIGN }, /* 0, PEOA */ -#endif +# endif { CSPCL, CWORD, CWORD }, /* 1, ' ' */ { CNL, CNL, CNL }, /* 2, \n */ { CWORD, CCTL, CCTL }, /* 3, !*-/:=?[]~ */ @@ -2662,46 +2655,50 @@ static const char S_I_T[][3] = { { CBACK, CBACK, CCTL }, /* 9, \ */ { CBQUOTE, CBQUOTE, CWORD }, /* 10, ` */ { CENDVAR, CENDVAR, CWORD }, /* 11, } */ -#ifndef USE_SIT_FUNCTION +# ifndef USE_SIT_FUNCTION { CENDFILE, CENDFILE, CENDFILE }, /* 12, PEOF */ { CWORD, CWORD, CWORD }, /* 13, 0-9A-Za-z */ { CCTL, CCTL, CCTL } /* 14, CTLESC ... */ -#endif +# endif }; #endif /* SH_MATH_SUPPORT */ +/* c in SIT(c, syntax) must be an *unsigned char* or PEOA or PEOF, + * caller must ensure proper cast on it if c is *char_ptr! + */ + #ifdef USE_SIT_FUNCTION static int SIT(int c, int syntax) { static const char spec_symbls[] ALIGN1 = "\t\n !\"$&'()*-/:;<=>?[\\]`|}~"; -#if ENABLE_ASH_ALIAS - static const char syntax_index_table[] ALIGN1 = { +# if ENABLE_ASH_ALIAS + static const uint8_t syntax_index_table[] ALIGN1 = { 1, 2, 1, 3, 4, 5, 1, 6, /* "\t\n !\"$&'" */ 7, 8, 3, 3, 3, 3, 1, 1, /* "()*-/:;<" */ 3, 1, 3, 3, 9, 3, 10, 1, /* "=>?[\\]`|" */ 11, 3 /* "}~" */ }; -#else - static const char syntax_index_table[] ALIGN1 = { +# else + static const uint8_t syntax_index_table[] ALIGN1 = { 0, 1, 0, 2, 3, 4, 0, 5, /* "\t\n !\"$&'" */ 6, 7, 2, 2, 2, 2, 0, 0, /* "()*-/:;<" */ 2, 0, 2, 2, 8, 2, 9, 0, /* "=>?[\\]`|" */ 10, 2 /* "}~" */ }; -#endif +# endif const char *s; int indx; if (c == PEOF) { /* 2^8+2 */ return CENDFILE; } -#if ENABLE_ASH_ALIAS +# if ENABLE_ASH_ALIAS if (c == PEOA) { /* 2^8+1 */ indx = 0; } else -#endif +# endif { if ((unsigned char)c >= CTLESC && (unsigned char)c <= CTLQUOTEMARK @@ -2719,304 +2716,304 @@ SIT(int c, int syntax) #else /* !USE_SIT_FUNCTION */ -#if ENABLE_ASH_ALIAS -#define CSPCL_CIGN_CIGN_CIGN 0 -#define CSPCL_CWORD_CWORD_CWORD 1 -#define CNL_CNL_CNL_CNL 2 -#define CWORD_CCTL_CCTL_CWORD 3 -#define CDQUOTE_CENDQUOTE_CWORD_CWORD 4 -#define CVAR_CVAR_CWORD_CVAR 5 -#define CSQUOTE_CWORD_CENDQUOTE_CWORD 6 -#define CSPCL_CWORD_CWORD_CLP 7 -#define CSPCL_CWORD_CWORD_CRP 8 -#define CBACK_CBACK_CCTL_CBACK 9 -#define CBQUOTE_CBQUOTE_CWORD_CBQUOTE 10 -#define CENDVAR_CENDVAR_CWORD_CENDVAR 11 -#define CENDFILE_CENDFILE_CENDFILE_CENDFILE 12 -#define CWORD_CWORD_CWORD_CWORD 13 -#define CCTL_CCTL_CCTL_CCTL 14 -#else -#define CSPCL_CWORD_CWORD_CWORD 0 -#define CNL_CNL_CNL_CNL 1 -#define CWORD_CCTL_CCTL_CWORD 2 -#define CDQUOTE_CENDQUOTE_CWORD_CWORD 3 -#define CVAR_CVAR_CWORD_CVAR 4 -#define CSQUOTE_CWORD_CENDQUOTE_CWORD 5 -#define CSPCL_CWORD_CWORD_CLP 6 -#define CSPCL_CWORD_CWORD_CRP 7 -#define CBACK_CBACK_CCTL_CBACK 8 -#define CBQUOTE_CBQUOTE_CWORD_CBQUOTE 9 -#define CENDVAR_CENDVAR_CWORD_CENDVAR 10 -#define CENDFILE_CENDFILE_CENDFILE_CENDFILE 11 -#define CWORD_CWORD_CWORD_CWORD 12 -#define CCTL_CCTL_CCTL_CCTL 13 -#endif - -static const char syntax_index_table[258] = { +# if ENABLE_ASH_ALIAS +# define CSPCL_CIGN_CIGN_CIGN 0 +# define CSPCL_CWORD_CWORD_CWORD 1 +# define CNL_CNL_CNL_CNL 2 +# define CWORD_CCTL_CCTL_CWORD 3 +# define CDQUOTE_CENDQUOTE_CWORD_CWORD 4 +# define CVAR_CVAR_CWORD_CVAR 5 +# define CSQUOTE_CWORD_CENDQUOTE_CWORD 6 +# define CSPCL_CWORD_CWORD_CLP 7 +# define CSPCL_CWORD_CWORD_CRP 8 +# define CBACK_CBACK_CCTL_CBACK 9 +# define CBQUOTE_CBQUOTE_CWORD_CBQUOTE 10 +# define CENDVAR_CENDVAR_CWORD_CENDVAR 11 +# define CENDFILE_CENDFILE_CENDFILE_CENDFILE 12 +# define CWORD_CWORD_CWORD_CWORD 13 +# define CCTL_CCTL_CCTL_CCTL 14 +# else +# define CSPCL_CWORD_CWORD_CWORD 0 +# define CNL_CNL_CNL_CNL 1 +# define CWORD_CCTL_CCTL_CWORD 2 +# define CDQUOTE_CENDQUOTE_CWORD_CWORD 3 +# define CVAR_CVAR_CWORD_CVAR 4 +# define CSQUOTE_CWORD_CENDQUOTE_CWORD 5 +# define CSPCL_CWORD_CWORD_CLP 6 +# define CSPCL_CWORD_CWORD_CRP 7 +# define CBACK_CBACK_CCTL_CBACK 8 +# define CBQUOTE_CBQUOTE_CWORD_CBQUOTE 9 +# define CENDVAR_CENDVAR_CWORD_CENDVAR 10 +# define CENDFILE_CENDFILE_CENDFILE_CENDFILE 11 +# define CWORD_CWORD_CWORD_CWORD 12 +# define CCTL_CCTL_CCTL_CCTL 13 +# endif + +static const uint8_t syntax_index_table[258] = { /* BASESYNTAX_DQSYNTAX_SQSYNTAX_ARISYNTAX */ - /* 0 PEOF */ CENDFILE_CENDFILE_CENDFILE_CENDFILE, -#if ENABLE_ASH_ALIAS - /* 1 PEOA */ CSPCL_CIGN_CIGN_CIGN, -#endif - /* 2 -128 0x80 */ CWORD_CWORD_CWORD_CWORD, - /* 3 -127 CTLESC */ CCTL_CCTL_CCTL_CCTL, - /* 4 -126 CTLVAR */ CCTL_CCTL_CCTL_CCTL, - /* 5 -125 CTLENDVAR */ CCTL_CCTL_CCTL_CCTL, - /* 6 -124 CTLBACKQ */ CCTL_CCTL_CCTL_CCTL, - /* 7 -123 CTLQUOTE */ CCTL_CCTL_CCTL_CCTL, - /* 8 -122 CTLARI */ CCTL_CCTL_CCTL_CCTL, - /* 9 -121 CTLENDARI */ CCTL_CCTL_CCTL_CCTL, - /* 10 -120 CTLQUOTEMARK */ CCTL_CCTL_CCTL_CCTL, - /* 11 -119 */ CWORD_CWORD_CWORD_CWORD, - /* 12 -118 */ CWORD_CWORD_CWORD_CWORD, - /* 13 -117 */ CWORD_CWORD_CWORD_CWORD, - /* 14 -116 */ CWORD_CWORD_CWORD_CWORD, - /* 15 -115 */ CWORD_CWORD_CWORD_CWORD, - /* 16 -114 */ CWORD_CWORD_CWORD_CWORD, - /* 17 -113 */ CWORD_CWORD_CWORD_CWORD, - /* 18 -112 */ CWORD_CWORD_CWORD_CWORD, - /* 19 -111 */ CWORD_CWORD_CWORD_CWORD, - /* 20 -110 */ CWORD_CWORD_CWORD_CWORD, - /* 21 -109 */ CWORD_CWORD_CWORD_CWORD, - /* 22 -108 */ CWORD_CWORD_CWORD_CWORD, - /* 23 -107 */ CWORD_CWORD_CWORD_CWORD, - /* 24 -106 */ CWORD_CWORD_CWORD_CWORD, - /* 25 -105 */ CWORD_CWORD_CWORD_CWORD, - /* 26 -104 */ CWORD_CWORD_CWORD_CWORD, - /* 27 -103 */ CWORD_CWORD_CWORD_CWORD, - /* 28 -102 */ CWORD_CWORD_CWORD_CWORD, - /* 29 -101 */ CWORD_CWORD_CWORD_CWORD, - /* 30 -100 */ CWORD_CWORD_CWORD_CWORD, - /* 31 -99 */ CWORD_CWORD_CWORD_CWORD, - /* 32 -98 */ CWORD_CWORD_CWORD_CWORD, - /* 33 -97 */ CWORD_CWORD_CWORD_CWORD, - /* 34 -96 */ CWORD_CWORD_CWORD_CWORD, - /* 35 -95 */ CWORD_CWORD_CWORD_CWORD, - /* 36 -94 */ CWORD_CWORD_CWORD_CWORD, - /* 37 -93 */ CWORD_CWORD_CWORD_CWORD, - /* 38 -92 */ CWORD_CWORD_CWORD_CWORD, - /* 39 -91 */ CWORD_CWORD_CWORD_CWORD, - /* 40 -90 */ CWORD_CWORD_CWORD_CWORD, - /* 41 -89 */ CWORD_CWORD_CWORD_CWORD, - /* 42 -88 */ CWORD_CWORD_CWORD_CWORD, - /* 43 -87 */ CWORD_CWORD_CWORD_CWORD, - /* 44 -86 */ CWORD_CWORD_CWORD_CWORD, - /* 45 -85 */ CWORD_CWORD_CWORD_CWORD, - /* 46 -84 */ CWORD_CWORD_CWORD_CWORD, - /* 47 -83 */ CWORD_CWORD_CWORD_CWORD, - /* 48 -82 */ CWORD_CWORD_CWORD_CWORD, - /* 49 -81 */ CWORD_CWORD_CWORD_CWORD, - /* 50 -80 */ CWORD_CWORD_CWORD_CWORD, - /* 51 -79 */ CWORD_CWORD_CWORD_CWORD, - /* 52 -78 */ CWORD_CWORD_CWORD_CWORD, - /* 53 -77 */ CWORD_CWORD_CWORD_CWORD, - /* 54 -76 */ CWORD_CWORD_CWORD_CWORD, - /* 55 -75 */ CWORD_CWORD_CWORD_CWORD, - /* 56 -74 */ CWORD_CWORD_CWORD_CWORD, - /* 57 -73 */ CWORD_CWORD_CWORD_CWORD, - /* 58 -72 */ CWORD_CWORD_CWORD_CWORD, - /* 59 -71 */ CWORD_CWORD_CWORD_CWORD, - /* 60 -70 */ CWORD_CWORD_CWORD_CWORD, - /* 61 -69 */ CWORD_CWORD_CWORD_CWORD, - /* 62 -68 */ CWORD_CWORD_CWORD_CWORD, - /* 63 -67 */ CWORD_CWORD_CWORD_CWORD, - /* 64 -66 */ CWORD_CWORD_CWORD_CWORD, - /* 65 -65 */ CWORD_CWORD_CWORD_CWORD, - /* 66 -64 */ CWORD_CWORD_CWORD_CWORD, - /* 67 -63 */ CWORD_CWORD_CWORD_CWORD, - /* 68 -62 */ CWORD_CWORD_CWORD_CWORD, - /* 69 -61 */ CWORD_CWORD_CWORD_CWORD, - /* 70 -60 */ CWORD_CWORD_CWORD_CWORD, - /* 71 -59 */ CWORD_CWORD_CWORD_CWORD, - /* 72 -58 */ CWORD_CWORD_CWORD_CWORD, - /* 73 -57 */ CWORD_CWORD_CWORD_CWORD, - /* 74 -56 */ CWORD_CWORD_CWORD_CWORD, - /* 75 -55 */ CWORD_CWORD_CWORD_CWORD, - /* 76 -54 */ CWORD_CWORD_CWORD_CWORD, - /* 77 -53 */ CWORD_CWORD_CWORD_CWORD, - /* 78 -52 */ CWORD_CWORD_CWORD_CWORD, - /* 79 -51 */ CWORD_CWORD_CWORD_CWORD, - /* 80 -50 */ CWORD_CWORD_CWORD_CWORD, - /* 81 -49 */ CWORD_CWORD_CWORD_CWORD, - /* 82 -48 */ CWORD_CWORD_CWORD_CWORD, - /* 83 -47 */ CWORD_CWORD_CWORD_CWORD, - /* 84 -46 */ CWORD_CWORD_CWORD_CWORD, - /* 85 -45 */ CWORD_CWORD_CWORD_CWORD, - /* 86 -44 */ CWORD_CWORD_CWORD_CWORD, - /* 87 -43 */ CWORD_CWORD_CWORD_CWORD, - /* 88 -42 */ CWORD_CWORD_CWORD_CWORD, - /* 89 -41 */ CWORD_CWORD_CWORD_CWORD, - /* 90 -40 */ CWORD_CWORD_CWORD_CWORD, - /* 91 -39 */ CWORD_CWORD_CWORD_CWORD, - /* 92 -38 */ CWORD_CWORD_CWORD_CWORD, - /* 93 -37 */ CWORD_CWORD_CWORD_CWORD, - /* 94 -36 */ CWORD_CWORD_CWORD_CWORD, - /* 95 -35 */ CWORD_CWORD_CWORD_CWORD, - /* 96 -34 */ CWORD_CWORD_CWORD_CWORD, - /* 97 -33 */ CWORD_CWORD_CWORD_CWORD, - /* 98 -32 */ CWORD_CWORD_CWORD_CWORD, - /* 99 -31 */ CWORD_CWORD_CWORD_CWORD, - /* 100 -30 */ CWORD_CWORD_CWORD_CWORD, - /* 101 -29 */ CWORD_CWORD_CWORD_CWORD, - /* 102 -28 */ CWORD_CWORD_CWORD_CWORD, - /* 103 -27 */ CWORD_CWORD_CWORD_CWORD, - /* 104 -26 */ CWORD_CWORD_CWORD_CWORD, - /* 105 -25 */ CWORD_CWORD_CWORD_CWORD, - /* 106 -24 */ CWORD_CWORD_CWORD_CWORD, - /* 107 -23 */ CWORD_CWORD_CWORD_CWORD, - /* 108 -22 */ CWORD_CWORD_CWORD_CWORD, - /* 109 -21 */ CWORD_CWORD_CWORD_CWORD, - /* 110 -20 */ CWORD_CWORD_CWORD_CWORD, - /* 111 -19 */ CWORD_CWORD_CWORD_CWORD, - /* 112 -18 */ CWORD_CWORD_CWORD_CWORD, - /* 113 -17 */ CWORD_CWORD_CWORD_CWORD, - /* 114 -16 */ CWORD_CWORD_CWORD_CWORD, - /* 115 -15 */ CWORD_CWORD_CWORD_CWORD, - /* 116 -14 */ CWORD_CWORD_CWORD_CWORD, - /* 117 -13 */ CWORD_CWORD_CWORD_CWORD, - /* 118 -12 */ CWORD_CWORD_CWORD_CWORD, - /* 119 -11 */ CWORD_CWORD_CWORD_CWORD, - /* 120 -10 */ CWORD_CWORD_CWORD_CWORD, - /* 121 -9 */ CWORD_CWORD_CWORD_CWORD, - /* 122 -8 */ CWORD_CWORD_CWORD_CWORD, - /* 123 -7 */ CWORD_CWORD_CWORD_CWORD, - /* 124 -6 */ CWORD_CWORD_CWORD_CWORD, - /* 125 -5 */ CWORD_CWORD_CWORD_CWORD, - /* 126 -4 */ CWORD_CWORD_CWORD_CWORD, - /* 127 -3 */ CWORD_CWORD_CWORD_CWORD, - /* 128 -2 */ CWORD_CWORD_CWORD_CWORD, - /* 129 -1 */ CWORD_CWORD_CWORD_CWORD, - /* 130 0 */ CWORD_CWORD_CWORD_CWORD, - /* 131 1 */ CWORD_CWORD_CWORD_CWORD, - /* 132 2 */ CWORD_CWORD_CWORD_CWORD, - /* 133 3 */ CWORD_CWORD_CWORD_CWORD, - /* 134 4 */ CWORD_CWORD_CWORD_CWORD, - /* 135 5 */ CWORD_CWORD_CWORD_CWORD, - /* 136 6 */ CWORD_CWORD_CWORD_CWORD, - /* 137 7 */ CWORD_CWORD_CWORD_CWORD, - /* 138 8 */ CWORD_CWORD_CWORD_CWORD, - /* 139 9 "\t" */ CSPCL_CWORD_CWORD_CWORD, - /* 140 10 "\n" */ CNL_CNL_CNL_CNL, - /* 141 11 */ CWORD_CWORD_CWORD_CWORD, - /* 142 12 */ CWORD_CWORD_CWORD_CWORD, - /* 143 13 */ CWORD_CWORD_CWORD_CWORD, - /* 144 14 */ CWORD_CWORD_CWORD_CWORD, - /* 145 15 */ CWORD_CWORD_CWORD_CWORD, - /* 146 16 */ CWORD_CWORD_CWORD_CWORD, - /* 147 17 */ CWORD_CWORD_CWORD_CWORD, - /* 148 18 */ CWORD_CWORD_CWORD_CWORD, - /* 149 19 */ CWORD_CWORD_CWORD_CWORD, - /* 150 20 */ CWORD_CWORD_CWORD_CWORD, - /* 151 21 */ CWORD_CWORD_CWORD_CWORD, - /* 152 22 */ CWORD_CWORD_CWORD_CWORD, - /* 153 23 */ CWORD_CWORD_CWORD_CWORD, - /* 154 24 */ CWORD_CWORD_CWORD_CWORD, - /* 155 25 */ CWORD_CWORD_CWORD_CWORD, - /* 156 26 */ CWORD_CWORD_CWORD_CWORD, - /* 157 27 */ CWORD_CWORD_CWORD_CWORD, - /* 158 28 */ CWORD_CWORD_CWORD_CWORD, - /* 159 29 */ CWORD_CWORD_CWORD_CWORD, - /* 160 30 */ CWORD_CWORD_CWORD_CWORD, - /* 161 31 */ CWORD_CWORD_CWORD_CWORD, - /* 162 32 " " */ CSPCL_CWORD_CWORD_CWORD, - /* 163 33 "!" */ CWORD_CCTL_CCTL_CWORD, - /* 164 34 """ */ CDQUOTE_CENDQUOTE_CWORD_CWORD, - /* 165 35 "#" */ CWORD_CWORD_CWORD_CWORD, - /* 166 36 "$" */ CVAR_CVAR_CWORD_CVAR, - /* 167 37 "%" */ CWORD_CWORD_CWORD_CWORD, - /* 168 38 "&" */ CSPCL_CWORD_CWORD_CWORD, - /* 169 39 "'" */ CSQUOTE_CWORD_CENDQUOTE_CWORD, - /* 170 40 "(" */ CSPCL_CWORD_CWORD_CLP, - /* 171 41 ")" */ CSPCL_CWORD_CWORD_CRP, - /* 172 42 "*" */ CWORD_CCTL_CCTL_CWORD, - /* 173 43 "+" */ CWORD_CWORD_CWORD_CWORD, - /* 174 44 "," */ CWORD_CWORD_CWORD_CWORD, - /* 175 45 "-" */ CWORD_CCTL_CCTL_CWORD, - /* 176 46 "." */ CWORD_CWORD_CWORD_CWORD, - /* 177 47 "/" */ CWORD_CCTL_CCTL_CWORD, - /* 178 48 "0" */ CWORD_CWORD_CWORD_CWORD, - /* 179 49 "1" */ CWORD_CWORD_CWORD_CWORD, - /* 180 50 "2" */ CWORD_CWORD_CWORD_CWORD, - /* 181 51 "3" */ CWORD_CWORD_CWORD_CWORD, - /* 182 52 "4" */ CWORD_CWORD_CWORD_CWORD, - /* 183 53 "5" */ CWORD_CWORD_CWORD_CWORD, - /* 184 54 "6" */ CWORD_CWORD_CWORD_CWORD, - /* 185 55 "7" */ CWORD_CWORD_CWORD_CWORD, - /* 186 56 "8" */ CWORD_CWORD_CWORD_CWORD, - /* 187 57 "9" */ CWORD_CWORD_CWORD_CWORD, - /* 188 58 ":" */ CWORD_CCTL_CCTL_CWORD, - /* 189 59 ";" */ CSPCL_CWORD_CWORD_CWORD, - /* 190 60 "<" */ CSPCL_CWORD_CWORD_CWORD, - /* 191 61 "=" */ CWORD_CCTL_CCTL_CWORD, - /* 192 62 ">" */ CSPCL_CWORD_CWORD_CWORD, - /* 193 63 "?" */ CWORD_CCTL_CCTL_CWORD, - /* 194 64 "@" */ CWORD_CWORD_CWORD_CWORD, - /* 195 65 "A" */ CWORD_CWORD_CWORD_CWORD, - /* 196 66 "B" */ CWORD_CWORD_CWORD_CWORD, - /* 197 67 "C" */ CWORD_CWORD_CWORD_CWORD, - /* 198 68 "D" */ CWORD_CWORD_CWORD_CWORD, - /* 199 69 "E" */ CWORD_CWORD_CWORD_CWORD, - /* 200 70 "F" */ CWORD_CWORD_CWORD_CWORD, - /* 201 71 "G" */ CWORD_CWORD_CWORD_CWORD, - /* 202 72 "H" */ CWORD_CWORD_CWORD_CWORD, - /* 203 73 "I" */ CWORD_CWORD_CWORD_CWORD, - /* 204 74 "J" */ CWORD_CWORD_CWORD_CWORD, - /* 205 75 "K" */ CWORD_CWORD_CWORD_CWORD, - /* 206 76 "L" */ CWORD_CWORD_CWORD_CWORD, - /* 207 77 "M" */ CWORD_CWORD_CWORD_CWORD, - /* 208 78 "N" */ CWORD_CWORD_CWORD_CWORD, - /* 209 79 "O" */ CWORD_CWORD_CWORD_CWORD, - /* 210 80 "P" */ CWORD_CWORD_CWORD_CWORD, - /* 211 81 "Q" */ CWORD_CWORD_CWORD_CWORD, - /* 212 82 "R" */ CWORD_CWORD_CWORD_CWORD, - /* 213 83 "S" */ CWORD_CWORD_CWORD_CWORD, - /* 214 84 "T" */ CWORD_CWORD_CWORD_CWORD, - /* 215 85 "U" */ CWORD_CWORD_CWORD_CWORD, - /* 216 86 "V" */ CWORD_CWORD_CWORD_CWORD, - /* 217 87 "W" */ CWORD_CWORD_CWORD_CWORD, - /* 218 88 "X" */ CWORD_CWORD_CWORD_CWORD, - /* 219 89 "Y" */ CWORD_CWORD_CWORD_CWORD, - /* 220 90 "Z" */ CWORD_CWORD_CWORD_CWORD, - /* 221 91 "[" */ CWORD_CCTL_CCTL_CWORD, - /* 222 92 "\" */ CBACK_CBACK_CCTL_CBACK, - /* 223 93 "]" */ CWORD_CCTL_CCTL_CWORD, - /* 224 94 "^" */ CWORD_CWORD_CWORD_CWORD, - /* 225 95 "_" */ CWORD_CWORD_CWORD_CWORD, - /* 226 96 "`" */ CBQUOTE_CBQUOTE_CWORD_CBQUOTE, - /* 227 97 "a" */ CWORD_CWORD_CWORD_CWORD, - /* 228 98 "b" */ CWORD_CWORD_CWORD_CWORD, - /* 229 99 "c" */ CWORD_CWORD_CWORD_CWORD, - /* 230 100 "d" */ CWORD_CWORD_CWORD_CWORD, - /* 231 101 "e" */ CWORD_CWORD_CWORD_CWORD, - /* 232 102 "f" */ CWORD_CWORD_CWORD_CWORD, - /* 233 103 "g" */ CWORD_CWORD_CWORD_CWORD, - /* 234 104 "h" */ CWORD_CWORD_CWORD_CWORD, - /* 235 105 "i" */ CWORD_CWORD_CWORD_CWORD, - /* 236 106 "j" */ CWORD_CWORD_CWORD_CWORD, - /* 237 107 "k" */ CWORD_CWORD_CWORD_CWORD, - /* 238 108 "l" */ CWORD_CWORD_CWORD_CWORD, - /* 239 109 "m" */ CWORD_CWORD_CWORD_CWORD, - /* 240 110 "n" */ CWORD_CWORD_CWORD_CWORD, - /* 241 111 "o" */ CWORD_CWORD_CWORD_CWORD, - /* 242 112 "p" */ CWORD_CWORD_CWORD_CWORD, - /* 243 113 "q" */ CWORD_CWORD_CWORD_CWORD, - /* 244 114 "r" */ CWORD_CWORD_CWORD_CWORD, - /* 245 115 "s" */ CWORD_CWORD_CWORD_CWORD, - /* 246 116 "t" */ CWORD_CWORD_CWORD_CWORD, - /* 247 117 "u" */ CWORD_CWORD_CWORD_CWORD, - /* 248 118 "v" */ CWORD_CWORD_CWORD_CWORD, - /* 249 119 "w" */ CWORD_CWORD_CWORD_CWORD, - /* 250 120 "x" */ CWORD_CWORD_CWORD_CWORD, - /* 251 121 "y" */ CWORD_CWORD_CWORD_CWORD, - /* 252 122 "z" */ CWORD_CWORD_CWORD_CWORD, - /* 253 123 "{" */ CWORD_CWORD_CWORD_CWORD, - /* 254 124 "|" */ CSPCL_CWORD_CWORD_CWORD, - /* 255 125 "}" */ CENDVAR_CENDVAR_CWORD_CENDVAR, - /* 256 126 "~" */ CWORD_CCTL_CCTL_CWORD, - /* 257 127 */ CWORD_CWORD_CWORD_CWORD, + /* 0 */ CWORD_CWORD_CWORD_CWORD, + /* 1 */ CWORD_CWORD_CWORD_CWORD, + /* 2 */ CWORD_CWORD_CWORD_CWORD, + /* 3 */ CWORD_CWORD_CWORD_CWORD, + /* 4 */ CWORD_CWORD_CWORD_CWORD, + /* 5 */ CWORD_CWORD_CWORD_CWORD, + /* 6 */ CWORD_CWORD_CWORD_CWORD, + /* 7 */ CWORD_CWORD_CWORD_CWORD, + /* 8 */ CWORD_CWORD_CWORD_CWORD, + /* 9 "\t" */ CSPCL_CWORD_CWORD_CWORD, + /* 10 "\n" */ CNL_CNL_CNL_CNL, + /* 11 */ CWORD_CWORD_CWORD_CWORD, + /* 12 */ CWORD_CWORD_CWORD_CWORD, + /* 13 */ CWORD_CWORD_CWORD_CWORD, + /* 14 */ CWORD_CWORD_CWORD_CWORD, + /* 15 */ CWORD_CWORD_CWORD_CWORD, + /* 16 */ CWORD_CWORD_CWORD_CWORD, + /* 17 */ CWORD_CWORD_CWORD_CWORD, + /* 18 */ CWORD_CWORD_CWORD_CWORD, + /* 19 */ CWORD_CWORD_CWORD_CWORD, + /* 20 */ CWORD_CWORD_CWORD_CWORD, + /* 21 */ CWORD_CWORD_CWORD_CWORD, + /* 22 */ CWORD_CWORD_CWORD_CWORD, + /* 23 */ CWORD_CWORD_CWORD_CWORD, + /* 24 */ CWORD_CWORD_CWORD_CWORD, + /* 25 */ CWORD_CWORD_CWORD_CWORD, + /* 26 */ CWORD_CWORD_CWORD_CWORD, + /* 27 */ CWORD_CWORD_CWORD_CWORD, + /* 28 */ CWORD_CWORD_CWORD_CWORD, + /* 29 */ CWORD_CWORD_CWORD_CWORD, + /* 30 */ CWORD_CWORD_CWORD_CWORD, + /* 31 */ CWORD_CWORD_CWORD_CWORD, + /* 32 " " */ CSPCL_CWORD_CWORD_CWORD, + /* 33 "!" */ CWORD_CCTL_CCTL_CWORD, + /* 34 """ */ CDQUOTE_CENDQUOTE_CWORD_CWORD, + /* 35 "#" */ CWORD_CWORD_CWORD_CWORD, + /* 36 "$" */ CVAR_CVAR_CWORD_CVAR, + /* 37 "%" */ CWORD_CWORD_CWORD_CWORD, + /* 38 "&" */ CSPCL_CWORD_CWORD_CWORD, + /* 39 "'" */ CSQUOTE_CWORD_CENDQUOTE_CWORD, + /* 40 "(" */ CSPCL_CWORD_CWORD_CLP, + /* 41 ")" */ CSPCL_CWORD_CWORD_CRP, + /* 42 "*" */ CWORD_CCTL_CCTL_CWORD, + /* 43 "+" */ CWORD_CWORD_CWORD_CWORD, + /* 44 "," */ CWORD_CWORD_CWORD_CWORD, + /* 45 "-" */ CWORD_CCTL_CCTL_CWORD, + /* 46 "." */ CWORD_CWORD_CWORD_CWORD, + /* 47 "/" */ CWORD_CCTL_CCTL_CWORD, + /* 48 "0" */ CWORD_CWORD_CWORD_CWORD, + /* 49 "1" */ CWORD_CWORD_CWORD_CWORD, + /* 50 "2" */ CWORD_CWORD_CWORD_CWORD, + /* 51 "3" */ CWORD_CWORD_CWORD_CWORD, + /* 52 "4" */ CWORD_CWORD_CWORD_CWORD, + /* 53 "5" */ CWORD_CWORD_CWORD_CWORD, + /* 54 "6" */ CWORD_CWORD_CWORD_CWORD, + /* 55 "7" */ CWORD_CWORD_CWORD_CWORD, + /* 56 "8" */ CWORD_CWORD_CWORD_CWORD, + /* 57 "9" */ CWORD_CWORD_CWORD_CWORD, + /* 58 ":" */ CWORD_CCTL_CCTL_CWORD, + /* 59 ";" */ CSPCL_CWORD_CWORD_CWORD, + /* 60 "<" */ CSPCL_CWORD_CWORD_CWORD, + /* 61 "=" */ CWORD_CCTL_CCTL_CWORD, + /* 62 ">" */ CSPCL_CWORD_CWORD_CWORD, + /* 63 "?" */ CWORD_CCTL_CCTL_CWORD, + /* 64 "@" */ CWORD_CWORD_CWORD_CWORD, + /* 65 "A" */ CWORD_CWORD_CWORD_CWORD, + /* 66 "B" */ CWORD_CWORD_CWORD_CWORD, + /* 67 "C" */ CWORD_CWORD_CWORD_CWORD, + /* 68 "D" */ CWORD_CWORD_CWORD_CWORD, + /* 69 "E" */ CWORD_CWORD_CWORD_CWORD, + /* 70 "F" */ CWORD_CWORD_CWORD_CWORD, + /* 71 "G" */ CWORD_CWORD_CWORD_CWORD, + /* 72 "H" */ CWORD_CWORD_CWORD_CWORD, + /* 73 "I" */ CWORD_CWORD_CWORD_CWORD, + /* 74 "J" */ CWORD_CWORD_CWORD_CWORD, + /* 75 "K" */ CWORD_CWORD_CWORD_CWORD, + /* 76 "L" */ CWORD_CWORD_CWORD_CWORD, + /* 77 "M" */ CWORD_CWORD_CWORD_CWORD, + /* 78 "N" */ CWORD_CWORD_CWORD_CWORD, + /* 79 "O" */ CWORD_CWORD_CWORD_CWORD, + /* 80 "P" */ CWORD_CWORD_CWORD_CWORD, + /* 81 "Q" */ CWORD_CWORD_CWORD_CWORD, + /* 82 "R" */ CWORD_CWORD_CWORD_CWORD, + /* 83 "S" */ CWORD_CWORD_CWORD_CWORD, + /* 84 "T" */ CWORD_CWORD_CWORD_CWORD, + /* 85 "U" */ CWORD_CWORD_CWORD_CWORD, + /* 86 "V" */ CWORD_CWORD_CWORD_CWORD, + /* 87 "W" */ CWORD_CWORD_CWORD_CWORD, + /* 88 "X" */ CWORD_CWORD_CWORD_CWORD, + /* 89 "Y" */ CWORD_CWORD_CWORD_CWORD, + /* 90 "Z" */ CWORD_CWORD_CWORD_CWORD, + /* 91 "[" */ CWORD_CCTL_CCTL_CWORD, + /* 92 "\" */ CBACK_CBACK_CCTL_CBACK, + /* 93 "]" */ CWORD_CCTL_CCTL_CWORD, + /* 94 "^" */ CWORD_CWORD_CWORD_CWORD, + /* 95 "_" */ CWORD_CWORD_CWORD_CWORD, + /* 96 "`" */ CBQUOTE_CBQUOTE_CWORD_CBQUOTE, + /* 97 "a" */ CWORD_CWORD_CWORD_CWORD, + /* 98 "b" */ CWORD_CWORD_CWORD_CWORD, + /* 99 "c" */ CWORD_CWORD_CWORD_CWORD, + /* 100 "d" */ CWORD_CWORD_CWORD_CWORD, + /* 101 "e" */ CWORD_CWORD_CWORD_CWORD, + /* 102 "f" */ CWORD_CWORD_CWORD_CWORD, + /* 103 "g" */ CWORD_CWORD_CWORD_CWORD, + /* 104 "h" */ CWORD_CWORD_CWORD_CWORD, + /* 105 "i" */ CWORD_CWORD_CWORD_CWORD, + /* 106 "j" */ CWORD_CWORD_CWORD_CWORD, + /* 107 "k" */ CWORD_CWORD_CWORD_CWORD, + /* 108 "l" */ CWORD_CWORD_CWORD_CWORD, + /* 109 "m" */ CWORD_CWORD_CWORD_CWORD, + /* 110 "n" */ CWORD_CWORD_CWORD_CWORD, + /* 111 "o" */ CWORD_CWORD_CWORD_CWORD, + /* 112 "p" */ CWORD_CWORD_CWORD_CWORD, + /* 113 "q" */ CWORD_CWORD_CWORD_CWORD, + /* 114 "r" */ CWORD_CWORD_CWORD_CWORD, + /* 115 "s" */ CWORD_CWORD_CWORD_CWORD, + /* 116 "t" */ CWORD_CWORD_CWORD_CWORD, + /* 117 "u" */ CWORD_CWORD_CWORD_CWORD, + /* 118 "v" */ CWORD_CWORD_CWORD_CWORD, + /* 119 "w" */ CWORD_CWORD_CWORD_CWORD, + /* 120 "x" */ CWORD_CWORD_CWORD_CWORD, + /* 121 "y" */ CWORD_CWORD_CWORD_CWORD, + /* 122 "z" */ CWORD_CWORD_CWORD_CWORD, + /* 123 "{" */ CWORD_CWORD_CWORD_CWORD, + /* 124 "|" */ CSPCL_CWORD_CWORD_CWORD, + /* 125 "}" */ CENDVAR_CENDVAR_CWORD_CENDVAR, + /* 126 "~" */ CWORD_CCTL_CCTL_CWORD, + /* 127 del */ CWORD_CWORD_CWORD_CWORD, + /* 128 0x80 */ CWORD_CWORD_CWORD_CWORD, + /* 129 CTLESC */ CCTL_CCTL_CCTL_CCTL, + /* 130 CTLVAR */ CCTL_CCTL_CCTL_CCTL, + /* 131 CTLENDVAR */ CCTL_CCTL_CCTL_CCTL, + /* 132 CTLBACKQ */ CCTL_CCTL_CCTL_CCTL, + /* 133 CTLQUOTE */ CCTL_CCTL_CCTL_CCTL, + /* 134 CTLARI */ CCTL_CCTL_CCTL_CCTL, + /* 135 CTLENDARI */ CCTL_CCTL_CCTL_CCTL, + /* 136 CTLQUOTEMARK */ CCTL_CCTL_CCTL_CCTL, + /* 137 */ CWORD_CWORD_CWORD_CWORD, + /* 138 */ CWORD_CWORD_CWORD_CWORD, + /* 139 */ CWORD_CWORD_CWORD_CWORD, + /* 140 */ CWORD_CWORD_CWORD_CWORD, + /* 141 */ CWORD_CWORD_CWORD_CWORD, + /* 142 */ CWORD_CWORD_CWORD_CWORD, + /* 143 */ CWORD_CWORD_CWORD_CWORD, + /* 144 */ CWORD_CWORD_CWORD_CWORD, + /* 145 */ CWORD_CWORD_CWORD_CWORD, + /* 146 */ CWORD_CWORD_CWORD_CWORD, + /* 147 */ CWORD_CWORD_CWORD_CWORD, + /* 148 */ CWORD_CWORD_CWORD_CWORD, + /* 149 */ CWORD_CWORD_CWORD_CWORD, + /* 150 */ CWORD_CWORD_CWORD_CWORD, + /* 151 */ CWORD_CWORD_CWORD_CWORD, + /* 152 */ CWORD_CWORD_CWORD_CWORD, + /* 153 */ CWORD_CWORD_CWORD_CWORD, + /* 154 */ CWORD_CWORD_CWORD_CWORD, + /* 155 */ CWORD_CWORD_CWORD_CWORD, + /* 156 */ CWORD_CWORD_CWORD_CWORD, + /* 157 */ CWORD_CWORD_CWORD_CWORD, + /* 158 */ CWORD_CWORD_CWORD_CWORD, + /* 159 */ CWORD_CWORD_CWORD_CWORD, + /* 160 */ CWORD_CWORD_CWORD_CWORD, + /* 161 */ CWORD_CWORD_CWORD_CWORD, + /* 162 */ CWORD_CWORD_CWORD_CWORD, + /* 163 */ CWORD_CWORD_CWORD_CWORD, + /* 164 */ CWORD_CWORD_CWORD_CWORD, + /* 165 */ CWORD_CWORD_CWORD_CWORD, + /* 166 */ CWORD_CWORD_CWORD_CWORD, + /* 167 */ CWORD_CWORD_CWORD_CWORD, + /* 168 */ CWORD_CWORD_CWORD_CWORD, + /* 169 */ CWORD_CWORD_CWORD_CWORD, + /* 170 */ CWORD_CWORD_CWORD_CWORD, + /* 171 */ CWORD_CWORD_CWORD_CWORD, + /* 172 */ CWORD_CWORD_CWORD_CWORD, + /* 173 */ CWORD_CWORD_CWORD_CWORD, + /* 174 */ CWORD_CWORD_CWORD_CWORD, + /* 175 */ CWORD_CWORD_CWORD_CWORD, + /* 176 */ CWORD_CWORD_CWORD_CWORD, + /* 177 */ CWORD_CWORD_CWORD_CWORD, + /* 178 */ CWORD_CWORD_CWORD_CWORD, + /* 179 */ CWORD_CWORD_CWORD_CWORD, + /* 180 */ CWORD_CWORD_CWORD_CWORD, + /* 181 */ CWORD_CWORD_CWORD_CWORD, + /* 182 */ CWORD_CWORD_CWORD_CWORD, + /* 183 */ CWORD_CWORD_CWORD_CWORD, + /* 184 */ CWORD_CWORD_CWORD_CWORD, + /* 185 */ CWORD_CWORD_CWORD_CWORD, + /* 186 */ CWORD_CWORD_CWORD_CWORD, + /* 187 */ CWORD_CWORD_CWORD_CWORD, + /* 188 */ CWORD_CWORD_CWORD_CWORD, + /* 189 */ CWORD_CWORD_CWORD_CWORD, + /* 190 */ CWORD_CWORD_CWORD_CWORD, + /* 191 */ CWORD_CWORD_CWORD_CWORD, + /* 192 */ CWORD_CWORD_CWORD_CWORD, + /* 193 */ CWORD_CWORD_CWORD_CWORD, + /* 194 */ CWORD_CWORD_CWORD_CWORD, + /* 195 */ CWORD_CWORD_CWORD_CWORD, + /* 196 */ CWORD_CWORD_CWORD_CWORD, + /* 197 */ CWORD_CWORD_CWORD_CWORD, + /* 198 */ CWORD_CWORD_CWORD_CWORD, + /* 199 */ CWORD_CWORD_CWORD_CWORD, + /* 200 */ CWORD_CWORD_CWORD_CWORD, + /* 201 */ CWORD_CWORD_CWORD_CWORD, + /* 202 */ CWORD_CWORD_CWORD_CWORD, + /* 203 */ CWORD_CWORD_CWORD_CWORD, + /* 204 */ CWORD_CWORD_CWORD_CWORD, + /* 205 */ CWORD_CWORD_CWORD_CWORD, + /* 206 */ CWORD_CWORD_CWORD_CWORD, + /* 207 */ CWORD_CWORD_CWORD_CWORD, + /* 208 */ CWORD_CWORD_CWORD_CWORD, + /* 209 */ CWORD_CWORD_CWORD_CWORD, + /* 210 */ CWORD_CWORD_CWORD_CWORD, + /* 211 */ CWORD_CWORD_CWORD_CWORD, + /* 212 */ CWORD_CWORD_CWORD_CWORD, + /* 213 */ CWORD_CWORD_CWORD_CWORD, + /* 214 */ CWORD_CWORD_CWORD_CWORD, + /* 215 */ CWORD_CWORD_CWORD_CWORD, + /* 216 */ CWORD_CWORD_CWORD_CWORD, + /* 217 */ CWORD_CWORD_CWORD_CWORD, + /* 218 */ CWORD_CWORD_CWORD_CWORD, + /* 219 */ CWORD_CWORD_CWORD_CWORD, + /* 220 */ CWORD_CWORD_CWORD_CWORD, + /* 221 */ CWORD_CWORD_CWORD_CWORD, + /* 222 */ CWORD_CWORD_CWORD_CWORD, + /* 223 */ CWORD_CWORD_CWORD_CWORD, + /* 224 */ CWORD_CWORD_CWORD_CWORD, + /* 225 */ CWORD_CWORD_CWORD_CWORD, + /* 226 */ CWORD_CWORD_CWORD_CWORD, + /* 227 */ CWORD_CWORD_CWORD_CWORD, + /* 228 */ CWORD_CWORD_CWORD_CWORD, + /* 229 */ CWORD_CWORD_CWORD_CWORD, + /* 230 */ CWORD_CWORD_CWORD_CWORD, + /* 231 */ CWORD_CWORD_CWORD_CWORD, + /* 232 */ CWORD_CWORD_CWORD_CWORD, + /* 233 */ CWORD_CWORD_CWORD_CWORD, + /* 234 */ CWORD_CWORD_CWORD_CWORD, + /* 235 */ CWORD_CWORD_CWORD_CWORD, + /* 236 */ CWORD_CWORD_CWORD_CWORD, + /* 237 */ CWORD_CWORD_CWORD_CWORD, + /* 238 */ CWORD_CWORD_CWORD_CWORD, + /* 239 */ CWORD_CWORD_CWORD_CWORD, + /* 230 */ CWORD_CWORD_CWORD_CWORD, + /* 241 */ CWORD_CWORD_CWORD_CWORD, + /* 242 */ CWORD_CWORD_CWORD_CWORD, + /* 243 */ CWORD_CWORD_CWORD_CWORD, + /* 244 */ CWORD_CWORD_CWORD_CWORD, + /* 245 */ CWORD_CWORD_CWORD_CWORD, + /* 246 */ CWORD_CWORD_CWORD_CWORD, + /* 247 */ CWORD_CWORD_CWORD_CWORD, + /* 248 */ CWORD_CWORD_CWORD_CWORD, + /* 249 */ CWORD_CWORD_CWORD_CWORD, + /* 250 */ CWORD_CWORD_CWORD_CWORD, + /* 251 */ CWORD_CWORD_CWORD_CWORD, + /* 252 */ CWORD_CWORD_CWORD_CWORD, + /* 253 */ CWORD_CWORD_CWORD_CWORD, + /* 254 */ CWORD_CWORD_CWORD_CWORD, + /* 255 */ CWORD_CWORD_CWORD_CWORD, +# if ENABLE_ASH_ALIAS + /* PEOA */ CSPCL_CIGN_CIGN_CIGN, +# endif + /* PEOF */ CENDFILE_CENDFILE_CENDFILE_CENDFILE, }; -#define SIT(c, syntax) (S_I_T[(int)syntax_index_table[(int)(c) + SYNBASE]][syntax]) +# define SIT(c, syntax) (S_I_T[syntax_index_table[c]][syntax]) #endif /* USE_SIT_FUNCTION */ @@ -4229,9 +4226,10 @@ cmdputs(const char *s) }; const char *p, *str; - char c, cc[2] = " "; + char cc[2] = " "; char *nextc; - int subtype = 0; + unsigned char c; + unsigned char subtype = 0; int quoted = 0; nextc = makestrspace((strlen(s) + 1) * 8, cmdnextc); @@ -5454,7 +5452,7 @@ rmescapes(char *str, int flag) globbing = flag & RMESCAPE_GLOB; protect_against_glob = globbing; while (*p) { - if (*p == CTLQUOTEMARK) { + if ((unsigned char)*p == CTLQUOTEMARK) { // TODO: if no RMESCAPE_QUOTED in flags, inquotes never becomes 0 // (alternates between RMESCAPE_QUOTED and ~RMESCAPE_QUOTED). Is it ok? // Note: both inquotes and protect_against_glob only affect whether @@ -5469,7 +5467,7 @@ rmescapes(char *str, int flag) protect_against_glob = 0; goto copy; } - if (*p == CTLESC) { + if ((unsigned char)*p == CTLESC) { p++; if (protect_against_glob && inquotes && *p != '/') { *q++ = '\\'; @@ -5514,8 +5512,8 @@ memtodest(const char *p, size_t len, int syntax, int quotes) q = makestrspace(quotes ? len * 2 : len, q); while (len--) { - int c = signed_char2int(*p++); - if (!c) + unsigned char c = *p++; + if (c == '\0') continue; if (quotes) { int n = SIT(c, syntax); @@ -5600,7 +5598,7 @@ removerecordregions(int endoff) static char * exptilde(char *startp, char *p, int flags) { - char c; + unsigned char c; char *name; struct passwd *pw; const char *home; @@ -5795,7 +5793,7 @@ expari(int quotes) do { int esc; - while (*p != CTLARI) { + while ((unsigned char)*p != CTLARI) { p--; #if DEBUG if (p < start) { @@ -5857,10 +5855,9 @@ argstr(char *p, int flags, struct strlist *var_str_list) #if ENABLE_SH_MATH_SUPPORT CTLENDARI, #endif - 0 + '\0' }; const char *reject = spclchars; - int c; int quotes = flags & (EXP_FULL | EXP_CASE | EXP_REDIR); /* do CTLESC */ int breakall = flags & EXP_WORD; int inquotes; @@ -5888,8 +5885,10 @@ argstr(char *p, int flags, struct strlist *var_str_list) start: startloc = expdest - (char *)stackblock(); for (;;) { + unsigned char c; + length += strcspn(p + length, reject); - c = (unsigned char) p[length]; + c = p[length]; if (c) { if (!(c & 0x80) #if ENABLE_SH_MATH_SUPPORT @@ -6044,7 +6043,7 @@ scanleft(char *startp, char *rmesc, char *rmescend UNUSED_PARAM, char *str, int *loc2 = c; if (match) // if (!match) return loc; - if (quotes && *loc == CTLESC) + if (quotes && (unsigned char)*loc == CTLESC) loc++; loc++; loc2++; @@ -6096,7 +6095,7 @@ varunset(const char *end, const char *var, const char *umsg, int varflags) tail = nullstr; msg = "parameter not set"; if (umsg) { - if (*end == CTLENDVAR) { + if ((unsigned char)*end == CTLENDVAR) { if (varflags & VSNUL) tail = " or null"; } else { @@ -6180,7 +6179,7 @@ subevalvar(char *p, char *str, int strloc, int subtype, /* Adjust the length by the number of escapes */ for (ptr = startp; ptr < (str - 1); ptr++) { - if (*ptr == CTLESC) { + if ((unsigned char)*ptr == CTLESC) { len--; ptr++; } @@ -6214,11 +6213,11 @@ subevalvar(char *p, char *str, int strloc, int subtype, len = orig_len - pos; for (str = startp; pos; str++, pos--) { - if (quotes && *str == CTLESC) + if (quotes && (unsigned char)*str == CTLESC) str++; } for (loc = startp; len; len--) { - if (quotes && *str == CTLESC) + if (quotes && (unsigned char)*str == CTLESC) *loc++ = *str++; *loc++ = *str++; } @@ -6282,7 +6281,7 @@ subevalvar(char *p, char *str, int strloc, int subtype, /* No match, advance */ restart_detect = stackblock(); STPUTC(*idx, expdest); - if (quotes && *idx == CTLESC) { + if (quotes && (unsigned char)*idx == CTLESC) { idx++; len++; STPUTC(*idx, expdest); @@ -6297,7 +6296,7 @@ subevalvar(char *p, char *str, int strloc, int subtype, if (subtype == VSREPLACEALL) { while (idx < loc) { - if (quotes && *idx == CTLESC) + if (quotes && (unsigned char)*idx == CTLESC) idx++; idx++; rmesc++; @@ -6416,7 +6415,7 @@ varvalue(char *name, int varflags, int flags, struct strlist *var_str_list) goto param; /* fall through */ case '*': - sep = ifsset() ? signed_char2int(ifsval()[0]) : ' '; + sep = ifsset() ? (unsigned char)(ifsval()[0]) : ' '; if (quotes && (SIT(sep, syntax) == CCTL || SIT(sep, syntax) == CBACK)) sepq = 1; param: @@ -6634,7 +6633,7 @@ evalvar(char *p, int flags, struct strlist *var_str_list) if (subtype != VSNORMAL) { /* skip to end of alternative */ int nesting = 1; for (;;) { - char c = *p++; + unsigned char c = *p++; if (c == CTLESC) p++; else if (c == CTLBACKQ || c == (CTLBACKQ|CTLQUOTE)) { @@ -6682,7 +6681,7 @@ ifsbreakup(char *string, struct arglist *arglist) ifsspc = 0; while (p < string + ifsp->endoff) { q = p; - if (*p == CTLESC) + if ((unsigned char)*p == CTLESC) p++; if (!strchr(ifs, *p)) { p++; @@ -6708,7 +6707,7 @@ ifsbreakup(char *string, struct arglist *arglist) break; } q = p; - if (*p == CTLESC) + if ((unsigned char)*p == CTLESC) p++; if (strchr(ifs, *p) == NULL) { p = q; @@ -9434,12 +9433,6 @@ preadfd(void) */ //#define pgetc_debug(...) bb_error_msg(__VA_ARGS__) #define pgetc_debug(...) ((void)0) -/* - * NB: due to SIT(c) internals (syntax_index_table[] vector), - * pgetc() and related functions must return chars SIGN-EXTENDED into ints, - * not zero-extended. Seems fragile to me. Affects only !USE_SIT_FUNCTION case, - * so we can fix it by ditching !USE_SIT_FUNCTION if Unicode requires that. - */ static int preadbuffer(void) { @@ -9540,12 +9533,12 @@ preadbuffer(void) g_parsefile->left_in_line, g_parsefile->next_to_pgetc, g_parsefile->next_to_pgetc); - return signed_char2int(*g_parsefile->next_to_pgetc++); + return (unsigned char)*g_parsefile->next_to_pgetc++; } #define pgetc_as_macro() \ (--g_parsefile->left_in_line >= 0 \ - ? signed_char2int(*g_parsefile->next_to_pgetc++) \ + ? (unsigned char)*g_parsefile->next_to_pgetc++ \ : preadbuffer() \ ) @@ -10431,16 +10424,14 @@ fixredir(union node *n, const char *text, int err) static int noexpand(const char *text) { - const char *p; - char c; + unsigned char c; - p = text; - while ((c = *p++) != '\0') { + while ((c = *text++) != '\0') { if (c == CTLQUOTEMARK) continue; if (c == CTLESC) - p++; - else if (SIT((signed char)c, BASESYNTAX) == CCTL) + text++; + else if (SIT(c, BASESYNTAX) == CCTL) return 0; } return 1; @@ -10825,7 +10816,7 @@ static int decode_dollar_squote(void) * If eofmark is NULL, read a word or a redirection symbol. If eofmark * is not NULL, read a here document. In the latter case, eofmark is the * word which marks the end of the document and striptabs is true if - * leading tabs should be stripped from the document. The argument firstc + * leading tabs should be stripped from the document. The argument c * is the first character of the input token or document. * * Because C does not have internal subroutines, I have simulated them @@ -10839,10 +10830,10 @@ static int decode_dollar_squote(void) #define PARSEBACKQNEW() {oldstyle = 0; goto parsebackq; parsebackq_newreturn:;} #define PARSEARITH() {goto parsearith; parsearith_return:;} static int -readtoken1(int firstc, int syntax, char *eofmark, int striptabs) +readtoken1(int c, int syntax, char *eofmark, int striptabs) { /* NB: syntax parameter fits into smallint */ - int c = firstc; + /* c parameter is an unsigned char or PEOF or PEOA */ char *out; int len; char line[EOFMARKLEN + 1]; @@ -11207,14 +11198,14 @@ parseredir: { (((unsigned)(c) - 33 < 32) \ && ((0xc1ff920dU >> ((unsigned)(c) - 33)) & 1)) parsesub: { - int subtype; + unsigned char subtype; int typeloc; int flags; char *p; static const char types[] ALIGN1 = "}-+?="; c = pgetc(); - if (c <= PEOA_OR_PEOF + if (c > 255 /* PEOA or PEOF */ || (c != '(' && c != '{' && !is_name(c) && !is_special(c)) ) { #if ENABLE_ASH_BASH_COMPAT @@ -11251,11 +11242,11 @@ parsesub: { } else subtype = 0; } - if (c > PEOA_OR_PEOF && is_name(c)) { + if (c <= 255 /* not PEOA or PEOF */ && is_name(c)) { do { STPUTC(c, out); c = pgetc(); - } while (c > PEOA_OR_PEOF && is_in_name(c)); + } while (c <= 255 /* not PEOA or PEOF */ && is_in_name(c)); } else if (isdigit(c)) { do { STPUTC(c, out); @@ -11317,7 +11308,7 @@ parsesub: { } if (dblquote || arinest) flags |= VSQUOTE; - *((char *)stackblock() + typeloc) = subtype | flags; + ((unsigned char *)stackblock())[typeloc] = subtype | flags; if (subtype != VSNORMAL) { varnest++; if (dblquote || arinest) { @@ -11401,7 +11392,7 @@ parsebackq: { if (pc != '\\' && pc != '`' && pc != '$' && (!dblquote || pc != '"')) STPUTC('\\', pout); - if (pc > PEOA_OR_PEOF) { + if (pc <= 255 /* not PEOA or PEOF */) { break; } /* fall through */ @@ -13056,6 +13047,10 @@ init(void) /* from trap.c: */ signal(SIGCHLD, SIG_DFL); + /* bash re-enables SIGHUP which is SIG_IGNed on entry. + * Try: "trap '' HUP; bash; echo RET" and type "kill -HUP $$" + */ + signal(SIGHUP, SIG_DFL); /* from var.c: */ { @@ -13311,7 +13306,7 @@ int ash_main(int argc UNUSED_PARAM, char **argv) } if (sflag || minusc == NULL) { -#if MAX_HISTORY > 0 && ENABLE_FEATURE_EDITING_SAVEHISTORY +#if defined MAX_HISTORY && MAX_HISTORY > 0 && ENABLE_FEATURE_EDITING_SAVEHISTORY if (iflag) { const char *hp = lookupvar("HISTFILE"); if (hp) diff --git a/testsuite/awk.tests b/testsuite/awk.tests index 0db99ab21..5fb27cf1e 100755 --- a/testsuite/awk.tests +++ b/testsuite/awk.tests @@ -47,4 +47,21 @@ testing "awk NF in BEGIN" \ ":0::::\n" \ "" "" +prg=' +function b(tmp) { + tmp = 0; + print "" tmp; #this line causes the bug + return tmp; +} +function c(tmpc) { + tmpc = b(); return tmpc; +} +BEGIN { + print (c() ? "string" : "number"); +}' +testing "awk string cast (bug 725)" \ + "awk '$prg'" \ + "0\nnumber\n" \ + "" "" + exit $FAILCOUNT diff --git a/testsuite/grep.tests b/testsuite/grep.tests index 7e3dff0d6..33a237b24 100755 --- a/testsuite/grep.tests +++ b/testsuite/grep.tests @@ -90,4 +90,9 @@ testing "grep -E -o prints all matches" \ "00:19:3E:00:AA:5E\n00:1D:60:3D:3A:FB\n00:22:43:49:FB:AA\n" \ "" "00:19:3E:00:AA:5E 00:1D:60:3D:3A:FB 00:22:43:49:FB:AA\n" +testing "grep -o does not loop forever" \ + 'grep -o "[^/]*$"' \ + "test\n" \ + "" "/var/test\n" + exit $FAILCOUNT diff --git a/util-linux/mount.c b/util-linux/mount.c index 56c32e126..7784681a0 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c @@ -1958,6 +1958,7 @@ int mount_main(int argc UNUSED_PARAM, char **argv) // If we're mounting all } else { + struct mntent *mp; // No, mount -a won't mount anything, // even user mounts, for mere humans if (nonroot) @@ -1985,10 +1986,25 @@ int mount_main(int argc UNUSED_PARAM, char **argv) // NFS mounts want this to be xrealloc-able mtcur->mnt_opts = xstrdup(mtcur->mnt_opts); - // Mount this thing - if (singlemount(mtcur, 1)) { - // Count number of failed mounts - rc++; + // If nothing is mounted on this directory... + // (otherwise repeated "mount -a" mounts everything again) + mp = find_mount_point(mtcur->mnt_dir, /*subdir_too:*/ 0); + // We do not check fsname match of found mount point - + // "/" may have fsname of "/dev/root" while fstab + // says "/dev/something_else". + if (mp) { + if (verbose) { + bb_error_msg("according to %s, " + "%s is already mounted on %s", + bb_path_mtab_file, + mp->mnt_fsname, mp->mnt_dir); + } + } else { + // ...mount this thing + if (singlemount(mtcur, /*ignore_busy:*/ 1)) { + // Count number of failed mounts + rc++; + } } free(mtcur->mnt_opts); } -- 2.25.1