This repository was archived by the owner on Nov 9, 2017. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -292,6 +292,19 @@ static const char *wt_status_diff_status_string(int status)
292
292
}
293
293
}
294
294
295
+ static int maxwidth (const char * (* label )(int ), int minval , int maxval )
296
+ {
297
+ int result = 0 , i ;
298
+
299
+ for (i = minval ; i <= maxval ; i ++ ) {
300
+ const char * s = label (i );
301
+ int len = s ? utf8_strwidth (s ) : 0 ;
302
+ if (len > result )
303
+ result = len ;
304
+ }
305
+ return result ;
306
+ }
307
+
295
308
static void wt_status_print_change_data (struct wt_status * s ,
296
309
int change_type ,
297
310
struct string_list_item * it )
@@ -310,13 +323,8 @@ static void wt_status_print_change_data(struct wt_status *s,
310
323
int len ;
311
324
312
325
if (!padding ) {
313
- /* If DIFF_STATUS_* uses outside this range, we're in trouble */
314
- for (status = 'A' ; status <= 'Z' ; status ++ ) {
315
- what = wt_status_diff_status_string (status );
316
- len = what ? strlen (what ) : 0 ;
317
- if (len > label_width )
318
- label_width = len ;
319
- }
326
+ /* If DIFF_STATUS_* uses outside the range [A..Z], we're in trouble */
327
+ label_width = maxwidth (wt_status_diff_status_string , 'A' , 'Z' );
320
328
label_width += strlen (" " );
321
329
padding = xmallocz (label_width );
322
330
memset (padding , ' ' , label_width );
You can’t perform that action at this time.
0 commit comments