[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Findutils-patches] [PATCH] fix bug #46784: frcode drops last char if no
From: |
James Youngman |
Subject: |
[Findutils-patches] [PATCH] fix bug #46784: frcode drops last char if no final newline |
Date: |
Fri, 25 Mar 2016 09:13:04 +0000 |
* locate/testsuite/config/unix.exp (locate_textonly): Don't append
a newline to the input file. Instead use exactly the data
specified by the caller. This means that in some cases the input
now lacks a final newline. Ignore any warning message produced by
frcode.
* locate/frcode.c (main): If the final character of the line
returned by getdelim is not the delimiter, don't overwrite it with
a NUL character. Instead, issue a warning message.
* NEWS: Mention this bugfix.
---
NEWS | 4 ++++
locate/frcode.c | 9 ++++++++-
locate/testsuite/config/unix.exp | 13 ++++++++-----
3 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/NEWS b/NEWS
index e0bb51e..556eab8 100644
--- a/NEWS
+++ b/NEWS
@@ -27,6 +27,10 @@ the --help option. Previously, when the user passed invalid
options
or arguments, the user's attention to the corresponding error
diagnostic was distracted by that lengthy text.
+** Bug Fixes
+
+#46784: frcode drops last char if no final newline
+
** Translations
Updated translations: Hungarian, Slovak, Dutch, German, Danish, Greek.
diff --git a/locate/frcode.c b/locate/frcode.c
index c1fea64..e143005 100644
--- a/locate/frcode.c
+++ b/locate/frcode.c
@@ -295,7 +295,14 @@ main (int argc, char **argv)
while ((line_len = getdelim (&path, &pathsize, delimiter, stdin)) > 0)
{
- path[line_len - 1] = '\0'; /* FIXME temporary: nuke the newline. */
+ if (path[line_len - 1] != delimiter)
+ {
+ error (0, 0, _("The input file should end with the delimiter"));
+ }
+ else
+ {
+ path[line_len - 1] = '\0'; /* FIXME temporary: nuke the delimiter. */
+ }
count = prefix_length (oldpath, path);
diffcount = count - oldcount;
diff --git a/locate/testsuite/config/unix.exp b/locate/testsuite/config/unix.exp
index 93da8c8..e955686 100644
--- a/locate/testsuite/config/unix.exp
+++ b/locate/testsuite/config/unix.exp
@@ -115,11 +115,14 @@ proc locate_textonly { passfail id intext locateoptions
outtext } {
# Generate the "frcode" input.
catch { file delete -force $listfle }
set f [open $listfile w]
- puts $f "$intext"
+ puts -nonewline $f "$intext"
close $f
- # Run frcode
- exec $FRCODE < $listfile > $dbfile
+ # Run frcode. Redirect stderr so that warning messages don't
+ # cause the function to fail when a warning message is issued.
+ # Don't use catch here because we would still want to diagnose a
+ # problem if frcode's exit status is non-zero.
+ exec $FRCODE < $listfile > $dbfile 2> /dev/null
# Now run locate.
set locatecmd "$LOCATE -d $dbfile $locateoptions"
@@ -144,8 +147,8 @@ proc locate_textonly { passfail id intext locateoptions
outtext } {
}
} else {
send_log "Output mismatch.\n"
- send_log "Expected: $outtext\n"
- send_log "Got : $result\n"
+ send_log "Expected:\n$outtext\n"
+ send_log "Got :\n$result\n"
fail "$testname-$id"
}
}
--
2.1.4
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Findutils-patches] [PATCH] fix bug #46784: frcode drops last char if no final newline,
James Youngman <=