Fossil SCM
Experimental changes for more precise handling of new lines.
Commit
816faa5af962ddc252ed80cedcf93953e77bbdaa
Parent
c7c3d99a6081d76…
2 files changed
+9
-5
+6
-2
+9
-5
| --- src/comformat.c | ||
| +++ src/comformat.c | ||
| @@ -91,23 +91,27 @@ | ||
| 91 | 91 | for(;;){ |
| 92 | 92 | if( zText[0]==0 ){ |
| 93 | 93 | if( doIndent ){ |
| 94 | 94 | fossil_print("%*s", indent, ""); |
| 95 | 95 | } |
| 96 | - fossil_print("%.*s\n", (int)(zText - zBuf), zBuf); | |
| 97 | - lineCnt++; | |
| 96 | + fossil_print("%.*s", (int)(zText - zBuf), zBuf); | |
| 97 | + if( fossil_force_newline() ){ | |
| 98 | + lineCnt++; | |
| 99 | + } | |
| 98 | 100 | break; |
| 99 | 101 | } |
| 100 | 102 | len += ((zText[0]=='\t') ? 8 : 1); |
| 101 | 103 | if( zText[0]=='\n' || len>=tlen ){ |
| 102 | 104 | if( doIndent ){ |
| 103 | 105 | fossil_print("%*s", indent, ""); |
| 104 | 106 | } |
| 105 | 107 | doIndent = 1; |
| 106 | - while( !fossil_isspace(zText[0]) ){ zText--; } | |
| 107 | - fossil_print("%.*s\n", (int)(zText - zBuf), zBuf); | |
| 108 | - lineCnt++; | |
| 108 | + while( zText>zBuf && !fossil_isspace(zText[0]) ){ zText--; } | |
| 109 | + fossil_print("%.*s", (int)(zText - zBuf), zBuf); | |
| 110 | + if( fossil_force_newline() ){ | |
| 111 | + lineCnt++; | |
| 112 | + } | |
| 109 | 113 | zBuf = zText; |
| 110 | 114 | if( !zBuf++ ) break; |
| 111 | 115 | len = 0; |
| 112 | 116 | } |
| 113 | 117 | zText++; |
| 114 | 118 |
| --- src/comformat.c | |
| +++ src/comformat.c | |
| @@ -91,23 +91,27 @@ | |
| 91 | for(;;){ |
| 92 | if( zText[0]==0 ){ |
| 93 | if( doIndent ){ |
| 94 | fossil_print("%*s", indent, ""); |
| 95 | } |
| 96 | fossil_print("%.*s\n", (int)(zText - zBuf), zBuf); |
| 97 | lineCnt++; |
| 98 | break; |
| 99 | } |
| 100 | len += ((zText[0]=='\t') ? 8 : 1); |
| 101 | if( zText[0]=='\n' || len>=tlen ){ |
| 102 | if( doIndent ){ |
| 103 | fossil_print("%*s", indent, ""); |
| 104 | } |
| 105 | doIndent = 1; |
| 106 | while( !fossil_isspace(zText[0]) ){ zText--; } |
| 107 | fossil_print("%.*s\n", (int)(zText - zBuf), zBuf); |
| 108 | lineCnt++; |
| 109 | zBuf = zText; |
| 110 | if( !zBuf++ ) break; |
| 111 | len = 0; |
| 112 | } |
| 113 | zText++; |
| 114 |
| --- src/comformat.c | |
| +++ src/comformat.c | |
| @@ -91,23 +91,27 @@ | |
| 91 | for(;;){ |
| 92 | if( zText[0]==0 ){ |
| 93 | if( doIndent ){ |
| 94 | fossil_print("%*s", indent, ""); |
| 95 | } |
| 96 | fossil_print("%.*s", (int)(zText - zBuf), zBuf); |
| 97 | if( fossil_force_newline() ){ |
| 98 | lineCnt++; |
| 99 | } |
| 100 | break; |
| 101 | } |
| 102 | len += ((zText[0]=='\t') ? 8 : 1); |
| 103 | if( zText[0]=='\n' || len>=tlen ){ |
| 104 | if( doIndent ){ |
| 105 | fossil_print("%*s", indent, ""); |
| 106 | } |
| 107 | doIndent = 1; |
| 108 | while( zText>zBuf && !fossil_isspace(zText[0]) ){ zText--; } |
| 109 | fossil_print("%.*s", (int)(zText - zBuf), zBuf); |
| 110 | if( fossil_force_newline() ){ |
| 111 | lineCnt++; |
| 112 | } |
| 113 | zBuf = zText; |
| 114 | if( !zBuf++ ) break; |
| 115 | len = 0; |
| 116 | } |
| 117 | zText++; |
| 118 |
+6
-2
| --- src/printf.c | ||
| +++ src/printf.c | ||
| @@ -862,12 +862,16 @@ | ||
| 862 | 862 | |
| 863 | 863 | /* |
| 864 | 864 | ** Force the standard output cursor to move to the beginning |
| 865 | 865 | ** of a line, if it is not there already. |
| 866 | 866 | */ |
| 867 | -void fossil_force_newline(void){ | |
| 868 | - if( g.cgiOutput==0 && stdoutAtBOL==0 ) fossil_puts("\n", 0); | |
| 867 | +int fossil_force_newline(void){ | |
| 868 | + if( g.cgiOutput==0 && stdoutAtBOL==0 ){ | |
| 869 | + fossil_puts("\n", 0); | |
| 870 | + return 1; | |
| 871 | + } | |
| 872 | + return 0; | |
| 869 | 873 | } |
| 870 | 874 | |
| 871 | 875 | /* |
| 872 | 876 | ** Indicate that the cursor has moved to the start of a line by means |
| 873 | 877 | ** other than writing to standard output. |
| 874 | 878 |
| --- src/printf.c | |
| +++ src/printf.c | |
| @@ -862,12 +862,16 @@ | |
| 862 | |
| 863 | /* |
| 864 | ** Force the standard output cursor to move to the beginning |
| 865 | ** of a line, if it is not there already. |
| 866 | */ |
| 867 | void fossil_force_newline(void){ |
| 868 | if( g.cgiOutput==0 && stdoutAtBOL==0 ) fossil_puts("\n", 0); |
| 869 | } |
| 870 | |
| 871 | /* |
| 872 | ** Indicate that the cursor has moved to the start of a line by means |
| 873 | ** other than writing to standard output. |
| 874 |
| --- src/printf.c | |
| +++ src/printf.c | |
| @@ -862,12 +862,16 @@ | |
| 862 | |
| 863 | /* |
| 864 | ** Force the standard output cursor to move to the beginning |
| 865 | ** of a line, if it is not there already. |
| 866 | */ |
| 867 | int fossil_force_newline(void){ |
| 868 | if( g.cgiOutput==0 && stdoutAtBOL==0 ){ |
| 869 | fossil_puts("\n", 0); |
| 870 | return 1; |
| 871 | } |
| 872 | return 0; |
| 873 | } |
| 874 | |
| 875 | /* |
| 876 | ** Indicate that the cursor has moved to the start of a line by means |
| 877 | ** other than writing to standard output. |
| 878 |