Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

external-toybox: Commit

external/toybox


Commit MetaInfo

Revision7f401dbddef921116ddb9c8a7860965af864af80 (tree)
Time2018-02-27 05:05:55
AuthorElliott Hughes <enh@goog...>
Commiterandroid-build-merger

Log Message

Merge remote-tracking branch 'toybox/master' into HEAD am: 14cafec540
am: 4d29f725c0

Change-Id: Id383a5a6051093a22d568dc7c690ae259d73022a

Change Summary

Incremental Difference

--- a/generated/help.h
+++ b/generated/help.h
@@ -62,7 +62,7 @@
6262
6363 #define HELP_hostid "usage: hostid\n\nPrint the numeric identifier for the current host.\n\n"
6464
65-#define HELP_hello "usage: hello [-s]\n\nA hello world program. You don't need this.\n\nMostly used as a simple template for adding new commands.\nOccasionally nice to smoketest kernel booting via \"init=/usr/bin/hello\".\n\n"
65+#define HELP_hello "usage: hello\n\nA hello world program.\n\nMostly used as a simple template for adding new commands.\nOccasionally nice to smoketest kernel booting via \"init=/usr/bin/hello\".\n\n"
6666
6767 #define HELP_test_utf8towc "usage: test_utf8towc\n\nPrint differences between toybox's utf8 conversion routines vs libc du jour.\n\n"
6868
--- a/main.c
+++ b/main.c
@@ -9,7 +9,7 @@
99 #ifndef TOYBOX_VENDOR
1010 #define TOYBOX_VENDOR ""
1111 #endif
12-#define TOYBOX_VERSION "0.7.5"TOYBOX_VENDOR
12+#define TOYBOX_VERSION "0.7.6"TOYBOX_VENDOR
1313 #endif
1414
1515 // Populate toy_list[].
--- a/toys/example/hello.c
+++ b/toys/example/hello.c
@@ -4,6 +4,7 @@
44 *
55 * See http://pubs.opengroup.org/onlinepubs/9699919799/utilities/
66 * See http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/cmdbehav.html
7+ * See https://www.ietf.org/rfc/rfc3.txt
78
89 USE_HELLO(NEWTOY(hello, 0, TOYFLAG_USR|TOYFLAG_BIN))
910
@@ -11,9 +12,9 @@ config HELLO
1112 bool "hello"
1213 default n
1314 help
14- usage: hello [-s]
15+ usage: hello
1516
16- A hello world program. You don't need this.
17+ A hello world program.
1718
1819 Mostly used as a simple template for adding new commands.
1920 Occasionally nice to smoketest kernel booting via "init=/usr/bin/hello".
--- a/toys/example/skeleton.c
+++ b/toys/example/skeleton.c
@@ -5,6 +5,7 @@
55 *
66 * See http://pubs.opengroup.org/onlinepubs/9699919799/utilities/
77 * See http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/cmdbehav.html
8+ * See https://www.ietf.org/rfc/rfc3.txt
89
910 // Accept many different kinds of command line argument (see top of lib/args.c)
1011 // Demonstrate two commands in the same file (see www/documentation.html)
--- a/toys/posix/logger.c
+++ b/toys/posix/logger.c
@@ -29,29 +29,55 @@ GLOBALS(
2929 char *ident;
3030 )
3131
32+// find str in names[], accepting unambiguous short matches
33+// returns offset into array of match, or -1 if no match
34+int arrayfind(char *str, char *names[], int len)
35+{
36+ int try, i, matchlen = 0, found = -1, ambiguous = 1;
37+
38+ for (try = 0; try<len; try++) {
39+ for (i=0; ; i++) {
40+ if (!str[i]) {
41+ if (matchlen<i) found = try, ambiguous = 0;
42+ if (matchlen==i) ambiguous++;
43+ if (!names[try][i]) return try;
44+ break;
45+ }
46+ if (!names[try][i]) break;
47+ if (toupper(str[i]) != toupper(names[try][i])) break;
48+ }
49+ }
50+ return ambiguous ? -1 : found;
51+}
52+
3253 void logger_main(void)
3354 {
3455 int facility = LOG_USER, priority = LOG_NOTICE, len;
35- char *s1, *s2, **arg;
36- CODE *code;
56+ char *s1, *s2, **arg,
57+ *priorities[] = {"emerg", "alert", "crit", "error", "warning", "notice",
58+ "info", "debug"},
59+ *facilities[] = {"kern", "user", "mail", "daemon", "auth", "syslog",
60+ "lpr", "news", "uucp", "cron", "authpriv", "ftp"};
3761
3862 if (!TT.ident) TT.ident = xstrdup(xgetpwuid(geteuid())->pw_name);
3963 if (toys.optflags & FLAG_p) {
4064 if (!(s1 = strchr(TT.priority, '.'))) s1 = TT.priority;
4165 else {
42- *s1++ = 0;
43- for (code = facilitynames; code->c_name; code++)
44- if (!strcasecmp(TT.priority, code->c_name)) break;
45- if (!code->c_name) error_exit("bad facility: %s", TT.priority);
46- facility = code->c_val;
66+ *s1++ = len = 0;
67+ facility = arrayfind(TT.priority, facilities, ARRAY_LEN(facilities));
68+ if (facility == -1 && strncasecmp(TT.priority, "local", 5)) {
69+ facility = s1[5]-'0';
70+ if (facility>7 || s1[6]) facility = -1;
71+ if (facility>=0) facility += 16;
72+ }
73+ if (facility<0) error_exit("bad facility: %s", TT.priority);
74+ facility *= 8;
4775 }
4876
49- for (code = prioritynames; code->c_name; code++)
50- if (!strcasecmp(s1, code->c_name)) break;
51- if (!code->c_name) error_exit("bad priority: %s", s1);
77+ priority = arrayfind(s1, priorities, ARRAY_LEN(priorities));
78+ if (priority<0) error_exit("bad priority: %s", s1);
5279 }
5380
54-
5581 if (toys.optc) {
5682 for (len = 0, arg = toys.optargs; *arg; arg++) len += strlen(*arg)+1;
5783 s1 = s2 = xmalloc(len);
Show on old repository browser