summaryrefslogtreecommitdiff
path: root/src/engine/command.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/command.cpp')
-rw-r--r--src/engine/command.cpp211
1 files changed, 114 insertions, 97 deletions
diff --git a/src/engine/command.cpp b/src/engine/command.cpp
index 74efff2..0029e4d 100644
--- a/src/engine/command.cpp
+++ b/src/engine/command.cpp
@@ -73,7 +73,9 @@ static inline const char *forcestr(tagval &v)
{
case VAL_FLOAT: s = floatstr(v.f); break;
case VAL_INT: s = intstr(v.i); break;
- case VAL_STR: case VAL_MACRO: return v.s;
+ case VAL_STR:
+ [[fallthrough]];
+ case VAL_MACRO: return v.s;
}
freearg(v);
v.setstr(newstring(s));
@@ -101,12 +103,12 @@ static inline ident *forceident(tagval &v)
v.setident(id);
return id;
}
- case VAL_STR:
- {
- ident *id = newident(v.s, IDF_UNKNOWN);
- delete[] v.s;
- v.setident(id);
- return id;
+ case VAL_STR:
+ {
+ ident *id = newident(v.s, IDF_UNKNOWN);
+ delete[] v.s;
+ v.setident(id);
+ return id;
}
}
freearg(v);
@@ -143,11 +145,11 @@ tagval noret = nullval, *commandret = &noret;
void clear_command()
{
- enumerate(idents, ident, i,
+ enumerate(idents, ident, i,
{
- if(i.type==ID_ALIAS)
- {
- DELETEA(i.name);
+ if(i.type==ID_ALIAS)
+ {
+ DELETEA(i.name);
i.forcenull();
DELETEA(i.code);
}
@@ -160,7 +162,7 @@ void clearoverride(ident &i)
switch(i.type)
{
case ID_ALIAS:
- if(i.valtype==VAL_STR)
+ if(i.valtype==VAL_STR)
{
if(!i.val.s[0]) break;
delete[] i.val.s;
@@ -216,7 +218,7 @@ static bool initidents()
newident(argname, IDF_ARG);
}
dummyident = newident("//dummy", IDF_UNKNOWN);
- if(identinits)
+ if(identinits)
{
loopv(*identinits) addident((*identinits)[i]);
DELETEP(identinits);
@@ -305,7 +307,7 @@ static void debugcodeline(const char *p, const char *fmt, ...)
}
ICOMMAND(nodebug, "e", (uint *body), { nodebug++; executeret(body, *commandret); nodebug--; });
-
+
void addident(ident *id)
{
addident(*id);
@@ -319,7 +321,7 @@ static inline void pusharg(ident &id, const tagval &v, identstack &stack)
id.stack = &stack;
id.setval(v);
cleancode(id);
-}
+}
static inline void poparg(ident &id)
{
@@ -344,7 +346,7 @@ ICOMMAND(push, "rte", (ident *id, tagval *v, uint *code),
static inline void pushalias(ident &id, identstack &stack)
{
- if(id.type == ID_ALIAS && id.index >= MAXARGS)
+ if(id.type == ID_ALIAS && id.index >= MAXARGS)
{
pusharg(id, nullval, stack);
id.flags &= ~IDF_UNKNOWN;
@@ -374,7 +376,7 @@ ident *newident(const char *name, int flags)
ident *id = idents.access(name);
if(!id)
{
- if(checknumber(name))
+ if(checknumber(name))
{
debugcode("number %s is not a valid identifier name", name);
return dummyident;
@@ -402,7 +404,7 @@ ident *readident(const char *name)
return NULL;
return id;
}
-
+
void resetvar(char *name)
{
ident *id = idents.access(name);
@@ -439,9 +441,9 @@ static inline void setalias(ident &id, tagval &v)
static void setalias(const char *name, tagval &v)
{
ident *id = idents.access(name);
- if(id)
+ if(id)
{
- if(id->type == ID_ALIAS)
+ if(id->type == ID_ALIAS)
{
if(id->index < MAXARGS) setarg(*id, v); else setalias(*id, v);
}
@@ -451,7 +453,7 @@ static void setalias(const char *name, tagval &v)
freearg(v);
}
}
- else if(checknumber(name))
+ else if(checknumber(name))
{
debugcode("cannot alias number %s", name);
freearg(v);
@@ -463,7 +465,7 @@ static void setalias(const char *name, tagval &v)
}
void alias(const char *name, const char *str)
-{
+{
tagval v;
v.setstr(newstring(str));
setalias(name, v);
@@ -886,7 +888,7 @@ static inline char *cutstring(const char *&p, int &len)
{
p++;
const char *end = parsestring(p);
- char *s = newstring(end - p);
+ char *s = newstring(end - p);
len = unescapestring(s, p, end);
s[len] = '\0';
p = end;
@@ -980,7 +982,7 @@ static inline void compileident(vector<uint> &code, ident *id)
{
code.add((id->index < MAXARGS ? CODE_IDENTARG : CODE_IDENT)|(id->index<<8));
}
-
+
static inline void compileident(vector<uint> &code, const char *word = NULL)
{
compileident(code, word ? newident(word, IDF_UNKNOWN) : dummyident);
@@ -1020,7 +1022,7 @@ static inline void compileval(vector<uint> &code, int wordtype, char *word, int
case VAL_ANY: compilestr(code, word, wordlen); break;
case VAL_FLOAT: compilefloat(code, word); break;
case VAL_INT: compileint(code, word); break;
- case VAL_CODE:
+ case VAL_CODE:
{
int start = code.length();
code.add(CODE_BLOCK);
@@ -1074,7 +1076,7 @@ static void compilelookup(vector<uint> &code, const char *&p, int ltype)
for(const char *fmt = id->args; *fmt; fmt++) switch(*fmt)
{
case 's': compilestr(code, NULL, 0, true); numargs++; break;
- case 'i': compileint(code); numargs++; break;
+ case 'i': compileint(code); numargs++; break;
case 'b': compileint(code, INT_MIN); numargs++; break;
case 'f': compilefloat(code); numargs++; break;
case 't': compilenull(code); numargs++; break;
@@ -1087,7 +1089,7 @@ static void compilelookup(vector<uint> &code, const char *&p, int ltype)
#endif
case 'C': comtype = CODE_COMC; numargs = 1; goto endfmt;
case 'V': comtype = CODE_COMV; numargs = 2; goto endfmt;
- case '1': case '2': case '3': case '4': break;
+ case '1': case '2': case '3': case '4': break;
}
endfmt:
code.add(comtype|(ltype < VAL_ANY ? ltype<<CODE_RET : 0)|(id->index<<8));
@@ -1120,7 +1122,7 @@ invalid:
static bool compileblockstr(vector<uint> &code, const char *str, const char *end, bool macro)
{
int start = code.length();
- code.add(macro ? CODE_MACRO : CODE_VAL|RET_STR);
+ code.add(macro ? CODE_MACRO : CODE_VAL|RET_STR);
char *buf = (char *)code.reserve((end-str)/sizeof(uint)+1).buf;
int len = 0;
while(str < end)
@@ -1155,8 +1157,10 @@ static bool compileblockstr(vector<uint> &code, const char *str, const char *end
else buf[len++] = *str++;
break;
case '@':
+ [[fallthrough]];
case ']':
if(str < end) { buf[len++] = *str++; break; }
+ [[fallthrough]];
case '\0': goto done;
}
}
@@ -1234,10 +1238,10 @@ static void compileblock(vector<uint> &code, const char *&p, int wordtype)
break;
case '[': brak++; break;
case ']': brak--; break;
- case '@':
+ case '@':
{
const char *esc = p;
- while(*p == '@') p++;
+ while(*p == '@') p++;
int level = p - (esc - 1);
if(brak > level) continue;
else if(brak < level) debugcodeline(line, "too many @s");
@@ -1256,7 +1260,7 @@ static void compileblock(vector<uint> &code, const char *&p, int wordtype)
}
}
done:
- if(p-1 > start)
+ if(p-1 > start)
{
if(!concs) switch(wordtype)
{
@@ -1281,7 +1285,7 @@ done:
}
compileblockstr(code, start, p-1, concs > 0);
if(concs > 1) concs++;
- }
+ }
if(concs)
{
code.add(CODE_CONCM|(wordtype < VAL_ANY ? wordtype<<CODE_RET : RET_STR)|(concs<<8));
@@ -1294,16 +1298,16 @@ done:
case VAL_STR: case VAL_NULL: case VAL_ANY:
if(!concs && p-1 <= start) compilestr(code);
break;
- default:
- if(!concs)
+ default:
+ if(!concs)
{
if(p-1 <= start) compileval(code, wordtype, NULL, 0);
else code.add(CODE_FORCE|(wordtype<<CODE_RET));
}
break;
}
-}
-
+}
+
static bool compileword(vector<uint> &code, const char *&p, int wordtype, char *&word, int &wordlen)
{
skipcomments(p);
@@ -1321,7 +1325,7 @@ static bool compileword(vector<uint> &code, const char *&p, int wordtype, char *
case VAL_CODE: code.add(CODE_COMPILE); break;
case VAL_IDENT: code.add(CODE_IDENTU); break;
}
- return true;
+ return true;
case '[':
p++;
compileblock(code, p, wordtype);
@@ -1337,7 +1341,7 @@ static inline bool compilearg(vector<uint> &code, const char *&p, int wordtype)
int wordlen = 0;
bool more = compileword(code, p, wordtype, word, wordlen);
if(!more) return false;
- if(word)
+ if(word)
{
compileval(code, wordtype, word, wordlen);
delete[] word;
@@ -1359,13 +1363,24 @@ static void compilestatements(vector<uint> &code, const char *&p, int rettype, i
bool more = compileword(code, p, VAL_ANY, idname, idlen);
if(!more) goto endstatement;
skipcomments(p);
- if(p[0] == '=') switch(p[1])
- {
- case '/':
+ if(p[0] == '=') switch(p[1])
+ {
+ case '/':
if(p[2] != '/') break;
- case ';': case ' ': case '\t': case '\r': case '\n': case '\0':
+ [[fallthrough]];
+ case ';':
+ [[fallthrough]];
+ case ' ':
+ [[fallthrough]];
+ case '\t':
+ [[fallthrough]];
+ case '\r':
+ [[fallthrough]];
+ case '\n':
+ [[fallthrough]];
+ case '\0':
p++;
- if(idname)
+ if(idname)
{
id = newident(idname, IDF_UNKNOWN);
if(id) switch(id->type)
@@ -1408,13 +1423,13 @@ static void compilestatements(vector<uint> &code, const char *&p, int rettype, i
else
{
id = idents.access(idname);
- if(!id)
+ if(!id)
{
if(!checknumber(idname)) { compilestr(code, idname, idlen); delete[] idname; goto noid; }
char *end = idname;
int val = int(strtoul(idname, &end, 0));
if(*end) compilestr(code, idname, idlen);
- else compileint(code, val);
+ else compileint(code, val);
code.add(CODE_RESULT);
}
else switch(id->type)
@@ -1429,9 +1444,9 @@ static void compilestatements(vector<uint> &code, const char *&p, int rettype, i
bool rep = false;
for(const char *fmt = id->args; *fmt; fmt++) switch(*fmt)
{
- case 's':
+ case 's':
if(more) more = compilearg(code, p, VAL_STR);
- if(!more)
+ if(!more)
{
if(rep) break;
compilestr(code, NULL, 0, true);
@@ -1447,7 +1462,7 @@ static void compilestatements(vector<uint> &code, const char *&p, int rettype, i
break;
case 'i': if(more) more = compilearg(code, p, VAL_INT); if(!more) { if(rep) break; compileint(code); fakeargs++; } numargs++; break;
case 'b': if(more) more = compilearg(code, p, VAL_INT); if(!more) { if(rep) break; compileint(code, INT_MIN); fakeargs++; } numargs++; break;
- case 'f': if(more) more = compilearg(code, p, VAL_FLOAT); if(!more) { if(rep) break; compilefloat(code); fakeargs++; } numargs++; break;
+ case 'f': if(more) more = compilearg(code, p, VAL_FLOAT); if(!more) { if(rep) break; compilefloat(code); fakeargs++; } numargs++; break;
case 't': if(more) more = compilearg(code, p, VAL_ANY); if(!more) { if(rep) break; compilenull(code); fakeargs++; } numargs++; break;
case 'e': if(more) more = compilearg(code, p, VAL_CODE); if(!more) { if(rep) break; compileblock(code); fakeargs++; } numargs++; break;
case 'r': if(more) more = compilearg(code, p, VAL_IDENT); if(!more) { if(rep) break; compileident(code); fakeargs++; } numargs++; break;
@@ -1489,7 +1504,7 @@ static void compilestatements(vector<uint> &code, const char *&p, int rettype, i
break;
case ID_SVAR:
if(!(more = compilearg(code, p, VAL_STR))) code.add(CODE_PRINT|(id->index<<8));
- else
+ else
{
int numconc = 0;
while(numconc+1 < MAXARGS && (more = compilearg(code, p, VAL_ANY))) numconc++;
@@ -1497,12 +1512,12 @@ static void compilestatements(vector<uint> &code, const char *&p, int rettype, i
code.add(CODE_SVAR1|(id->index<<8));
}
break;
- }
+ }
endcommand:
delete[] idname;
}
endstatement:
- if(more) while(compilearg(code, p, VAL_ANY)) code.add(CODE_POP);
+ if(more) while(compilearg(code, p, VAL_ANY)) code.add(CODE_POP);
p += strcspn(p, ")];/\n\0");
int c = *p++;
switch(c)
@@ -1515,7 +1530,7 @@ static void compilestatements(vector<uint> &code, const char *&p, int rettype, i
case ')':
case ']':
if(c == brak) return;
- debugcodeline(line, "unexpected \"%c\"", c);
+ debugcodeline(line, "unexpected \"%c\"", c);
break;
case '/':
@@ -1568,7 +1583,7 @@ void freecode(uint *code)
{
if(!code) return;
switch(*code&CODE_OP_MASK)
- {
+ {
case CODE_START:
*code -= 0x100;
if(int(*code) < 0x100) delete[] code;
@@ -1756,7 +1771,7 @@ cleanup:
#define MAXRUNDEPTH 255
static int rundepth = 0;
-
+
static const uint *runcode(const uint *code, tagval &result)
{
result.setnull();
@@ -1779,11 +1794,11 @@ static const uint *runcode(const uint *code, tagval &result)
case CODE_POP:
freearg(args[--numargs]);
- continue;
- case CODE_ENTER:
- code = runcode(code, args[numargs++]);
continue;
- case CODE_EXIT|RET_NULL: case CODE_EXIT|RET_STR: case CODE_EXIT|RET_INT: case CODE_EXIT|RET_FLOAT:
+ case CODE_ENTER:
+ code = runcode(code, args[numargs++]);
+ continue;
+ case CODE_EXIT|RET_NULL: case CODE_EXIT|RET_STR: case CODE_EXIT|RET_INT: case CODE_EXIT|RET_FLOAT:
forcearg(result, op&CODE_RET_MASK);
goto exit;
case CODE_PRINT:
@@ -1798,7 +1813,7 @@ static const uint *runcode(const uint *code, tagval &result)
loopi(numargs) popalias(*args[i].id);
goto exit;
}
-
+
case CODE_MACRO:
{
uint len = op>>8;
@@ -1873,19 +1888,19 @@ static const uint *runcode(const uint *code, tagval &result)
{
pusharg(*id, nullval, aliasstack->argstack[id->index]);
aliasstack->usedargs |= 1<<id->index;
- }
+ }
args[numargs++].setident(id);
continue;
}
case CODE_IDENTU:
{
tagval &arg = args[numargs-1];
- ident *id = arg.type == VAL_STR || arg.type == VAL_MACRO ? newident(arg.s, IDF_UNKNOWN) : dummyident;
+ ident *id = arg.type == VAL_STR || arg.type == VAL_MACRO ? newident(arg.s, IDF_UNKNOWN) : dummyident;
if(id->index < MAXARGS && !(aliasstack->usedargs&(1<<id->index)))
{
pusharg(*id, nullval, aliasstack->argstack[id->index]);
aliasstack->usedargs |= 1<<id->index;
- }
+ }
freearg(arg);
arg.setident(id);
continue;
@@ -1925,7 +1940,7 @@ static const uint *runcode(const uint *code, tagval &result)
nval; \
continue; \
}
- LOOKUPU(arg.setstr(newstring(id->getstr())),
+ LOOKUPU(arg.setstr(newstring(id->getstr())),
arg.setstr(newstring(*id->storage.s)),
arg.setstr(newstring(intstr(*id->storage.i))),
arg.setstr(newstring(floatstr(*id->storage.f))),
@@ -1993,14 +2008,14 @@ static const uint *runcode(const uint *code, tagval &result)
case CODE_FVAR|RET_STR: args[numargs++].setstr(newstring(floatstr(*identmap[op>>8]->storage.f))); continue;
case CODE_FVAR|RET_INT: args[numargs++].setint(int(*identmap[op>>8]->storage.f)); continue;
case CODE_FVAR1: setfvarchecked(identmap[op>>8], args[0].f); numargs = 0; continue;
-
+
case CODE_COM|RET_NULL: case CODE_COM|RET_STR: case CODE_COM|RET_FLOAT: case CODE_COM|RET_INT:
id = identmap[op>>8];
#ifndef STANDALONE
callcom:
#endif
forcenull(result);
- CALLCOM(numargs)
+ CALLCOM(numargs)
forceresult:
freeargs(args, numargs, 0);
forcearg(result, op&CODE_RET_MASK);
@@ -2016,7 +2031,7 @@ static const uint *runcode(const uint *code, tagval &result)
id = identmap[op>>8];
forcenull(result);
((comfunv)id->fun)(args, numargs);
- goto forceresult;
+ goto forceresult;
case CODE_COMC|RET_NULL: case CODE_COMC|RET_STR: case CODE_COMC|RET_FLOAT: case CODE_COMC|RET_INT:
id = identmap[op>>8];
forcenull(result);
@@ -2115,7 +2130,7 @@ static const uint *runcode(const uint *code, tagval &result)
debugcode("unknown command: %s", args[0].s);
forcenull(result);
goto forceresult;
- }
+ }
forcenull(result);
switch(id->type)
{
@@ -2132,7 +2147,7 @@ static const uint *runcode(const uint *code, tagval &result)
loopj(numargs-1) pushalias(*forceident(args[j+1]), locals[j]);
code = runcode(code, result);
loopj(numargs-1) popalias(*args[j+1].id);
- goto exit;
+ goto exit;
}
case ID_VAR:
if(numargs <= 1) printvar(id); else setvarchecked(id, &args[1], numargs-1);
@@ -2142,7 +2157,7 @@ static const uint *runcode(const uint *code, tagval &result)
goto forceresult;
case ID_SVAR:
if(numargs <= 1) printvar(id); else setsvarchecked(id, forcestr(args[1]));
- goto forceresult;
+ goto forceresult;
case ID_ALIAS:
if(id->index < MAXARGS && !(aliasstack->usedargs&(1<<id->index))) goto forceresult;
if(id->valtype==VAL_NULL) goto noid;
@@ -2159,10 +2174,10 @@ exit:
--rundepth;
return code;
}
-
+
void executeret(const uint *code, tagval &result)
{
- runcode(code, result);
+ runcode(code, result);
}
void executeret(const char *p, tagval &result)
@@ -2238,7 +2253,7 @@ char *executestr(const char *p)
char *executestr(ident *id, tagval *args, int numargs, bool lookup)
{
- tagval result;
+ tagval result;
executeret(id, args, numargs, lookup, result);
if(result.type == VAL_NULL) return NULL;
forcestr(result);
@@ -2292,7 +2307,7 @@ static inline bool getbool(const char *s)
{
switch(s[0])
{
- case '+': case '-':
+ case '+': case '-':
switch(s[1])
{
case '0': break;
@@ -2468,8 +2483,10 @@ void writecfg(const char *name)
case VAL_STR:
if(!id.val.s[0]) break;
if(!validateblock(id.val.s)) { f->printf("%s = %s\n", escapeid(id), escapestring(id.val.s)); break; }
+ [[fallthrough]];
case VAL_FLOAT:
- case VAL_INT:
+ [[fallthrough]];
+ case VAL_INT:
f->printf("%s = [%s]\n", escapeid(id), id.getstr()); break;
}
}
@@ -2487,7 +2504,7 @@ void changedvars()
enumerate(idents, ident, id, if(id.flags&IDF_OVERRIDDEN) ids.add(&id));
ids.sortname();
loopv(ids) printvar(ids[i]);
-}
+}
COMMAND(changedvars, "");
// below the commands that implement a small imperative language. thanks to the semantics of
@@ -2637,15 +2654,15 @@ ICOMMAND(loopconcatword, "rie", (ident *id, int *n, uint *body),
});
void concat(tagval *v, int n)
-{
+{
commandret->setstr(conc(v, n, true));
}
COMMAND(concat, "V");
void concatword(tagval *v, int n)
-{
+{
commandret->setstr(conc(v, n, false));
-}
+}
COMMAND(concatword, "V");
void append(ident *id, tagval *v, bool space)
@@ -2749,7 +2766,7 @@ static bool parselist(const char *&s, const char *&start = liststart, const char
case '(': case '[': if(c == braktype) brak++; break;
case ')': if(braktype == '(' && --brak <= 0) goto endblock; break;
case ']': if(braktype == '[' && --brak <= 0) goto endblock; break;
- }
+ }
}
endblock:
end = s-1;
@@ -2762,7 +2779,7 @@ static bool parselist(const char *&s, const char *&start = liststart, const char
if(*s == ';') s++;
return true;
}
-
+
void explodelist(const char *s, vector<char *> &elems, int limit)
{
const char *start, *end;
@@ -2793,7 +2810,7 @@ void at(tagval *args, int numargs)
{
const char *list = start;
int pos = args[i].getint();
- for(; pos > 0; pos--) if(!parselist(list)) break;
+ for(; pos > 0; pos--) if(!parselist(list)) break;
if(pos > 0 || !parselist(list, start, end)) start = end = "";
}
commandret->setstr(newstring(start, end-start));
@@ -2839,7 +2856,7 @@ void sublist(const char *s, int *skip, int *count, int *numargs)
if(len < 0) { if(offset > 0) skiplist(s); commandret->setstr(newstring(s)); return; }
const char *list = s, *start, *end, *qstart, *qend = s;
if(len > 0 && parselist(s, start, end, list, qend)) while(--len > 0 && parselist(s, start, end, qstart, qend));
- commandret->setstr(newstring(list, qend - list));
+ commandret->setstr(newstring(list, qend - list));
}
COMMAND(sublist, "siiN");
@@ -2984,7 +3001,7 @@ void prettylist(const char *s, const char *conj)
}
p.add(' ');
}
- }
+ }
p.add('\0');
result(p.getbuf());
}
@@ -3002,7 +3019,7 @@ int listincludes(const char *list, const char *needle, int needlelen)
return -1;
}
ICOMMAND(indexof, "ss", (char *list, char *elem), intret(listincludes(list, elem, strlen(elem))));
-
+
char *listdel(const char *s, const char *del)
{
vector<char> p;
@@ -3058,17 +3075,17 @@ ICOMMAND(loopfiles, "rsse", (ident *id, char *dir, char *ext, uint *body),
bool redundant = false;
loopj(i) if(!strcmp(files[j], file)) { redundant = true; break; }
if(redundant) delete[] files.removeunordered(i);
- }
+ }
loopv(files)
{
char *file = files[i];
- if(i)
+ if(i)
{
if(id->valtype == VAL_STR) delete[] id->val.s;
else id->valtype = VAL_STR;
id->val.s = file;
}
- else
+ else
{
tagval t;
t.setstr(file);
@@ -3081,7 +3098,7 @@ ICOMMAND(loopfiles, "rsse", (ident *id, char *dir, char *ext, uint *body),
});
void findfile_(char *name)
-{
+{
string fname;
copystring(fname, name);
path(fname);
@@ -3098,7 +3115,7 @@ struct sortitem
{
const char *str, *quotestart, *quoteend;
};
-
+
struct sortfun
{
ident *x, *y;
@@ -3115,7 +3132,7 @@ struct sortfun
return executebool(body);
}
};
-
+
void sortlist(char *list, ident *x, ident *y, uint *body)
{
if(x == y || x->type != ID_ALIAS || y->type != ID_ALIAS) return;
@@ -3130,7 +3147,7 @@ void sortlist(char *list, ident *x, ident *y, uint *body)
sortitem item = { &macros[start - list], quotestart, quoteend };
items.add(item);
total += int(quoteend - quotestart);
- }
+ }
identstack xstack, ystack;
pusharg(*x, nullval, xstack); x->flags &= ~IDF_UNKNOWN;
@@ -3141,7 +3158,7 @@ void sortlist(char *list, ident *x, ident *y, uint *body)
poparg(*x);
poparg(*y);
-
+
char *sorted = macros;
int sortedlen = total + max(items.length() - 1, 0);
if(macrolen < sortedlen)
@@ -3160,7 +3177,7 @@ void sortlist(char *list, ident *x, ident *y, uint *body)
offset += len;
}
sorted[offset] = '\0';
-
+
commandret->setstr(sorted);
}
COMMAND(sortlist, "srre");
@@ -3196,8 +3213,8 @@ ICOMMAND(>>, "ii", (int *a, int *b), intret(*a >> clamp(*b, 0, 31)));
ICOMMAND(&&, "e1V", (tagval *args, int numargs),
{
if(!numargs) intret(1);
- else loopi(numargs)
- {
+ else loopi(numargs)
+ {
if(i) freearg(*commandret);
executeret(args[i].code, *commandret);
if(!getbool(*commandret)) break;
@@ -3207,7 +3224,7 @@ ICOMMAND(||, "e1V", (tagval *args, int numargs),
{
if(!numargs) intret(0);
else loopi(numargs)
- {
+ {
if(i) freearg(*commandret);
executeret(args[i].code, *commandret);
if(getbool(*commandret)) break;
@@ -3342,7 +3359,7 @@ ICOMMAND(strlen, "s", (char *s), intret(strlen(s)));
ICOMMAND(strcode, "si", (char *s, int *i), intret(*i > 0 ? (memchr(s, 0, *i) ? 0 : uchar(s[*i])) : uchar(s[0])));
ICOMMAND(codestr, "i", (int *i), { char *s = newstring(1); s[0] = char(*i); s[1] = '\0'; stringret(s); });
ICOMMAND(struni, "si", (char *s, int *i), intret(*i > 0 ? (memchr(s, 0, *i) ? 0 : cube2uni(s[*i])) : cube2uni(s[0])));
-ICOMMAND(unistr, "i", (int *i), { char *s = newstring(1); s[0] = uni2cube(*i); s[1] = '\0'; stringret(s); });
+ICOMMAND(unistr, "i", (int *i), { char *s = newstring(1); s[0] = uni2cube(*i); s[1] = '\0'; stringret(s); });
int naturalsort(const char *a, const char *b)
{