More changes to pacify C++ compilers.

This commit is contained in:
Paul Eggert
2005-07-14 23:57:45 +00:00
parent e2688cd96e
commit c70fdfcd20
2 changed files with 11 additions and 8 deletions

View File

@@ -6,7 +6,7 @@
* tests/cxx-type.at (_AT_TEST_GLR_CXXTYPES): Define YYSTACKEXPANDABLE. * tests/cxx-type.at (_AT_TEST_GLR_CXXTYPES): Define YYSTACKEXPANDABLE.
* tests/glr-regression.at * tests/glr-regression.at
(Improper handling of embedded actions and dollar(-N) in GLR parsers): (Improper handling of embedded actions and dollar(-N) in GLR parsers):
YYSTYPE is char *, not char const *, so that strcpy ($$, ...) works. Add casts to pacify C++ compilers.
* tests/glr-regression.at (Improper merging of GLR delayed action * tests/glr-regression.at (Improper merging of GLR delayed action
sets): Declare yylex before using it. sets): Declare yylex before using it.
* tests/Makefile.am (maintainer-check-g++): Fix a stray * tests/Makefile.am (maintainer-check-g++): Fix a stray

View File

@@ -121,7 +121,7 @@ AT_DATA_GRAMMAR([glr-regr2a.y],
/* Reported by S. Eken */ /* Reported by S. Eken */
%{ %{
#define YYSTYPE char * #define YYSTYPE char const *
#define yyfalse 0 #define yyfalse 0
#define yytrue 1 #define yytrue 1
@@ -156,10 +156,11 @@ var_list:
{ $$ = $1; } { $$ = $1; }
| var ',' var_list | var ',' var_list
{ {
$$ = malloc (strlen ($1) + 1 + strlen ($3) + 1); char *s = (char *) malloc (strlen ($1) + 1 + strlen ($3) + 1);
strcpy ($$, $1); strcpy (s, $1);
strcat ($$, ","); strcat (s, ",");
strcat ($$, $3); strcat (s, $3);
$$ = s;
} }
; ;
@@ -174,6 +175,7 @@ int
yylex (void) yylex (void)
{ {
char buf[50]; char buf[50];
char *s;
switch (fscanf (yyin, " %1[a-z,]", buf)) { switch (fscanf (yyin, " %1[a-z,]", buf)) {
case 1: case 1:
return buf[0]; return buf[0];
@@ -186,8 +188,9 @@ yylex (void)
abort (); abort ();
if (sizeof buf - 1 <= strlen (buf)) if (sizeof buf - 1 <= strlen (buf))
abort (); abort ();
yylval = malloc (strlen (buf) + 1); s = (char *) malloc (strlen (buf) + 1);
strcpy (yylval, buf); strcpy (s, buf);
yylval = s;
return 'V'; return 'V';
} }