From 9b0ff95b0d13eca06e550d8605bdc6f47eb827b9 Mon Sep 17 00:00:00 2001 From: SteveMcNeill Date: Wed, 17 Oct 2018 14:03:44 -0400 Subject: [PATCH 1/6] Fix to _PRINTSTRING bug fix so that printstring will work correctly when the optional imagehandle is used. _PRINTSTRING (x,y), text$, optional_imagehandle --- internal/c/libqb.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/internal/c/libqb.cpp b/internal/c/libqb.cpp index d2b397741..7c3119268 100644 --- a/internal/c/libqb.cpp +++ b/internal/c/libqb.cpp @@ -18748,27 +18748,31 @@ void sub_put2(int32 i,int64 offset,void *element,int32 passed){ void sub__printstring(float x,float y,qbs* text,int32 i,int32 passed){ if (new_error) return; + + int32 old_dest = func__dest(); + if (passed&2){ + sub__dest(i); if (i>=0){//validate i validatepage(i); i=page[i]; }else{ - i=-i; if (i>=nextimg){error(258); return;} if (!img[i].valid){error(258); return;} + i=-i; if (i>=nextimg){error(258); goto printstring_exit;} if (!img[i].valid){error(258); goto printstring_exit;} } }else{ i=write_page_index; } static img_struct *im; im=&img[i]; - if (!text->len) return; + if (!text->len) goto printstring_exit; if (im->text){ int oldx = func_pos(0), oldy = func_csrlin(); qbg_sub_locate(y, x, 0, 0, 0, 3); qbs_print(text, 0); qbg_sub_locate(oldy, oldx, 0, 0, 0, 3); - return; + goto printstring_exit; } //graphics modes only - if (!text->len) return; + if (!text->len) goto printstring_exit; //Step? if (passed&1){im->x+=x; im->y+=y;}else{im->x=x; im->y=y;} //Adjust co-ordinates for viewport? @@ -18784,7 +18788,7 @@ void sub_put2(int32 i,int64 offset,void *element,int32 passed){ x2=qbr_float_to_long(im->x); y2=qbr_float_to_long(im->y); } - if (!text->len) return; + if (!text->len) goto printstring_exit; static uint32 w,h,z,z2,z3,a,a2,a3,color,background_color,f; @@ -18810,7 +18814,7 @@ void sub_put2(int32 i,int64 offset,void *element,int32 passed){ // uint8**out_data,int32*out_x,int32 *out_y,int32*out_x_pre_increment,int32*out_x_post_increment){ ok=FontRenderTextASCII(font[f],(uint8*)text->chr,text->len,1, &rt_data,&rt_w,&rt_h,&rt_pre_x,&rt_post_x); - if (!ok) return; + if (!ok) goto printstring_exit; w=rt_w; @@ -18841,7 +18845,7 @@ void sub_put2(int32 i,int64 offset,void *element,int32 passed){ } free(rt_data); - return; + goto printstring_exit; }//1-8 bit //assume 32-bit blended @@ -18857,7 +18861,7 @@ void sub_put2(int32 i,int64 offset,void *element,int32 passed){ ok=FontRenderTextASCII(font[f],(uint8*)text->chr,text->len,0, &rt_data,&rt_w,&rt_h,&rt_pre_x,&rt_post_x); - if (!ok) return; + if (!ok) goto printstring_exit; w=rt_w; @@ -18919,7 +18923,7 @@ void sub_put2(int32 i,int64 offset,void *element,int32 passed){ break; } free(rt_data); - return; + goto printstring_exit; }//custom font //default fonts @@ -18950,6 +18954,7 @@ void sub_put2(int32 i,int64 offset,void *element,int32 passed){ } x+=8; }//z + if (passed&2) sub__dest(old_dest); return; } From 6844913b8eb127533c62cc3764a4ba6c92d794c0 Mon Sep 17 00:00:00 2001 From: SteveMcNeill Date: Wed, 17 Oct 2018 14:09:42 -0400 Subject: [PATCH 2/6] Fix to fix Forgot to add the goto label... /blush --- internal/c/libqb.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/c/libqb.cpp b/internal/c/libqb.cpp index 7c3119268..5c6adedf0 100644 --- a/internal/c/libqb.cpp +++ b/internal/c/libqb.cpp @@ -18954,6 +18954,8 @@ void sub_put2(int32 i,int64 offset,void *element,int32 passed){ } x+=8; }//z + + printstring_exit: if (passed&2) sub__dest(old_dest); return; } From 505556a1c7c8fa4015adcdf0f6b689622f17cc8e Mon Sep 17 00:00:00 2001 From: SteveMcNeill Date: Wed, 17 Oct 2018 17:14:19 -0400 Subject: [PATCH 3/6] Change for 64-bit compatability change so that the windowhandle will return a 64-bit value for QB64x64 versions, while returning a 32-bit value for QB64. This allows for upgrade to 64-bit to be as simple as just swapping compilers and then rebuilding QB64 with the setup script. --- internal/c/libqb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/c/libqb.cpp b/internal/c/libqb.cpp index 5c6adedf0..4c8f3090b 100644 --- a/internal/c/libqb.cpp +++ b/internal/c/libqb.cpp @@ -12595,7 +12595,7 @@ int32 func__handle(){ #ifdef QB64_GUI #ifdef QB64_WINDOWS while (!window_handle){Sleep(100);} - return (int32)window_handle; + return (ptrszint)window_handle; #endif #endif From 4787076573f249d86ff0255453283dda6f7c3a41 Mon Sep 17 00:00:00 2001 From: SteveMcNeill Date: Sun, 21 Oct 2018 23:01:22 -0400 Subject: [PATCH 4/6] Fix for $LET/$IF Fix to the precompiler so $IF/$LET work as expected. Adds ability to see if a precompiler variable is DEFINED or UNDEFINED, to exclude duplicate code in libraries and such. --- source/qb64.bas | 160 ++++++++++++++++++------------------------------ 1 file changed, 61 insertions(+), 99 deletions(-) diff --git a/source/qb64.bas b/source/qb64.bas index ca9412b65..3e646b49f 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -1757,62 +1757,6 @@ DO END IF END IF - IF LEFT$(temp$, 5) = "$LET " THEN - temp$ = LTRIM$(MID$(temp$, 5)) 'simply shorten our string to parse - 'For starters, let's make certain that we have 3 elements to deal with - temp = INSTR(temp$, "=") 'without an = in there, we can't get a value from the left and right side - IF temp = 0 THEN a$ = "Invalid Syntax. $LET = ": GOTO errmes - l$ = RTRIM$(LEFT$(temp$, temp - 1)): r$ = LTRIM$(MID$(temp$, temp + 1)) - 'then validate to make certain the left side looks proper - l1$ = "" - FOR i = 1 TO LEN(l$) - a = ASC(l$, i) - SELECT CASE a - CASE 32 'strip out spaces - CASE 46: l1$ = l1$ + CHR$(a) - CASE IS < 48, IS > 90: a$ = "Invalid symbol left of equal sign (" + CHR$(a) + ")": GOTO errmes - CASE ELSE: l1$ = l1$ + CHR$(a) - END SELECT - NEXT - l$ = l1$ - IF LEFT$(r$, 1) = CHR$(34) THEN r$ = LTRIM$(MID$(r$, 2)) - IF RIGHT$(r$, 1) = CHR$(34) THEN r$ = RTRIM$(LEFT$(r$, LEN(r$) - 1)) - IF LEFT$(r$, 1) = "-" THEN - r1$ = "-" - r$ = LTRIM$(MID$(r$, 2)) - ELSE - r1$ = "" - END IF - 'then validate to make certain the left side looks proper - FOR i = 1 TO LEN(r$) - a = ASC(r$, i) - SELECT CASE a - CASE 32 - CASE 46 'periods are fine. - r1$ = r1$ + "." - CASE IS < 48, IS > 90 - a$ = "Invalid symbol right of equal sign (" + CHR$(a) + ")": GOTO errmes - CASE ELSE - r1$ = r1$ + CHR$(a) - END SELECT - NEXT - r$ = r1$ - layout$ = "$LET " + l$ + " = " + r$ - 'First look to see if we have an existing setting like this and if so, update it - FOR i = 7 TO UserDefineCount 'UserDefineCount 1-6 are reserved for automatic OS/BIT detection - IF UserDefine(0, i) = l$ THEN UserDefine(1, i) = r$: GOTO finishedlinepp - NEXT - 'Otherwise create a new setting and set the initial value for it - UserDefineCount = UserDefineCount + 1 - IF UserDefineCount > UBOUND(UserDefine, 2) THEN - REDIM _PRESERVE UserDefine(1, UBOUND(UserDefine, 2) + 10) 'Add another 10 elements to the array so it'll expand as the user adds to it - END IF - UserDefine(0, UserDefineCount) = l$ - UserDefine(1, UserDefineCount) = r$ - GOTO finishedlinepp - END IF - - IF LEFT$(temp$, 4) = "$IF " THEN IF RIGHT$(temp$, 5) <> " THEN" THEN a$ = "$IF without THEN": GOTO errmes temp$ = LTRIM$(MID$(temp$, 4)) 'strip off the $IF and extra spaces @@ -1884,6 +1828,60 @@ DO GOTO finishedlinepp 'we don't check for anything inside lines that we've marked for skipping END IF + IF LEFT$(temp$, 5) = "$LET " THEN + temp$ = LTRIM$(MID$(temp$, 5)) 'simply shorten our string to parse + 'For starters, let's make certain that we have 3 elements to deal with + temp = INSTR(temp$, "=") 'without an = in there, we can't get a value from the left and right side + IF temp = 0 THEN a$ = "Invalid Syntax. $LET = ": GOTO errmes + l$ = RTRIM$(LEFT$(temp$, temp - 1)): r$ = LTRIM$(MID$(temp$, temp + 1)) + 'then validate to make certain the left side looks proper + l1$ = "" + FOR i = 1 TO LEN(l$) + a = ASC(l$, i) + SELECT CASE a + CASE 32 'strip out spaces + CASE 46: l1$ = l1$ + CHR$(a) + CASE IS < 48, IS > 90: a$ = "Invalid symbol left of equal sign (" + CHR$(a) + ")": GOTO errmes + CASE ELSE: l1$ = l1$ + CHR$(a) + END SELECT + NEXT + l$ = l1$ + IF LEFT$(r$, 1) = CHR$(34) THEN r$ = LTRIM$(MID$(r$, 2)) + IF RIGHT$(r$, 1) = CHR$(34) THEN r$ = RTRIM$(LEFT$(r$, LEN(r$) - 1)) + IF LEFT$(r$, 1) = "-" THEN + r1$ = "-" + r$ = LTRIM$(MID$(r$, 2)) + ELSE + r1$ = "" + END IF + 'then validate to make certain the left side looks proper + FOR i = 1 TO LEN(r$) + a = ASC(r$, i) + SELECT CASE a + CASE 32 + CASE 46 'periods are fine. + r1$ = r1$ + "." + CASE IS < 48, IS > 90 + a$ = "Invalid symbol right of equal sign (" + CHR$(a) + ")": GOTO errmes + CASE ELSE + r1$ = r1$ + CHR$(a) + END SELECT + NEXT + r$ = r1$ + layout$ = "$LET " + l$ + " = " + r$ + 'First look to see if we have an existing setting like this and if so, update it + FOR i = 7 TO UserDefineCount 'UserDefineCount 1-6 are reserved for automatic OS/BIT detection + IF UserDefine(0, i) = l$ THEN UserDefine(1, i) = r$: GOTO finishedlinepp + NEXT + 'Otherwise create a new setting and set the initial value for it + UserDefineCount = UserDefineCount + 1 + IF UserDefineCount > UBOUND(UserDefine, 2) THEN + REDIM _PRESERVE UserDefine(1, UBOUND(UserDefine, 2) + 10) 'Add another 10 elements to the array so it'll expand as the user adds to it + END IF + UserDefine(0, UserDefineCount) = l$ + UserDefine(1, UserDefineCount) = r$ + GOTO finishedlinepp + END IF @@ -3028,13 +3026,9 @@ DO 'precompiler commands should always be executed FIRST. - IF LEFT$(a3u$, 5) = "$LET " THEN layout$ = a3$: GOTO finishednonexec 'we dealt with this basically in the prepass - ' so we could define CONST and such and have them available for later IDE passes + IF InValidLine(linenumber) THEN layoutdone = 0: GOTO finishednonexec 'We do nothing if the PC has already determined a line to be invalid IF a3u$ = "$END IF" OR a3u$ = "$ENDIF" THEN - IF DefineElse(ExecCounter) = 0 THEN a$ = "$END IF without $IF": GOTO errmes - DefineElse(ExecCounter) = 0 'We no longer have an $IF block at this level - ExecCounter = ExecCounter - 1 layout$ = "$END IF" controltype(controllevel) = 0 controllevel = controllevel - 1 @@ -3046,16 +3040,6 @@ DO temp$ = RTRIM$(LEFT$(temp$, LEN(temp$) - 4)) 'and strip off the THEN and extra spaces temp = INSTR(temp$, "=") - ExecCounter = ExecCounter + 1 - ExecLevel(ExecCounter) = -1 'default to a skip value - DefineElse(ExecCounter) = 1 '1 says we have an $IF statement at this level - result = EvalPreIF(temp$, a$) - IF a$ <> "" THEN GOTO errmes - IF result <> 0 THEN - ExecLevel(ExecCounter) = ExecLevel(ExecCounter - 1) 'So we inherit the execlevel from above - IF ExecLevel(ExecCounter) = 0 THEN DefineElse(ExecCounter) = DefineElse(ExecCounter) OR 4 'Else if used and conditon found - END IF - controllevel = controllevel + 1 controltype(controllevel) = 6 IF temp = 0 THEN layout$ = "$IF " + temp$ + " THEN": GOTO finishednonexec 'no = sign in the $IF statement, so we're going to assume the user is doing something like $IF flag @@ -3065,14 +3049,6 @@ DO END IF IF a3u$ = "$ELSE" THEN - IF DefineElse(ExecCounter) = 0 THEN a$ = "$ELSE without $IF": GOTO errmes - IF DefineElse(ExecCounter) AND 2 THEN a$ = "$IF block already has $ELSE statement in it": GOTO errmes - DefineElse(ExecCounter) = DefineElse(ExecCounter) OR 2 'set the flag to declare an $ELSE already in this block - IF DefineElse(ExecCounter) AND 4 THEN 'If we executed code in a previous IF or ELSE IF statement, we can't do it here - ExecLevel(ExecCounter) = -1 'So we inherit the execlevel from above - ELSE - ExecLevel(ExecCounter) = ExecLevel(ExecCounter - 1) 'If we were processing code before, code after this segment is going to be SKIPPED - END IF layout$ = "$ELSE" lhscontrollevel = lhscontrollevel - 1 GOTO finishednonexec @@ -3081,23 +3057,8 @@ DO IF LEFT$(a3u$, 5) = "$ELSE" THEN temp$ = LTRIM$(MID$(a3u$, 6)) IF LEFT$(temp$, 3) = "IF " THEN - IF DefineElse(ExecCounter) = 0 THEN a$ = "$ELSE IF without $IF": GOTO errmes - IF DefineElse(ExecCounter) AND 2 THEN a$ = "$ELSE IF cannot follow $ELSE": GOTO errmes - IF RIGHT$(temp$, 5) <> " THEN" THEN a$ = "$ELSE IF without THEN": GOTO errmes temp$ = LTRIM$(MID$(temp$, 3)) 'strip off the IF and extra spaces temp$ = RTRIM$(LEFT$(temp$, LEN(temp$) - 4)) 'and strip off the THEN and extra spaces - IF DefineElse(ExecCounter) AND 4 THEN 'If we executed code in a previous IF or ELSE IF statement, we can't do it here - ExecLevel(ExecCounter) = -1 - ELSE - result = EvalPreIF(temp$, a$) - IF a$ <> "" THEN GOTO errmes - IF result <> 0 THEN - ExecLevel(ExecCounter) = ExecLevel(ExecCounter - 1) 'So we inherit the execlevel from above - IF ExecLevel(ExecCounter) = 0 THEN DefineElse(ExecCounter) = DefineElse(ExecCounter) OR 4 'Else if used and conditon found - END IF - END IF - - lhscontrollevel = lhscontrollevel - 1 temp = INSTR(temp$, "=") IF temp = 0 THEN layout$ = "$ELSEIF " + temp$ + " THEN": GOTO finishednonexec 'no = sign in the $IF statement, so we're going to assume the user is doing something like $IF flag @@ -3107,10 +3068,8 @@ DO END IF END IF - IF ExecLevel(ExecCounter) THEN 'don't check for any more metacommands except the one's which worth with the precompiler - layoutdone = 0 - GOTO finishednonexec 'we don't check for anything inside lines that we've marked for skipping - END IF + IF LEFT$(a3u$, 5) = "$LET " THEN layout$ = a3$: GOTO finishednonexec 'we dealt with this basically in the prepass + ' so we could define CONST and such and have them available for later IDE passes @@ -25227,9 +25186,13 @@ FUNCTION EvalPreIF (text$, err$) NEXT END IF IF INSTR(symbol$, "=") THEN 'check to see if we're equal in any case with = + UserFound = 0 FOR i = 0 TO UserDefineCount IF UserDefine(0, i) = l$ AND UserDefine(1, i) = r$ THEN result$ = " -1 ": GOTO finishedcheck + IF UserDefine(0, i) = l$ THEN UserFound = -1 NEXT + IF NOT UserFound AND LTRIM$(RTRIM$(r$)) = "UNDEFINED" THEN result$ = " -1 ": GOTO finishedcheck + IF UserFound AND LTRIM$(RTRIM$(r$)) = "DEFINED" THEN result$ = " -1 ": GOTO finishedcheck END IF IF INSTR(symbol$, ">") THEN 'check to see if we're greater than in any case with > @@ -25332,7 +25295,6 @@ FUNCTION EvalPreIF (text$, err$) END IF NEXT END IF - END SUB FUNCTION VerifyNumber (text$) From 67af468b7d74b793ed1e442c89dbee83e67c8894 Mon Sep 17 00:00:00 2001 From: SteveMcNeill Date: Mon, 22 Oct 2018 01:02:48 -0400 Subject: [PATCH 5/6] Fix memory leak with PRINT USING When USING follows another print in the same statement (such as PRINT "123"; USING "###"; 456), it created a memory leak due to the temp variable being created twice and only freed once. This patch corrects that issue. --- source/qb64.bas | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/qb64.bas b/source/qb64.bas index 3e646b49f..e3a6153ef 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -22335,7 +22335,7 @@ SUB xprint (a$, ca$, n) IF puformat$ = "" THEN Give_Error "Expected PRINT USING formatstring ; ...": EXIT SUB IF i = n THEN Give_Error "Expected PRINT USING formatstring ; ...": EXIT SUB 'create build string - PRINT #12, "tqbs=qbs_new(0,0);" + IF TQBSset = 0 THEN PRINT #12, "tqbs=qbs_new(0,0);" 'set format start/index variable PRINT #12, "tmp_long=0;" 'scan format from beginning @@ -22439,6 +22439,7 @@ SUB xprint (a$, ca$, n) e$ = "" last = 0 PRINT #12, "tqbs=qbs_new(0,0);" 'initialize the temp string + TQBSset = -1 'set the temporary flag so we don't create a temp string twice, in case USING comes after something FOR i = 2 TO n a2$ = getelement(ca$, i) IF a2$ = "(" THEN b = b + 1 From 96947193fc34f7f75fa69689ef086304eee3f828 Mon Sep 17 00:00:00 2001 From: Luke Ceddia Date: Tue, 23 Oct 2018 23:26:23 +1100 Subject: [PATCH 6/6] Remove README for Linux and OS X --- README for Linux and OS X.txt | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 README for Linux and OS X.txt diff --git a/README for Linux and OS X.txt b/README for Linux and OS X.txt deleted file mode 100644 index ac7a94b1f..000000000 --- a/README for Linux and OS X.txt +++ /dev/null @@ -1,12 +0,0 @@ -If you have problems running the install scripts under Linux (./setup_lnx.sh) or OS X (./setup_osx.command), run the following line in terminal, from your QB64 folder: - -For Linux: -find . -name '*.sh' -exec sed -i "s/\r//g" {} \; - -For OS X (don't forget you need to have Xcode installed to use QB64): -find . -name '*.command' -exec perl -pi -e 's/\r\n|\n|\r/\n/g' {} \; - -If you have any other issues, check out the Forum: -http://www.qb64.net/forum/ - -http://www.qb64.net/forum/index.php?topic=13359.msg115525#msg115525 \ No newline at end of file