Skip to content

Commit 0576525

Browse files
committed
Disallow commas/newlines after SPC/TAB
They aren't that useful, and were broken - acting as if a semicolon followed. Now only semicolons are allowed, but that could be reexamined in future releases. There is currently no implementation support for them though, so the code would have to be complicated a little.
1 parent 7b5946c commit 0576525

File tree

4 files changed

+18
-56
lines changed

4 files changed

+18
-56
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Version 1.01.0
5656
- #723: LINE clipping now doesn't affect which (unclipped) pixels are plotted, eliminating rounding differences and correctly preserving the position of the style bits
5757
- BLOAD now gives an error if it encounters a BMP file with an unknown header size
5858
- BLOAD was misreading bitfields in BMP files with undocumented BITMAPV3HEADER format (56-byte headers)
59+
- PRINT now disallows commas/newlines after SPC/TAB, instead of silently ignoring them
5960

6061

6162
Version 1.00.0 (former 0.91.0):

src/compiler/parser-quirk-file.bas

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,29 +117,26 @@ function cPrintStmt _
117117
issemicolon = TRUE
118118
end if
119119

120+
if( (isspc or istab) and (issemicolon = FALSE) ) then
121+
'' only semicolons are supported after SPC()/TAB() (QB editor autocorrected them)
122+
errReport( FB_ERRMSG_EXPECTEDSEMICOLON )
123+
end if
124+
120125
'' handle PRINT w/o expressions
121126
if( (iscomma = FALSE) and _
122127
(issemicolon = FALSE) and _
123128
(expr = NULL) ) then
124129
exit do
125130
end if
126131

127-
if( isspc ) then
132+
if( isspc or istab ) then
128133
filexprcopy = astCloneTree( filexpr )
129134
if( rtlPrintSPC( filexprcopy, _
130135
expr, _
136+
istab, _
131137
islprint ) = FALSE ) then
132138
exit function
133139
end if
134-
135-
elseif( istab ) then
136-
filexprcopy = astCloneTree( filexpr )
137-
if( rtlPrintTab( filexprcopy, _
138-
expr, _
139-
islprint ) = FALSE ) then
140-
exit function
141-
end if
142-
143140
else
144141
if( usingexpr = NULL /'or expr = NULL'/ ) then
145142
/' (commented check allows multiple consecutive commas/semicolons in USING statements.

src/compiler/rtl-print.bas

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -790,11 +790,12 @@ function rtlPrint _
790790
end function
791791

792792
'':::::
793-
function rtlPrintSPC _
793+
function rtlPrintSPCTab _
794794
( _
795795
byval fileexpr as ASTNODE ptr, _
796796
byval expr as ASTNODE ptr, _
797-
byval islprint as integer = FALSE _
797+
byval istab as integer, _
798+
byval islprint as integer = FALSE _
798799
) as integer
799800

800801
dim as ASTNODE ptr proc = any
@@ -806,7 +807,11 @@ function rtlPrintSPC _
806807
end if
807808

808809
''
809-
proc = astNewCALL( PROCLOOKUP( PRINTSPC ) )
810+
if( istab ) then
811+
proc = astNewCALL( PROCLOOKUP( PRINTSPC ) )
812+
else
813+
proc = astNewCALL( PROCLOOKUP( PRINTTAB ) )
814+
end if
810815

811816
'' byval filenum as integer
812817
if( astNewARG( proc, fileexpr ) = NULL ) then
@@ -824,41 +829,6 @@ function rtlPrintSPC _
824829

825830
end function
826831

827-
'':::::
828-
function rtlPrintTab _
829-
( _
830-
byval fileexpr as ASTNODE ptr, _
831-
byval expr as ASTNODE ptr, _
832-
byval islprint as integer = FALSE _
833-
) as integer
834-
835-
dim as ASTNODE ptr proc = any
836-
837-
function = FALSE
838-
839-
if islprint then
840-
rtlPrinter_cb( NULL )
841-
end if
842-
843-
''
844-
proc = astNewCALL( PROCLOOKUP( PRINTTAB ) )
845-
846-
'' byval filenum as integer
847-
if( astNewARG( proc, fileexpr ) = NULL ) then
848-
exit function
849-
end if
850-
851-
'' byval newcol as integer
852-
if( astNewARG( proc, expr ) = NULL ) then
853-
exit function
854-
end if
855-
856-
astAdd( proc )
857-
858-
function = TRUE
859-
860-
end function
861-
862832
'':::::
863833
function rtlWrite _
864834
( _

src/compiler/rtl.bi

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,17 +1269,11 @@ declare function rtlPrint _
12691269
byval islprint as integer = FALSE _
12701270
) as integer
12711271

1272-
declare function rtlPrintSPC _
1273-
( _
1274-
byval fileexpr as ASTNODE ptr, _
1275-
byval expr as ASTNODE ptr, _
1276-
byval islprint as integer = FALSE _
1277-
) as integer
1278-
1279-
declare function rtlPrintTab _
1272+
declare function rtlPrintSPCTab _
12801273
( _
12811274
byval fileexpr as ASTNODE ptr, _
12821275
byval expr as ASTNODE ptr, _
1276+
byval istab as integer, _
12831277
byval islprint as integer = FALSE _
12841278
) as integer
12851279

0 commit comments

Comments
 (0)