aboutsummaryrefslogtreecommitdiff
path: root/scripts/mkflags.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2015-12-10 15:57:08 -0600
committerRob Landley <rob@landley.net>2015-12-10 15:57:08 -0600
commitaaecbbac2f94b7a93eb2df7f9db78828cbb7b647 (patch)
treeac2a23d038113e359b583e042170d9d319690cf2 /scripts/mkflags.c
parent5cb65054067391af7602bc303d77349c76648faf (diff)
downloadtoybox-aaecbbac2f94b7a93eb2df7f9db78828cbb7b647.tar.gz
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.
Diffstat (limited to 'scripts/mkflags.c')
-rw-r--r--scripts/mkflags.c22
1 files changed, 14 insertions, 8 deletions
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;
}