Page MenuHomeFeedback Tracker

Preprocessor is lacking correct string handling
New, NormalPublic

Description

The preprocessor that is used for arma 3 sqf scripts is not able to handle a double quote which is included in a single quoted string. E.G ' something " something' That results in one of your internal variables to be set to "alright no parsing until next double quote" and this leads to the error cases described below.

Details

Severity
Minor
Resolution
Open
Reproducibility
Always
Operating System
Windows 7
Operating System Version
latest stable build
Category
Scripting
Steps To Reproduce
#define arma3iscool configFile
diag_log('Your ' + getText( arma3iscool >> 'CfgVehicles' >> 'C_offroad_01_f' >> 'displayName' ) + ' is ready'); // works
diag_log('Your "' + getText( arma3iscool >> 'CfgVehicles' >> 'C_offroad_01_f' >> 'displayName' ) + '" is ready'); // does not work

results of this code executed in a .sqf script is:

2017/11/27, 21:45:05 "Your Offroad is ready"
2017/11/27, 21:45:05 Error in expression <s ready');
diag_log('Your "' + getText( arma3iscool >> 'CfgVehicles' >> 'C_offro>
2017/11/27, 21:45:05   Error position: <arma3iscool >> 'CfgVehicles' >> 'C_offro>
2017/11/27, 21:45:05   Error Undefined variable in expression: arma3iscool
2017/11/27, 21:45:05 File mpmissions\__cur_mp.Altis\init.sqf, line 7

Another case that shows that proves my above explaination:

diag_log('Your " s"' + getText( arma3iscool >> 'CfgVehicles' >> 'C_offroad_01_f' >> 'displayName' ) + 's " is ready'); // does not work

results in

2017/11/27, 22:05:14 Error in expression <' >> 'displayName' ) + 's " is ready'); // does not work>
2017/11/27, 22:05:14   Error position: <// does not work>
Additional Information
diag_log('Your "' + getText( configFile >> 'CfgVehicles' >> 'C_offroad_01_f' >> 'displayName' ) + '" is ready'); // works

valid output is

2017/11/27, 21:57:39 "Your ""Offroad"" is ready"

so this is legal SQF syntax

Event Timeline

Arkensor updated the task description. (Show Details)
dedmen added a subscriber: dedmen.Nov 28 2017, 11:59 AM

init.sqf content

#define arma3iscool configFile

diag_log ('Your ' + (getText (arma3iscool >> 'CfgVehicles' >> 'C_offroad_01_f' >> 'displayName' )) + ' is ready');// comment
diag_log ('Your "' + (getText (arma3iscool >> 'CfgVehicles' >> 'C_offroad_01_f' >> 'displayName' ))+ '" is ready');// comment
diag_log (
	'Your " s"' 
	+ 
	(getText (arma3iscool >> 'CfgVehicles' >> 'C_offroad_01_f' >> 'displayName' ))
	+ 
	's " is ready'
); // comment

Preprocessor output

"#line 1 ""xxx.VR\init.sqf""

diag_log ('Your ' + (getText (configFile >> 'CfgVehicles' >> 'C_offroad_01_f' >> 'displayName' )) + ' is ready'); 
diag_log ('Your ""' + (getText (arma3iscool >> 'CfgVehicles' >> 'C_offroad_01_f' >> 'displayName' ))+ '"" is ready'); 
diag_log (
'Your "" s""' 
+ 
(getText (configFile >> 'CfgVehicles' >> 'C_offroad_01_f' >> 'displayName' ))
+ 
's "" is ready'
); // comment"