[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-gawk] [PATCH] gawk 4.1.1 replace "/inet" with preprocessor macro
From: |
Dave Sines |
Subject: |
[bug-gawk] [PATCH] gawk 4.1.1 replace "/inet" with preprocessor macro |
Date: |
Mon, 14 Apr 2014 16:26:29 +0100 |
User-agent: |
tin/2.2.0-20131224 ("Lochindaal") (UNIX) (Linux/3.0.0-1 (i686)) |
This is not a bug report, I'm just posting it on the off-chance someone
else finds it useful.
"/inet" is a directory on my system so to avoid confusion I usually build
gawk without network support.
The following patch allows an alternative base path to be specified via
CPPFLAGS during the build. The documentation is not modified.
CPPFLAGS="-DGAWK_INET_PATH='\"whatever\"'" \
./configure && make && make check
Briefly tested with GAWK_INET_PATH defined to "net://inet", "/dev/inet"
and undefined (defaulting to "/inet").
(The !inetfile() following the first strncmp() is to catch "/dev/mumble".)
#v+
--- gawk-4.1.1/io.c.orig 2014-03-05 04:00:36.000000000 +0000
+++ gawk-4.1.1/io.c 2014-04-14 15:03:54.000000000 +0100
@@ -100,6 +100,10 @@
#define AF_INET6 10
#endif
+#ifndef GAWK_INET_PATH
+#define GAWK_INET_PATH "/inet"
+#endif
+
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
@@ -1549,7 +1553,7 @@
return openfd;
}
- if (strncmp(name, "/dev/", 5) == 0) {
+ if (strncmp(name, "/dev/", 5) == 0 && !inetfile(name, NULL, NULL)) {
cp = (char *) name + 5;
if (strcmp(cp, "stdin") == 0 && (flag & O_ACCMODE) == O_RDONLY)
@@ -3749,22 +3753,22 @@
{
bool ret = false;
- if (strncmp(str, "/inet/", 6) == 0) {
+ if (strncmp(str, GAWK_INET_PATH "/", sizeof(GAWK_INET_PATH "/") - 1) ==
0) {
ret = true;
if (length != NULL)
- *length = 6;
+ *length = sizeof(GAWK_INET_PATH "/") - 1;
if (family != NULL)
*family = AF_UNSPEC;
- } else if (strncmp(str, "/inet4/", 7) == 0) {
+ } else if (strncmp(str, GAWK_INET_PATH "4/", sizeof(GAWK_INET_PATH
"4/") - 1) == 0) {
ret = true;
if (length != NULL)
- *length = 7;
+ *length = sizeof(GAWK_INET_PATH "4/") - 1;
if (family != NULL)
*family = AF_INET;
- } else if (strncmp(str, "/inet6/", 7) == 0) {
+ } else if (strncmp(str, GAWK_INET_PATH "6/", sizeof(GAWK_INET_PATH
"6/") - 1) == 0) {
ret = true;
if (length != NULL)
- *length = 7;
+ *length = sizeof(GAWK_INET_PATH "6/") - 1;
if (family != NULL)
*family = AF_INET6;
#ifndef HAVE_GETADDRINFO
#v-
- [bug-gawk] [PATCH] gawk 4.1.1 replace "/inet" with preprocessor macro,
Dave Sines <=
- Re: [bug-gawk] [PATCH] gawk 4.1.1 replace "/inet" with preprocessor macro, Eli Zaretskii, 2014/04/14
- Re: [bug-gawk] [PATCH] gawk 4.1.1 replace "/inet" with preprocessor macro, Dave Sines, 2014/04/15
- Re: [bug-gawk] [PATCH] gawk 4.1.1 replace "/inet" with preprocessor macro, Andrew J. Schorr, 2014/04/15
- Re: [bug-gawk] [PATCH] gawk 4.1.1 replace "/inet" with preprocessor macro, Dave Sines, 2014/04/15
- Re: [bug-gawk] [PATCH] gawk 4.1.1 replace "/inet" with preprocessor macro, Aharon Robbins, 2014/04/17
- Re: [bug-gawk] [PATCH] gawk 4.1.1 replace "/inet" with preprocessor macro, Andrew J. Schorr, 2014/04/17
- Re: [bug-gawk] [PATCH] gawk 4.1.1 replace "/inet" with preprocessor macro, Aharon Robbins, 2014/04/17
- Re: [bug-gawk] [PATCH] gawk 4.1.1 replace "/inet" with preprocessor macro, Andrew J. Schorr, 2014/04/17
- Re: [bug-gawk] [PATCH] gawk 4.1.1 replace "/inet" with preprocessor macro, Aharon Robbins, 2014/04/18
- Re: [bug-gawk] [PATCH] gawk 4.1.1 replace "/inet" with preprocessor macro, Andrew J. Schorr, 2014/04/18