Page MenuHomeFeedback Tracker

preprocessing a script that contains a problematic string can fail to remove comment lines
Closed, ResolvedPublic

Description

Let's say having a SQF file that contains t his:

_a = '"' ;
// comment

Where _a contains a string with a single double quotation mark. compile preprocessFileLineNumbers ing this SQF returns an error and fails to compile because preprocessed code still have the comment.
Having both that string and a comment can cause this. No comment line there won't throw an error.

Details

Severity
Minor
Resolution
Won't Fix
Reproducibility
Always
Operating System
Windows 10 x64
Category
Scripting

Event Timeline

POLPOX created this task.Dec 25 2023, 1:12 PM
Leopard20 closed this task as Resolved.
Leopard20 changed Resolution from Open to Won't Fix.
Leopard20 added a comment.EditedDec 28 2023, 7:04 PM

Looks like every preprocessor thing still works in single quotes '
So unfortunately I don't think we can fix this, for backward compatibility.
One example would be this (tho not sure if someone even does this at all):

#define MACRO 1
_script = '
systemChat "MACRO"
';

call compile _script;

If it ignored double quotes " in single quotes ', calling _script would print 1 instead of MACRO
Also to expand your ticket, there are many more cases that will break the preprocessing, for example:
'// this becomes a comment'

it'll PP into just ', which is a compile error