gentoo-ebuilds/dev-games/libnw/files/libnw-1.30.02-C23.patch
NHOrus 81bf071611
dev-games/libnw: fix incompatible pointer types, port to C23
Incompatible pointers reside in autogenerated code, regenerating it
with byson fails. Hence patching both .y and .c files. Patching order
must be preserved, or make tries to regenerate them and fails.
Minimal inclusion of changes to port to C23.

Bug: https://bugs.gentoo.org/931876
Signed-off-by: NHOrus <jy6x2b32pie9@yahoo.com>
Closes: https://github.com/gentoo/gentoo/pull/40117
Signed-off-by: Sam James <sam@gentoo.org>
2025-02-10 09:08:37 +00:00

210 lines
4.5 KiB
Diff

https://bugs.gentoo.org/931876
Fix incompatible pointer cast by pointing to hopefully correct struct
member.
Ordering of {.y,.c} is important so makefile doesn't try and fail to
regenerate autogenerated file we just edited.
--- a/libnw/mdly.y
+++ b/libnw/mdly.y
@@ -214,7 +214,7 @@
dummynodeelement
: token_parent token_string =
{
- cur_Node->parent = $2;
+ cur_Node->parent->name = $2;
}
| token_position xyz =
{
@@ -247,7 +247,7 @@
trimeshnodeelement
: token_parent token_string =
{
- cur_Node->parent = $2;
+ cur_Node->parent->name = $2;
}
| token_position xyz =
{
@@ -359,7 +359,7 @@
aabbnodeelement
: token_parent token_string =
{
- cur_Node->parent = $2;
+ cur_Node->parent->name = $2;
}
| token_ambient rgb =
{
--- a/libnw/mdly.c
+++ b/libnw/mdly.c
@@ -1142,7 +1142,7 @@
case 22:
#line 216 "mdly.y"
{
- cur_Node->parent = yyvsp[0].string;
+ cur_Node->parent->name = yyvsp[0].string;
}
break;
case 23:
@@ -1167,7 +1167,7 @@
case 30:
#line 249 "mdly.y"
{
- cur_Node->parent = yyvsp[0].string;
+ cur_Node->parent->name = yyvsp[0].string;
}
break;
case 31:
@@ -1294,7 +1294,7 @@
case 60:
#line 361 "mdly.y"
{
- cur_Node->parent = yyvsp[0].string;
+ cur_Node->parent->name = yyvsp[0].string;
}
break;
case 61:
Minimum amount of patching to make it compile with C23:
_POSIX_C_SOURCE for fileno and getopt
strings for strncasecmp
--- a/libnw/key.c
+++ b/libnw/key.c
@@ -9,6 +9,7 @@
# endif
# include <string.h>
#endif
+#include <strings.h>
#include "global.h"
#include "key.h"
#include "restyp.h"
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,4 +2,4 @@
EXTRA_DIST = README.tech TODO autogen.sh README.License-Torlack Doxyfile.in magic
-AM_CFLAGS = -Wall
+AM_CFLAGS = -Wall -D_POSIX_C_SOURCE=200809L
--- a/itpdis/Makefile.am
+++ b/itpdis/Makefile.am
@@ -10,4 +10,4 @@
INCLUDES = -I$(top_srcdir)/include
-AM_CFLAGS = -Wall
+AM_CFLAGS = -Wall -D_POSIX_C_SOURCE=200809L
--- a/libnw/Makefile.am
+++ b/libnw/Makefile.am
@@ -18,4 +18,4 @@
EXTRA_DIST = $(man_MANS) sety.h mdly.h agg_toc_load.3.in agg_toc_del.3.in \
agg_create.3.in bif_toc_load.3.in get_game_dir.3.in read_key.3.in
-AM_CFLAGS = -Wall
+AM_CFLAGS = -Wall -D_POSIX_C_SOURCE=200809L
--- a/nw2da2csv/Makefile.am
+++ b/nw2da2csv/Makefile.am
@@ -10,4 +10,4 @@
EXTRA_DIST = $(man_MANS) nw2da2csv.1.in
-AM_CFLAGS = -Wall
+AM_CFLAGS = -Wall -D_POSIX_C_SOURCE=200809L
--- a/nwaggext/Makefile.am
+++ b/nwaggext/Makefile.am
@@ -10,4 +10,4 @@
INCLUDES = -I$(top_srcdir)/include
-AM_CFLAGS = -Wall
+AM_CFLAGS = -Wall -D_POSIX_C_SOURCE=200809L
--- a/nwareamap/Makefile.am
+++ b/nwareamap/Makefile.am
@@ -10,4 +10,4 @@
INCLUDES = -I$(top_srcdir)/include
-AM_CFLAGS = -Wall
+AM_CFLAGS = -Wall -D_POSIX_C_SOURCE=200809L
--- a/nwmrgplc/Makefile.am
+++ b/nwmrgplc/Makefile.am
@@ -10,4 +10,4 @@
EXTRA_DIST = $(man_MANS) nwmrgplc.1.in
-AM_CFLAGS = -Wall
+AM_CFLAGS = -Wall -D_POSIX_C_SOURCE=200809L
--- a/nwresext/Makefile.am
+++ b/nwresext/Makefile.am
@@ -10,4 +10,4 @@
INCLUDES = -I$(top_srcdir)/include
-AM_CFLAGS = -Wall
+AM_CFLAGS = -Wall -D_POSIX_C_SOURCE=200809L
--- a/nwstrref/Makefile.am
+++ b/nwstrref/Makefile.am
@@ -10,4 +10,4 @@
INCLUDES = -I$(top_srcdir)/include
-AM_CFLAGS = -Wall
+AM_CFLAGS = -Wall -D_POSIX_C_SOURCE=200809L
--- a/nwtsfix/Makefile.am
+++ b/nwtsfix/Makefile.am
@@ -10,4 +10,4 @@
EXTRA_DIST = $(man_MANS) nwtsfix.1.in
-AM_CFLAGS = -Wall
+AM_CFLAGS = -Wall -D_POSIX_C_SOURCE=200809L
--- a/nwtsmerge/Makefile.am
+++ b/nwtsmerge/Makefile.am
@@ -10,4 +10,4 @@
EXTRA_DIST = $(man_MANS) nwtsmerge.1.in
-AM_CFLAGS = -Wall
+AM_CFLAGS = -Wall -D_POSIX_C_SOURCE=200809L
--- a/nwtsrefs/Makefile.am
+++ b/nwtsrefs/Makefile.am
@@ -10,4 +10,4 @@
EXTRA_DIST = $(man_MANS) nwtsrefs.1.in
-AM_CFLAGS = -Wall
+AM_CFLAGS = -Wall -D_POSIX_C_SOURCE=200809L
--- a/plistcheck/Makefile.am
+++ b/plistcheck/Makefile.am
@@ -6,4 +6,4 @@
INCLUDES = -I$(top_srcdir)/include
-AM_CFLAGS = -Wall
+AM_CFLAGS = -Wall -D_POSIX_C_SOURCE=200809L
--- a/itpdis/main.c
+++ b/itpdis/main.c
@@ -12,6 +12,7 @@
# endif
# include <string.h>
#endif
+#include <strings.h>
#include "global.h"
#include "gamedir.h"
#include "itp.h"
--- a/nwmrgplc/main.c
+++ b/nwmrgplc/main.c
@@ -12,6 +12,7 @@
# endif
# include <string.h>
#endif
+#include <strings.h>
#include "global.h"
#include "gamedir.h"
#include "2da.h"
--- a/nwtsrefs/main.c
+++ b/nwtsrefs/main.c
@@ -12,6 +12,7 @@
# endif
# include <string.h>
#endif
+#include <strings.h>
#include <ctype.h>
#include "global.h"
#include "gamedir.h"