aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2023-04-01 22:36:30 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2023-04-01 22:52:08 +0200
commitfd5fb2d2b59640910addf5c946a39d4cc5c09003 (patch)
tree91e31dd01ed21f2ff31cf6e35d70322eac6d3bc4
parent1409432d072e62c3838ef2e86b0d97637201dbd5 (diff)
downloadbusybox-w32-fd5fb2d2b59640910addf5c946a39d4cc5c09003.tar.gz
busybox-w32-fd5fb2d2b59640910addf5c946a39d4cc5c09003.tar.bz2
busybox-w32-fd5fb2d2b59640910addf5c946a39d4cc5c09003.zip
hush: speed up "big heredoc" code
function old new delta hush_main 1810 1815 +5 .rodata 102723 102721 -2 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 5/-2) Total: 3 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/hush.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/shell/hush.c b/shell/hush.c
index e42de8762..170edf415 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -10260,6 +10260,20 @@ int hush_main(int argc, char **argv)
10260 INIT_G(); 10260 INIT_G();
10261 if (EXIT_SUCCESS != 0) /* if EXIT_SUCCESS == 0, it is already done */ 10261 if (EXIT_SUCCESS != 0) /* if EXIT_SUCCESS == 0, it is already done */
10262 G.last_exitcode = EXIT_SUCCESS; 10262 G.last_exitcode = EXIT_SUCCESS;
10263#if !BB_MMU
10264 /* "Big heredoc" support via "sh -< STRING" invocation.
10265 * Check it first (do not bother to run the usual init code,
10266 * it is not needed for this case).
10267 */
10268 if (argv[1]
10269 && argv[1][0] == '-' && argv[1][1] == '<' /*&& !argv[1][2]*/
10270 /*&& argv[2] && !argv[3] - we don't check some conditions */
10271 ) {
10272 full_write1_str(argv[2]);
10273 _exit(0);
10274 }
10275 G.argv0_for_re_execing = argv[0];
10276#endif
10263#if ENABLE_HUSH_TRAP 10277#if ENABLE_HUSH_TRAP
10264# if ENABLE_HUSH_FUNCTIONS 10278# if ENABLE_HUSH_FUNCTIONS
10265 G.return_exitcode = -1; 10279 G.return_exitcode = -1;
@@ -10270,9 +10284,6 @@ int hush_main(int argc, char **argv)
10270#if ENABLE_HUSH_FAST 10284#if ENABLE_HUSH_FAST
10271 G.count_SIGCHLD++; /* ensure it is != G.handled_SIGCHLD */ 10285 G.count_SIGCHLD++; /* ensure it is != G.handled_SIGCHLD */
10272#endif 10286#endif
10273#if !BB_MMU
10274 G.argv0_for_re_execing = argv[0];
10275#endif
10276 10287
10277 cached_getpid = getpid(); /* for tcsetpgrp() during init */ 10288 cached_getpid = getpid(); /* for tcsetpgrp() during init */
10278 G.root_pid = cached_getpid; /* for $PID (NOMMU can override via -$HEXPID:HEXPPID:...) */ 10289 G.root_pid = cached_getpid; /* for $PID (NOMMU can override via -$HEXPID:HEXPPID:...) */
@@ -10388,7 +10399,7 @@ int hush_main(int argc, char **argv)
10388 int opt = getopt(argc, argv, "+" /* stop at 1st non-option */ 10399 int opt = getopt(argc, argv, "+" /* stop at 1st non-option */
10389 "cexinsl" 10400 "cexinsl"
10390#if !BB_MMU 10401#if !BB_MMU
10391 "<:$:R:V:" 10402 "$:R:V:"
10392# if ENABLE_HUSH_FUNCTIONS 10403# if ENABLE_HUSH_FUNCTIONS
10393 "F:" 10404 "F:"
10394# endif 10405# endif
@@ -10438,9 +10449,6 @@ int hush_main(int argc, char **argv)
10438 flags |= OPT_login; 10449 flags |= OPT_login;
10439 break; 10450 break;
10440#if !BB_MMU 10451#if !BB_MMU
10441 case '<': /* "big heredoc" support */
10442 full_write1_str(optarg);
10443 _exit(0);
10444 case '$': { 10452 case '$': {
10445 unsigned long long empty_trap_mask; 10453 unsigned long long empty_trap_mask;
10446 10454