Fossil SCM

Merge updates from branch. Gracefully handle the case where the first line contains no spaces.

mistachkin 2014-06-19 05:43 experimental merge
Commit d54762928054fa44c6f184db87cef6b78a5c033b
+9 -2
--- src/comformat.c
+++ src/comformat.c
@@ -99,20 +99,27 @@
9999
}
100100
break;
101101
}
102102
len += ((zText[0]=='\t') ? 8 : 1);
103103
if( zText[0]=='\n' || len>=tlen ){
104
+ const char *zNewLine;
104105
if( doIndent ){
105106
fossil_print("%*s", indent, "");
106107
}
107108
doIndent = 1;
109
+ zNewLine = zText + 1;
108110
while( zText>zLine && !fossil_isspace(zText[0]) ){ zText--; }
109
- fossil_print("%.*s", (int)(zText - zLine), zLine);
111
+ if( zText>zLine ){
112
+ fossil_print("%.*s", (int)(zText - zLine), zLine);
113
+ zLine = zText;
114
+ }else{
115
+ fossil_print("%.*s", (int)(zNewLine - zLine), zLine);
116
+ zLine = zNewLine;
117
+ }
110118
if( fossil_force_newline() ){
111119
lineCnt++;
112120
}
113
- zLine = zText;
114121
if( !zLine++ ) break;
115122
len = 0;
116123
}
117124
zText++;
118125
}
119126
120127
ADDED test/comment.test
--- src/comformat.c
+++ src/comformat.c
@@ -99,20 +99,27 @@
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>zLine && !fossil_isspace(zText[0]) ){ zText--; }
109 fossil_print("%.*s", (int)(zText - zLine), zLine);
 
 
 
 
 
 
110 if( fossil_force_newline() ){
111 lineCnt++;
112 }
113 zLine = zText;
114 if( !zLine++ ) break;
115 len = 0;
116 }
117 zText++;
118 }
119
120 DDED test/comment.test
--- src/comformat.c
+++ src/comformat.c
@@ -99,20 +99,27 @@
99 }
100 break;
101 }
102 len += ((zText[0]=='\t') ? 8 : 1);
103 if( zText[0]=='\n' || len>=tlen ){
104 const char *zNewLine;
105 if( doIndent ){
106 fossil_print("%*s", indent, "");
107 }
108 doIndent = 1;
109 zNewLine = zText + 1;
110 while( zText>zLine && !fossil_isspace(zText[0]) ){ zText--; }
111 if( zText>zLine ){
112 fossil_print("%.*s", (int)(zText - zLine), zLine);
113 zLine = zText;
114 }else{
115 fossil_print("%.*s", (int)(zNewLine - zLine), zLine);
116 zLine = zNewLine;
117 }
118 if( fossil_force_newline() ){
119 lineCnt++;
120 }
 
121 if( !zLine++ ) break;
122 len = 0;
123 }
124 zText++;
125 }
126
127 DDED test/comment.test
+9 -2
--- src/comformat.c
+++ src/comformat.c
@@ -99,20 +99,27 @@
9999
}
100100
break;
101101
}
102102
len += ((zText[0]=='\t') ? 8 : 1);
103103
if( zText[0]=='\n' || len>=tlen ){
104
+ const char *zNewLine;
104105
if( doIndent ){
105106
fossil_print("%*s", indent, "");
106107
}
107108
doIndent = 1;
109
+ zNewLine = zText + 1;
108110
while( zText>zLine && !fossil_isspace(zText[0]) ){ zText--; }
109
- fossil_print("%.*s", (int)(zText - zLine), zLine);
111
+ if( zText>zLine ){
112
+ fossil_print("%.*s", (int)(zText - zLine), zLine);
113
+ zLine = zText;
114
+ }else{
115
+ fossil_print("%.*s", (int)(zNewLine - zLine), zLine);
116
+ zLine = zNewLine;
117
+ }
110118
if( fossil_force_newline() ){
111119
lineCnt++;
112120
}
113
- zLine = zText;
114121
if( !zLine++ ) break;
115122
len = 0;
116123
}
117124
zText++;
118125
}
119126
120127
ADDED test/comment.test
--- src/comformat.c
+++ src/comformat.c
@@ -99,20 +99,27 @@
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>zLine && !fossil_isspace(zText[0]) ){ zText--; }
109 fossil_print("%.*s", (int)(zText - zLine), zLine);
 
 
 
 
 
 
110 if( fossil_force_newline() ){
111 lineCnt++;
112 }
113 zLine = zText;
114 if( !zLine++ ) break;
115 len = 0;
116 }
117 zText++;
118 }
119
120 DDED test/comment.test
--- src/comformat.c
+++ src/comformat.c
@@ -99,20 +99,27 @@
99 }
100 break;
101 }
102 len += ((zText[0]=='\t') ? 8 : 1);
103 if( zText[0]=='\n' || len>=tlen ){
104 const char *zNewLine;
105 if( doIndent ){
106 fossil_print("%*s", indent, "");
107 }
108 doIndent = 1;
109 zNewLine = zText + 1;
110 while( zText>zLine && !fossil_isspace(zText[0]) ){ zText--; }
111 if( zText>zLine ){
112 fossil_print("%.*s", (int)(zText - zLine), zLine);
113 zLine = zText;
114 }else{
115 fossil_print("%.*s", (int)(zNewLine - zLine), zLine);
116 zLine = zNewLine;
117 }
118 if( fossil_force_newline() ){
119 lineCnt++;
120 }
 
121 if( !zLine++ ) break;
122 len = 0;
123 }
124 zText++;
125 }
126
127 DDED test/comment.test
--- a/test/comment.test
+++ b/test/comment.test
@@ -0,0 +1,2 @@
1
+#
2
+#\n c\n c
--- a/test/comment.test
+++ b/test/comment.test
@@ -0,0 +1,2 @@
 
 
--- a/test/comment.test
+++ b/test/comment.test
@@ -0,0 +1,2 @@
1 #
2 #\n c\n c
--- a/test/comment.test
+++ b/test/comment.test
@@ -1,2 +1,2 @@
11
#
2
-# Copyri
2
+#\n c\n c
--- a/test/comment.test
+++ b/test/comment.test
@@ -1,2 +1,2 @@
1 #
2 # Copyri
--- a/test/comment.test
+++ b/test/comment.test
@@ -1,2 +1,2 @@
1 #
2 #\n c\n c
+7 -6
--- test/tester.tcl
+++ test/tester.tcl
@@ -21,10 +21,11 @@
2121
#
2222
# Where ../test/tester.tcl is the name of this file and ../bld/fossil
2323
# is the name of the executable to be tested.
2424
#
2525
26
+set testrundir [pwd]
2627
set testdir [file normalize [file dir $argv0]]
2728
set fossilexe [file normalize [lindex $argv 0]]
2829
set argv [lrange $argv 1 end]
2930
3031
set i [lsearch $argv -halt]
@@ -59,25 +60,25 @@
5960
6061
# start protocol
6162
#
6263
proc protInit {cmd} {
6364
if {$::PROT} {
64
- set out [open "prot" w]
65
+ set out [open [file join $::testrundir prot] w]
6566
fconfigure $out -translation platform
66
- puts $out "starting tests with:$cmd"
67
+ puts $out "starting tests with: $cmd"
6768
close $out
6869
}
6970
}
7071
7172
# write protocol
7273
#
7374
proc protOut {msg} {
74
- puts "$msg"
75
+ puts stdout $msg
7576
if {$::PROT} {
76
- set out [open "prot" a]
77
+ set out [open [file join $::testrundir prot] a]
7778
fconfigure $out -translation platform
78
- puts $out "$msg"
79
+ puts $out $msg
7980
close $out
8081
}
8182
}
8283
8384
# Run the fossil program
@@ -92,11 +93,11 @@
9293
9394
flush stdout
9495
set rc [catch {eval exec $cmd} result]
9596
global RESULT CODE
9697
set CODE $rc
97
- if {$rc} {puts "ERROR: $result"}
98
+ if {$rc} {protOut "ERROR: $result"}
9899
set RESULT $result
99100
}
100101
101102
# Read a file into memory.
102103
#
103104
--- test/tester.tcl
+++ test/tester.tcl
@@ -21,10 +21,11 @@
21 #
22 # Where ../test/tester.tcl is the name of this file and ../bld/fossil
23 # is the name of the executable to be tested.
24 #
25
 
