@@ -344,13 +344,13 @@ static void mismatch_print(command_file_ctx_t *cc, char const *command,
344344 bool print_diff )
345345{
346346 char * g , * e ;
347- char * spaces ;
348347
349348 ERROR ("%s failed %s/%s:%d" , command , cc -> path , cc -> filename , cc -> lineno );
350- ERROR (" got : %.*s" , (int ) got_len , got );
351- ERROR (" expected : %.*s" , (int ) expected_len , expected );
352349
353- if (print_diff ) {
350+ if (!print_diff ) {
351+ ERROR (" got : %.*s" , (int ) got_len , got );
352+ ERROR (" expected : %.*s" , (int ) expected_len , expected );
353+ } else {
354354 g = got ;
355355 e = expected ;
356356
@@ -359,15 +359,23 @@ static void mismatch_print(command_file_ctx_t *cc, char const *command,
359359 e ++ ;
360360 }
361361
362- spaces = talloc_zero_array (NULL , char , (e - expected ) + 1 );
363- memset (spaces , ' ' , talloc_array_length (spaces ) - 1 );
364- if (((e - expected ) < 80 ) && (expected_len < 80 )) {
365- ERROR (" %s^ differs here" , spaces );
362+ if (expected_len < 80 ) {
363+ char const * spaces = " " ;
364+
365+ ERROR (" got : %.*s" , (int ) got_len , got );
366+ ERROR (" expected : %.*s" , (int ) expected_len , expected );
367+ ERROR (" %s^ differs here (%zu)" , spaces , e - expected );
366368 } else {
367- ERROR (" %s^ differs here (%zu) ... %.*s ..." , spaces , e - expected ,
368- 16 , e );
369+ size_t glen , elen ;
370+
371+ elen = strlen (e );
372+ if (elen > 40 ) elen = 40 ;
373+ glen = strlen (g );
374+ if (glen > 40 ) glen = 40 ;
375+
376+ ERROR ("(%zu) ... %.*s ... " , e - expected , (int ) elen , e );
377+ ERROR ("(%zu) ... %.*s ... " , e - expected , (int ) glen , g );
369378 }
370- talloc_free (spaces );
371379 }
372380}
373381
0 commit comments