diff options
author | Elliott Hughes <enh@google.com> | 2020-01-13 10:13:25 -0800 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2020-01-13 10:14:52 -0800 |
commit | ce2b356a0746e1203be0cf1ab9c90abdb0394e47 (patch) | |
tree | 7ab9a93cef26b8518ed2a986fa3e85e0a41c7cdb /toys | |
parent | 1dab2b948c97f26fe85e822bd7742d15e0cf3c63 (diff) | |
parent | 0e4baaed4ec6e3f2df72a30a331dc54b669b1473 (diff) | |
download | toybox-ce2b356a0746e1203be0cf1ab9c90abdb0394e47.tar.gz |
Merge remote-tracking branch 'toybox/master' into HEAD
Change-Id: Ife0ee073b4040fcf5e1c439a072c009b6568dc8c
Diffstat (limited to 'toys')
-rw-r--r-- | toys/net/sntp.c | 2 | ||||
-rw-r--r-- | toys/other/setsid.c | 1 | ||||
-rw-r--r-- | toys/pending/readelf.c | 18 | ||||
-rw-r--r-- | toys/pending/sh.c | 27 | ||||
-rw-r--r-- | toys/posix/find.c | 2 |
5 files changed, 25 insertions, 25 deletions
diff --git a/toys/net/sntp.c b/toys/net/sntp.c index ab6a6031..0cb0b7b4 100644 --- a/toys/net/sntp.c +++ b/toys/net/sntp.c @@ -39,7 +39,7 @@ GLOBALS( ) // Seconds from 1900 to 1970, including appropriate leap days -#define SEVENTIES 2208988800UL +#define SEVENTIES 2208988800ULL // Get time and return ntptime (saving timespec in pointer if not null) // NTP time is high 32 bits = seconds since 1970 (blame RFC 868), low 32 bits diff --git a/toys/other/setsid.c b/toys/other/setsid.c index 57a926ef..70672424 100644 --- a/toys/other/setsid.c +++ b/toys/other/setsid.c @@ -14,6 +14,7 @@ config SETSID -d Detach from tty -c Control tty (become foreground process & receive keyboard signals) + -w Wait for child (and exit with its status) */ #define FOR_setsid diff --git a/toys/pending/readelf.c b/toys/pending/readelf.c index 58e31432..a9554265 100644 --- a/toys/pending/readelf.c +++ b/toys/pending/readelf.c @@ -35,7 +35,7 @@ GLOBALS( char *x, *p; char *elf, *shstrtab, *f; - off_t shoff, phoff, size; + long long shoff, phoff, size; int bits, shnum, shentsize, phentsize; int64_t (*elf_int)(void *ptr, unsigned size); ) @@ -258,10 +258,10 @@ static void show_notes(long offset, long size) printf(" %-20.*s 0x%08x\t", namesz, name, descsz); if (!memcmp(name, "GNU", 4)) { if (type == 1) { - printf("NT_GNU_ABI_TAG\tOS: %s, ABI: %ld.%ld.%ld", + printf("NT_GNU_ABI_TAG\tOS: %s, ABI: %d.%d.%d", !TT.elf_int(note+16, 4)?"Linux":"?", - TT.elf_int(note+20, 4), TT.elf_int(note+24, 4), - TT.elf_int(note+28, 4)), j=1; + (int)TT.elf_int(note+20, 4), (int)TT.elf_int(note+24, 4), + (int)TT.elf_int(note+28, 4)), j=1; } else if (type == 3) { printf("NT_GNU_BUILD_ID\t"); for (;j<descsz;j++) printf("%02x",note[16+j]); @@ -270,7 +270,7 @@ static void show_notes(long offset, long size) } } else if (!memcmp(name, "Android", 8)) { if (type == 1) { - printf("NT_VERSION\tAPI level %ld", TT.elf_int(note+20, 4)), j=1; + printf("NT_VERSION\tAPI level %d", (int)TT.elf_int(note+20, 4)), j=1; if (descsz>=132) printf(", NDK %.64s (%.64s)",note+24,note+24+64); } } else if (!memcmp(name, "CORE", 5) || !memcmp(name, "LINUX", 6)) { @@ -353,9 +353,9 @@ static void scan_elf() printf(" Version: 0x%x\n", (int) TT.elf_int(TT.elf+20, 4)); printf(" Entry point address: 0x%x\n", entry); - printf(" Start of program headers: %ld (bytes into file)\n", + printf(" Start of program headers: %lld (bytes into file)\n", TT.phoff); - printf(" Start of section headers: %ld (bytes into file)\n", + printf(" Start of section headers: %lld (bytes into file)\n", TT.shoff); printf(" Flags: 0x%x\n", flags); printf(" Size of this header: %d (bytes)\n", ehsize); @@ -371,7 +371,7 @@ static void scan_elf() if (!TT.shnum) printf("\nThere are no sections in this file.\n"); else { if (!FLAG(h)) { - printf("There are %d section headers, starting at offset %#lx:\n", + printf("There are %d section headers, starting at offset %#llx:\n", TT.shnum, TT.shoff); } printf("\n" @@ -414,7 +414,7 @@ static void scan_elf() if (!FLAG(h)) { printf("Elf file type is %s\n" "Entry point %#x\n" - "There are %d program headers, starting at offset %ld\n" + "There are %d program headers, starting at offset %lld\n" "\n", et_type(elf_type), entry, phnum, TT.phoff); } diff --git a/toys/pending/sh.c b/toys/pending/sh.c index 482639da..29c030e7 100644 --- a/toys/pending/sh.c +++ b/toys/pending/sh.c @@ -271,7 +271,7 @@ static void expand_arg_nobrace(struct sh_arg *arg, char *old, unsigned flags, // Tilde expansion if (!(flags&NO_TILDE) && *new == '~') { struct passwd *pw = 0; - char *s, *ss; + char *s, *ss, *sss; // first expansion so don't need to free previous new ss = 0; @@ -280,8 +280,8 @@ static void expand_arg_nobrace(struct sh_arg *arg, char *old, unsigned flags, if (!(ss = getvar("HOME")) || !*ss) pw = bufgetpwuid(getuid()); } else { // TODO bufgetpwnam - pw = getpwnam(new = xstrndup(new+1, (s-new)-1)); - free(new); + pw = getpwnam(sss = xstrndup(new+1, (s-new)-1)); + free(sss); } if (pw && pw->pw_dir) ss = pw->pw_dir; if (!ss || !*ss) ss = "/"; @@ -477,7 +477,6 @@ static void expand_arg(struct sh_arg *arg, char *old, unsigned flags, // Expand exactly one arg, returning NULL if it split. -// If return != new you need to free it. static char *expand_one_arg(char *new, unsigned flags, struct arg_list **del) { struct sh_arg arg; @@ -485,11 +484,9 @@ static char *expand_one_arg(char *new, unsigned flags, struct arg_list **del) int i; memset(&arg, 0, sizeof(arg)); - expand_arg(&arg, new, flags, 0); - if (arg.c == 1) { - s = *arg.v; - if (del && s != new) dlist_add((void *)del, s); - } else for (i = 0; i < arg.c; i++) free(arg.v[i]); + expand_arg(&arg, new, flags, del); + if (arg.c == 1) s = *arg.v; + else if (!del) for (i = 0; i < arg.c; i++) free(arg.v[i]); free(arg.v); return s; @@ -624,7 +621,7 @@ void run_subshell(struct sh_pipeline *sp) static struct sh_process *expand_redir(struct sh_arg *arg, int envlen, int *urd) { struct sh_process *pp; - char *s, *ss, *sss, *cv = 0; + char *s = s, *ss, *sss, *cv = 0; int j, to, from, here = 0; TT.hfd = 10; @@ -896,7 +893,6 @@ if (BUGBUG) { int i; dprintf(255, "envlen=%d arg->c=%d run=", envlen, arg->c); f } environ = env; } - if (-1 == (pp->pid = xpopen_both(pp->arg.v, 0))) perror_msg("%s: vfork", *pp->arg.v); @@ -933,9 +929,6 @@ static char *parse_word(char *start) // Redirections. 123<<file- parses as 2 args: "123<<" "file-". s = end + redir_prefix(end); if ((i = anystart(s, (void *)redirectors))) s += i; - // Flow control characters that end pipeline segments - else s = end + anystart(end, (char *[]){";;&", ";;", ";&", ";", "||", - "|&", "|", "&&", "&", "(", ")", 0}); if (s != end) return (end == start) ? s : end; // (( is a special quote at the start of a word @@ -979,6 +972,11 @@ static char *parse_word(char *start) if (isspace(*end)) break; if (*end == ')') return end+(start==end); + + // Flow control characters that end pipeline segments + s = end + anystart(end, (char *[]){";;&", ";;", ";&", ";", "||", + "|&", "|", "&&", "&", "(", ")", 0}); + if (s != end) return (end == start) ? s : end; } // Things the same unquoted or in most non-single-quote contexts @@ -1690,6 +1688,7 @@ static int sh_run(char *new) // TODO: parse with len? (End early?) + memset(&scratch, 0, sizeof(struct sh_function)); if (!parse_line(new, &scratch)) run_function(&scratch); free_function(&scratch); rc = toys.exitval; diff --git a/toys/posix/find.c b/toys/posix/find.c index 8a837385..3fb97b1c 100644 --- a/toys/posix/find.c +++ b/toys/posix/find.c @@ -636,7 +636,7 @@ static int do_find(struct dirtree *new) } else if (ch == 'p') ll = (long)(ff = dirtree_path(new, 0)); else if (ch == 'T') { if (*++fmt!='@') error_exit("bad -printf %%T: %%T%c", *fmt); - sprintf(buf, "%ld.%ld", new->st.st_mtim.tv_sec, + sprintf(buf, "%lld.%ld", (long long)new->st.st_mtim.tv_sec, new->st.st_mtim.tv_nsec); ll = (long)buf; } else if (ch == 'Z') { |