26 set testdir [file normalize [file dir $argv0]]
27 set fossilexe [file normalize [lindex $argv 0]]
28 set argv [lrange $argv 1 end]
29
30 set i [lsearch $argv -halt]
@@ -59,25 +60,25 @@
59
60 # start protocol
61 #
62 proc protInit {cmd} {
63 if {$::PROT} {
64 set out [open "prot" w]
65 fconfigure $out -translation platform
66 puts $out "starting tests with:$cmd"
67 close $out
68 }
69 }
70
71 # write protocol
72 #
73 proc protOut {msg} {
74 puts "$msg"
75 if {$::PROT} {
76 set out [open "prot" a]
77 fconfigure $out -translation platform
78 puts $out "$msg"
79 close $out
80 }
81 }
82
83 # Run the fossil program
@@ -92,11 +93,11 @@
92
93 flush stdout
94 set rc [catch {eval exec $cmd} result]
95 global RESULT CODE
96 set CODE $rc
97 if {$rc} {puts "ERROR: $result"}
98 set RESULT $result
99 }
100
101 # Read a file into memory.
102 #
103
--- test/tester.tcl
+++ test/tester.tcl
@@ -21,10 +21,11 @@
21 #
22 # Where ../test/tester.tcl is the name of this file and ../bld/fossil
23 # is the name of the executable to be tested.
24 #
25
26 set testrundir [pwd]
27 set testdir [file normalize [file dir $argv0]]
28 set fossilexe [file normalize [lindex $argv 0]]
29 set argv [lrange $argv 1 end]
30
31 set i [lsearch $argv -halt]
@@ -59,25 +60,25 @@
60
61 # start protocol
62 #
63 proc protInit {cmd} {
64 if {$::PROT} {
65 set out [open [file join $::testrundir prot] w]
66 fconfigure $out -translation platform
67 puts $out "starting tests with: $cmd"
68 close $out
69 }
70 }
71
72 # write protocol
73 #
74 proc protOut {msg} {
75 puts stdout $msg
76 if {$::PROT} {
77 set out [open [file join $::testrundir prot] a]
78 fconfigure $out -translation platform
79 puts $out $msg
80 close $out
81 }
82 }
83
84 # Run the fossil program
@@ -92,11 +93,11 @@
93
94 flush stdout
95 set rc [catch {eval exec $cmd} result]
96 global RESULT CODE
97 set CODE $rc
98 if {$rc} {protOut "ERROR: $result"}
99 set RESULT $result
100 }
101
102 # Read a file into memory.
103 #
104

Keyboard Shortcuts

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