bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: inconstancy with RS = "(\r?\n){2}"


From: Alex fxmbsw7 Ratchev
Subject: Re: inconstancy with RS = "(\r?\n){2}"
Date: Sun, 25 Jul 2021 15:55:11 +0200

thank you big time, but can you once again post it as a file
this bloated chrome stuff copies \r's and maybe space instead of \r

i dunno, .. :

patching file awk.h
Hunk #1 FAILED at 960.
Hunk #2 FAILED at 1601.
2 out of 2 hunks FAILED -- saving rejects to file awk.h.rej
patching file io.c
Hunk #1 FAILED at 3466.
Hunk #2 FAILED at 3759.
2 out of 2 hunks FAILED -- saving rejects to file io.c.rej
patching file posix/gawkmisc.c
Hunk #1 succeeded at 283 with fuzz 1 (offset 10 lines).

On Sun, Jul 25, 2021 at 3:27 PM <arnold@skeeve.com> wrote:
>
> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]