pspp-dev
[Top][All Lists]
Advanced

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

dos2unix treatment of formfeeds


From: Ben Pfaff
Subject: dos2unix treatment of formfeeds
Date: Fri, 19 Nov 2010 20:31:14 -0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

Hi.  Harry Thijssen, a user of GNU PSPP (software that I
maintain), wrote to me that dos2unix reported that some of the
text files included with PSPP are binary instead of text.  I took
a look at the problem and discovered that dos2unix treats the
ASCII FF (formfeed) character as an indication that a file is
binary.  Formfeeds are fairly common in GNU software because of
the following paragraph in the GNU coding standards:

       Please use formfeed characters (control-L) to divide the
    program into pages at logical places (but not within a
    function).  It does not matter just how long the pages are,
    since they do not have to fit on a printed page.  The
    formfeeds should appear alone on lines by themselves.

I'm appending a patch that changes dos2unix to consider formfeeds
a valid character in text files.  I hope that you will consider
applying it or an equivalent in an upcoming dos2unix release.

Thanks,

Ben.

Index: dos2unix.c
===================================================================
--- dos2unix.c  (revision 197)
+++ dos2unix.c  (working copy)
@@ -304,7 +304,8 @@
               (TempChar < 32) &&
               (TempChar != '\x0a') &&  /* Not an LF */
               (TempChar != '\x0d') &&  /* Not a CR */
-              (TempChar != '\x09')) {  /* Not a TAB */
+              (TempChar != '\x09') &&  /* Not a TAB */
+              (TempChar != '\x0c')) {  /* Not a form feed */
             RetVal = -1;
             ipFlag->status |= BINARY_FILE ;
             break;
@@ -327,7 +328,8 @@
               (TempChar < 32) &&
               (TempChar != '\x0a') &&  /* Not an LF */
               (TempChar != '\x0d') &&  /* Not a CR */
-              (TempChar != '\x09')) {  /* Not a TAB */
+              (TempChar != '\x09') &&  /* Not a TAB */
+              (TempChar != '\x0c')) {  /* Not a form feed */
             RetVal = -1;
             ipFlag->status |= BINARY_FILE ;
             break;
@@ -350,7 +352,8 @@
               (TempChar < 32) &&
               (TempChar != '\x0a') &&  /* Not an LF */
               (TempChar != '\x0d') &&  /* Not a CR */
-              (TempChar != '\x09')) {  /* Not a TAB */
+              (TempChar != '\x09') &&  /* Not a TAB */
+              (TempChar != '\x0c')) {  /* Not a form feed */
             RetVal = -1;
             ipFlag->status |= BINARY_FILE ;
             break;
@@ -373,7 +376,8 @@
               (TempChar < 32) &&
               (TempChar != '\x0a') &&  /* Not an LF */
               (TempChar != '\x0d') &&  /* Not a CR */
-              (TempChar != '\x09')) {  /* Not a TAB */
+              (TempChar != '\x09') &&  /* Not a TAB */
+              (TempChar != '\x0c')) {  /* Not a form feed */
             RetVal = -1;
             ipFlag->status |= BINARY_FILE ;
             break;
Index: unix2dos.c
===================================================================
--- unix2dos.c  (revision 197)
+++ unix2dos.c  (working copy)
@@ -281,7 +281,8 @@
               (TempChar < 32) &&
               (TempChar != '\x0a') &&  /* Not an LF */
               (TempChar != '\x0d') &&  /* Not a CR */
-              (TempChar != '\x09')) {  /* Not a TAB */
+              (TempChar != '\x09') &&  /* Not a TAB */
+              (TempChar != '\x0c')) {  /* Not a form feed */
             RetVal = -1;
             ipFlag->status |= BINARY_FILE ;
             break;
@@ -319,7 +320,8 @@
               (TempChar < 32) &&
               (TempChar != '\x0a') &&  /* Not an LF */
               (TempChar != '\x0d') &&  /* Not a CR */
-              (TempChar != '\x09')) {  /* Not a TAB */
+              (TempChar != '\x09') &&  /* Not a TAB */
+              (TempChar != '\x0c')) {  /* Not a form feed */
             RetVal = -1;
             ipFlag->status |= BINARY_FILE ;
             break;
@@ -357,7 +359,8 @@
               (TempChar < 32) &&
               (TempChar != '\x0a') &&  /* Not an LF */
               (TempChar != '\x0d') &&  /* Not a CR */
-              (TempChar != '\x09')) {  /* Not a TAB */
+              (TempChar != '\x09') &&  /* Not a TAB */
+              (TempChar != '\x0c')) {  /* Not a form feed */
             RetVal = -1;
             ipFlag->status |= BINARY_FILE ;
             break;
@@ -395,7 +398,8 @@
               (TempChar < 32) &&
               (TempChar != '\x0a') &&  /* Not an LF */
               (TempChar != '\x0d') &&  /* Not a CR */
-              (TempChar != '\x09')) {  /* Not a TAB */
+              (TempChar != '\x09') &&  /* Not a TAB */
+              (TempChar != '\x0c')) {  /* Not a form feed */
             RetVal = -1;
             ipFlag->status |= BINARY_FILE ;
             break;

-- 
Ben Pfaff 
http://benpfaff.org



reply via email to

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