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)
292292 }
293293}
294294
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+
295308static void wt_status_print_change_data (struct wt_status * s ,
296309 int change_type ,
297310 struct string_list_item * it )
@@ -310,13 +323,8 @@ static void wt_status_print_change_data(struct wt_status *s,
310323 int len ;
311324
312325 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' );
320328 label_width += strlen (" " );
321329 padding = xmallocz (label_width );
322330 memset (padding , ' ' , label_width );
You can’t perform that action at this time.
0 commit comments