Fossil SCM

Experimental changes for more precise handling of new lines.

mistachkin 2014-06-19 02:39 experimental
Commit 816faa5af962ddc252ed80cedcf93953e77bbdaa
2 files changed +9 -5 +6 -2
+9 -5
--- src/comformat.c
+++ src/comformat.c
@@ -91,23 +91,27 @@
9191
for(;;){
9292
if( zText[0]==0 ){
9393
if( doIndent ){
9494
fossil_print("%*s", indent, "");
9595
}
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
+ }
98100
break;
99101
}
100102
len += ((zText[0]=='\t') ? 8 : 1);
101103
if( zText[0]=='\n' || len>=tlen ){
102104
if( doIndent ){
103105
fossil_print("%*s", indent, "");
104106
}
105107
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
+ }
109113
zBuf = zText;
110114
if( !zBuf++ ) break;
111115
len = 0;
112116
}
113117
zText++;
114118
--- 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 @@
862862
863863
/*
864864
** Force the standard output cursor to move to the beginning
865865
** of a line, if it is not there already.
866866
*/
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;
869873
}
870874
871875
/*
872876
** Indicate that the cursor has moved to the start of a line by means
873877
** other than writing to standard output.
874878
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button