Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__FB_ARG_EXTRACT__ incorrectly recognizes commas nested in other forms with variadic macros #321

Closed
jayrm opened this issue Jun 18, 2021 · 2 comments

Comments

@jayrm
Copy link
Member

jayrm commented Jun 18, 2021

__FB_ARG_EXTRACT__ currently uses a simple internal compiler procedure hSplitStr() to find the arguments in text; this procedure does not recognize other common forms found in fbc source code.

As shown in the following example, we should expect same output for both DUMP1() and DUMPX() macros.

Example:

#macro dump1( n, arg0, arg1 )
	#print arg1
	#print
#endmacro

#print DUMP1
dump1( 1, x, (y, z) )   '' expect (y, z)
dump1( 1, x, "y, z" )   '' expect "y, z"
dump1( 1, x, $"y, z" )  '' expect "y, z"
dump1( 1, x, !"y, z" )  '' expect "y, z"
dump1( 1, x, /'y, z'/ ) '' expect ""

#macro dumpX( n, args... )
	#print __fb_arg_extract__( n, args )
	#print
#endmacro

#print DUMPX
dumpX( 1, x, (y, z) )   '' expect (y, z)
dumpX( 1, x, "y, z" )   '' expect "y, z"
dumpX( 1, x, $"y, z" )  '' expect "y, z"
dumpX( 1, x, !"y, z" )  '' expect "y, z"
dumpX( 1, x, /'y, z'/ ) '' expect ""

/'
OUTPUT:

DUMP1
(y, z)
y, z
y, z
y, z
DUMPX
(y
args.bas(20) warning 12(1): Missing closing quote in literal string
y
args.bas(21) warning 12(1): Missing closing quote in literal string
y
args.bas(22) warning 12(1): Missing closing quote in literal string
y
'/

Currently working on a fix by implementing a hStr2Args() procedure that recognizes comma's nested in parentheses, quotes, and comments.

@jayrm jayrm changed the title __FB_ARG_EXTRACT__ incorrectly recognizes commas nested in other forms __FB_ARG_EXTRACT__ incorrectly recognizes commas nested in other forms with variadic macros Jun 19, 2021
@jayrm
Copy link
Member Author

jayrm commented Jun 19, 2021

It is suggested that the above example be changed as follows:

??? - maybe this was supposed to be an example for #312 ?

ok, updated the title of this PR. The issue is with variadic macros. In the original example given in this PR we should expect same output for dump1() and dumpx()

@jayrm
Copy link
Member Author

jayrm commented Jun 19, 2021

__FB_ARG_EXTRACT__ variadic argument parsing changed in:

fbc-1.08.1 [28d7adb]
fbc-1.09.0 [146862f]

@jayrm jayrm closed this as completed Jun 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant