The branch main has been updated by mjg:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=7e05fa3b449007adaa6e588ebb3b8d76f30b355c

commit 7e05fa3b449007adaa6e588ebb3b8d76f30b355c
Author:     наб <nabijaczlew...@nabijaczleweli.xyz>
AuthorDate: 2022-02-18 13:34:40 +0000
Commit:     Mateusz Guzik <m...@freebsd.org>
CommitDate: 2022-02-18 16:30:10 +0000

    uname: -v: strip final whitespace compatibly with uname(3)
    
    This restores POSIX.1 conformance
    
    PR: 260938
---
 usr.bin/uname/uname.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/usr.bin/uname/uname.c b/usr.bin/uname/uname.c
index e97b9c3cb744..109505e4b9da 100644
--- a/usr.bin/uname/uname.c
+++ b/usr.bin/uname/uname.c
@@ -256,8 +256,12 @@ NATIVE_SYSCTL2_GET(version, CTL_KERN, KERN_VERSION) {
        p = NATIVE_BUFFER;
        n = NATIVE_LENGTH;
        for (; n--; ++p)
-               if (*p == '\n' || *p == '\t')
-                       *p = ' ';
+               if (*p == '\n' || *p == '\t') {
+                       if (n > 1)
+                               *p = ' ';
+                       else
+                               *p = '\0';
+               }
 } NATIVE_SET;
 
 NATIVE_SYSCTL2_GET(platform, CTL_HW, HW_MACHINE) {

Reply via email to