summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2015-04-19 21:50:51 -0500
committerRob Landley <rob@landley.net>2015-04-19 21:50:51 -0500
commit5b493dc48db03c7e27c8ce002fe216bcd778fe92 (patch)
treeb7bb7af18aff4d01bab1b635384d455add1aeb33 /lib
parent3cf9b08cc9ebeddc449638608f7a28c4c4ba20f9 (diff)
downloadtoybox-5b493dc48db03c7e27c8ce002fe216bcd778fe92.tar.gz
toybox-5b493dc48db03c7e27c8ce002fe216bcd778fe92.tar.bz2
toybox-5b493dc48db03c7e27c8ce002fe216bcd778fe92.zip
Cleanup getprop, add qstrcmp() to lib for qsort (because posix-2008 broke
alphasort), add compile-time probe for config symbol TOYBOX_ON_ANDROID.
Diffstat (limited to 'lib')
-rw-r--r--lib/lib.c8
-rw-r--r--lib/lib.h1
2 files changed, 9 insertions, 0 deletions
diff --git a/lib/lib.c b/lib/lib.c
index 99d2ea6..1a60a7f 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -887,3 +887,11 @@ int human_readable(char *buf, unsigned long long num)
return end;
}
+
+// The qsort man page says you can use alphasort, the posix committee
+// disagreed, and doubled down: http://austingroupbugs.net/view.php?id=142
+// So just do our own. (The const is entirely to humor the stupid compiler.)
+int qstrcmp(const void *a, const void *b)
+{
+ return strcmp(*(char **)a, *(char **)b);
+}
diff --git a/lib/lib.h b/lib/lib.h
index 3cda7d9..a4e5808 100644
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -176,6 +176,7 @@ void base64_init(char *p);
int terminal_size(unsigned *x, unsigned *y);
int yesno(char *prompt, int def);
int human_readable(char *buf, unsigned long long num);
+int qstrcmp(const void *a, const void *b);
// net.c
int xsocket(int domain, int type, int protocol);