PreviousNextTracker indexSee it online !

(18/211) 2935 - C/C++ string syntax doesn't recognise '\' for strings

The C/C++ syntax highlighting doesn't recognise this (correct) syntax:

1 char paragraph\[\] = "There once was a string \
2 that was far too long, so his father \
3 cut him to pieces with newlines.";

Lines 2 and 3 are not highlighted as strings when they should be.

Submitted bhelyer - 2007-08-24 05:57:49 Assigned tsourick
Priority 5 Labels
Status open Group minor bug
Resolution None

Comments

2007-08-24 11:27:05
*anonymous

Logged In: YES
user_id=1477607
Originator: NO

Wow, for those interested, it seems this very example makes it easy to reproduce the text area corruption bug. If you type this text in a new buffer, then save it in a file with ".cpp" extension, and then use the jEdit menu to open the modes in the FSB, the text area will get corrupted and remain corrupted even as buffers are switched.

2007-08-24 11:30:41
*anonymous

Logged In: YES
user_id=1477607
Originator: NO

The text area corruption in this example seems to be related to folding mode. E.g. I reproduce it easily with CtagsSideKick folding mode, but when no folding mode is used, I can't.

2007-09-09 23:02:03
*anonymous

Logged In: YES
user_id=1477607
Originator: NO

File Added: cpatch

2007-09-09 23:03:58
*anonymous

Logged In: YES
user_id=1477607
Originator: NO

I've attached a tiny patch to the modes/c.xml mode file, which enables strings to span multiple lines. I don't know why the mode files limit strings to a single line, anyone knows?
I think this is also the same for Java.

2007-09-10 00:11:34
k_satoda

Logged In: YES
user_id=1483238
Originator: NO

ISO C/C++ doesn't allow new-line characters in string leterals. I think
the right way to fix this bug is escaping the new-line character which
is immediately preceded by a backslash as non-line-break in syntax
analysis. It will fix some other problems; e.g. multi line macro
definitions.

2009-12-07 16:39:58
k_satoda

There are some more comments on #1235126 which was closed as a duplicate
of this item.
https://sourceforge.net/support/tracker.php?aid=1235126

An easy user side workaround is closing the quote at the end of line,
and opening it again at the start of the next line. That is also a
correct syntax, and less confusing for jEdit, other tools, and possibly
some poeple.

2012-01-15 21:48:56
ezust

- **assigned_to**: nobody --> shlomy

2012-01-15 21:54:28
ezust

Shlomy, can you please open a fresh ticket on how to reproduce the text area corruption bug?
Also, your attached patch does not have context and no longer is good. Please update it.

2012-02-29 20:46:16
*anonymous

- **assigned_to**: shlomy --> nobody

2012-06-09 01:11:55
ezust

Figured out what line you were talking about and committed rev# 21774

2012-06-09 01:11:55
ezust

- **assigned_to**: nobody --> ezust
- **labels**: 102669 -->
- **status**: open --> closed-accepted

2012-06-09 01:13:41
ezust

oh damn. It works but it also makes certain invalid C++ code valid.
So if you forget the \ at the end of the line, you still have multiline strings which is forbidden in C++ and C.
Damn. So The patch is invalid, and I will remove it and roll back # 21774.

2012-06-09 01:14:15
ezust

- **status**: closed-accepted --> open

2012-06-09 01:17:07
ezust

- **assigned_to**: ezust --> nobody

2017-12-04 03:32:03.976000
tsourick

- **assigned_to**: Roman Tsourick
- **Group**: --> minor bug