mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-19 09:13:04 +00:00
tests: address portability issues about strdup
Reported by Dennis Clarke <https://lists.gnu.org/r/bug-bison/2021-10/msg00005.html>. In particular <https://lists.gnu.org/r/bug-bison/2021-10/msg00023.html>. * doc/bison.texi, examples/c/glr/c++-types.y, * examples/c/bistromathic/parse.y tests/testsuite.h: Define _XOPEN_SOURCE to 600, to get a strdup that works on Solaris. * tests/glr-regression.at: Use strdup freely.
This commit is contained in:
@@ -2644,6 +2644,13 @@ calculator.
|
|||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
%code top {
|
||||||
|
/* Portability issues for strdup. */
|
||||||
|
#ifndef _XOPEN_SOURCE
|
||||||
|
# define _XOPEN_SOURCE 600
|
||||||
|
#endif
|
||||||
|
}
|
||||||
@end example
|
@end example
|
||||||
@end ignore
|
@end ignore
|
||||||
|
|
||||||
@@ -2875,7 +2882,7 @@ found, a pointer to that symbol is returned; otherwise zero is returned.
|
|||||||
not make these assumptions. */
|
not make these assumptions. */
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h> /* malloc, realloc. */
|
#include <stdlib.h> /* malloc, realloc. */
|
||||||
#include <string.h> /* strlen. */
|
#include <string.h> /* strdup, strlen. */
|
||||||
@end group
|
@end group
|
||||||
|
|
||||||
@group
|
@group
|
||||||
|
|||||||
@@ -21,6 +21,11 @@
|
|||||||
|
|
||||||
// Emitted on top of the implementation file.
|
// Emitted on top of the implementation file.
|
||||||
%code top {
|
%code top {
|
||||||
|
/* Portability issues for strdup. */
|
||||||
|
#ifndef _XOPEN_SOURCE
|
||||||
|
# define _XOPEN_SOURCE 600
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <ctype.h> // isdigit
|
#include <ctype.h> // isdigit
|
||||||
#include <locale.h> // LC_ALL
|
#include <locale.h> // LC_ALL
|
||||||
#include <math.h> // cos, sin, etc.
|
#include <math.h> // cos, sin, etc.
|
||||||
|
|||||||
@@ -53,6 +53,10 @@
|
|||||||
|
|
||||||
%code
|
%code
|
||||||
{
|
{
|
||||||
|
/* Portability issues for strdup. */
|
||||||
|
#ifndef _XOPEN_SOURCE
|
||||||
|
# define _XOPEN_SOURCE 600
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|||||||
@@ -295,9 +295,7 @@ FILE *input;
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
assert (strlen (buf) < sizeof buf - 1);
|
assert (strlen (buf) < sizeof buf - 1);
|
||||||
char *s = YY_CAST (char *, malloc (strlen (buf) + 1));
|
]AT_VAL[ = strdup (buf);
|
||||||
strcpy (s, buf);
|
|
||||||
]AT_VAL[ = s;
|
|
||||||
return 'V';
|
return 'V';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -10,3 +10,8 @@
|
|||||||
# pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
|
# pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* We use strdup, make it available. */
|
||||||
|
#ifndef _XOPEN_SOURCE
|
||||||
|
# define _XOPEN_SOURCE 600
|
||||||
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user