summaryrefslogtreecommitdiffabout
path: root/include
authorSergey Poznyakoff <gray@gnu.org>2016-07-16 09:21:27 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2016-07-16 09:21:27 (GMT)
commit529fed25f92e04d694c30b3fc6bc8645e2703f4e (patch) (side-by-side diff)
treec575001b35a43ba8f325bf7af60d7b9fb8b8b32a /include
parent6201e61fb932dbe6153f92ede836e07247d04b7c (diff)
downloadgrecs-529fed25f92e04d694c30b3fc6bc8645e2703f4e.tar.gz
grecs-529fed25f92e04d694c30b3fc6bc8645e2703f4e.tar.bz2
Disable adjacent string concatenation.
The adjacent string concatenation feature doesn't work well with multiple-argument statements. The common example (found in GNU pies) is the "env" statement: env "PATH=/sbin:$PATH" "PRELOAD=true" The intent was to pass it two arguments, but in fact they get concatenated into one. To control this, the grecs_parser_options variable is introduced. If it has the GRECS_OPTION_QUOTED_STRING_CONCAT bit set, adjacent string concatenation is enabled. By default it is disabled. The GRECS_OPTION_ADJUST_STRING_LOCATIONS bit controls the way the quoted sring locations are computed. If it is set, the beginning of the string is counted at the first character after the opening double quote, and its end at the character immediately preceding the closing double quote. Otherwise, both double-quote characters are included in the location (the default). The change is backward incompatible. * doc/grecs-syntax.texi: Update. * include/grecs/parser.h (grecs_adjust_string_locations): Remove. (grecs_parser_options): New extern. * src/grecs-lex.l: QSTRING is returned only if GRECS_OPTION_QUOTED_STRING_CONCAT option is set. The GRECS_OPTION_ADJUST_STRING_LOCATIONS option controls string locus adjustment. * src/parser.c (grecs_adjust_string_locations): Remove. (grecs_parser_options): New variable. * tests/Makefile.am: Add strcat.at, stradj.at * tests/testsuite.at: Likewise. * tests/gcffmt.c: New options -strcat and -stradj * tests/stradj.at: New test case. * tests/strcat.at: New test case.
Diffstat (limited to 'include') (more/less context) (ignore whitespace changes)
-rw-r--r--include/grecs/parser.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/include/grecs/parser.h b/include/grecs/parser.h
index 00878f4..41b3ae4 100644
--- a/include/grecs/parser.h
+++ b/include/grecs/parser.h
@@ -28,9 +28,12 @@ extern int grecs_default_port;
extern struct grecs_locus_point grecs_current_locus_point;
extern grecs_locus_t grecs_locus;
-extern int grecs_adjust_string_locations;
extern int grecs_error_count;
+#define GRECS_OPTION_ADJUST_STRING_LOCATIONS 0x01
+#define GRECS_OPTION_QUOTED_STRING_CONCAT 0x02
+extern int grecs_parser_options;
+
/* Main entry point */
struct grecs_node *grecs_parse(const char *name);
void grecs_gram_trace(int n);

Return to:

Send suggestions and report system problems to the System administrator.