aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/sort.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2012-10-08 00:02:30 -0500
committerRob Landley <rob@landley.net>2012-10-08 00:02:30 -0500
commitc0e56edaf256adb6c60c5a052525a1ffbb927901 (patch)
treed6bcc5c181ca46910a12d4dece4b26d6c71be3e1 /toys/posix/sort.c
parentdc7a77d1940858495f76998f4d13cac9f73e0226 (diff)
downloadtoybox-c0e56edaf256adb6c60c5a052525a1ffbb927901.tar.gz
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Diffstat (limited to 'toys/posix/sort.c')
-rw-r--r--toys/posix/sort.c22
1 files changed, 2 insertions, 20 deletions
diff --git a/toys/posix/sort.c b/toys/posix/sort.c
index 27aeb777..8f26f5d3 100644
--- a/toys/posix/sort.c
+++ b/toys/posix/sort.c
@@ -60,9 +60,10 @@ config SORT_FLOAT
*/
+#define FOR_sort
#include "toys.h"
-DEFINE_GLOBALS(
+GLOBALS(
char *key_separator;
struct arg_list *raw_keys;
char *outfile;
@@ -73,30 +74,11 @@ DEFINE_GLOBALS(
char **lines;
)
-#define TT this.sort
-
// The sort types are n, g, and M.
// u, c, s, and z apply to top level only, not to keys.
// b at top level implies bb.
// The remaining options can be applied to search keys.
-#define FLAG_n (1<<0) // Sort type: numeric
-#define FLAG_u (1<<1) // Unique
-#define FLAG_r (1<<2) // Reverse output order
-
-#define FLAG_i (1<<3) // Ignore !isprint()
-#define FLAG_f (1<<4) // Force uppercase
-#define FLAG_d (1<<5) // Ignore !(isalnum()|isspace())
-#define FLAG_z (1<<6) // Input is null terminated, not \n
-#define FLAG_s (1<<7) // Stable sort, no ascii fallback at end
-#define FLAG_c (1<<8) // Check only. No output, exit(!ordered)
-#define FLAG_M (1<<9) // Sort type: date
-#define FLAG_b (1<<10) // Ignore leading blanks
-#define FLAG_x (1<<11) // Hex sort
-#define FLAG_g (1<<18) // Sort type: strtod()
-
-// Left off dealing with FLAG_b/FLAG_bb logic...
-
#define FLAG_bb (1<<31) // Ignore trailing blanks
struct sort_key