[Rd] Multi-line string constants: proposed patch
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Sat Sep 11 01:29:33 CEST 2004
Kevin Wright <kwright at eskimo.com> writes:
> R 1.9.1 requires multi-line strings to contain a backslash at the
> end of each line (except the last line). As noted by Mark
> Bravington (http://tolstoy.newcastle.edu.au/R/help/02b/5199.html)
> this requirement appears to be undocumented.
>
> In S-Plus 6.2, multi-line strings do not need a backslash for continuation.
>
> I recently (http://tolstoy.newcastle.edu.au/R/devel/04b/0256.html)
> requested compatability with S-Plus and was told to contribute
> a patch and then it would be considered. Here is the proposed patch.
>
> In the files src/main/gram.y and src/main/gram.c strings
> are parsed with the StringValue function. Looking at the function it is
> clear that a newline character (not the two-byte '\n') generates an error:
>
> static int StringValue(int c)
> {
> ...
> if (c == '\n') {
> xxungetc(c);
> return ERROR;
> }
>
> ...
> }
...
>
> C:\R\R-devel\src\main>diff ogram.c gram.c
> 3122,3125c3122,3125
> < if (c == '\n') {
> < xxungetc(c);
> < return ERROR;
> < }
> ---
> // if (c == '\n') {
> // xxungetc(c);
> // return ERROR;
> // }
>
> Presumably the same change should be made in gram.y
>
>
> Thanks for considering this patch.
Sorry, I don't think that is good enough (notwithstanding the
nonstandard comment character). Notice that Splus does this:
> x <- "foo
Continue string: bar
Continue string: baz"
(and the entry is interruptible with Ctrl-C too)
There's a very good reason for the change of prompt, as anyone who has
debugged SAS code with stray quotes will tell you: The system would
appear to be completely unresponsive because all input is being eaten
by the string readers.
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-devel
mailing list