Hi Dennis, > Le 21 oct. 2021 à 03:58, Dennis Clarke <dcla...@blastwave.org> a écrit : > >>> #define _XOPEN_SOURCE 600 >> >> Would that be the difference? If you define this early enough in >> the original test case, does it work properly? >> >> I have attached "without-my-strdup.y", that must be installed as >> mfcalc.y, for convenience.
> PASS: examples/c/mfcalc/mfcalc.test > PASS: examples/c/rpcalc/rpcalc.test > SKIP: examples/c/bistromathic/bistromathic.test > PASS: examples/c/calc/calc.test > FAIL: examples/c/glr/c++-types.test > PASS: examples/c/lexcalc/lexcalc.test > PASS: examples/c/pushcalc/calc.test > SKIP: examples/c/reccalc/reccalc.test Good. I have installed the following patch. Amusingly enough strdup is the example chosen to explain _XOPEN_SOURCE on this answer on SO: https://stackoverflow.com/a/5724485. Could you please try this tarball? https://www.lrde.epita.fr/~akim/private/bison/bison-3.8.2.6-59bb.tar.gz https://www.lrde.epita.fr/~akim/private/bison/bison-3.8.2.6-59bb.tar.lz https://www.lrde.epita.fr/~akim/private/bison/bison-3.8.2.6-59bb.tar.xz Thanks! commit ff9771d26e5e387cde51393d97d4f8d42837a25a Author: Akim Demaille <akim.demai...@gmail.com> Date: Sat Oct 23 06:01:44 2021 +0200 examples: 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 (_XOPEN_SOURCE): Define to 600, to get a strdup that works on Solaris. diff --git a/doc/bison.texi b/doc/bison.texi index a559649c..77357813 100644 --- a/doc/bison.texi +++ b/doc/bison.texi @@ -2644,6 +2644,13 @@ @node Mfcalc Declarations You should have received a copy of the GNU General Public License 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 ignore @@ -2875,7 +2882,7 @@ @node Mfcalc Symbol Table not make these assumptions. */ #include <assert.h> #include <stdlib.h> /* malloc, realloc. */ -#include <string.h> /* strlen. */ +#include <string.h> /* strdup, strlen. */ @end group @group diff --git a/examples/c/glr/c++-types.y b/examples/c/glr/c++-types.y index 3a14d9bf..232d0112 100644 --- a/examples/c/glr/c++-types.y +++ b/examples/c/glr/c++-types.y @@ -53,6 +53,10 @@ %code { + /* Portability issues for strdup. */ +#ifndef _XOPEN_SOURCE +# define _XOPEN_SOURCE 600 +#endif #include <assert.h> #include <ctype.h>