Bracket-delineated format strings marked as invalid/illegal #222
Description
Prerequisites
- Put an X between the brackets on this line if you have done all of the following:
- Reproduced the problem in Safe Mode: http://flight-manual.atom.io/hacking-atom/sections/debugging/#using-safe-mode
- Followed all applicable steps in the debugging guide: http://flight-manual.atom.io/hacking-atom/sections/debugging/
- Checked the FAQs on the message board for common solutions: https://discuss.atom.io/c/faq
- Checked that your issue isn't already filed: https://github.com/issues?utf8=✓&q=is%3Aissue+user%3Aatom
- Checked that there is not already an Atom package that provides the described functionality: https://atom.io/packages
Description
When using the %[set]
string formatter for scanf
, fscanf
, sscanf
, scanf_s
, fscanf_s
, and sscanf_s
, the percent sign is scoped as an illegal character. This is reflected in syntax highlighting.
The %[set]
formatter is defined as:
matches a non-empty sequence of character from set of characters.
If the first character of the set is^
, then all characters not in the set are matched. If the set begins with]
or^]
then the]
character is also included into the set. It is implementation-defined whether the character - in the non-initial position in the scanset may be indicating a range, as in[0-9]
. If width specifier is used, matches only up to width. Always stores a null character in addition to the characters matched (so the argument array must have room for at least width+1 characters)
Steps to Reproduce
- Open a C file
- Use one of the above functions with a bracket-delineated format string. For example,
sscanf(user_input, "%c %[^\n]", &arg0, arg_str); // reads char into arg0, the remainder until \n to arg_str
- View the syntax highlighting and scope.
Expected behavior:
Brackets and %
are correctly scoped to constant.other.placeholder.c
, and syntax highlighting is correct within the brackets.
Actual behavior:
The %
symbol is scoped to invalid.illegal.placeholder.c
, and brackets and their contents are scoped as string.quoted.double.c
.
Because of this, syntax highlighting is incorrect:
Reproduces how often:
Always.
Versions
$ atom --version && apm --version
Atom : 1.15.0
Electron: 1.3.13
Chrome : 52.0.2743.82
Node : 6.5.0
apm 1.15.3
npm 3.10.5
node 4.4.5 x64
python 2.7.10
git 2.12.0
System Info
MacBook Pro (15-inch, 2016)
macOS Sierra 10.12.4
Intel Core i7-6920HQ CPU @ 2.90GHz
Additional Information
I'm relatively new to using this formatter, so apologies if I am misusing something.
Additionally, it seems that some properties of this formatter are implementation-defined. Hopefully this will not affect our ability to create a correct syntax highlighter.