From aaecbbac2f94b7a93eb2df7f9db78828cbb7b647 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Thu, 10 Dec 2015 15:57:08 -0600 Subject: Expand toys.optargs to 64 bits so people adding more options to ls don't run out. Keep the low 32 bits of FLAG_x constants as 32 bit numbers so that at least on little endian platforms it's still normal 32 bit math outside of lib/args.c. --- scripts/mkflags.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'scripts/mkflags.c') diff --git a/scripts/mkflags.c b/scripts/mkflags.c index b57f0577..e7ed684a 100644 --- a/scripts/mkflags.c +++ b/scripts/mkflags.c @@ -116,8 +116,8 @@ int main(int argc, char *argv[]) // See "intentionally crappy", above. if (!(out = outbuf)) return 1; - printf("#ifdef FORCE_FLAGS\n#define FORCED_FLAG 1\n" - "#else\n#define FORCED_FLAG 0\n#endif\n\n"); + printf("#ifdef FORCE_FLAGS\n#define FORCED_FLAG 1\n#define FORCED_FLAGLL 1LL\n" + "#else\n#define FORCED_FLAG 0\n#define FORCED_FLAGLL 0\n#endif\n\n"); for (;;) { struct flag *flist, *aflist, *offlist; @@ -173,27 +173,33 @@ int main(int argc, char *argv[]) out += strlen(out); while (aflist) { + char *llstr = bit>31 ? "LL" : ""; + + // Output flag macro for bare longopts if (aflist->lopt) { if (flist && flist->lopt && !strcmp(flist->lopt->command, aflist->lopt->command)) { - sprintf(out, "#define FLAG_%s (1<<%d)\n", flist->lopt->command, bit); + sprintf(out, "#define FLAG_%s (1%s<<%d)\n", flist->lopt->command, + llstr, bit); flist->lopt = flist->lopt->next; - } else sprintf(out, "#define FLAG_%s (FORCED_FLAG<<%d)\n", - aflist->lopt->command, bit); + } else sprintf(out, "#define FLAG_%s (FORCED_FLAG%s<<%d)\n", + aflist->lopt->command, llstr, bit); aflist->lopt = aflist->lopt->next; if (!aflist->command) { aflist = aflist->next; bit++; if (flist) flist = flist->next; } + // Output normal flag macro } else if (aflist->command) { if (flist && (!flist->command || *aflist->command == *flist->command)) { if (aflist->command) - sprintf(out, "#define FLAG_%c (1<<%d)\n", *aflist->command, bit); + sprintf(out, "#define FLAG_%c (1%s<<%d)\n", *aflist->command, + llstr, bit); flist = flist->next; - } else sprintf(out, "#define FLAG_%c (FORCED_FLAG<<%d)\n", - *aflist->command, bit); + } else sprintf(out, "#define FLAG_%c (FORCED_FLAG%s<<%d)\n", + *aflist->command, llstr, bit); bit++; aflist = aflist->next; } -- cgit v1.2.3