diff --git a/Makefile b/Makefile index 42051c4..216ce69 100644 --- a/Makefile +++ b/Makefile @@ -1,23 +1,43 @@ -BASE_CFLAGS = -Wall -Wextra -O2 -lm -lreadline --std=c99 +BASE_CFLAGS = --std=c99 -Wall -Wextra -Ofast -lm -lreadline -ifndef OS +ifdef OS +ifeq ($(findstring :/, $(PATH)), :/) +IS_LINUX = true +else +IS_LINUX = false +endif +else +IS_LINUX = true +endif + +ifeq ($(IS_LINUX), true) C = gcc CFLAGS = $(BASE_CFLAGS) ifeq ($(shell uname -s), Darwin) CFLAGS += -I/usr/local/opt/readline/include -L/usr/local/opt/readline/lib else +ifeq ($(shell uname -o), Android) +CFLAGS += -s +else CFLAGS += -s -no-pie endif +endif CBITS = $(shell getconf LONG_BIT) -BUILD__ = $(C) clibasic.c $(CFLAGS) -DB$(CBITS) -o clibasic && chmod +x ./clibasic -BUILD32 = $(C) clibasic.c -m32 $(CFLAGS) -DB32 -o clibasic && chmod +x ./clibasic +BUILD_TO = "clibasic" +BUILD__ = $(C) clibasic.c $(CFLAGS) -DB$(CBITS) -o $(BUILD_TO) && chmod +x $(BUILD_TO) +BUILD32 = $(C) clibasic.c -m32 $(CFLAGS) -DB32 -o $(BUILD_TO) && chmod +x $(BUILD_TO) INSTALL_TO = "/usr/bin/clibasic" +INSTALL = if [ "$$(id -u)" -eq 0 ]; then cp $(BUILD_TO) $(INSTALL_TO); else echo "Root privileges are needed to install."; fi + +RUN = ./clibasic + +CLEAN = rm -f clibasic -INSTALL = if [ "$$(id -u)" -eq 0 ]; then cp ./clibasic $(INSTALL_TO); else echo "Root privileges are needed to install."; fi +.PHONY: all all32 build build32 update install install32 run clean cross all: clean build run @@ -30,22 +50,41 @@ build32: $(BUILD32) update: - printf "\\e[0m\\e[31;1mAre you sure? [y/N]: "; read -n 1 I; [ ! "$$I" == "" ] && printf "\\e[0m\\n" &&\ + printf "\\e[0m\\e[31;1mAre you sure? [y/N]:\\e[0m "; read -n 1 I; [ ! "$$I" == "" ] && printf "\\n" &&\ ([[ ! "$$I" =~ ^[^Yy]$$ ]] && sh -c 'git restore . && git pull' &> /dev/null && chmod +x *.sh) || exit 0 install: - if [ ! -f ./clibasic ]; then $(BUILD__); fi + if [ ! -f $(INSTALL_TO) ]; then $(BUILD__); fi $(INSTALL) install32: - if [ ! -f ./clibasic ]; then $(BUILD32); fi + if [ ! -f $(INSTALL_TO) ]; then $(BUILD32); fi $(INSTALL) run: - ./clibasic + $(RUN) clean: - rm -f ./clibasic + $(CLEAN) + +.ONESHELL: + +cross: +ifeq ($(MAKECMDGOALS), cross) + @$(MAKE) cross all +else + @$(eval C = x86_64-w64-mingw32-gcc) + @$(eval C32 = i686-w64-mingw32-gcc) + @$(eval CFLAGS = $(BASE_CFLAGS) -Ilib) + @$(eval BUILD_TO = "clibasic.exe") + @$(eval BUILD__ = cp -f lib/win64/*.dll . && $(C) clibasic.c $(CFLAGS) -Llib/win64 -DB$(CBITS) -o $(BUILD_TO) && chmod -x ./clibasic.exe) + @$(eval BUILD32 = cp -f lib/win32/*.dll . && $(C32) clibasic.c -m32 $(CFLAGS) -Llib/win32 -DB32 -o $(BUILD_TO) && chmod -x ./clibasic.exe) + @$(eval INSTALL_TO = "$$HOME/.wine/drive_c/windows/system32") + @$(eval INSTALL = cp $(BUILD_TO) *.dll $(INSTALL_TO)) + @$(eval RUN = wineconsole clibasic.exe) + @$(eval CLEAN = rm -f clibasic.exe *.dll) +endif + @true else @@ -53,8 +92,14 @@ C = gcc CFLAGS = $(BASE_CFLAGS) -Ilib -s -D_CRT_NONSTDC_NO_WARNINGS -BUILD64 = xcopy lib\win64\*.dll . /Y && $(C) clibasic.c -m64 $(CFLAGS) -Llib\win64 -DB64 -o clibasic.exe -BUILD32 = xcopy lib\win32\*.dll . /Y && $(C) clibasic.c -m32 $(CFLAGS) -Llib\win32 -DB32 -o clibasic.exe +BUILD_TO = clibasic.exe +BUILD64 = xcopy lib\win64\*.dll . /Y && $(C) clibasic.c -m64 $(CFLAGS) -Llib\win64 -DB64 -o $(BUILD_TO) +BUILD32 = xcopy lib\win32\*.dll . /Y && $(C) clibasic.c -m32 $(CFLAGS) -Llib\win32 -DB32 -o $(BUILD_TO) + +INSTALL_TO = "C:\\windows\\system32" +INSTALL = xcopy *.dll $(INSTALL_TO) /Y && xcopy $(BUILD_TO) $(INSTALL_TO) /Y + +.PHONY: all all32 build build32 update run clean all: clean build run @@ -69,11 +114,19 @@ build32: update: git restore . & git pull +install: + $(BUILD64) + $(INSTALL) + +install32: + $(BUILD32) + $(INSTALL) + run: - .\\clibasic.exe + .\\$(BUILD_TO) clean: - del /q /f clibasic.exe *.dll + del /q /f $(BUILD_TO) *.dll endif diff --git a/build.sh b/build.sh index c2eb8f4..a50d35a 100644 --- a/build.sh +++ b/build.sh @@ -1,3 +1,5 @@ +# tests if clibasic build on linux and windows successfully + make build clean -make -f Makefile-Cross build clean +make cross build clean diff --git a/clibasic.c b/clibasic.c index cf60a21..0b422d8 100644 --- a/clibasic.c +++ b/clibasic.c @@ -105,14 +105,17 @@ #include #endif -// More patch/checking defines/compares +// Useful macros /* Swap function to swap values */ #define swap(a, b) __typeof__(a) c = a; a = b; b = c +/* Free & set to NULL combo */ +#define nfree(ptr) free(ptr); ptr = NULL + // Base defines -char VER[] = "0.20"; +char VER[] = "0.21"; #if defined(__linux__) char OSVER[] = "Linux"; @@ -184,24 +187,34 @@ int cmdpos; bool didloop = false; bool lockpl = false; -int dlstack[CB_PROG_LOGIC_MAX]; -int dlpline[CB_PROG_LOGIC_MAX]; +typedef struct { + int pl; + int32_t cp; + int dlsp; + int fnsp; + int itsp; +} cb_jump; + +cb_jump dlstack[CB_PROG_LOGIC_MAX]; bool dldcmd[CB_PROG_LOGIC_MAX]; int dlstackp = -1; +int* mindlstackp = NULL; bool itdcmd[CB_PROG_LOGIC_MAX]; int itstackp = -1; +int* minitstackp = NULL; bool didelse = false; +bool* olddidelse = NULL; -int fnstack[CB_PROG_LOGIC_MAX]; +cb_jump fnstack[CB_PROG_LOGIC_MAX]; bool fndcmd[CB_PROG_LOGIC_MAX]; bool fninfor[CB_PROG_LOGIC_MAX]; -int fnpline[CB_PROG_LOGIC_MAX]; int fnstackp = -1; +int* minfnstackp = NULL; char fnvar[CB_BUF_SIZE]; char forbuf[4][CB_BUF_SIZE]; -char* errstr; +char* errstr = NULL; char conbuf[CB_BUF_SIZE]; char prompt[CB_BUF_SIZE]; @@ -209,7 +222,6 @@ char pstr[CB_BUF_SIZE]; uint8_t fgc = 15; uint8_t bgc = 0; - uint32_t truefgc = 0xFFFFFF; uint32_t truebgc = 0x000000; @@ -264,6 +276,21 @@ char* startcmd = NULL; bool changedtitle = false; bool changedtitlecmd = false; +typedef struct { + int pl; + int32_t cp; + bool used; + char* name; + int dlsp; + int fnsp; + int itsp; +} cb_goto; + +cb_goto* gotodata = NULL; +cb_goto** proggotodata = NULL; +int gotomaxct = 0; +int* proggotomaxct = NULL; + #ifdef __unix__ struct termios term, restore; @@ -345,7 +372,6 @@ void rl_sigh(int sig) { rl_redisplay(); } void txtqunlock() {} -//HANDLE hConsole; #ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING #define ENABLE_VIRTUAL_TERMINAL_PROCESSING 4 #endif @@ -594,7 +620,6 @@ int main(int argc, char** argv) { for (progargc = 1; progargc < argc - i; ++progargc) { progargs[progargc] = argv[i + progargc]; } - progargs[0] = progfn[progindex]; i = argc; } else if (!strcmp(argv[i], "--exec") || !strcmp(argv[i], "-x")) { if (runc) {fputs("Cannot run command and file.\n", stderr); exit(1);} @@ -610,7 +635,6 @@ int main(int argc, char** argv) { for (progargc = 1; progargc < argc - i; ++progargc) { progargs[progargc] = argv[i + progargc]; } - progargs[0] = progfn[progindex]; i = argc; } else if (!strcmp(argv[i], "--keep") || (shortopt && argv[i][shortopti] == 'k')) { if (keep) {fputs("Incorrect number of options passed.\n", stderr); exit(1);} @@ -800,6 +824,23 @@ int main(int argc, char** argv) { if (chkinProg) {inProg = true; chkinProg = false;} if (!inProg && !runc) { if (runfile) cleanExit(); + dlstackp = -1; + itstackp = -1; + fnstackp = -1; + for (int i = 0; i < CB_PROG_LOGIC_MAX; ++i) { + memset(&dlstack[i], 0, sizeof(cb_jump)); + dldcmd[i] = false; + memset(&fnstack[i], 0, sizeof(cb_jump)); + fnstack[i].cp = -1; + fndcmd[i] = false; + fninfor[i] = false; + itdcmd[i] = false; + } + for (int i = 0; i < gotomaxct; ++i) { + nfree(gotodata[i].name); + } + nfree(gotodata); + gotomaxct = 0; char* tmpstr = NULL; int tmpt = getVal(prompt, pstr); if (tmpt != 1) strcpy(pstr, "CLIBASIC> "); @@ -851,19 +892,6 @@ int main(int argc, char** argv) { } if (runc) runc = false; cmdl = 0; - if (chkinProg) { - dlstackp = -1; - itstackp = -1; - fnstackp = -1; - for (int i = 0; i < CB_PROG_LOGIC_MAX; ++i) { - dlstack[i] = 0; - dldcmd[i] = false; - fnstack[i] = -1; - fndcmd[i] = false; - fninfor[i] = false; - itdcmd[i] = false; - } - } didloop = false; didelse = false; bool inStr = false; @@ -986,7 +1014,6 @@ __sighandler_t gcpoldsigh; bool gcpint = false; void gcpsigh() { - puts("\nOOOOOF\n\n"); setsig(SIGINT, gcpsigh); gcpoldsigh(0); gcpint = true; @@ -1040,32 +1067,37 @@ void unloadProg() { progbuf[progindex] = NULL; progfn = (char**)realloc(progfn, progindex * sizeof(char*)); progbuf = (char**)realloc(progbuf, progindex * sizeof(char*)); + free(gotodata); + gotodata = proggotodata[progindex]; + gotomaxct = proggotomaxct[progindex]; cp = progcp[progindex]; cmdl = progcmdl[progindex]; progLine = proglinebuf[progindex]; + didelse = olddidelse[progindex]; + dlstackp = mindlstackp[progindex]; + itstackp = minitstackp[progindex]; + fnstackp = minfnstackp[progindex]; progcp = (int64_t*)realloc(progcp, progindex * sizeof(int64_t)); progcmdl = (int*)realloc(progcmdl, progindex * sizeof(int)); proglinebuf = (int*)realloc(proglinebuf, progindex * sizeof(int)); + mindlstackp = (int*)realloc(mindlstackp, progindex * sizeof(int)); + minitstackp = (int*)realloc(minitstackp, progindex * sizeof(int)); + minfnstackp = (int*)realloc(minfnstackp, progindex * sizeof(int)); + olddidelse = (bool*)realloc(olddidelse, progindex * sizeof(bool)); + proggotodata = (cb_goto**)realloc(proggotodata, progindex * sizeof(cb_goto*)); + proggotomaxct = (int*)realloc(proggotomaxct, progindex * sizeof(int)); progindex--; if (progindex < 0) inProg = false; } void unloadAllProg() { - for (int i = 0; i < progindex; ++i) { - free(progbuf[i]); - free(progfn[i]); - } - progindex = -1; - progcp = (int64_t*)realloc(progcp, (progindex + 1) * sizeof(int64_t)); - progcmdl = (int*)realloc(progcmdl, (progindex + 1) * sizeof(int)); - proglinebuf = (int*)realloc(proglinebuf, (progindex + 1) * sizeof(int)); - progbuf = (char**)realloc(progbuf, (progindex + 1) * sizeof(char*)); - progfn = (char**)realloc(progfn, (progindex + 1) * sizeof(char*)); - inProg = false; + for (int i = 0; i <= progindex; ++i) { + unloadProg(); + } } bool loadProg(char* filename) { - printf("Loading..."); + fputs("Loading...", stdout); fflush(stdout); seterrstr(filename); cerr = 27; @@ -1103,9 +1135,9 @@ bool loadProg(char* filename) { putchar('\r'); return false; } - progindex++; + ++progindex; fseek(prog, 0, SEEK_END); - printf("\b\b\b \b\b"); + fputs("\b\b\b \b\b", stdout); fflush(stdout); progfn = (char**)realloc(progfn, (progindex + 1) * sizeof(char*)); #ifdef _WIN32 @@ -1114,16 +1146,33 @@ bool loadProg(char* filename) { progfn[progindex] = realpath(filename, NULL); #endif progfnstr = progfn[progindex]; - progbuf = (char**)realloc(progbuf, (progindex + 1) * sizeof(char*)); - progcp = (int64_t*)realloc(progcp, (progindex + 1) * sizeof(int64_t)); - progcmdl = (int*)realloc(progcmdl, (progindex + 1) * sizeof(int)); - proglinebuf = (int*)realloc(proglinebuf, (progindex + 1) * sizeof(int)); + ++progindex; + progbuf = (char**)realloc(progbuf, progindex * sizeof(char*)); + progcp = (int64_t*)realloc(progcp, progindex * sizeof(int64_t)); + progcmdl = (int*)realloc(progcmdl, progindex * sizeof(int)); + proglinebuf = (int*)realloc(proglinebuf, progindex * sizeof(int)); + mindlstackp = (int*)realloc(mindlstackp, progindex * sizeof(int)); + minitstackp = (int*)realloc(minitstackp, progindex * sizeof(int)); + olddidelse = (bool*)realloc(olddidelse, progindex * sizeof(bool)); + minfnstackp = (int*)realloc(minfnstackp, progindex * sizeof(int)); + proggotodata = (cb_goto**)realloc(proggotodata, progindex * sizeof(cb_goto*)); + proggotomaxct = (int*)realloc(proggotomaxct, progindex * sizeof(int)); + --progindex; progcp[progindex] = cp; progcmdl[progindex] = cmdl; proglinebuf[progindex] = progLine; + mindlstackp[progindex] = dlstackp; + minitstackp[progindex] = itstackp; + olddidelse[progindex] = didelse; + minfnstackp[progindex] = fnstackp; + proggotodata[progindex] = gotodata; + proggotomaxct[progindex] = gotomaxct; + gotodata = NULL; + gotomaxct = 0; cp = 0; cmdl = 0; progLine = 1; + didelse = false; getCurPos(); int tmpx = curx, tmpy = cury; uint32_t fsize = (uint32_t)ftell(prog); @@ -1137,7 +1186,6 @@ bool loadProg(char* filename) { printf("(%llu bytes)...", (long long unsigned)fsize); fflush(stdout); progbuf[progindex] = (char*)malloc(fsize + 1); - int64_t j = 0; bool comment = false; bool inStr = false; @@ -1501,6 +1549,8 @@ uint8_t getFunc(char* inbuf, char* outbuf) { return ftype; } +bool chkvar = true; + uint8_t getVar(char* vn, char* varout) { int32_t vnlen = strlen(vn); if (vn[vnlen - 1] == ')') { @@ -1520,7 +1570,7 @@ uint8_t getVar(char* vn, char* varout) { bool isArray = false; int32_t aindex = 0; for (register int32_t i = 0; vn[i]; ++i) { - if (!isValidVarChar(vn[i])) { + if (chkvar && !isValidVarChar(vn[i])) { cerr = 4; seterrstr(vn); return 0; @@ -1600,7 +1650,7 @@ bool setVar(char* vn, char* val, uint8_t t, int32_t s) { bool isArray = false; int32_t aindex = 0; for (register int32_t i = 0; vn[i]; ++i) { - if (!isValidVarChar(vn[i])) { + if (chkvar && !isValidVarChar(vn[i])) { cerr = 4; seterrstr(vn); return false; @@ -1690,7 +1740,7 @@ bool delVar(char* vn) { return false; } for (register int32_t i = 0; vn[i]; ++i) { - if (!isValidVarChar(vn[i])) { + if (chkvar && !isValidVarChar(vn[i])) { cerr = 4; seterrstr(vn); return false; @@ -1875,13 +1925,12 @@ uint8_t getVal(char* inbuf, char* outbuf) { if (t == 2) { copyStrSnip(inbuf, jp, strlen(inbuf), tmp[1]); copyStrApnd(tmp[1], tmp[0]); - double tmpchknz = atof(tmp[0]); - if (tmpchknz == -0) {tmp[0][0] = '0';} register int32_t p1, p2, p3; bool inStr = false; pct = 0; bct = 0; while (1) { + //printf("-: [%d]: [%d] [%d %d %d] {%s} {%s} {%s} {%s}\n", getValIndex, numAct, p1, p2, p3, tmp[0], tmp[1], tmp[2], tmp[3]); numAct = 0; p1 = 0, p2 = 0, p3 = 0; for (register int32_t i = 0; tmp[0][i]; ++i) { @@ -1996,7 +2045,7 @@ uint8_t getVal(char* inbuf, char* outbuf) { } } gvforexit2:; - if (tmp[0][p1] == '+') p1++; + if (p1 != 0 && isSpChar(tmp[0][p1])) p1++; copyStrSnip(tmp[0], p1, p2, tmp[2]); t = getType(tmp[2]); if (t == 0) {cerr = 1; dt = 0; goto gvreturn;} else @@ -2018,26 +2067,21 @@ uint8_t getVal(char* inbuf, char* outbuf) { if (num1 == 0) {if (num2 == 0) {cerr = 5; dt = 0; goto gvreturn;} num3 = 0; break;} if (num2 == 0) {num3 = 1; break;} num3 = pow(num1, num2); - if (num1 < 0 && num3 > 0) {num3 *= -1;} break; } - tmp[1][0] = 0; - if (num3 == -0 || (num3 < 0 && num3 > -0.0000005)) { - tmp[2][0] = '0'; - tmp[2][1] = 0; - goto skipstrchk; - } - if (num3 < -0.0000004 && num3 > -0.0000009) { - copyStr("-0.000001", tmp[0]); - goto skipstrchk; - } - sprintf(tmp[2], "%lf", num3); - skipstrchk:; - int32_t i = 0; - while (tmp[2][i] == '0') i++; - copyStrSnip(tmp[2], i, strlen(tmp[2]), tmp[2]); + sprintf(tmp[1], "%lf", num3); + int32_t i = 0, j = strlen(tmp[1]) - 1; + bool dp = false; + while (tmp[1][i]) {if (tmp[1][i++] == '.') {dp = true; tmp[1][i + 6] = 0; break;}} + if (dp) {while (tmp[1][j] == '0') {--j;} if (tmp[1][j] == '.') {--j;}} + i = (tmp[1][0] == '-'); dp = (bool)i; + while (tmp[1][i] == '0') {++i;} + if (!tmp[1][i] || tmp[1][i] == '.') {--i;} + if (dp) tmp[1][--i] = '-'; + copyStrSnip(tmp[1], i, j + 1, tmp[2]); copyStrSnip(tmp[0], p3, strlen(tmp[0]), tmp[3]); if (p1) copyStrSnip(tmp[0], 0, p1, tmp[1]); + else {tmp[1][0] = 0;} copyStrApnd(tmp[2], tmp[1]); copyStrApnd(tmp[3], tmp[1]); swap(tmp[1], tmp[0]); @@ -2049,22 +2093,16 @@ uint8_t getVal(char* inbuf, char* outbuf) { } gvfexit:; if (dt == 2) { - if (tmp[1][0] == '.' && !tmp[1][1]) {cerr = 1; dt = 0; goto gvreturn;} - int32_t i = 0, j = strlen(tmp[1]); + if (!strcmp(tmp[1], ".")) {cerr = 1; dt = 0; goto gvreturn;} + int32_t i = 0, j = strlen(tmp[1]) - 1; bool dp = false; - while (tmp[1][i]) {if (tmp[1][i] == '.') {tmp[1][i + 7] = 0; dp = true; break;} i++;} - i = 0; - while (tmp[1][i++] == '0' && tmp[1][i] != '.') {} - --i; - if (dp) { - j--; - while (tmp[1][j] == '0' || !tmp[1][j]) {j--;} - if (tmp[1][j] == '.') {j--;} - j++; - } - copyStrSnip(tmp[1], i, j, tmp[2]); - if (tmp[1][i] == '.') strcpy(outbuf, "0"); - copyStr(tmp[2], outbuf); + while (tmp[1][i]) {if (tmp[1][i++] == '.') {dp = true; tmp[1][i + 6] = 0; break;}} + if (dp) {while (tmp[1][j] == '0') {--j;} if (tmp[1][j] == '.') {--j;}} + i = (tmp[1][0] == '-'); dp = (bool)i; + while (tmp[1][i] == '0') {++i;} + if (!tmp[1][i] || tmp[1][i] == '.') {--i;} + if (dp) tmp[1][--i] = '-'; + copyStrSnip(tmp[1], i, j + 1, outbuf); } else { copyStr(tmp[1], outbuf); } @@ -2120,16 +2158,21 @@ static inline int getArg(int num, char* inbuf, char* outbuf) { int ct = 0; int32_t len = 0; for (int32_t i = 0; inbuf[i] && ct <= num; ++i) { - if (inbuf[i] == '(' && !inStr) {pct++;} - if (inbuf[i] == ')' && !inStr) {pct--;} - if (inbuf[i] == '[' && !inStr) {bct++;} - if (inbuf[i] == ']' && !inStr) {bct--;} - if (inbuf[i] == '"') {inStr = !inStr;} - if (inbuf[i] == ' ' && !inStr) {} else - if (inbuf[i] == ',' && !inStr && pct == 0 && bct == 0) {ct++;} else - if (ct == num) {outbuf[len] = inbuf[i]; len++;} + if (!inStr) { + switch (inbuf[i]) { + case '(': ++pct; break; + case ')': --pct; break; + case '[': ++bct; break; + case ']': --bct; break; + } + } + if (inbuf[i] == '"') inStr = !inStr; + if (!inStr && pct == 0 && bct == 0 && inbuf[i] == ',') {++ct;} else + if (ct == num && (inStr || inbuf[i] != ' ')) {outbuf[len] = inbuf[i]; len++;} } + if (pct || bct || inStr) {outbuf[0] = 0; cerr = 1; return -1;} outbuf[len] = 0; + //printf("arg outbuf: {%s}\n", outbuf); return len; } @@ -2176,18 +2219,16 @@ void mkargs() { for (int i = 0; i <= argct; ++i) {tmpargs[i][argl[i]] = 0;} } -int ltIndex = 0; char lttmp[3][CB_BUF_SIZE]; -uint8_t logictest(char* inbuf) { +uint8_t logictestexpr(char* inbuf) { int32_t tmpp = 0; uint8_t t1 = 0; uint8_t t2 = 0; int32_t p = 0; bool inStr = false; int pct = 0, bct = 0; - ltIndex++; - while (inbuf[p] == ' ') {p++;} + while (inbuf[p] == ' ') {++p;} if (p >= (int32_t)strlen(inbuf)) {cerr = 10; goto ltreturn;} for (int32_t i = p; true; ++i) { if (inbuf[i] == '(' && !inStr) {pct++;} @@ -2221,57 +2262,85 @@ uint8_t logictest(char* inbuf) { if (t2 == 0) goto ltreturn; if (t1 != t2) {cerr = 2; goto ltreturn;} if (!strcmp(lttmp[1], "=")) { - ltIndex--; return (uint8_t)(bool)!strcmp(lttmp[0], lttmp[2]); } else if (!strcmp(lttmp[1], "<>")) { - ltIndex--; return (uint8_t)(bool)strcmp(lttmp[0], lttmp[2]); } else if (!strcmp(lttmp[1], ">")) { if (t1 == 1) {cerr = 2; goto ltreturn;} double num1, num2; sscanf(lttmp[0], "%lf", &num1); sscanf(lttmp[2], "%lf", &num2); - ltIndex--; return num1 > num2; } else if (!strcmp(lttmp[1], "<")) { if (t1 == 1) {cerr = 2; goto ltreturn;} double num1, num2; sscanf(lttmp[0], "%lf", &num1); sscanf(lttmp[2], "%lf", &num2); - ltIndex--; return num1 < num2; } else if (!strcmp(lttmp[1], ">=")) { if (t1 == 1) {cerr = 2; goto ltreturn;} double num1, num2; sscanf(lttmp[0], "%lf", &num1); sscanf(lttmp[2], "%lf", &num2); - ltIndex--; return num1 >= num2; } else if (!strcmp(lttmp[1], "<=")) { if (t1 == 1) {cerr = 2; goto ltreturn;} double num1, num2; sscanf(lttmp[0], "%lf", &num1); sscanf(lttmp[2], "%lf", &num2); - ltIndex--; return num1 <= num2; } else if (!strcmp(lttmp[1], "=>")) { if (t1 == 1) {cerr = 2; goto ltreturn;} double num1, num2; sscanf(lttmp[0], "%lf", &num1); sscanf(lttmp[2], "%lf", &num2); - ltIndex--; return num1 >= num2; } else if (!strcmp(lttmp[1], "=<")) { if (t1 == 1) {cerr = 2; goto ltreturn;} double num1, num2; sscanf(lttmp[0], "%lf", &num1); sscanf(lttmp[2], "%lf", &num2); - ltIndex--; return num1 <= num2; } cerr = 1; ltreturn:; - return -1; + return 255; +} + +char ltbuf[CB_BUF_SIZE]; + +uint8_t logictest(char* inbuf) { + bool inStr = false; + int32_t i = 0, j = 0; + uint8_t ret = 0, out = 0; + uint8_t logicActOld = 0; + while (inbuf[i]) { + uint8_t logicAct = 0; + for (;inbuf[j] && !logicAct; ++j) { + switch (inbuf[j]) { + case '"': inStr = !inStr; break; + case '|': if (!inStr) {logicAct = 1; --j;} break; + case '&': if (!inStr) {logicAct = 2; --j;} break; + } + } + copyStrSnip(inbuf, i, j, ltbuf); + switch (logicActOld) { + case 1: + if ((ret = logictestexpr(ltbuf)) == 255) {return 255;} + out |= ret; + break; + case 2: + if ((ret = logictestexpr(ltbuf)) == 255) {return 255;} + out &= ret; + break; + default: + out = logictestexpr(ltbuf); + break; + } + i = ++j; + logicActOld = logicAct; + } + return out; } char ltmp[2][CB_BUF_SIZE]; @@ -2282,6 +2351,9 @@ bool runlogic() { while (cmd[i] == ' ') {i++;} int32_t j = i; while (cmd[j] != ' ' && cmd[j]) {j++;} + int32_t h = j; + while (cmd[h] == ' ') {h++;} + if (cmd[h] == '=') return false; copyStrSnip(cmd, i, j, ltmp[0]); upCase(ltmp[0]); cerr = 0; @@ -2300,8 +2372,6 @@ void initBaseMem() { bfnbuf = malloc(CB_BUF_SIZE); } -#define nfree(ptr) free(ptr); ptr = NULL - void freeBaseMem() { nfree(getVal_tmp[0]); nfree(getVal_tmp[1]); @@ -2314,7 +2384,7 @@ void freeBaseMem() { void printError(int error) { getCurPos(); - if (curx != 1) printf("\n"); + if (curx != 1) putchar('\n'); if (inProg) {printf("Error %d on line %d of '%s': '%s': ", error, progLine, basefilename(progfnstr), cmd);} else {printf("Error %d: ", error);} switch (error) { @@ -2402,6 +2472,12 @@ void printError(int error) { case 27: printf("Failed to open file '%s' (errno: [%d] %s)", errstr, errno, strerror(errno)); break; + case 28: + fputs("Label is already defined", stdout); + break; + case 29: + fputs("Label is not defined", stdout); + break; case 125: printf("Function only valid in program: '%s'", errstr); break; @@ -2421,7 +2497,7 @@ void printError(int error) { printf("Not a command: '%s'", arg[0]); break; case -1: - fputs("Internal error.", stdout); + fputs("Internal error", stdout); break; } putchar('\n'); @@ -2432,9 +2508,9 @@ void runcmd() { cerr = 0; bool lgc = runlogic(); if (lgc) goto cmderr; - if (dlstackp > -1) {if (dldcmd[dlstackp]) return;} - if (itstackp > -1) {if (itdcmd[itstackp]) return;} - if (fnstackp > -1) {if (fndcmd[fnstackp]) return;} + if (dlstackp > ((progindex > -1) ? mindlstackp[progindex] : -1)) {if (dldcmd[dlstackp]) return;} + if (itstackp > ((progindex > -1) ? minitstackp[progindex] : -1)) {if (itdcmd[itstackp]) return;} + if (fnstackp > ((progindex > -1) ? minfnstackp[progindex] : -1)) {if (fndcmd[fnstackp]) return;} mkargs(); argt = (uint8_t*)realloc(argt, argct + 1); arg = (char**)realloc(arg, (argct + 1) * sizeof(char*)); diff --git a/commands.c b/commands.c index cc9643e..db7bea4 100644 --- a/commands.c +++ b/commands.c @@ -19,6 +19,54 @@ if (chkCmd(2, "SET", "LET")) { if (!setVar(tmpargs[1], arg[2], argt[2], -1)) goto cmderr; goto noerr; } +if (chkCmd(2, "@", "LABEL")) { + if (argct != 1) {cerr = 3; goto cmderr;} + cerr = 0; + int i = -1; + for (int j = 0; j < gotomaxct; ++j) { + if (!gotodata[j].used) {i = j; break;} + else if (!strcmp(gotodata[j].name, tmpargs[1])) {cerr = 28; goto cmderr;} + } + if (i == -1) { + i = gotomaxct; + ++gotomaxct; + gotodata = realloc(gotodata, gotomaxct * sizeof(cb_goto)); + } + gotodata[i].name = malloc(argl[i] + 1); + copyStr(tmpargs[1], gotodata[i].name); + gotodata[i].cp = cmdpos; + gotodata[i].pl = progLine; + gotodata[i].used = true; + gotodata[i].dlsp = dlstackp; + gotodata[i].fnsp = fnstackp; + gotodata[i].itsp = itstackp; +} +if (chkCmd(2, "%", "GOTO")) { + if (argct != 1) {cerr = 3; goto cmderr;} + cerr = 0; + int i = -1; + for (int j = 0; j < gotomaxct; ++j) { + if (gotodata[j].used) { + if (!strcmp(gotodata[j].name, tmpargs[1])) {i = j;} + } + } + if (i == -1) {cerr = 29; goto cmderr;} + if (inProg) { + cp = gotodata[i].cp; + } else { + concp = gotodata[i].cp; + } + progLine = gotodata[i].pl; + dlstackp = gotodata[i].dlsp; + fnstackp = gotodata[i].fnsp; + itstackp = gotodata[i].itsp; + gotodata[i].used = false; + bool r = false; + while (gotomaxct > 0 && !gotodata[gotomaxct].used) {--gotomaxct; r = true;} + if (r) gotodata = realloc(gotodata, gotomaxct * sizeof(cb_goto)); + didloop = true; + lockpl = true; +} if (chkCmd(1, "DIM")) { if (argct != 3) {cerr = 3; goto cmderr;} cerr = 0; @@ -248,7 +296,7 @@ if (chkCmd(1, "RUN")) { updateTxtAttrib(); goto noerr; } -if (chkCmd(1, "SH")) { +if (chkCmd(2, "$", "SH")) { cerr = 0; if (argct != 1) {cerr = 3; goto cmderr;} if (!solvearg(1)) goto cmderr; diff --git a/docs/manual.odt b/docs/manual.odt index 7cdf37c..41e6990 100644 Binary files a/docs/manual.odt and b/docs/manual.odt differ diff --git a/docs/manual.pdf b/docs/manual.pdf index 808ea91..317cc23 100644 Binary files a/docs/manual.pdf and b/docs/manual.pdf differ diff --git a/examples/info.bas b/examples/info.bas index dcb359f..583b09b 100644 --- a/examples/info.bas +++ b/examples/info.bas @@ -1,3 +1,4 @@ -print "You are running CLIBASIC "; _VER$(); " on "; _OS$(); " "; _BITS$(); "-bit." +print "You are running CLIBASIC "; _VER$(); " on "; _OS$(); " "; _BITS$(); "-bit." call dirname$(_arg$(0)) + "color.bas" +'goto te diff --git a/examples/speedtest.bas b/examples/speedtest.bas index 667e052..59a4478 100644 --- a/examples/speedtest.bas +++ b/examples/speedtest.bas @@ -1,6 +1,6 @@ score = 0 'set the 'score' variable to 0 resettimer 'reset the timer to 0 -dowhile timer() < 5 'do the following commands while the timer is less than 5000000 us (5 sec) +dowhile timer() < 5 'do the following commands while the timer is less than 5 seconds score = score + 1 'add 1 to the score loop 'loop back to the dowhile -put "Score: ", score, "\n" 'output the score \ No newline at end of file +put "Score: ", score, "\n" 'output the score diff --git a/examples/truecolor.bas b/examples/truecolor.bas index 7636615..913fae7 100644 --- a/examples/truecolor.bas +++ b/examples/truecolor.bas @@ -1,12 +1,10 @@ -r = val(input$("red: ")) -g = val(input$("green: ")) -b = val(input$("blue: ")) +r = limit(val(input$("red: ")), 0, 255) +g = limit(val(input$("green: ")), 0, 255) +b = limit(val(input$("blue: ")), 0, 255) c = rgb(r, g, b) h = pad$(hex$(c), 6, "0") -put "Color " _txtattrib "truecolor", "on" -color c -print "#"; h +print "Color #"; h _txtattrib "bgc", "on" color , c put " " diff --git a/functions.c b/functions.c index af27f95..c1cf040 100644 --- a/functions.c +++ b/functions.c @@ -612,6 +612,32 @@ if (chkCmd(1, "RGB")) { sprintf(outbuf, "%u", (r << 16) | (g << 8) | b); goto fexit; } +if (chkCmd(1, "LIMIT")) { + cerr = 0; + ftype = 2; + double num = 0; + if (fargct < 2 || fargct > 3) {cerr = 3; goto fexit;} + if (fargt[1] != 2 || fargt[2] != 2) {cerr = 2; goto fexit;} + if (fargct == 3 && fargt[3] == 1) {cerr = 2; goto fexit;} + num = atof(farg[1]); + if (fargct == 2) { + double max = atof(farg[2]); + if (num > max) {num = max;} + } else if (fargct == 3 && fargt[3] == 0) { + double min = atof(farg[2]); + if (num < min) {num = min;} + } else if (fargct == 3) { + double min = atof(farg[2]); + double max = atof(farg[3]); + if (num > max) {num = max;} + else if (num < min) {num = min;} + } else { + cerr = 3; + goto fexit; + } + sprintf(outbuf, "%lf", num); + goto fexit; +} if (chkCmd(1, "PAD$")) { cerr = 0; ftype = 1; @@ -665,7 +691,7 @@ if (chkCmd(1, "WIDTH")) { int tmpret; tmpret = GetConsoleScreenBufferInfo(hConsole, &csbi); (void)tmpret; - sprintf(outbuf, "%d", csbi.dwSize.X); + sprintf(outbuf, "%d", csbi.srWindow.Right - csbi.srWindow.Left + 1); #endif goto fexit; } @@ -682,7 +708,7 @@ if (chkCmd(1, "HEIGHT")) { int tmpret; tmpret = GetConsoleScreenBufferInfo(hConsole, &csbi); (void)tmpret; - sprintf(outbuf, "%d", csbi.dwSize.Y); + sprintf(outbuf, "%d", csbi.srWindow.Bottom - csbi.srWindow.Top + 1); #endif goto fexit; } @@ -924,8 +950,9 @@ if (chkCmd(1, "_ARG$")) { if (fargt[1] != 2) {cerr = 2; goto fexit;} int i = atoi(farg[1]); if (i < 0) {cerr = 16; goto fexit;} - if (i > progargc - 1) {outbuf[0] = 0; goto fexit;} - copyStr(progargs[i], outbuf); + if (i > progargc - 1 && i > 0) {outbuf[0] = 0; goto fexit;} + if (i == 0) copyStr(progfn[progindex], outbuf); + else copyStr(progargs[i], outbuf); } else { cerr = 3; goto fexit; } diff --git a/logic.c b/logic.c index 6c72072..7317da3 100644 --- a/logic.c +++ b/logic.c @@ -1,12 +1,12 @@ if (chkCmd(1, "REM")) return true; if (chkCmd(2, "?", "PRINT")) { - if (dlstackp > -1) { + if (dlstackp > ((progindex > -1) ? mindlstackp[progindex] : -1)) { if (dldcmd[dlstackp]) return true; } - if (itstackp > -1) { + if (itstackp > ((progindex > -1) ? minitstackp[progindex] : -1)) { if (itdcmd[itstackp]) return true; } - if (fnstackp > -1) { + if (fnstackp > ((progindex > -1) ? minfnstackp[progindex] : -1)) { if (fndcmd[fnstackp]) return true; } while (cmd[j] == ' ') j++; @@ -46,60 +46,68 @@ if (chkCmd(2, "?", "PRINT")) { if (chkCmd(1, "DO")) { if (dlstackp >= CB_PROG_LOGIC_MAX - 1) {cerr = 12; return true;} dlstackp++; - if (itstackp > -1) { + if (itstackp > ((progindex > -1) ? minitstackp[progindex] : -1)) { if (itdcmd[itstackp]) {dldcmd[dlstackp] = true; return true;} } - if (dlstackp > 0) { + if (dlstackp > ((progindex > -1) ? mindlstackp[progindex] + 1 : 0)) { if (dldcmd[dlstackp - 1]) {dldcmd[dlstackp] = true; return true;} } - if (fnstackp > -1) { + if (fnstackp > ((progindex > -1) ? minfnstackp[progindex] : -1)) { if (fndcmd[fnstackp]) return true; } int32_t p = j; while (cmd[p]) {if (cmd[p] != ' ') {cerr = 1; return true;} p++;} dldcmd[dlstackp] = false; - dlstack[dlstackp] = cmdpos; - dlpline[dlstackp] = progLine; + dlstack[dlstackp].cp = cmdpos; + dlstack[dlstackp].pl = progLine; + dlstack[dlstackp].fnsp = fnstackp; + dlstack[dlstackp].itsp = itstackp; return true; } if (chkCmd(1, "DOWHILE")) { if (dlstackp >= CB_PROG_LOGIC_MAX - 1) {cerr = 12; return true;} dlstackp++; - if (itstackp > -1) { + if (itstackp > ((progindex > -1) ? minitstackp[progindex] : -1)) { if (itdcmd[itstackp]) {dldcmd[dlstackp] = true; return true;} } - if (dlstackp > 0) { + if (dlstackp > ((progindex > -1) ? mindlstackp[progindex] + 1 : 0)) { if (dldcmd[dlstackp - 1]) {dldcmd[dlstackp] = true; return true;} } - if (fnstackp > -1) { + if (fnstackp > ((progindex > -1) ? minfnstackp[progindex] : -1)) { if (fndcmd[fnstackp]) return true; } copyStrSnip(cmd, j + 1, strlen(cmd), ltmp[1]); uint8_t testval = logictest(ltmp[1]); if (testval != 1 && testval) return true; - if (testval == 1) dlpline[dlstackp] = progLine; - if (testval == 1) dlstack[dlstackp] = cmdpos; + if (testval == 1) { + dlstack[dlstackp].pl = progLine; + dlstack[dlstackp].cp = cmdpos; + dlstack[dlstackp].fnsp = fnstackp; + dlstack[dlstackp].itsp = itstackp; + } dldcmd[dlstackp] = (bool)testval; dldcmd[dlstackp] = !dldcmd[dlstackp]; return true; } if (chkCmd(1, "LOOP")) { if (dlstackp <= -1) {cerr = 6; return true;} - if (dlstackp > -1) { + if (dlstackp > ((progindex > -1) ? mindlstackp[progindex] : -1)) { if (dldcmd[dlstackp]) {dlstackp--; return true;} } - if (itstackp > -1) { + if (itstackp > ((progindex > -1) ? minitstackp[progindex] : -1)) { if (itdcmd[itstackp]) return true; } - if (fnstackp > -1) { + if (fnstackp > ((progindex > -1) ? minfnstackp[progindex] : -1)) { if (fndcmd[fnstackp]) return true; } if (inProg) { - cp = dlstack[dlstackp]; + cp = dlstack[dlstackp].cp; } else { - concp = dlstack[dlstackp]; + concp = dlstack[dlstackp].cp; } - progLine = dlpline[dlstackp]; + progLine = dlstack[dlstackp].pl; + fnstackp = dlstack[dlstackp].fnsp; + itstackp = dlstack[dlstackp].itsp; lockpl = true; dldcmd[dlstackp] = false; dlstackp--; @@ -110,13 +118,13 @@ if (chkCmd(1, "LOOP")) { } if (chkCmd(1, "LOOPWHILE")) { if (dlstackp <= -1) {cerr = 6; return true;} - if (itstackp > -1) { + if (itstackp > ((progindex > -1) ? minitstackp[progindex] : -1)) { if (itdcmd[itstackp]) return true; } - if (dlstackp > -1) { + if (dlstackp > ((progindex > -1) ? mindlstackp[progindex] : -1)) { if (dldcmd[dlstackp]) {dlstackp--; return true;} } - if (fnstackp > -1) { + if (fnstackp > ((progindex > -1) ? minfnstackp[progindex] : -1)) { if (fndcmd[fnstackp]) return true; } copyStrSnip(cmd, j + 1, strlen(cmd), ltmp[1]); @@ -124,11 +132,13 @@ if (chkCmd(1, "LOOPWHILE")) { if (testval != 1 && testval) return true; if (testval == 1) { if (inProg) { - cp = dlstack[dlstackp]; + cp = dlstack[dlstackp].cp; } else { - concp = dlstack[dlstackp]; + concp = dlstack[dlstackp].cp; } - progLine = dlpline[dlstackp]; + progLine = dlstack[dlstackp].pl; + fnstackp = dlstack[dlstackp].fnsp; + itstackp = dlstack[dlstackp].itsp; lockpl = true; } dldcmd[dlstackp] = false; @@ -139,13 +149,13 @@ if (chkCmd(1, "LOOPWHILE")) { if (chkCmd(1, "IF")) { if (itstackp >= CB_PROG_LOGIC_MAX - 1) {cerr = 13; return true;} itstackp++; - if (itstackp > 0) { + if (itstackp > ((progindex > -1) ? minitstackp[progindex] + 1 : 0)) { if (itdcmd[itstackp - 1]) {itdcmd[itstackp] = true; return true;} } - if (dlstackp > -1) { + if (dlstackp > ((progindex > -1) ? mindlstackp[progindex] : -1)) { if (dldcmd[dlstackp]) {itdcmd[itstackp] = true; return true;} } - if (fnstackp > -1) { + if (fnstackp > ((progindex > -1) ? minfnstackp[progindex] : -1)) { if (fndcmd[fnstackp]) return true; } copyStrSnip(cmd, j + 1, strlen(cmd), ltmp[1]); @@ -156,13 +166,13 @@ if (chkCmd(1, "IF")) { } if (chkCmd(1, "ELSE")) { if (itstackp <= -1) {cerr = 8; return true;} - if (itstackp > 0) { + if (itstackp > ((progindex > -1) ? minitstackp[progindex] + 1 : 0)) { if (itdcmd[itstackp - 1]) return true; } - if (dlstackp > -1) { + if (dlstackp > ((progindex > -1) ? mindlstackp[progindex] : -1)) { if (dldcmd[dlstackp]) return true; } - if (fnstackp > -1) { + if (fnstackp > ((progindex > -1) ? minfnstackp[progindex] : -1)) { if (fndcmd[fnstackp]) return true; } if (didelse) {cerr = 11; return true;} @@ -172,24 +182,27 @@ if (chkCmd(1, "ELSE")) { } if (chkCmd(1, "ENDIF")) { if (itstackp <= -1) {cerr = 7; return true;} - if (fnstackp > -1) { + itstackp--; + if (dlstackp > ((progindex > -1) ? mindlstackp[progindex] : -1)) { + if (dldcmd[dlstackp]) return true; + } + if (fnstackp > ((progindex > -1) ? minfnstackp[progindex] : -1)) { if (fndcmd[fnstackp]) return true; } - itdcmd[itstackp] = false; + itdcmd[itstackp + 1] = false; didelse = false; - itstackp--; return true; } if (chkCmd(1, "FOR")) { if (itstackp >= CB_PROG_LOGIC_MAX - 1) {cerr = 13; return true;} fnstackp++; - if (itstackp > -1) { + if (itstackp > ((progindex > -1) ? minitstackp[progindex] : -1)) { if (itdcmd[itstackp]) {return true;} } - if (dlstackp > -1) { + if (dlstackp > ((progindex > -1) ? mindlstackp[progindex] : -1)) { if (dldcmd[dlstackp]) {return true;} } - if (fnstackp > 0) { + if (fnstackp > ((progindex > -1) ? minfnstackp[progindex] + 1 : 0)) { if (fndcmd[fnstackp - 1]) {return true;} } copyStrSnip(cmd, j + 1, strlen(cmd), ltmp[1]); @@ -202,7 +215,7 @@ if (chkCmd(1, "FOR")) { getArg(3, ltmp[1], forbuf[3]); if (getVal(forbuf[3], forbuf[3]) != 2) return true; setVar(fnvar, forbuf[1], 2, -1); - if (fnstack[fnstackp] == -1) { + if (fnstack[fnstackp].cp == -1) { copyStr(forbuf[1], forbuf[0]); } getArg(2, ltmp[1], forbuf[2]); @@ -214,30 +227,41 @@ if (chkCmd(1, "FOR")) { if (testval == -1) return true; fndcmd[fnstackp] = !(bool)testval; if (!(fninfor[fnstackp] = (bool)testval)) {cerr = 0; return true;} - if (!fninfor[fnstackp] && fnstack[fnstackp] == -1) { + if (!fninfor[fnstackp] && fnstack[fnstackp].cp == -1) { sprintf(forbuf[0], "%lf", atof(forbuf[0]) - atof(forbuf[3])); setVar(fnvar, forbuf[0], 2, -1); } - fnstack[fnstackp] = cmdpos; - fnpline[fnstackp] = progLine; + fnstack[fnstackp].cp = cmdpos; + fnstack[fnstackp].pl = progLine; + fnstack[fnstackp].dlsp = dlstackp; + fnstack[fnstackp].itsp = itstackp; cerr = 0; return true; } if (chkCmd(1, "NEXT")) { if (fnstackp <= -1) {cerr = 9; return true;} + fnstackp--; + if (itstackp > ((progindex > -1) ? minitstackp[progindex] : -1)) { + if (itdcmd[itstackp]) {return true;} + } + if (dlstackp > ((progindex > -1) ? mindlstackp[progindex] : -1)) { + if (dldcmd[dlstackp]) {return true;} + } + fnstackp++; if (fninfor[fnstackp]) { if (inProg) { - cp = fnstack[fnstackp]; + cp = fnstack[fnstackp].cp; } else { - concp = fnstack[fnstackp]; + concp = fnstack[fnstackp].cp; } - progLine = fnpline[fnstackp]; + progLine = fnstack[fnstackp].pl; + dlstackp = fnstack[fnstackp].dlsp; + itstackp = fnstack[fnstackp].itsp; lockpl = true; didloop = true; - fnstackp--; } else { - fnstack[fnstackp] = -1; - fnstackp--; + fnstack[fnstackp].cp = -1; } + fnstackp--; return true; } diff --git a/package.sh b/package.sh index c1db98e..770c1ae 100644 --- a/package.sh +++ b/package.sh @@ -1,3 +1,5 @@ +# makes clibasic release files + # erase old versions rm -f clibasic-linux-x64.zip rm -f clibasic-linux-x86.zip @@ -24,14 +26,14 @@ zip clibasic-linux-x86.zip clibasic make clean 1> /dev/null rm -f clibasic.exe -make -f Makefile-Cross build 1> /dev/null +make cross build 1> /dev/null zip clibasic-windows-x64.zip clibasic.exe *.dll -make -f Makefile-Cross clean 1> /dev/null +make cross clean 1> /dev/null rm -f clibasic.exe -make -f Makefile-Cross build32 1> /dev/null +make cross build32 1> /dev/null zip clibasic-windows-x86.zip clibasic.exe *.dll -make -f Makefile-Cross clean 1> /dev/null +make cross clean 1> /dev/null # clean up mv clibasic.tmp clibasic 2> /dev/null