From 539a71ef25abf45b55ab3b60e550b048f215b945 Mon Sep 17 00:00:00 2001 From: QB64Cobalt <56514693+QB64Cobalt@users.noreply.github.com> Date: Thu, 5 Dec 2019 07:08:31 -0800 Subject: [PATCH 1/6] Update qbx.cpp --- internal/c/qbx.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/internal/c/qbx.cpp b/internal/c/qbx.cpp index 18701369b..9a6b70259 100644 --- a/internal/c/qbx.cpp +++ b/internal/c/qbx.cpp @@ -641,12 +641,12 @@ extern float string2s(qbs*str); extern double string2d(qbs*str); extern long double string2f(qbs*str); //Cobalt(aka Dave) added the next 2 lines -int64 func__shr(int64 a1, int b1); -int64 func__shl(int64 a1, int b1); -int64 func__readbit(int64 a1, int b1); -int64 func__setbit(int64 a1, int b1); -int64 func__resetbit(int64 a1, int b1); -int64 func__togglebit(int64 a1, int b1); +uint64 func__shr(uint64 a1, int b1); +uint64 func__shl(uint64 a1, int b1); +int64 func__readbit(uint64 a1, int b1); +uint64 func__setbit(uint64 a1, int b1); +uint64 func__resetbit(uint64 a1, int b1); +uint64 func__togglebit(uint64 a1, int b1); #ifndef QB64_WINDOWS extern void Sleep(uint32 milliseconds); extern void ZeroMemory(void *ptr,int64 bytes); @@ -975,22 +975,22 @@ inline int32 func_sgn(long double v){ } //bit-shifting -inline int64 func__shl(int64 a1,int b1) +inline uint64 func__shl(uint64 a1,int b1) {return a1<>b1;} -inline int64 func__readbit(int64 a1, int b1) +inline int64 func__readbit(uint64 a1, int b1) {if (a1 & 1ull< Date: Thu, 5 Dec 2019 07:10:31 -0800 Subject: [PATCH 2/6] Update subs_functions.bas --- source/subs_functions/subs_functions.bas | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/source/subs_functions/subs_functions.bas b/source/subs_functions/subs_functions.bas index 015979061..35cd2e890 100644 --- a/source/subs_functions/subs_functions.bas +++ b/source/subs_functions/subs_functions.bas @@ -3268,8 +3268,8 @@ id.n = "_SHR" id.subfunc = 1 id.callname = "func__shr" id.args = 2 -id.arg = MKL$(INTEGER64TYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER) -id.ret = INTEGER64TYPE - ISPOINTER +id.arg = MKL$(UINTEGER64TYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER) +id.ret = UINTEGER64TYPE - ISPOINTER regid clearid @@ -3277,8 +3277,8 @@ id.n = "_SHL" id.subfunc = 1 id.callname = "func__shl" id.args = 2 -id.arg = MKL$(INTEGER64TYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER) -id.ret = INTEGER64TYPE - ISPOINTER +id.arg = MKL$(UINTEGER64TYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER) +id.ret = UINTEGER64TYPE - ISPOINTER regid clearid @@ -3413,7 +3413,7 @@ id.n = "_READBIT" id.subfunc = 1 id.callname = "func__readbit" id.args = 2 -id.arg = MKL$(INTEGER64TYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER) +id.arg = MKL$(UINTEGER64TYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER) id.ret = INTEGER64TYPE - ISPOINTER regid @@ -3422,8 +3422,8 @@ id.n = "_SETBIT" id.subfunc = 1 id.callname = "func__setbit" id.args = 2 -id.arg = MKL$(INTEGER64TYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER) -id.ret = INTEGER64TYPE - ISPOINTER +id.arg = MKL$(UINTEGER64TYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER) +id.ret = UINTEGER64TYPE - ISPOINTER regid clearid @@ -3431,8 +3431,8 @@ id.n = "_RESETBIT" id.subfunc = 1 id.callname = "func__resetbit" id.args = 2 -id.arg = MKL$(INTEGER64TYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER) -id.ret = INTEGER64TYPE - ISPOINTER +id.arg = MKL$(UINTEGER64TYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER) +id.ret = UINTEGER64TYPE - ISPOINTER regid clearid @@ -3440,6 +3440,6 @@ id.n = "_TOGGLEBIT" id.subfunc = 1 id.callname = "func__togglebit" id.args = 2 -id.arg = MKL$(INTEGER64TYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER) -id.ret = INTEGER64TYPE - ISPOINTER +id.arg = MKL$(UINTEGER64TYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER) +id.ret = UINTEGER64TYPE - ISPOINTER regid From 752a4445442fa3b661da4dfee03f7b39352d21d8 Mon Sep 17 00:00:00 2001 From: SteveMcNeill Date: Sat, 7 Dec 2019 08:46:29 -0500 Subject: [PATCH 3/6] Update to enable SLEEP with a set TIME for use with Windows Console --- internal/c/libqb.cpp | 71 +++++++++++++++++++++++++++++++------------- 1 file changed, 50 insertions(+), 21 deletions(-) diff --git a/internal/c/libqb.cpp b/internal/c/libqb.cpp index 787b77b85..404234e05 100644 --- a/internal/c/libqb.cpp +++ b/internal/c/libqb.cpp @@ -6792,6 +6792,12 @@ void sub__keyclear(int32 buf, int32 passed) { //INP(&H60) buffer port60h_events = 0; } + #ifdef QB64_WINDOWS + //Windows Console Buffer + FlushConsoleInputBuffer(GetStdHandle (STD_INPUT_HANDLE)); + #endif + + } //STR() functions @@ -15290,27 +15296,51 @@ void sub_put2(int32 i,int64 offset,void *element,int32 passed){ void sub_sleep(int32 seconds,int32 passed){ if (new_error) return; + + sleep_break=0; + double prev,ms,now,elapsed;//cannot be static + prev=GetTicks(); + ms=1000.0*(double)seconds; #ifdef QB64_WINDOWS + if (read_page->console){ int32 junk=0,junk2=0; + DWORD dwRet; + HANDLE hStdin = GetStdHandle (STD_INPUT_HANDLE); + FlushConsoleInputBuffer(hStdin); + if (passed){ + do{ + now=GetTicks(); + if (now0);//as long as our timer hasn't expired, we continue to run the loop and countdown the time remaining + return; //if we get here, something odd happened. We should expire automatically with the WAIT_TIMEOUT event before this occurs. + } do{ //ignore all console input unless it's a keydown event - do{ //ignore all console input uless it's a keyboard event - junk=func__getconsoleinput(); - junk2=consolekey; - }while(junk!=1); //only when junk = 1 do we have a keyboard event - }while(junk2<=0); //only when junk2 > 0 do we have a key down event. (values less than 0 are key up events; 0 is a non event) - do{ //now continue to get the console input junk=func__getconsoleinput(); - }while(consolekey!=-junk2); //until that key is released. We don't need to leave the key up sequence in the buffer to screw things up with future reads. + }while(junk!=1); //only when junk = 1 do we have a keyboard event + Sleep(100); //Give the user time to remove their finger from the key, before clearing the buffer. + FlushConsoleInputBuffer(hStdin); //and flush the keyboard buffer after, so we don't leave stray events to be processed. return; } #endif - sleep_break=0; - double prev,ms,now,elapsed;//cannot be static - if (passed) prev=GetTicks(); - ms=1000.0*(double)seconds; + recalculate: wait: evnt(0);//handle general events @@ -19746,6 +19776,7 @@ void sub_put2(int32 i,int64 offset,void *element,int32 passed){ #ifdef QB64_WINDOWS cout<<"\nPress any key to continue"; int32 junk; + FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE)); //clear any stray buffer events before we run END. do{ //ignore all console input junk=func__getconsoleinput(); }while(junk!=1); //until we have a key down event @@ -29631,19 +29662,16 @@ void reinit_glut_callbacks(){ int32 func__getconsoleinput(){ HANDLE hStdin = GetStdHandle (STD_INPUT_HANDLE); INPUT_RECORD irInputRecord; - DWORD dwEventsRead, fdwMode; + DWORD dwEventsRead, fdwMode, dwMode; CONSOLE_SCREEN_BUFFER_INFO cl_bufinfo; - SECURITY_ATTRIBUTES SecAttribs = {sizeof(SECURITY_ATTRIBUTES), 0, 1}; - HANDLE cl_conout = CreateFileA("CONOUT$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, & SecAttribs, OPEN_EXISTING, 0, 0); - HANDLE cl_conin = CreateFileA("CONIN$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, & SecAttribs, OPEN_EXISTING, 0, 0); - GetConsoleScreenBufferInfo(cl_conout, &cl_bufinfo); - + + GetConsoleMode(hStdin, (LPDWORD)&dwMode); fdwMode = ENABLE_EXTENDED_FLAGS; - SetConsoleMode(cl_conin, fdwMode); - fdwMode = ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT; - SetConsoleMode(cl_conin, fdwMode); + SetConsoleMode(hStdin, fdwMode); + fdwMode = dwMode | ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT; + SetConsoleMode(hStdin, fdwMode); - ReadConsoleInputA (cl_conin, &irInputRecord, 1, &dwEventsRead); + ReadConsoleInputA (hStdin, &irInputRecord, 1, &dwEventsRead); switch(irInputRecord.EventType){ case KEY_EVENT: //keyboard input consolekey = irInputRecord.Event.KeyEvent.wVirtualScanCode; @@ -29653,6 +29681,7 @@ void reinit_glut_callbacks(){ consolemousex = irInputRecord.Event.MouseEvent.dwMousePosition.X + 1; consolemousey = irInputRecord.Event.MouseEvent.dwMousePosition.Y - cl_bufinfo.srWindow.Top + 1; consolebutton = irInputRecord.Event.MouseEvent.dwButtonState; //button state for all buttons + //SetConsoleMode(hStdin, dwMode); return 2; } return 0; //in case it's some other odd input From e74c1fb9e350f108dee2fccc1da3b733c6adec43 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Sat, 7 Dec 2019 19:36:43 -0300 Subject: [PATCH 4/6] Adjusts "Ignore #Warnings" menu item according to + + the rest of the menu implementation. --- source/ide/ide_global.bas | 2 +- source/ide/ide_methods.bas | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/ide/ide_global.bas b/source/ide/ide_global.bas index e83b6859b..37c4ff46b 100644 --- a/source/ide/ide_global.bas +++ b/source/ide/ide_global.bas @@ -201,7 +201,7 @@ DIM SHARED menusize(1 TO 10) DIM SHARED menus AS INTEGER, idecontextualmenuID AS INTEGER DIM SHARED ideeditmenuID AS INTEGER, SearchMenuID AS INTEGER DIM SHARED OptionsMenuID AS INTEGER, OptionsMenuSwapMouse AS INTEGER, OptionsMenuPasteCursor AS INTEGER -DIM SHARED OptionsMenuShowErrorsImmediately AS INTEGER +DIM SHARED OptionsMenuShowErrorsImmediately AS INTEGER, OptionsMenuIgnoreWarnings AS INTEGER DIM SHARED ViewMenuID AS INTEGER, ViewMenuShowLineNumbersSubMenuID AS INTEGER DIM SHARED ViewMenuShowSeparatorID AS INTEGER, ViewMenuShowBGID AS INTEGER DIM SHARED ViewMenuCompilerWarnings AS INTEGER diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index ec9e633ce..5161dd7b0 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -333,8 +333,8 @@ FUNCTION ide2 (ignore) END IF OptionsMenuIgnoreWarnings = i - menu$(m, 11) = "Ignore Warnings": i = 12 - IF IgnoreWarnings THEN menu$(OptionsMenuID, 11) = CHR$(7) + "Ignore Warnings" + menu$(m, i) = "Ignore #Warnings": i = i + 1 + IF IgnoreWarnings THEN menu$(OptionsMenuID, OptionsMenuIgnoreWarnings) = CHR$(7) + "Ignore #Warnings" @@ -4664,16 +4664,16 @@ FUNCTION ide2 (ignore) GOTO ideloop END IF - IF RIGHT$(menu$(m, s), 15) = "Ignore Warnings" THEN + IF RIGHT$(menu$(m, s), 16) = "Ignore #Warnings" THEN PCOPY 2, 0 IF Ignorewarnings = 0 THEN Ignorewarnings = -1 WriteConfigSetting "'[GENERAL SETTINGS]", "IgnoreWarnings", "TRUE" - menu$(OptionsMenuID, 11) = CHR$(7) + "Ignore Warnings" + menu$(OptionsMenuID, OptionsMenuIgnoreWarnings) = CHR$(7) + "Ignore #Warnings" ELSE Ignorewarnings = 0 WriteConfigSetting "'[GENERAL SETTINGS]", "IgnoreWarnings", "FALSE" - menu$(OptionsMenuID, 11) = "Ignore Warnings" + menu$(OptionsMenuID, OptionsMenuIgnoreWarnings) = "Ignore #Warnings" END IF idechangemade = 1 PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt From d40902a1edaf11f9f0da43fc6a29cd3dc3a0bd3e Mon Sep 17 00:00:00 2001 From: Roland Heyder <51290299+RhoSigma-QB64@users.noreply.github.com> Date: Sun, 8 Dec 2019 01:13:57 +0100 Subject: [PATCH 5/6] extended support for &B prefixed number strings Aditonal to VAL, the &B prefixed numbers are now also recognized by INPUT (keyboard and file input) and also by READ, if those numbers are noted in DATA statements. --- internal/c/libqb.cpp | 378 ++++++++++++++++++++++++++++--------------- 1 file changed, 248 insertions(+), 130 deletions(-) diff --git a/internal/c/libqb.cpp b/internal/c/libqb.cpp index 404234e05..bd8e07048 100644 --- a/internal/c/libqb.cpp +++ b/internal/c/libqb.cpp @@ -11528,63 +11528,84 @@ void qbg_sub_locate(int32 row,int32 column,int32 cursor,int32 start,int32 stop,i //input helper functions: uint64 hexoct2uint64_value; -int32 hexoct2uint64(qbs* h){ - //returns 0=failed - // 1=HEX value (default if unspecified) - // 2=OCT value - static int32 i,i2; - static uint64 result; - result=0; - static int32 type; - type=0; - hexoct2uint64_value=0; - if (!h->len) return 1; - if (h->chr[0]!=38) return 0;//not "&" - if (h->len==1) return 1;//& received, but awaiting further input - i=h->chr[1]; - if ((i==72)||(i==104)) type=1;//"H"or"h" - if ((i==79)||(i==111)) type=2;//"O"or"o" - if (!type) return 0; - if (h->len==2) return type; - - if (type==1){ - if (h->len>18) return 0;//larger than int64 - for (i=2;ilen;i++){ - result<<=4; - i2=h->chr[i]; - // 0 - 9 A - F a - f - if ( ((i2>=48)&&(i2<=57)) || ((i2>=65)&&(i2<=70)) || ((i2>=97)&&(i2<=102)) ){ - if (i2>=97) i2-=32; - if (i2>=65) i2-=7; - i2-=48; - //i2 is now a values between 0 and 15 - result+=i2; - }else return 0;//invalid character - }//i - hexoct2uint64_value=result; - return 1; - }//type==1 - - if (type==2){ - //unsigned _int64 max=18446744073709551615 (decimal, 20 chars) - // =1777777777777777777777 (octal, 22 chars) - // =FFFFFFFFFFFFFFFF (hex, 16 chars) - if (h->len>24) return 0;//larger than int64 - if (h->len==24){ - if ((h->chr[2]!=48)&&(h->chr[2]!=49)) return 0;//larger than int64 - } - for (i=2;ilen;i++){ - result<<=3; - i2=h->chr[i]; - if ((i2>=48)&&(i2<=55)){//0-7 - i2-=48; - result+=i2; - }else return 0;//invalid character - }//i - hexoct2uint64_value=result; - return 2; - }//type==2 - +int32 hexoct2uint64(qbs *h) { + // returns 0 = failed + // 1 = HEX value (default if unspecified) + // 2 = OCT value + // 3 = BIN value + static int32 i, i2; + static uint64 result; + result = 0; + static int32 type; + type = 0; + hexoct2uint64_value = 0; + if (!h->len) return 1; + if (h->chr[0] != 38) return 0; // not "&" + if (h->len == 1) return 1; // "&" received, but awaiting further input + i = h->chr[1]; + if ((i == 72) || (i == 104)) type = 1; // "H" or "h" + if ((i == 79) || (i == 111)) type = 2; // "O" or "o" + if ((i == 66) || (i == 98)) type = 3; // "B" or "b" + if (!type) return 0; + if (h->len == 2) return type; + + // unsigned _int64 max = 18446744073709551615 (decimal, 20 chars) + // = 1111111 etc., max. 64x (binary, 64 chars) + // = 1777777777777777777777 (octal, 22 chars) + // = FFFFFFFFFFFFFFFF (hex, 16 chars) + + if (type == 1) { + if (h->len > 18) return 0; // larger than int64 + for (i = 2; i < h->len; i++) { + result <<= 4; + i2 = h->chr[i]; + // 0 - 9 / A - F / a - f + if (((i2 >= 48) && (i2 <= 57)) || ((i2 >= 65) && (i2 <= 70)) || ((i2 >= 97) && (i2 <= 102))) { + if (i2 >= 97) i2 -= 32; + if (i2 >= 65) i2 -= 7; + i2 -= 48; + // i2 is now a values between 0 and 15 + result += i2; + } else + return 0; // invalid character + } // i + hexoct2uint64_value = result; + return 1; + } // type == 1 + + if (type == 2) { + if (h->len > 24) return 0; // larger than int64 + if (h->len == 24) { + if ((h->chr[2] != 48) && (h->chr[2] != 49)) + return 0; // larger than int64 + } + for (i = 2; i < h->len; i++) { + result <<= 3; + i2 = h->chr[i]; + if ((i2 >= 48) && (i2 <= 55)) { // 0-7 + i2 -= 48; + result += i2; + } else + return 0; // invalid character + } // i + hexoct2uint64_value = result; + return 2; + } // type == 2 + + if (type == 3) { + if (h->len > 66) return 0; // larger than int64 + for (i = 2; i < h->len; i++) { + result <<= 1; + i2 = h->chr[i]; + if ((i2 >= 48) && (i2 <= 49)) { // 0-1 + i2 -= 48; + result += i2; + } else + return 0; // invalid character + } // i + hexoct2uint64_value = result; + return 3; + } // type == 3 } @@ -11755,7 +11776,7 @@ void qbs_input(int32 numvariables,uint8 newline){ max<<=i4; max--; - //check for hex/oct + //check for hex/oct/bin if (i3=hexoct2uint64(qbs_input_arguements[argn])){ hexvalue=hexoct2uint64_value; if (hexvalue>max){valid=0; goto typechecked;} @@ -11780,7 +11801,18 @@ void qbs_input(int32 numvariables,uint8 newline){ value>>=3; } if (l>(2+i)){valid=0; goto typechecked;} - if (l==1) completewith=111;//"O" + if (l==1) completewith=79;//"O" + if (l==2) completewith=48;//"0" + } + if (i3==3){ + value=max; + i=0; + for (i2=1;i2<=64;i2++){ + if (value&0x1) i=i2; + value>>=1; + } + if (l>(2+i)){valid=0; goto typechecked;} + if (l==1) completewith=66;//"B" if (l==2) completewith=48;//"0" } finalvalue=hexvalue; @@ -11852,13 +11884,14 @@ void qbs_input(int32 numvariables,uint8 newline){ if ((qbs_input_variabletypes[argn]&511)==64){ if (l==0){completewith=48; *(int64*)qbs_input_variableoffsets[argn]=0; goto typechecked;} - //check for hex/oct + //check for hex/oct/bin if (i3=hexoct2uint64(qbs_input_arguements[argn])){ hexvalue=hexoct2uint64_value; if (hexvalue>max){valid=0; goto typechecked;} //set completewith value (if necessary) if (i3==1) if (l==1) completewith=72;//"H" - if (i3==2) if (l==1) completewith=111;//"O" + if (i3==2) if (l==1) completewith=79;//"O" + if (i3==3) if (l==1) completewith=66;//"B" if (l==2) completewith=48;//"0" *(uint64*)qbs_input_variableoffsets[argn]=hexvalue; goto typechecked; @@ -11942,12 +11975,13 @@ void qbs_input(int32 numvariables,uint8 newline){ //begin with a generic assessment, regardless of whether it is single, double or float if (l==0){completewith=48; goto typechecked;} - //check for hex/oct + //check for hex/oct/bin if (i3=hexoct2uint64(qbs_input_arguements[argn])){ hexvalue=hexoct2uint64_value; //set completewith value (if necessary) if (i3==1) if (l==1) completewith=72;//"H" - if (i3==2) if (l==1) completewith=111;//"O" + if (i3==2) if (l==1) completewith=79;//"O" + if (i3==3) if (l==1) completewith=66;//"B" if (l==2) completewith=48;//"0" //nb. because VC6 didn't support... //error C2520: conversion from uint64 to double not implemented, use signed int64 @@ -13277,8 +13311,9 @@ uint8 n_digit[256]; int64 n_exp;//if 0, there is one digit in front of the decimal place uint8 n_neg;//if 1, the number is negative uint8 n_hex;//if 1, the digits are in hexidecimal and n_exp should be ignored -//if 2, the digits are in octal and n_exp should be ignored -//(consider revising variable name n_hex) + //if 2, the digits are in octal and n_exp should be ignored + //if 3, the digits are in binary and n_exp should be ignored + //(consider revising variable name n_hex) int32 n_roundincrement(){ static int32 i,i2,i3; @@ -13329,6 +13364,17 @@ int32 n_float(){ n_float_value=value; return 1; } + //bin? + if (n_hex==3){ + if (n_digits>64) return 0; + for (i=0;i308)return 0;//overflow @@ -13399,7 +13445,6 @@ int32 n_int64(){ return 1; } //oct - if (n_hex==2){ if (n_digits>=22){ @@ -13413,6 +13458,17 @@ int32 n_int64(){ n_int64_value=value; return 1; } + //bin + if (n_hex==3){ + if (n_digits>64) return 0; + for (i=0;i18)return 0;//overflow @@ -13493,6 +13549,17 @@ int32 n_uint64(){ n_uint64_value=uvalue; return 1; } + //bin + if (n_hex==3){ + if (n_digits>64) return 0; + for (i=0;i=data_size) goto gotnumber; - c=data[*data_offset]; - if (c==44){(*data_offset)++; goto gotnumber;} - if ((c==72)||(c==104)){//"H"or"h" - nexthexchr: - (*data_offset)++; if (*data_offset>=data_size) goto gotnumber; - c=data[*data_offset]; - if (c==44){(*data_offset)++; goto gotnumber;} - if ( ((c>=48)&&(c<=57)) || ((c>=65)&&(c<=70)) || ((c>=97)&&(c<=102)) ){//0-9 or A-F or a-f - if (n_digits==256) return 1;//Overflow - n_digit[n_digits]=c; - n_digits++; - n_hex=1; - goto nexthexchr; - } - return 3;//Syntax error + // hex/oct/bin + if (c == 38) { // "&" + (*data_offset)++; + if (*data_offset >= data_size) goto gotnumber; + c = data[*data_offset]; + if (c == 44) { + (*data_offset)++; + goto gotnumber; + } + if ((c == 72) || (c == 104)) { // "H" or "h" + nexthexchr: + (*data_offset)++; + if (*data_offset >= data_size) goto gotnumber; + c = data[*data_offset]; + if (c == 44) { + (*data_offset)++; + goto gotnumber; } - if ((c==79)||(c==111)){//"O"or"o" - nexthexchr2: - (*data_offset)++; if (*data_offset>=data_size) goto gotnumber; - c=data[*data_offset]; - if (c==44){(*data_offset)++; goto gotnumber;} - if ((c>=48)&&(c<=55)){//0-7 - if (n_digits==256) return 1;//Overflow - n_digit[n_digits]=c; - n_digits++; - n_hex=2; - goto nexthexchr2; - } - return 3;//Syntax error + if (((c >= 48) && (c <= 57)) || ((c >= 65) && (c <= 70)) || + ((c >= 97) && (c <= 102))) { // 0-9 or A-F or a-f + if (n_digits == 256) return 1; // Overflow + n_digit[n_digits] = c; + n_digits++; + n_hex = 1; + goto nexthexchr; } - return 3;//Syntax error - }//& + return 3; // Syntax error + } + if ((c == 79) || (c == 111)) { // "O" or "o" + nexthexchr2: + (*data_offset)++; + if (*data_offset >= data_size) goto gotnumber; + c = data[*data_offset]; + if (c == 44) { + (*data_offset)++; + goto gotnumber; + } + if ((c >= 48) && (c <= 55)) { // 0-7 + if (n_digits == 256) return 1; // Overflow + n_digit[n_digits] = c; + n_digits++; + n_hex = 2; + goto nexthexchr2; + } + return 3; // Syntax error + } + if ((c == 66) || (c == 98)) { // "B" or "b" + nexthexchr3: + (*data_offset)++; + if (*data_offset >= data_size) goto gotnumber; + c = data[*data_offset]; + if (c == 44) { + (*data_offset)++; + goto gotnumber; + } + if ((c >= 48) && (c <= 49)) { // 0-1 + if (n_digits == 256) return 1; // Overflow + n_digit[n_digits] = c; + n_digits++; + n_hex = 3; + goto nexthexchr3; + } + return 3; // Syntax error + } + return 3; // Syntax error + } // "&" readnextchr: if (c==44){(*data_offset)++; goto gotnumber;} @@ -13737,36 +13835,53 @@ int32 n_inputnumberfromfile(int32 fileno){ if (c==-1){return_value=2; goto error;}//input past end of file }while(c==32); - //hex/oct - if (c==38){//& - c=file_input_chr(fileno); if (c==-2) return 3; - if (c==-1) goto gotnumber; - if ((c==72)||(c==104)){//"H"or"h" - nexthexchr: - c=file_input_chr(fileno); if (c==-2) return 3; - if ( ((c>=48)&&(c<=57)) || ((c>=65)&&(c<=70)) || ((c>=97)&&(c<=102)) ){//0-9 or A-F or a-f - if (n_digits==256) goto error;//overflow - n_digit[n_digits]=c; - n_digits++; - n_hex=1; - goto nexthexchr; - } - goto gotnumber; - } - if ((c==79)||(c==111)){//"O"or"o" - nexthexchr2: - c=file_input_chr(fileno); if (c==-2) return 3; - if ((c>=48)&&(c<=55)){//0-7 - if (n_digits==256) goto error;//overflow - n_digit[n_digits]=c; - n_digits++; - n_hex=2; - goto nexthexchr2; - } - goto gotnumber; + // hex/oct/bin + if (c == 38) { // "&" + c = file_input_chr(fileno); + if (c == -2) return 3; + if (c == -1) goto gotnumber; + if ((c == 72) || (c == 104)) { // "H" or "h" + nexthexchr: + c = file_input_chr(fileno); + if (c == -2) return 3; + if (((c >= 48) && (c <= 57)) || ((c >= 65) && (c <= 70)) || + ((c >= 97) && (c <= 102))) { // 0-9 or A-F or a-f + if (n_digits == 256) goto error; // overflow + n_digit[n_digits] = c; + n_digits++; + n_hex = 1; + goto nexthexchr; } goto gotnumber; - }//& + } + if ((c == 79) || (c == 111)) { // "O" or "o" + nexthexchr2: + c = file_input_chr(fileno); + if (c == -2) return 3; + if ((c >= 48) && (c <= 55)) { // 0-7 + if (n_digits == 256) goto error; // overflow + n_digit[n_digits] = c; + n_digits++; + n_hex = 2; + goto nexthexchr2; + } + goto gotnumber; + } + if ((c == 66) || (c == 98)) { // "B" or "b" + nexthexchr3: + c = file_input_chr(fileno); + if (c == -2) return 3; + if ((c >= 48) && (c <= 49)) { // 0-1 + if (n_digits == 256) goto error; // overflow + n_digit[n_digits] = c; + n_digits++; + n_hex = 3; + goto nexthexchr3; + } + goto gotnumber; + } + goto gotnumber; + } // "&" readnextchr: if (c==-1) goto gotnumber; @@ -14052,7 +14167,7 @@ long double func_read_float(uint8 *data,ptrszint *data_offset,ptrszint data_size } if ((value>maxval)||(valuemaxval)||(valuewidth*d->height*d->bytes_per_pixel; d->offset=(uint8*)malloc(bytes); From 8cc5a157428535cf01a5464b1f4395def7e9583b Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Sun, 8 Dec 2019 11:53:19 -0300 Subject: [PATCH 6/6] Fixes menu glith reported in #107 --- source/ide/ide_methods.bas | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index 5161dd7b0..fd18960b5 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -4127,8 +4127,20 @@ FUNCTION ide2 (ignore) s = 0 parentMenu = 0 parentMenuSetup%% = 0 - IF idecontextualmenu = 1 THEN idectxmenuX = mX: idectxmenuY = mY: m = idecontextualmenuID - IF idecontextualmenu = 2 THEN idectxmenuX = xx + w + 3: idectxmenuY = yy + r: parentMenu = m: m = ViewMenuShowLineNumbersSubMenuID + SELECT CASE idecontextualmenu + CASE 1 + 'right-click on text area + idectxmenuX = mX + idectxmenuY = mY + m = idecontextualmenuID + CASE 2 + 'line numbers menu item in View menu + idectxmenuX = xx + w + 3 + idectxmenuY = yy + r + parentMenu = m + m = ViewMenuShowLineNumbersSubMenuID + END SELECT + IdeMakeEditMenu IF totalWarnings = 0 THEN @@ -4298,6 +4310,7 @@ FUNCTION ide2 (ignore) m = parentMenu r = parentMenuR parentMenu = 0 + parentMenuR = 0 idecontextualmenu = 0 PCOPY 3, 2 _CONTINUE @@ -4308,6 +4321,7 @@ FUNCTION ide2 (ignore) GOTO ideloop END IF END IF + IF NOT mouseup AND NOT mousedown THEN 'Check if we're hovering on menu options IF parentMenu > 0 AND oldmy <> mY AND oldmx <> mX AND _ mX >= backToParent.x1 AND mX =< backToParent.x2 AND _ @@ -4315,6 +4329,7 @@ FUNCTION ide2 (ignore) m = parentMenu r = parentMenuR parentMenu = 0 + parentMenuR = 0 idecontextualmenu = 0 PCOPY 3, 2 _CONTINUE @@ -4342,6 +4357,8 @@ FUNCTION ide2 (ignore) IF mX >= x AND mX < x2 THEN m = i r = 1 + parentMenuR = 0 + parentMenu = 0 IF idecontextualmenu > 1 THEN idecontextualmenu = 0: PCOPY 3, 2 EXIT FOR END IF