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

Error in C syntax coloring on string literal #334

Open
1 task done
rshamsnejad opened this issue Sep 9, 2019 · 2 comments
Open
1 task done

Error in C syntax coloring on string literal #334

rshamsnejad opened this issue Sep 9, 2019 · 2 comments

Comments

@rshamsnejad
Copy link

rshamsnejad commented Sep 9, 2019

Edit by @rsese to add alternate example with 1.42.0-nightly6 on macOS 10.14.6

#define SQLITE_UNIX_CURRENT_TS "hello"
#define MINUTE "world"

int main() {
  char *s = "WHERE timestamp < " SQLITE_UNIX_CURRENT_TS " - (1 * " MINUTE ")";

  return 0;
}

Bug_Atom4

" - (1 * " isn't treated as a string in this case.

With Tree-sitter disabled:

textmate-c


Prerequisites

Description

The following string literal in C breaks syntax coloring in Atom :

"WHERE timestamp < " SQLITE_UNIX_CURRENT_TS " - (1 * " MINUTE ")";

The only parts not between quotes are SQLITE_UNIX_CURRENT_TS and MINUTE. However, here is the result :

Bug_Atom

I am sure that this piece of code's syntax is correct, because it compiles without errors. The problem seems to be caused by the * operator of my SQL query, ie. the following code is correctly colored :

"WHERE timestamp < " SQLITE_UNIX_CURRENT_TS " - (1 " MINUTE ")";

As you can see :

Bug_Atom2

However, removing the - operator breaks coloring in another way, ie. in the following code :

"WHERE timestamp < " SQLITE_UNIX_CURRENT_TS " (1 * " MINUTE ")";

Which yields the following :

Bug_Atom3

Steps to Reproduce

  1. Create an empty file with C syntax coloring
  2. Paste the following code : "WHERE timestamp < " SQLITE_UNIX_CURRENT_TS " - (1 * " MINUTE ")";

Expected behavior:

Coloring as in the 2nd screenshot (but including the * operator)

Actual behavior:

Wrong coloring as in the 1st and 3rd screenshots.

Reproduces how often:

I have only seen this occurring on the exact piece of code stated in the "Steps to reproduce" section.

Versions

$ inxi -SCMG
System:    Host: rsd-vm-lmde Kernel: 4.9.0-11-amd64 x86_64 bits: 64 Desktop: Cinnamon 4.2.4 Distro: LMDE 3 Cindy 
Machine:   Type: Virtualbox System: innotek product: VirtualBox v: 1.2 serial: <root required> 
           Mobo: Oracle model: VirtualBox v: 1.2 serial: <root required> BIOS: innotek v: VirtualBox date: 12/01/2006 
CPU:       Topology: Quad Core model: Intel Core i5-8265U bits: 64 type: MCP L2 cache: 6144 KiB 
           Speed: 1800 MHz min/max: N/A Core speeds (MHz): 1: 1800 2: 1800 3: 1800 4: 1800 
Graphics:  Device-1: VMware SVGA II Adapter driver: vmwgfx v: 2.12.0.0 
           Display: x11 server: X.Org 1.19.2 driver: vmware unloaded: fbdev,modesetting,vesa resolution: 1920x950~60Hz 
           OpenGL: renderer: Gallium 0.4 on llvmpipe (LLVM 3.9 256 bits) v: 3.3 Mesa 13.0.6 
$ atom --version
Atom    : 1.40.1
Electron: 3.1.10
Chrome  : 66.0.3359.181
Node    : 10.2.0
$ apm --version
apm  2.4.3
npm  6.2.0
node 10.2.1 x64
atom 1.40.1
python 2.7.13
git 2.11.0

Additional Information

None that I can think of.

@rsese rsese transferred this issue from atom/atom Sep 9, 2019
@rsese
Copy link

rsese commented Sep 10, 2019

Thanks for the report! Does this seem like a good full minimal working example of the problem? I can reproduce the issue you described with this snippet but it's always helpful to have a self-contained minimal example so just wanted to double check.

#define SQLITE_UNIX_CURRENT_TS "hello"
#define MINUTE "world"

int main() {
  char *s = "WHERE timestamp < " SQLITE_UNIX_CURRENT_TS " - (1 * " MINUTE ")";

  return 0;
}

@rshamsnejad
Copy link
Author

Hi Robert,

Yes, I confirm that your snippet compiles without errors, and produces the same syntax coloring issue :

Bug_Atom4

Thanks !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants