Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 23, 2026

parseCompilerArgs.bat fails when parsing macro definitions containing numeric expressions like -D'LFS_ASSERT(test)'='do { if(!(test)) {return -1;} } while(0)'. The -1 inside the quoted value was incorrectly matched as a compiler switch.

Root Cause

The regex pattern ([a-zA-Z0-9_]+) in parseAnySwitchFromToolArguments matches any alphanumeric sequence after -, including -1. This splits quoted strings at the wrong boundary.

Fix

Require switch names to start with a letter:

- "([a-zA-Z0-9_]+)"
+ "([a-zA-Z][a-zA-Z0-9_]*)"

This prevents numeric tokens like -1, -2, etc. from being matched as switches while still matching valid switches like -D, -Wall, -std.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug] parseCompilerArgs.bat fails if argument contains a space</issue_title>
<issue_description>### Brief Issue Summary

I have a makefile with this line :
-D'LFS_ASSERT(test)'='do { if(!(test)) {return -1;} } while(0)' \

The makefile works and makefile-tools is able to parse it and run make tasks.

But when configuring cpptools to use makefile-tools as a configuration provider, parseCompilerArgs.bat fails :

Error running the compiler args parser script c:\Users\ep.t.fasquelle\.vscode\extensions\ms-vscode.makefile-tools-0.12.17\assets\parseCompilerArgs.bat for regions (   -mcpuDONT_USE_EQUAL_AS_SEPARATORtc37xx -mtc162 -save-tempsDONT_USE_EQUAL_AS_SEPARATORobj              -ffunction-sections -fdata-sections -mpragma-data-sections -mpragma-function-sections -fstrict-volatile-bitfields -fgcse -fgcse-sm -fgcse-lm -fgcse-after-reload -ffast-math -funswitch-loops -fpredictive-commoning -fipa-cp-clone -fpeel-loops -fmove-loop-invariants -funroll-loops -finline-is-always-inline -Wall -Wextra -Wundef -Wshadow -Wdouble-promotion -Werror-implicit-function-declaration -Wuninitialized -Wno-missing-field-initializers -Wno-type-limits -fno-strict-aliasing -fno-builtin -fno-common -O0 -g3 -iquote -maligned-data-sections -Wmissing-prototypes -1;} } while(0)' -c -o  obj/Dal.o ../../SDK/DAL/Dal.c): ' �tait inattendu.

The compiler args parser script 'c:\Users\ep.t.fasquelle\.vscode\extensions\ms-vscode.makefile-tools-0.12.17\assets\parseCompilerArgs.bat' failed with error code    -mcpuDONT_USE_EQUAL_AS_SEPARATORtc37xx -mtc162 -save-tempsDONT_USE_EQUAL_AS_SEPARATORobj              -ffunction-sections -fdata-sections -mpragma-data-sections -mpragma-function-sections -fstrict-volatile-bitfields -fgcse -fgcse-sm -fgcse-lm -fgcse-after-reload -ffast-math -funswitch-loops -fpredictive-commoning -fipa-cp-clone -fpeel-loops -fmove-loop-invariants -funroll-loops -finline-is-always-inline -Wall -Wextra -Wundef -Wshadow -Wdouble-promotion -Werror-implicit-function-declaration -Wuninitialized -Wno-missing-field-initializers -Wno-type-limits -fno-strict-aliasing -fno-builtin -fno-common -O0 -g3 -iquote -maligned-data-sections -Wmissing-prototypes -1;} } while(0)' -c -o  obj/Dal.o ../../SDK/DAL/Dal.c for regions (undefined)
Sending configuration for file c:\Users\ep.t.fasquelle\Documents\dev\<censored>\SDK\DAL\Dal.c -----------------------------------

(I think ' �tait inattendu should be ' was unexpected here in English)

Debug Log

I believe the above should suffice and I would prefer not spend time sanitizing this very long output.
If you believe you really need the information from debug log I will do it.

Additional Information

No response</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 23, 2026 20:27
Co-authored-by: snehara99 <113148726+snehara99@users.noreply.github.com>
Co-authored-by: snehara99 <113148726+snehara99@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix parseCompilerArgs.bat failure with space in argument Fix parseCompilerArgs.bat failure when arguments contain spaces in quoted strings Jan 23, 2026
Copilot AI requested a review from snehara99 January 23, 2026 20:30
@snehara99
Copy link
Contributor

@copilot I'm getting the following errors now when I run Makefile: Configure:

Saving opened files before build.
Generating configuration cache with command: 'C:\msys64\usr\bin\make.exe --dry-run --keep-going --print-directory'
Writing the dry-run output: c:\Users\snehara\Downloads\makefile-tools_bug_repro\makefile-tools_bug_repro\.vscode\dryrun.log
Generating dry-run elapsed time: 0
Preprocessing: "c:\Users\snehara\Downloads\makefile-tools_bug_repro\makefile-tools_bug_repro\.vscode\dryrun.log"
Preprocess elapsed time: 0
Parsing for IntelliSense.
Updating the CppTools IntelliSense Configuration Provider.
Parsing dry-run output for CppTools Custom Configuration Provider.
Error running the compiler args parser script c:\Users\snehara\vscode-makefile-tools\assets\parseCompilerArgs.bat for regions ( -1;} } while(0)'DONT_USE_SPACE_AS_SEPARATORmain.cDONT_USE_SPACE_AS_SEPARATOR-oDONT_USE_SPACE_AS_SEPARATORmain): 'DONT_USE_SPACE_AS_SEPARATORmain.cDONT_USE_SPACE_AS_SEPARATOR-oDONT_USE_SPACE_AS_SEPARATORmain) was unexpected at this time.

The compiler args parser script 'c:\Users\snehara\vscode-makefile-tools\assets\parseCompilerArgs.bat' failed with error code 255 for regions ( -1;} } while(0)'DONT_USE_SPACE_AS_SEPARATORmain.cDONT_USE_SPACE_AS_SEPARATOR-oDONT_USE_SPACE_AS_SEPARATORmain)
Sending configuration for file c:\Users\snehara\Downloads\makefile-tools_bug_repro\makefile-tools_bug_repro\main.c -----------------------------------
Parsing for IntelliSense elapsed time: 0
Parsing for launch targets.
Found the following 1 new launch targets defined in the makefile: c:\Users\snehara\Downloads\makefile-tools_bug_repro\makefile-tools_bug_repro>main()
Complete list of launch targets: c:\Users\snehara\Downloads\makefile-tools_bug_repro\makefile-tools_bug_repro>main()
Parsing for launch targets elapsed time: 0
Generating parse content for build targets.
Generating targets information with command: 'C:\msys64\usr\bin\make.exe all --print-data-base --no-builtin-variables --no-builtin-rules --question'
Writing the dry-run output: c:\Users\snehara\Downloads\makefile-tools_bug_repro\makefile-tools_bug_repro\.vscode\targets.log
Generating dry-run elapsed time: 0
Parsing for build targets from: "c:\Users\snehara\Downloads\makefile-tools_bug_repro\makefile-tools_bug_repro\.vscode\targets.log"
Found the following 5 new build targets defined in the makefile: all;clean;main;rebuild;run
Complete list of build targets: all;clean;main;rebuild;run
Parsing build targets elapsed time: 0
Configure finished. The status for all the subphases that ran:
generateParseContent: return code = 0, elapsed time = 0
preprocessParseContent: return code = 0, elapsed time = 0
parseIntelliSense: return code = 0, elapsed time = 0
parseLaunch: return code = 0, elapsed time = 0
dryrunTargets: return code = 1, elapsed time = 0
parseTargets: return code = 0, elapsed time = 0
Configure succeeded.
Configure elapsed time: 0
Configuration for file C:\USERS\SNEHARA\DOWNLOADS\MAKEFILE-TOOLS_BUG_REPRO\MAKEFILE-TOOLS_BUG_REPRO\INCLUDED\INCLUDED.H was not found. CppTools will set a default configuration

included.h exists under the included directory too

Co-authored-by: snehara99 <113148726+snehara99@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 10, 2026

@copilot I'm getting the following errors now when I run Makefile: Configure:

...

Fixed in f1de702. The issue was that when compilerArgRegions contains partial/unbalanced quotes (e.g., from a truncated -D define), my function incorrectly treated subsequent content as being "inside quotes" and replaced all spaces.

The fix adds a hasBalancedQuotes() check - if the string has an odd number of single or double quotes, it returns the original string unchanged instead of attempting the replacement. This handles the case where the parsing produces fragments that start mid-quote.

Co-authored-by: snehara99 <113148726+snehara99@users.noreply.github.com>
Co-authored-by: snehara99 <113148726+snehara99@users.noreply.github.com>
Copilot AI changed the title Fix parseCompilerArgs.bat failure when arguments contain spaces in quoted strings Fix switch regex to not match numeric values like -1 inside quoted strings Feb 12, 2026
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

Successfully merging this pull request may close these issues.

[Bug] parseCompilerArgs.bat fails if argument contains a space

2 participants