From 958db76802e5614b9f5bfec36cbc73f78bca974c Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Sat, 24 Aug 2024 12:40:22 +0100 Subject: [PATCH] A few accumulated tweaks to recent commits src/cmd/ksh93/sh/lex.c: sh_syntax(): - Code simpilification, eliminating a block with two variables. No change in behaviour. (re: abeb5eaf) src/lib/libast/features/omitted: - Remove a hardcoded use of /tmp, which Android doesn't have. Use the current (i.e., build) directory instead. (re: c3fec93f) src/cmd/ksh93/tests/quoting.sh: - Delete a leftover increase of 'i' from an earlier iteration of the test code (never committed). Since i gets reassigned on the next iteration, there is no change in behaviour. (re: 6d690928) --- src/cmd/ksh93/data/lexstates.c | 2 +- src/cmd/ksh93/include/lexstates.h | 2 +- src/cmd/ksh93/sh/lex.c | 12 +++--------- src/cmd/ksh93/tests/quoting.sh | 1 - src/lib/libast/features/omitted | 4 ++-- src/lib/libast/misc/procclose.c | 2 +- src/lib/libast/misc/proclib.h | 2 +- 7 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/cmd/ksh93/data/lexstates.c b/src/cmd/ksh93/data/lexstates.c index 132867ccb0c9..cbdc96ab7166 100644 --- a/src/cmd/ksh93/data/lexstates.c +++ b/src/cmd/ksh93/data/lexstates.c @@ -738,6 +738,7 @@ const char e_unmatched[] = "`%s' unmatched"; const char e_emptysubscr[] = "[]: empty subscript"; const char e_badreflist[] = "invalid reference list"; const char e_heredoccomsub[] = "`<<%s' here-document not contained within command substitution"; +const char e_lexzerobyte[] = "zero byte"; const char e_endoffile[] = "end of file"; const char e_newline[] = "newline"; @@ -758,7 +759,6 @@ const char e_lexnested[] = "line %d: spaces required for nested subshell"; const char e_lexbadchar[] = "%c: invalid character in expression - %s"; const char e_lexfuture[] = "line %d: \\ in front of %c reserved for future use"; const char e_lexlongquote[] = "line %d: %c quote may be missing"; -const char e_lexzerobyte[] = "zero byte"; const char e_lexemptyfor[] = "line %d: empty for list"; const char e_lextypeset[] = "line %d: %s invalid typeset option order"; const char e_lexcharclass[] = "line %d: '^' as first character in character class not portable"; diff --git a/src/cmd/ksh93/include/lexstates.h b/src/cmd/ksh93/include/lexstates.h index 225dc9449c45..4487f2f9d037 100644 --- a/src/cmd/ksh93/include/lexstates.h +++ b/src/cmd/ksh93/include/lexstates.h @@ -137,6 +137,7 @@ extern const char e_unmatched[]; extern const char e_emptysubscr[]; extern const char e_badreflist[]; extern const char e_heredoccomsub[]; +extern const char e_lexzerobyte[]; extern const char e_endoffile[]; extern const char e_newline[]; @@ -156,7 +157,6 @@ extern const char e_lexnested[]; extern const char e_lexbadchar[]; extern const char e_lexlongquote[]; extern const char e_lexfuture[]; -extern const char e_lexzerobyte[]; extern const char e_lexemptyfor[]; extern const char e_lextypeset[]; extern const char e_lexcharclass[]; diff --git a/src/cmd/ksh93/sh/lex.c b/src/cmd/ksh93/sh/lex.c index 8e2bd3077c86..4a41976a372a 100644 --- a/src/cmd/ksh93/sh/lex.c +++ b/src/cmd/ksh93/sh/lex.c @@ -2134,16 +2134,10 @@ noreturn void sh_syntax(Lex_t *lp, int special) sfprintf(sh.strbuf, sh_translate(e_badreflist)); else if (special==3) sfprintf(sh.strbuf, sh_translate(e_heredoccomsub), lp->heredoc->ioname); + else if (eof) + sfprintf(sh.strbuf, sh_translate(e_unmatched), fmttoken(lp, lp->lasttok)); else - { - const char *msg; - int tok; - if (eof) - tok = lp->lasttok, msg = sh_translate(e_unmatched); - else - tok = lp->token, msg = sh_translate(e_unexpected); - sfprintf(sh.strbuf, msg, fmttoken(lp, tok)); - } + sfprintf(sh.strbuf, sh_translate(e_unexpected), fmttoken(lp, lp->token)); errormsg(SH_DICT, ERROR_exit(SYNBAD), "%s", sfstruse(sh.strbuf)); UNREACHABLE(); } diff --git a/src/cmd/ksh93/tests/quoting.sh b/src/cmd/ksh93/tests/quoting.sh index 0f89ced62746..80d4c2b5efea 100755 --- a/src/cmd/ksh93/tests/quoting.sh +++ b/src/cmd/ksh93/tests/quoting.sh @@ -394,7 +394,6 @@ do [[ $e == [0-9]* ]] && i=$e && continue done done done - ((i+=2)) done # ====== diff --git a/src/lib/libast/features/omitted b/src/lib/libast/features/omitted index 7e9f7cad8116..6c0d9414954f 100644 --- a/src/lib/libast/features/omitted +++ b/src/lib/libast/features/omitted @@ -33,7 +33,7 @@ tst note{ check for Win32 .exe botches }end output{ struct stat st; char buf[256]; - snprintf(buf, sizeof(buf), "rm -rf /tmp/iff-%d", getpid()); + snprintf(buf, sizeof(buf), "rm -rf .iff-%d", getpid()); if (_mkdir(buf+7, 0755)) return 1; if (_chdir(buf+7)) @@ -76,7 +76,7 @@ tst note{ check for Win32 .exe botches }end output{ printf("#define _win32_botch_execve 1\n"); printf("#define _win32_botch 1\n"); } - _chdir("/tmp"); + _chdir(".."); system(buf); return 0; } diff --git a/src/lib/libast/misc/procclose.c b/src/lib/libast/misc/procclose.c index 05b9d53b4efc..1e387f5a4107 100644 --- a/src/lib/libast/misc/procclose.c +++ b/src/lib/libast/misc/procclose.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2023 Contributors to ksh 93u+m * +* Copyright (c) 2020-2024 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 2.0 * * * diff --git a/src/lib/libast/misc/proclib.h b/src/lib/libast/misc/proclib.h index 4e6db03532bb..751498416e23 100644 --- a/src/lib/libast/misc/proclib.h +++ b/src/lib/libast/misc/proclib.h @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2012 AT&T Intellectual Property * -* Copyright (c) 2020-2022 Contributors to ksh 93u+m * +* Copyright (c) 2020-2024 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 2.0 * * *