* bug#58847: Patch to properly parse c++11 multiline strings
@ 2022-10-28 20:13 Jan Stranik via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-29 7:41 ` Eli Zaretskii
2022-10-29 7:43 ` Eli Zaretskii
0 siblings, 2 replies; 9+ messages in thread
From: Jan Stranik via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-10-28 20:13 UTC (permalink / raw)
To: 58847
[-- Attachment #1: Type: text/plain, Size: 241 bytes --]
Hello -
I’m happy user of emacs and ebrowse feature. Recently I noticed that ebrowse does not work for multi-line strings in c++.
The r-string parsing is on also for c files, but it does not matter since c does not have r strings.
[-- Attachment #2: ebrowse_rstring.patch --]
[-- Type: application/octet-stream, Size: 4289 bytes --]
EBROWSE: parse c++11 rstrings
C++11 allows definition of multi-line stirngs. This patch makes ebrowse propely parse these strings.
Example of test multi-line string:
repro.cxx:
----------
struct Foo {
using STR = const char*;
STR rstrprefix = R"prefix(is is a C++11 multi
line string
)prefix";
STR rstr = R"(
multiline string without a prefix
)";
STR rstr_test = R"prefix(
)prefix not at end
)prefixtoolong"
)pref" to short
string still continues
)prefix";
const char* str = "a regular string";
void func() {
}
};
----------
~/project/test/lit_repro $ c++ -std=c++10 -c repro.cxx # repro.cxx compiles
~/project/test/lit_repro $ ebrowse repro.cxx # current ebrowse chokes on file and produces wrong symbols
repro.cxx:3: newline in string constant
repro.cxx:4: newline in string constant
repro.cxx:7: newline in string constant
repro.cxx:8: newline in string constant
repro.cxx:11: newline in string constant
repro.cxx:12: newline in string constant
repro.cxx:14: newline in string constant
repro.cxx:15: newline in string constant
repro.cxx:16: newline in string constant
~/project/test/lit_repro $ cat BROWSE
[ebrowse-hs "ebrowse 5.0" " -x" () ()][ebrowse-ts [ebrowse-cs "Foo" () 0"repro.cxx" "struct Foo {" 12"repro.cxx" ]
()([ebrowse-ms "R" () 0 () "multiline string without a prefix
)\";" 175 0 () () 0]
[ebrowse-ms "pref" () 0 () ")prefix\";" 291 0 () () 0]
[ebrowse-ms "str" () 0 () " const char* str = \"a regular string\";" 334 0 () () 0]
)
([ebrowse-ms "func" () 0 () " void func()" 351 0 () " void func()" 351]
)
~/project/test/lit_repro $ ~/Downloads/emacs-master/lib-src/ebrowse repro.cxx # patch properly parses source and generates symbols
~/project/test/lit_repro $ cat BROWSE
[ebrowse-hs "ebrowse 5.0" " -x" () ()][ebrowse-ts [ebrowse-cs "Foo" () 0"repro.cxx" "struct Foo {" 12"repro.cxx" ]
()([ebrowse-ms "rstr" () 0 () "multiline string without a prefix
)\";" 175 0 () () 0]
[ebrowse-ms "rstr_test" () 0 () ")prefix\";" 291 0 () () 0]
[ebrowse-ms "rstrprefix" () 0 () ")prefix\";" 117 0 () () 0]
[ebrowse-ms "str" () 0 () " const char* str = \"a regular string\";" 334 0 () () 0]
)
([ebrowse-ms "func" () 0 () " void func()" 351 0 () " void func()" 351]
)
Index: emacs-master/lib-src/ebrowse.c
===================================================================
--- emacs-master.orig/lib-src/ebrowse.c
+++ emacs-master/lib-src/ebrowse.c
@@ -1574,6 +1574,51 @@ yylex (void)
end_string:
return end_char == '\'' ? CCHAR : CSTRING;
+ case 'R':
+ if (GET (c) == '"') {
+ /* c++11 rstrings */
+
+ #define RSTRING_EOF_CHECK do {if (c=='\0') { yyerror("unterminated c++11 rstring", NULL); UNGET(); return CSTRING;}}while(0)
+ char *rstring_prefix_start = in;
+
+ while (GET (c) != '(') {
+ RSTRING_EOF_CHECK;
+ if (c == '"')
+ {
+ yyerror ("malformed c++11 rstring", NULL);
+ return CSTRING;
+ }
+ }
+ char *rstring_prefix_end = in - 1;
+ while (TRUE) {
+ switch(GET (c)) {
+ default:
+ RSTRING_EOF_CHECK;
+ break;
+ case '\n':
+ INCREMENT_LINENO;
+ break;
+ case ')':
+ {
+ char *in_saved = in;
+ char *prefix = rstring_prefix_start;
+ while (prefix != rstring_prefix_end && GET (c) == *prefix) {
+ RSTRING_EOF_CHECK;
+ prefix++;
+ }
+ if (prefix == rstring_prefix_end) {
+ if (GET(c) == '"')
+ return CSTRING;
+ RSTRING_EOF_CHECK;
+ }
+ in = in_saved;
+ }
+ }
+ }
+ }
+
+ UNGET ();
+ /* fall through to ident */
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g':
case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n':
@@ -1581,7 +1626,7 @@ yylex (void)
case 'v': case 'w': case 'x': case 'y': case 'z':
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G':
case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N':
- case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U':
+ case 'O': case 'P': case 'Q': case 'S': case 'T': case 'U':
case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_':
{
/* Identifier and keywords. */
[-- Attachment #3: Type: text/plain, Size: 2 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#58847: Patch to properly parse c++11 multiline strings
2022-10-28 20:13 bug#58847: Patch to properly parse c++11 multiline strings Jan Stranik via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-10-29 7:41 ` Eli Zaretskii
2022-10-29 7:48 ` Gerd Möllmann
2022-10-29 7:43 ` Eli Zaretskii
1 sibling, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2022-10-29 7:41 UTC (permalink / raw)
To: Jan Stranik, Gerd Möllmann; +Cc: 58847
> Date: Fri, 28 Oct 2022 16:13:42 -0400
> From: Jan Stranik via "Bug reports for GNU Emacs,
> the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>
> Hello -
> I’m happy user of emacs and ebrowse feature. Recently I noticed that ebrowse does not work for multi-line strings in c++.
> The r-string parsing is on also for c files, but it does not matter since c does not have r strings.
Thanks. Gerd, any comments?
> EBROWSE: parse c++11 rstrings
>
> C++11 allows definition of multi-line stirngs. This patch makes ebrowse propely parse these strings.
>
> Example of test multi-line string:
>
> repro.cxx:
> ----------
> struct Foo {
> using STR = const char*;
> STR rstrprefix = R"prefix(is is a C++11 multi
> line string
> )prefix";
>
> STR rstr = R"(
> multiline string without a prefix
> )";
>
> STR rstr_test = R"prefix(
> )prefix not at end
> )prefixtoolong"
> )pref" to short
>
> string still continues
> )prefix";
>
> const char* str = "a regular string";
>
> void func() {
> }
> };
> ----------
>
> ~/project/test/lit_repro $ c++ -std=c++10 -c repro.cxx # repro.cxx compiles
>
> ~/project/test/lit_repro $ ebrowse repro.cxx # current ebrowse chokes on file and produces wrong symbols
> repro.cxx:3: newline in string constant
> repro.cxx:4: newline in string constant
> repro.cxx:7: newline in string constant
> repro.cxx:8: newline in string constant
> repro.cxx:11: newline in string constant
> repro.cxx:12: newline in string constant
> repro.cxx:14: newline in string constant
> repro.cxx:15: newline in string constant
> repro.cxx:16: newline in string constant
> ~/project/test/lit_repro $ cat BROWSE
> [ebrowse-hs "ebrowse 5.0" " -x" () ()][ebrowse-ts [ebrowse-cs "Foo" () 0"repro.cxx" "struct Foo {" 12"repro.cxx" ]
> ()([ebrowse-ms "R" () 0 () "multiline string without a prefix
> )\";" 175 0 () () 0]
> [ebrowse-ms "pref" () 0 () ")prefix\";" 291 0 () () 0]
> [ebrowse-ms "str" () 0 () " const char* str = \"a regular string\";" 334 0 () () 0]
> )
> ([ebrowse-ms "func" () 0 () " void func()" 351 0 () " void func()" 351]
> )
> ~/project/test/lit_repro $ ~/Downloads/emacs-master/lib-src/ebrowse repro.cxx # patch properly parses source and generates symbols
> ~/project/test/lit_repro $ cat BROWSE
> [ebrowse-hs "ebrowse 5.0" " -x" () ()][ebrowse-ts [ebrowse-cs "Foo" () 0"repro.cxx" "struct Foo {" 12"repro.cxx" ]
> ()([ebrowse-ms "rstr" () 0 () "multiline string without a prefix
> )\";" 175 0 () () 0]
> [ebrowse-ms "rstr_test" () 0 () ")prefix\";" 291 0 () () 0]
> [ebrowse-ms "rstrprefix" () 0 () ")prefix\";" 117 0 () () 0]
> [ebrowse-ms "str" () 0 () " const char* str = \"a regular string\";" 334 0 () () 0]
> )
> ([ebrowse-ms "func" () 0 () " void func()" 351 0 () " void func()" 351]
> )
> Index: emacs-master/lib-src/ebrowse.c
> ===================================================================
> --- emacs-master.orig/lib-src/ebrowse.c
> +++ emacs-master/lib-src/ebrowse.c
> @@ -1574,6 +1574,51 @@ yylex (void)
>
> end_string:
> return end_char == '\'' ? CCHAR : CSTRING;
> + case 'R':
> + if (GET (c) == '"') {
> + /* c++11 rstrings */
> +
> + #define RSTRING_EOF_CHECK do {if (c=='\0') { yyerror("unterminated c++11 rstring", NULL); UNGET(); return CSTRING;}}while(0)
> + char *rstring_prefix_start = in;
> +
> + while (GET (c) != '(') {
> + RSTRING_EOF_CHECK;
> + if (c == '"')
> + {
> + yyerror ("malformed c++11 rstring", NULL);
> + return CSTRING;
> + }
> + }
> + char *rstring_prefix_end = in - 1;
> + while (TRUE) {
> + switch(GET (c)) {
> + default:
> + RSTRING_EOF_CHECK;
> + break;
> + case '\n':
> + INCREMENT_LINENO;
> + break;
> + case ')':
> + {
> + char *in_saved = in;
> + char *prefix = rstring_prefix_start;
> + while (prefix != rstring_prefix_end && GET (c) == *prefix) {
> + RSTRING_EOF_CHECK;
> + prefix++;
> + }
> + if (prefix == rstring_prefix_end) {
> + if (GET(c) == '"')
> + return CSTRING;
> + RSTRING_EOF_CHECK;
> + }
> + in = in_saved;
> + }
> + }
> + }
> + }
> +
> + UNGET ();
> + /* fall through to ident */
>
> case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g':
> case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n':
> @@ -1581,7 +1626,7 @@ yylex (void)
> case 'v': case 'w': case 'x': case 'y': case 'z':
> case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G':
> case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N':
> - case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U':
> + case 'O': case 'P': case 'Q': case 'S': case 'T': case 'U':
> case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_':
> {
> /* Identifier and keywords. */
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#58847: Patch to properly parse c++11 multiline strings
2022-10-28 20:13 bug#58847: Patch to properly parse c++11 multiline strings Jan Stranik via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-29 7:41 ` Eli Zaretskii
@ 2022-10-29 7:43 ` Eli Zaretskii
2022-10-29 13:57 ` Jan Stranik via Bug reports for GNU Emacs, the Swiss army knife of text editors
1 sibling, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2022-10-29 7:43 UTC (permalink / raw)
To: Jan Stranik; +Cc: 58847
> Date: Fri, 28 Oct 2022 16:13:42 -0400
> From: Jan Stranik via "Bug reports for GNU Emacs,
> the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>
> I’m happy user of emacs and ebrowse feature. Recently I noticed that ebrowse does not work for multi-line strings in c++.
> The r-string parsing is on also for c files, but it does not matter since c does not have r strings.
This patch is long enough for us to require that you assign the
copyright for your code to the FSF. Would you be willing start your
legal paperwork at this time, so that we could accept your
contribution? If so, I will send you the form to fill and the
instructions to email it.
Thanks.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#58847: Patch to properly parse c++11 multiline strings
2022-10-29 7:41 ` Eli Zaretskii
@ 2022-10-29 7:48 ` Gerd Möllmann
0 siblings, 0 replies; 9+ messages in thread
From: Gerd Möllmann @ 2022-10-29 7:48 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Jan Stranik, 58847
Eli Zaretskii <eliz@gnu.org> writes:
>> Date: Fri, 28 Oct 2022 16:13:42 -0400
>> From: Jan Stranik via "Bug reports for GNU Emacs,
>> the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>>
>> Hello -
>> I’m happy user of emacs and ebrowse feature. Recently I noticed that
>> ebrowse does not work for multi-line strings in c++.
>> The r-string parsing is on also for c files, but it does not matter since c does not have r strings.
>
> Thanks. Gerd, any comments?
LGTM, excapt for the Non-GNU formatting style.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#58847: Patch to properly parse c++11 multiline strings
2022-10-29 7:43 ` Eli Zaretskii
@ 2022-10-29 13:57 ` Jan Stranik via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-29 15:14 ` Eli Zaretskii
0 siblings, 1 reply; 9+ messages in thread
From: Jan Stranik via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-10-29 13:57 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 58847
Happy to fill paperwork to assign all rights for this patch.
Sent from my iPhone
> On Oct 29, 2022, at 3:43 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>
>
>>
>> Date: Fri, 28 Oct 2022 16:13:42 -0400
>> From: Jan Stranik via "Bug reports for GNU Emacs,
>> the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>>
>> I’m happy user of emacs and ebrowse feature. Recently I noticed that ebrowse does not work for multi-line strings in c++.
>> The r-string parsing is on also for c files, but it does not matter since c does not have r strings.
>
> This patch is long enough for us to require that you assign the
> copyright for your code to the FSF. Would you be willing start your
> legal paperwork at this time, so that we could accept your
> contribution? If so, I will send you the form to fill and the
> instructions to email it.
>
> Thanks.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#58847: Patch to properly parse c++11 multiline strings
2022-10-29 13:57 ` Jan Stranik via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-10-29 15:14 ` Eli Zaretskii
2022-11-17 4:28 ` Jan Stranik via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2022-10-29 15:14 UTC (permalink / raw)
To: Jan Stranik; +Cc: 58847
> From: Jan Stranik <jan@stranik.org>
> Date: Sat, 29 Oct 2022 09:57:35 -0400
> Cc: 58847@debbugs.gnu.org
>
> Happy to fill paperwork to assign all rights for this patch.
Thanks, I've sent the form and the instructions off-list.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#58847: Patch to properly parse c++11 multiline strings
2022-10-29 15:14 ` Eli Zaretskii
@ 2022-11-17 4:28 ` Jan Stranik via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-17 6:58 ` Eli Zaretskii
2022-11-17 10:11 ` Eli Zaretskii
0 siblings, 2 replies; 9+ messages in thread
From: Jan Stranik via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-11-17 4:28 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 58847
Eli -
it took a while for the paperwork to land, but the assignment is now
fully executed.
Craig Topham helped me with that. Tracked under "[gnu.org #1887891] Jan
Stranik GNU EMACS"
Best,
Jan
On 10/29/22 11:14 AM, Eli Zaretskii wrote:
>> From: Jan Stranik <jan@stranik.org>
>> Date: Sat, 29 Oct 2022 09:57:35 -0400
>> Cc: 58847@debbugs.gnu.org
>>
>> Happy to fill paperwork to assign all rights for this patch.
> Thanks, I've sent the form and the instructions off-list.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#58847: Patch to properly parse c++11 multiline strings
2022-11-17 4:28 ` Jan Stranik via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-11-17 6:58 ` Eli Zaretskii
2022-11-17 10:11 ` Eli Zaretskii
1 sibling, 0 replies; 9+ messages in thread
From: Eli Zaretskii @ 2022-11-17 6:58 UTC (permalink / raw)
To: Jan Stranik; +Cc: 58847
> Date: Wed, 16 Nov 2022 23:28:46 -0500
> Cc: 58847@debbugs.gnu.org
> From: Jan Stranik <jan@stranik.org>
>
> Eli -
>
> it took a while for the paperwork to land, but the assignment is now
> fully executed.
>
> Craig Topham helped me with that. Tracked under "[gnu.org #1887891] Jan
> Stranik GNU EMACS"
Yes, I know. It's on my todo.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#58847: Patch to properly parse c++11 multiline strings
2022-11-17 4:28 ` Jan Stranik via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-17 6:58 ` Eli Zaretskii
@ 2022-11-17 10:11 ` Eli Zaretskii
1 sibling, 0 replies; 9+ messages in thread
From: Eli Zaretskii @ 2022-11-17 10:11 UTC (permalink / raw)
To: Jan Stranik; +Cc: 58847-done
> Date: Wed, 16 Nov 2022 23:28:46 -0500
> Cc: 58847@debbugs.gnu.org
> From: Jan Stranik <jan@stranik.org>
>
> Eli -
>
> it took a while for the paperwork to land, but the assignment is now
> fully executed.
Thanks, I installed the patch, and I'm closing the bug.
In the future, please try to follow our style better; you can examine
the changes I made by looking at what I actually committed. That
includes the commit log message as well, which was missing from the
original patch. You can find more guidance in the file CONTRIBUTE in
the Emacs source tree.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-11-17 10:11 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-28 20:13 bug#58847: Patch to properly parse c++11 multiline strings Jan Stranik via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-29 7:41 ` Eli Zaretskii
2022-10-29 7:48 ` Gerd Möllmann
2022-10-29 7:43 ` Eli Zaretskii
2022-10-29 13:57 ` Jan Stranik via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-29 15:14 ` Eli Zaretskii
2022-11-17 4:28 ` Jan Stranik via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-17 6:58 ` Eli Zaretskii
2022-11-17 10:11 ` Eli Zaretskii
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.