[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: inconstancy with RS = "(\r?\n){2}"
From: |
arnold |
Subject: |
Re: inconstancy with RS = "(\r?\n){2}" |
Date: |
Sun, 25 Jul 2021 07:27:43 -0600 |
User-agent: |
Heirloom mailx 12.5 7/5/10 |
You can try this patch instead. Untested.
Arnold
----------------------------------------------------
diff --git a/awk.h b/awk.h
index cb7c4990..49986949 100644
--- a/awk.h
+++ b/awk.h
@@ -960,6 +960,7 @@ typedef struct iobuf {
IOP_AT_EOF = 2,
IOP_CLOSED = 4,
IOP_AT_START = 8,
+ IOP_IS_SOCK = 16,
} flag;
} IOBUF;
@@ -1601,6 +1602,7 @@ extern void os_arg_fixup(int *argcp, char ***argvp);
extern int os_devopen(const char *name, int flag);
extern void os_close_on_exec(int fd, const char *name, const char *what, const
char *dir);
extern int os_isatty(int fd);
+extern int os_issock(int fd);
extern int os_isdir(int fd);
extern int os_isreadable(const awk_input_buf_t *iobuf, bool *isdir);
extern int os_is_setuid(void);
diff --git a/io.c b/io.c
index 91c94d9b..fd62f878 100644
--- a/io.c
+++ b/io.c
@@ -3466,6 +3466,8 @@ iop_finish(IOBUF *iop)
if (os_isatty(iop->public.fd))
iop->flag |= IOP_IS_TTY;
+ else if (os_issock(iop->public.fd))
+ iop->flag |= IOP_IS_SOCK;
iop->readsize = iop->size = optimal_bufsize(iop->public.fd, &
iop->public.sbuf);
if (do_lint && S_ISREG(iop->public.sbuf.st_mode) &&
iop->public.sbuf.st_size == 0)
@@ -3759,7 +3761,7 @@ again:
*/
/* succession of tests is easier to trace in GDB. */
- if (RSre->maybe_long) {
+ if (RSre->maybe_long && (iop->flag & (IOP_IS_TTY|IOP_IS_SOCK)) == 0) {
char *matchend = iop->off + reend;
if (iop->dataend - matchend < RS->stlen)
diff --git a/posix/gawkmisc.c b/posix/gawkmisc.c
index d2e33f41..92124be7 100644
--- a/posix/gawkmisc.c
+++ b/posix/gawkmisc.c
@@ -273,6 +273,16 @@ os_isatty(int fd)
return isatty(fd);
}
+/* os_issock --- return true if fd is a socket */
+
+int
+os_issock(int fd)
+{
+ struct stat sbuf;
+
+ return (fstat(fd, & sbuf) >= 0 && S_ISSOCK(sbuf.st_mode));
+}
+
/* files_are_same --- return true if files are identical */
int
- Re: inconstancy with RS = "(\r?\n){2}", (continued)
- Re: inconstancy with RS = "(\r?\n){2}", Alex fxmbsw7 Ratchev, 2021/07/25
- Re: inconstancy with RS = "(\r?\n){2}", Alex fxmbsw7 Ratchev, 2021/07/25
- Re: inconstancy with RS = "(\r?\n){2}", arnold, 2021/07/25
- Re: inconstancy with RS = "(\r?\n){2}", Alex fxmbsw7 Ratchev, 2021/07/25
- Re: inconstancy with RS = "(\r?\n){2}", arnold, 2021/07/25
- Re: inconstancy with RS = "(\r?\n){2}", Alex fxmbsw7 Ratchev, 2021/07/25
- Re: inconstancy with RS = "(\r?\n){2}", Alex fxmbsw7 Ratchev, 2021/07/25
- Re: inconstancy with RS = "(\r?\n){2}", Alex fxmbsw7 Ratchev, 2021/07/25
- Re: inconstancy with RS = "(\r?\n){2}", arnold, 2021/07/25
- Re: inconstancy with RS = "(\r?\n){2}", Alex fxmbsw7 Ratchev, 2021/07/25
- Re: inconstancy with RS = "(\r?\n){2}",
arnold <=
- Re: inconstancy with RS = "(\r?\n){2}", Alex fxmbsw7 Ratchev, 2021/07/25
- Re: inconstancy with RS = "(\r?\n){2}", Alex fxmbsw7 Ratchev, 2021/07/25
- Re: inconstancy with RS = "(\r?\n){2}", Alex fxmbsw7 Ratchev, 2021/07/25
- Re: inconstancy with RS = "(\r?\n){2}", Alex fxmbsw7 Ratchev, 2021/07/25
- Message not available
- Message not available
- Message not available
- Re: inconstancy with RS = "(\r?\n){2}", Alex fxmbsw7 Ratchev, 2021/07/26
- Re: inconstancy with RS = "(\r?\n){2}", Alex fxmbsw7 Ratchev, 2021/07/26
- Re: inconstancy with RS = "(\r?\n){2}", Alex fxmbsw7 Ratchev, 2021/07/26
- Message not available
- Message not available
- Message not available
- Message not available
- Message not available
- Message not available
- Fwd: inconstancy with RS = "(\r?\n){2}", Alex fxmbsw7 Ratchev, 2021/07/26
- Re: Fwd: inconstancy with RS = "(\r?\n){2}", Ed Morton, 2021/07/26
- Re: Fwd: inconstancy with RS = "(\r?\n){2}", Alex fxmbsw7 Ratchev, 2021/07/26