NetBSD-Bugs archive

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

bin/38209: fmt inserts empty lines before 1-character long ones



>Number:         38209
>Category:       bin
>Synopsis:       "fmt -C" inserts empty lines before 1-character long ones
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Mar 09 22:35:00 +0000 2008
>Originator:     Aleksej Saushev <asau%inbox.ru@localhost>
>Release:        NetBSD 4.99.55
>Organization:
>Environment:
System: NetBSD asau.local 4.99.55 NetBSD 4.99.55 (KERN) #0: Mon Mar 3 22:32:55 
MSK 2008 asau%asau.local@localhost:/usr/obj/sys/arch/i386/compile/KERN i386
Architecture: i386
Machine: i386
>Description:
        "fmt -C" inserts empty lines before 1-character long ones, 
        this is not intentional behaviour, "fmt -C" is supposed
        to center text, according to documentation.
>How-To-Repeat:
        echo 1 | fmt -C
        echo 22 | fmt -C
        Note the difference
>Fix:

--- fmt.c       15 Dec 2007 19:44:50 -0000      1.28
+++ fmt.c       9 Mar 2008 22:28:56 -0000
@@ -221,10 +221,10 @@
                        cp2 = cp + len - 1;
                        while (len-- && isspace((unsigned char)*cp))
                                cp++;
-                       while (cp2 > cp && isspace((unsigned char)*cp2))
-                               cp2--;
                        if (cp == cp2)
                                (void)putchar('\n');
+                       while (cp2 > cp && isspace((unsigned char)*cp2))
+                               cp2--;
                        col = cp2 - cp;
                        if (goal_length > col)
                                for (c = 0; c < (goal_length - col) / 2; c++)



Home | Main Index | Thread Index | Old Index