sortix-mirror/ports/gawk/gawk.patch

132 lines
4.0 KiB
Diff

diff -Paur --no-dereference -- gawk.upstream/builtin.c gawk/builtin.c
--- gawk.upstream/builtin.c
+++ gawk/builtin.c
@@ -1192,10 +1192,18 @@
* Use snprintf return value to tell if there
* is enough room in the buffer or not.
*/
+/* PATCH: Until Sortix has floating point printing. */
+#if defined(__sortix__) && !__SORTIX_HAS_FLOAT_PARSE__
+ while ((i = snprintf(cpbufs[1].buf,
+ cpbufs[1].bufsize, "%lld",
+ (long long)tmpval)) >=
+ cpbufs[1].bufsize) {
+#else
while ((i = snprintf(cpbufs[1].buf,
cpbufs[1].bufsize, "%.0f",
tmpval)) >=
cpbufs[1].bufsize) {
+#endif
if (cpbufs[1].buf == cpbufs[1].stackbuf)
cpbufs[1].buf = NULL;
if (i > 0) {
diff -Paur --no-dereference -- gawk.upstream/extension/filefuncs.c gawk/extension/filefuncs.c
--- gawk.upstream/extension/filefuncs.c
+++ gawk/extension/filefuncs.c
@@ -414,8 +414,12 @@
/* for block and character devices, add rdev, major and minor numbers */
if (S_ISBLK(sbuf->st_mode) || S_ISCHR(sbuf->st_mode)) {
array_set_numeric(array, "rdev", sbuf->st_rdev);
+#ifdef major
array_set_numeric(array, "major", major(sbuf->st_rdev));
+#endif
+#ifdef minor
array_set_numeric(array, "minor", minor(sbuf->st_rdev));
+#endif
}
#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
diff -Paur --no-dereference -- gawk.upstream/io.c gawk/io.c
--- gawk.upstream/io.c
+++ gawk/io.c
@@ -39,6 +39,8 @@
#include <sys/ioctl.h>
#endif /* HAVE_SYS_IOCTL_H */
+#include <sys/select.h>
+
#ifndef O_ACCMODE
#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
#endif
diff -Paur --no-dereference -- gawk.upstream/main.c gawk/main.c
--- gawk.upstream/main.c
+++ gawk/main.c
@@ -984,13 +984,7 @@
update_PROCINFO_num("api_minor", GAWK_API_MINOR_VERSION);
#endif
-#ifdef GETPGRP_VOID
-#define getpgrp_arg() /* nothing */
-#else
-#define getpgrp_arg() getpid()
-#endif
-
- value = getpgrp(getpgrp_arg());
+ value = getpgid(0);
update_PROCINFO_num("pgrpid", value);
/*
diff -Paur --no-dereference -- gawk.upstream/node.c gawk/node.c
--- gawk.upstream/node.c
+++ gawk/node.c
@@ -860,6 +860,8 @@
n->flags &= ~WSTRCUR;
}
+/* PATCH: Sortix doesn't have putwc(3) and this function is unused. */
+#if 0
static void __attribute__ ((unused))
dump_wstr(FILE *fp, const wchar_t *str, size_t len)
{
@@ -869,6 +871,7 @@
for (; len--; str++)
putwc(*str, fp);
}
+#endif
/* wstrstr --- walk haystack, looking for needle, wide char version */
diff -Paur --no-dereference -- gawk.upstream/support/getopt.c gawk/support/getopt.c
--- gawk.upstream/support/getopt.c
+++ gawk/support/getopt.c
@@ -55,18 +55,9 @@
#ifndef ELIDE_CODE
-/* This needs to come after some library #include
- to get __GNU_LIBRARY__ defined. */
-#if defined (__GNU_LIBRARY__) || defined (__CYGWIN__) || defined(__DJGPP__) || defined(__APPLE__) || defined(__MINGW32__) || defined(__sun) /* Illumos */
-/* Don't include stdlib.h for
- * non-GNU C libraries
- * non-Cygwin
- * non-DJGPP
- * non-MinGW
- * because some of them contain conflicting prototypes for getopt. */
+/* PATCH: #&%!ing gnu portability: You need stdlib.h for malloc. */
# include <stdlib.h>
# include <unistd.h>
-#endif /* GNU C library. */
#include <string.h>
diff -Paur --no-dereference -- gawk.upstream/support/getopt.h gawk/support/getopt.h
--- gawk.upstream/support/getopt.h
+++ gawk/support/getopt.h
@@ -1,3 +1,16 @@
+/* PATCH: Gawk doesn't seem to work with Sortix libc's getopt for some reason.
+ Gawk wants to use GNU getopt unconditionally. This causes conflicting
+ symbols, so rename gawk's replacements to avoid collisions. */
+#if defined(__sortix__)
+#define getopt gawk_getopt
+#define optarg gawk_optarg
+#define optind gawk_optind
+#define opterr gawk_opterr
+#define optopt gawk_optopt
+#define getopt_long gawk_getopt_long
+#define getopt_long_only gawk_getopt_long_only
+#define option gawk_option
+#endif
/* Declarations for getopt.
Copyright (C) 1989-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.