[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: The readdir library recognizes files as folders while getline is use
From: |
arnold |
Subject: |
Re: The readdir library recognizes files as folders while getline is used |
Date: |
Mon, 12 Jun 2023 03:09:31 -0600 |
User-agent: |
Heirloom mailx 12.5 7/5/10 |
Hello.
Thanks for the bug report. This has been fixed in git and the
fix will be in the next release. The relevant change follows.
Thanks
Arnold
---------------------------------
diff --git a/extension/readdir.c b/extension/readdir.c
index e367ff12..788e1d1e 100644
--- a/extension/readdir.c
+++ b/extension/readdir.c
@@ -249,7 +260,7 @@ dir_can_take_file(const awk_input_buf_t *iobuf)
if (iobuf == NULL)
return awk_false;
- return (iobuf->fd != INVALID_HANDLE || S_ISDIR(iobuf->sbuf.st_mode));
+ return (S_ISDIR(iobuf->sbuf.st_mode));
}
/*
---------------------------------
Евгений <voltasar@gmail.com> wrote:
> Configuration Information [Automatically generated, do not change]:
> Machine: x86_64
> OS: linux-gnu
> Compiler: gcc
> Compilation CFLAGS: -march=x86-64 -mtune=generic -O2 -pipe -fno-plt
> -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat
> -Werror=format-security -fstack-clash-protection -fcf-protection
> -g -ffile-prefix-map=/build/gawk/src=/usr/src/debug/gawk -flto=auto -DNDEBUG
> uname output: Linux Yoga-12 6.1.31-2-MANJARO #1 SMP PREEMPT_DYNAMIC Sun
> Jun 4 12:31:46 UTC 2023 x86_64 GNU/Linux
> Machine Type: x86_64-pc-linux-gnu
>
> Gawk Version: 5.2.1 (downgraded from 5.2.2)
>
> Attestation 1:
> I have read
> https://www.gnu.org/software/gawk/manual/html_node/Bugs.html.
> Yes
>
> Attestation 2:
> I have not modified the sources before building gawk.
> True
>
> Description:
> If the library `readdir` in 5.2.2 version is loaded, the `getline`
> instruction works incorrectly while reading a file. It recognizes files
> as directories and returns an error. The 5.2.1 version does not have
> this issue and works properly.
>
> Repeat-By:
> #!/usr/bin/gawk -f
> @load "readdir"
> BEGIN{
> while((getline < "file.txt") > 0){
> print $0
> }
> }