@@ -116,6 +116,9 @@ typedef struct {
116116
117117 int pending_empty_lines ;
118118
119+ int whitespace_corrected [64 ];
120+ int count_whitespace_corrected ;
121+
119122 char ongoing ;
120123 char skip_this_one ;
121124 char lead_in_active ;
@@ -380,7 +383,7 @@ fixdiff_find_original(dp_t *pdp, int *line_start)
380383 elog ("Unable to skip temp lines\n" );
381384 return 1 ;
382385 }
383- elog ("Stanza %d: removing extra lead-in\n" , pdp -> stanzas );
386+ elog (" stanza %d: removing extra lead-in\n" , pdp -> stanzas );
384387 pdp -> lead_in -- ;
385388 pdp -> lead_in_corrected ++ ;
386389 pdp -> pre -- ;
@@ -399,13 +402,16 @@ fixdiff_find_original(dp_t *pdp, int *line_start)
399402 return 1 ;
400403 }
401404
405+ pdp -> count_whitespace_corrected = 0 ;
406+
402407 /*
403408 * Outer loop walks through each line in source.
404409 * Inner loop tries to match starting from that line
405410 */
406411
407412 while (!hit ) {
408413 line_ending_t let , les ;
414+ int n ;
409415
410416 init_lbuf (& lb , "src_comp" );
411417 lb .fd = open (pdp -> pf , OFLAGS (O_RDONLY ));
@@ -437,7 +443,8 @@ fixdiff_find_original(dp_t *pdp, int *line_start)
437443 break ;
438444
439445 if (!ls ) {
440- elog ("Failed to match, best chunk %d lines started at %s:%d (tabs shown below as >)\n" ,
446+ elog ("**** Failed to match, best chunk %d lines started at %s:%d "
447+ "(tabs shown below as >)\n" ,
441448 lmc , pdp -> pf , lg_lis );
442449 elog ("last match: patch = '%s"
443450 "', source = '%s'\n" , b1 , b2 );
@@ -484,7 +491,12 @@ fixdiff_find_original(dp_t *pdp, int *line_start)
484491 if ((p1 < p1_end ) != (p2 < p2_end ))
485492 goto record_breakage ;
486493
487- elog ("(fixable whitespace-only difference at stanza line %d)\n" , lb_temp .li );
494+ for (n = 0 ; n < pdp -> count_whitespace_corrected ; n ++ )
495+ if (pdp -> whitespace_corrected [n ] == lb_temp .li )
496+ break ;
497+ if (n == pdp -> count_whitespace_corrected &&
498+ pdp -> count_whitespace_corrected < sizeof (pdp -> whitespace_corrected ) / sizeof (int ))
499+ pdp -> whitespace_corrected [pdp -> count_whitespace_corrected ++ ] = lb_temp .li ;
488500
489501 /*
490502 * We have to take care about picking up windows _TEXT
@@ -592,8 +604,7 @@ fixdiff_find_original(dp_t *pdp, int *line_start)
592604 }
593605
594606 if (lea != LE_ZERO )
595- if (write (lb_temp .fd , "\n" , TO_POSLEN (1 )) !=
596- (ssize_t )1 ) {
607+ if (write (lb_temp .fd , "\n" , TO_POSLEN (1 )) != (ssize_t )1 ) {
597608 close (lb_ef .fd );
598609 pdp -> reason = "failed to write extra "
599610 "stanza trailer to temp file" ;
@@ -608,12 +619,16 @@ fixdiff_find_original(dp_t *pdp, int *line_start)
608619 }
609620
610621 if (a )
611- elog ("Stanza %d: detected patch at EOF: "
622+ elog (" stanza %d: detected patch at EOF: "
612623 "added %d context at end\n" ,
613624 pdp -> stanzas , a );
614625
615626 close (lb_ef .fd );
616627 }
628+
629+ if (pdp -> count_whitespace_corrected )
630+ elog (" stanza %d: fixed %d lines with whitespace-only fuzz\n" ,
631+ pdp -> stanzas , pdp -> count_whitespace_corrected );
617632 }
618633
619634out :
@@ -642,7 +657,7 @@ fixdiff_stanza_end(dp_t *pdp)
642657 }
643658
644659 if (dp .pending_empty_lines )
645- elog (" Dropped %d unexpected empty lines\n" , dp .pending_empty_lines );
660+ elog (" stanza %d: Dropped %d unexpected empty lines\n" , pdp -> stanzas , dp .pending_empty_lines );
646661
647662 if (fixdiff_find_original (pdp , & orig )) {
648663 elog ("Unable to find original stanza in source\n" );
@@ -885,7 +900,8 @@ main(int argc, char *argv[])
885900 (in [0 ] == ' ' || in [0 ] == '-' || in [0 ] == '+' )) {
886901 char ctx [3 ];
887902
888- elog (" Treating %d unexpected newline(s) as context\n" , dp .pending_empty_lines );
903+ elog (" stanza %d: Treating %d unexpected newline(s) as context\n" ,
904+ dp .stanzas , dp .pending_empty_lines );
889905
890906 ctx [0 ] = ' ' ;
891907 ctx [1 ] = '\n' ;
@@ -959,15 +975,15 @@ main(int argc, char *argv[])
959975 in [2 ] = in [l1 + 1 ];
960976 in [3 ] = '\0' ;
961977 l = 3 ;
962- elog (" Reducing %u char whitespace-only line to CRLF\n" ,
963- (unsigned int )l1 );
978+ elog (" stanza %d: Reducing %u char whitespace-only "
979+ "line to CRLF\n" , dp . stanzas , (unsigned int )l1 );
964980 } else
965981 if (l1 > 1 && in [l1 ] == 0x0a && (l - l1 ) == 1 ) {
966982 in [1 ] = in [l1 ];
967983 in [2 ] = '\0' ;
968984 l = 2 ;
969- elog (" Reducing %d char whitespace-only line to LF\n" ,
970- (unsigned int )l1 );
985+ elog (" stanza %d: Reducing %d char whitespace-only"
986+ " line to LF\n" , dp . stanzas , (unsigned int )l1 );
971987 }
972988
973989 dp .post ++ ;
0 commit comments