Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Bracket-delineated format strings marked as invalid/illegal #222

Open
@afischer

Description

@afischer

Prerequisites

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

  1. Open a C file
  2. 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
  1. 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:
Incorrect highlighting of the set

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions