Index: ord.c ================================================================== --- ord.c +++ ord.c @@ -144,20 +144,18 @@ # ifndef _POSIX_IO /* fuck your buffering, it only ever makes * things worse */ setvbuf(stdout,null,_IONBF); # endif - word rv; enum { set_in, set_out, _set_sz } curset = set_in; word base[_set_sz] = { 10, 0 }; const char* in_vals[argc]; *in_vals = null; /* null-terminated! */ const char** invalp = in_vals; const char* pfxstr; forposix(size_t pfxstrlen); - bool raw = false; bool prefix = false; bool lowercase = false; @@ -238,10 +236,11 @@ for (const char** s = in_vals; *s != null; ++s) { word val; bad e = atoi(base[set_in], *s, &val); if (e == ok) { bad e = itoa(base[set_out], val, buf, ptr, &ptr, lowercase); + if (e != ok) return e; if (prefix) { if (pfxstr != null) { print(pfxstrlen, pfxstr); } else if (base[set_out] < sz(prefixes)) { print((size_t)prefixes[base[set_out]][0], @@ -253,10 +252,11 @@ forposix(lastptr = ptr); } else { return e; } } + return ok; } void usage(const char* name) { # ifdef _POSIX_IO typedef struct pstr { size_t len; const char* str; } pstr; @@ -338,11 +338,12 @@ if (argc == 0) return -1; if (argc == 1) usage(argv[0]); bad e = run(argc, argv); switch (e) { case ok: return 0; + case fail: return -1; # define e(kind, desc) case bad_##kind:\ - say("\x1b[31;1merror:\x1b[m "); say(desc "\n"); break; + say("\x1b[31;1merror:\x1b[m "); say(desc "\n"); return e; error_list # undef e } }