Fossil SCM

Tweak the command-line side-by-side diff output so that it deals sanely with \r and \f characters.

drh 2011-10-22 13:29 trunk
Commit 4092208afca3ffe24a1077800df01ff897945c96
1 file changed +5 -2
+5 -2
--- src/diff.c
+++ src/diff.c
@@ -317,15 +317,18 @@
317317
static int sbsWriteText(char *z, DLine *pLine, int width, int trunc){
318318
int n = pLine->h & LENGTH_MASK;
319319
int i, j;
320320
const char *zIn = pLine->z;
321321
for(i=j=0; i<n && j<width; i++){
322
- if( zIn[i]=='\t' ){
322
+ char c = zIn[i];
323
+ if( c=='\t' ){
323324
z[j++] = ' ';
324325
while( (j&7)!=0 && j<width ) z[j++] = ' ';
326
+ }else if( c=='\r' || c=='\f' ){
327
+ z[j++] = ' ';
325328
}else{
326
- z[j++] = zIn[i];
329
+ z[j++] = c;
327330
}
328331
}
329332
if( trunc ){
330333
z[j++] = '\n';
331334
z[j] = 0;
332335
--- src/diff.c
+++ src/diff.c
@@ -317,15 +317,18 @@
317 static int sbsWriteText(char *z, DLine *pLine, int width, int trunc){
318 int n = pLine->h & LENGTH_MASK;
319 int i, j;
320 const char *zIn = pLine->z;
321 for(i=j=0; i<n && j<width; i++){
322 if( zIn[i]=='\t' ){
 
323 z[j++] = ' ';
324 while( (j&7)!=0 && j<width ) z[j++] = ' ';
 
 
325 }else{
326 z[j++] = zIn[i];
327 }
328 }
329 if( trunc ){
330 z[j++] = '\n';
331 z[j] = 0;
332
--- src/diff.c
+++ src/diff.c
@@ -317,15 +317,18 @@
317 static int sbsWriteText(char *z, DLine *pLine, int width, int trunc){
318 int n = pLine->h & LENGTH_MASK;
319 int i, j;
320 const char *zIn = pLine->z;
321 for(i=j=0; i<n && j<width; i++){
322 char c = zIn[i];
323 if( c=='\t' ){
324 z[j++] = ' ';
325 while( (j&7)!=0 && j<width ) z[j++] = ' ';
326 }else if( c=='\r' || c=='\f' ){
327 z[j++] = ' ';
328 }else{
329 z[j++] = c;
330 }
331 }
332 if( trunc ){
333 z[j++] = '\n';
334 z[j] = 0;
335

Keyboard Shortcuts

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