@@ -55,10 +55,13 @@ static char *run(struct ui_ctx *, const struct command *);
5555static char * eat_whitespace (char * );
5656static char * * collect_args (char * * , size_t * , char * * );
5757
58- static char * act_create (struct ui_ctx * , char * target , size_t argc , char * * argv );
59- static char * act_remove (struct ui_ctx * , char * target , size_t argc , char * * argv );
58+ static char * act_create (
59+ struct ui_ctx * , char * target , size_t argc , char * * argv );
60+ static char * act_remove (
61+ struct ui_ctx * , char * target , size_t argc , char * * argv );
6062static char * act_rect (struct ui_ctx * , char * target , size_t argc , char * * argv );
61- static char * act_circle (struct ui_ctx * , char * target , size_t argc , char * * argv );
63+ static char * act_circle (
64+ struct ui_ctx * , char * target , size_t argc , char * * argv );
6265static char * act_line (struct ui_ctx * , char * target , size_t argc , char * * argv );
6366static char * act_copy_rect (
6467 struct ui_ctx * , char * target , size_t argc , char * * argv );
@@ -259,19 +262,21 @@ static char *call_action(struct ui_ctx *ctx, const struct command *c,
259262 char * ret = malloc (512 );
260263 snprintf (ret , 512 , "no such action found: %s" , c -> action );
261264 return ret ;
262- } else return NULL ;
265+ } else
266+ return NULL ;
263267}
264268
265269static char * run (struct ui_ctx * ctx , const struct command * c )
266270{
267271 char * ret = NULL ;
268272 if (strcmp (c -> target_name , "root" ) == 0 ) {
269273 if ((ret = call_action (ctx , c , root_actions ,
270- sizeof (root_actions ) / sizeof (* root_actions ), false)))
274+ sizeof (root_actions ) / sizeof (* root_actions ), false)))
271275 return ret ;
272276 }
273277
274- ret = call_action (ctx , c , actions , sizeof (actions ) / sizeof (* actions ), true);
278+ ret = call_action (
279+ ctx , c , actions , sizeof (actions ) / sizeof (* actions ), true);
275280 return ret ;
276281}
277282
@@ -330,7 +335,8 @@ static char *act_create(
330335 enum ui_failure r = ui_pane_create (ctx , target , fill );
331336 if (r != UI_OK ) {
332337 err_buf = malloc (1024 );
333- snprintf (err_buf , 1024 , "act_create: failed: %s" , ui_failure_str (r ));
338+ snprintf (
339+ err_buf , 1024 , "act_create: failed: %s" , ui_failure_str (r ));
334340 }
335341
336342 return err_buf ;
@@ -346,20 +352,23 @@ static char *act_remove(
346352 enum ui_failure r = ui_pane_remove (ctx , target );
347353 if (r != UI_OK ) {
348354 err_buf = malloc (1024 );
349- snprintf (err_buf , 1024 , "act_remove: failed: %s" , ui_failure_str (r ));
355+ snprintf (
356+ err_buf , 1024 , "act_remove: failed: %s" , ui_failure_str (r ));
350357 }
351358
352359 return err_buf ;
353360}
354361
355- static char * act_rect (struct ui_ctx * ctx , char * target , size_t argc , char * * argv )
362+ static char * act_rect (
363+ struct ui_ctx * ctx , char * target , size_t argc , char * * argv )
356364{
357365 char * err_buf = NULL ;
358366 struct rect rect ;
359367
360368 long x , y , w , h ;
361369
362- if ((err_buf = parse_args ("ciiii" , argc , argv , & rect .c , & x , & y , & w , & h )))
370+ if ((err_buf =
371+ parse_args ("ciiii" , argc , argv , & rect .c , & x , & y , & w , & h )))
363372 return err_buf ;
364373
365374 rect .x = x ;
@@ -372,7 +381,8 @@ static char *act_rect(struct ui_ctx *ctx, char *target, size_t argc, char **argv
372381
373382 if (r != UI_OK ) {
374383 err_buf = malloc (1024 );
375- snprintf (err_buf , 1024 , "act_rect: failed: %s" , ui_failure_str (r ));
384+ snprintf (
385+ err_buf , 1024 , "act_rect: failed: %s" , ui_failure_str (r ));
376386 }
377387
378388 return err_buf ;
@@ -398,20 +408,23 @@ static char *act_circle(
398408
399409 if (r != UI_OK ) {
400410 err_buf = malloc (1024 );
401- snprintf (err_buf , 1024 , "act_circle: failed: %s" , ui_failure_str (r ));
411+ snprintf (
412+ err_buf , 1024 , "act_circle: failed: %s" , ui_failure_str (r ));
402413 }
403414
404415 return err_buf ;
405416}
406417
407- static char * act_line (struct ui_ctx * ctx , char * target , size_t argc , char * * argv )
418+ static char * act_line (
419+ struct ui_ctx * ctx , char * target , size_t argc , char * * argv )
408420{
409421 char * err_buf = NULL ;
410422 struct line line ;
411423
412424 long x0 , y0 , x1 , y1 ;
413425
414- if ((err_buf = parse_args ("ciiii" , argc , argv , & line .c , & x0 , & y0 , & x1 , & y1 )))
426+ if ((err_buf = parse_args (
427+ "ciiii" , argc , argv , & line .c , & x0 , & y0 , & x1 , & y1 )))
415428 return err_buf ;
416429
417430 line .x0 = x0 ;
@@ -424,7 +437,8 @@ static char *act_line(struct ui_ctx *ctx, char *target, size_t argc, char **argv
424437
425438 if (r != UI_OK ) {
426439 err_buf = malloc (1024 );
427- snprintf (err_buf , 1024 , "act_line: failed: %s" , ui_failure_str (r ));
440+ snprintf (
441+ err_buf , 1024 , "act_line: failed: %s" , ui_failure_str (r ));
428442 }
429443
430444 return err_buf ;
@@ -439,7 +453,7 @@ static char *act_copy_rect(
439453 long dst_x , dst_y , src_x , src_y , w , h ;
440454
441455 if ((err_buf = parse_args (
442- "iiiiii" , argc , argv , & dst_x , & dst_y , & src_x , & src_y , & w , & h )))
456+ "iiiiii" , argc , argv , & dst_x , & dst_y , & src_x , & src_y , & w , & h )))
443457 return err_buf ;
444458
445459 rc .dst_x = dst_x ;
@@ -454,7 +468,8 @@ static char *act_copy_rect(
454468
455469 if (r != UI_OK ) {
456470 err_buf = malloc (1024 );
457- snprintf (err_buf , 1024 , "act_copy_rect: failed: %s" , ui_failure_str (r ));
471+ snprintf (err_buf , 1024 , "act_copy_rect: failed: %s" ,
472+ ui_failure_str (r ));
458473 }
459474
460475 return err_buf ;
@@ -526,10 +541,12 @@ static char *parse_args(const char *fmt, size_t argc, char **argv, ...)
526541 va_list args ;
527542 va_start (args , argv );
528543 char * err_buf = malloc (1024 );
529- if (!err_buf ) FATAL_ERR ("parse_args: OOM" );
544+ if (!err_buf )
545+ FATAL_ERR ("parse_args: OOM" );
530546
531547 if (argc != strlen (fmt )) {
532- snprintf (err_buf , 1024 , "failure: got %zu arguments, expected %lu." , argc ,
548+ snprintf (err_buf , 1024 ,
549+ "failure: got %zu arguments, expected %lu." , argc ,
533550 strlen (fmt ));
534551 return err_buf ;
535552 }
@@ -542,7 +559,8 @@ static char *parse_args(const char *fmt, size_t argc, char **argv, ...)
542559 case 'c' :
543560 struct color * cout = va_arg (args , struct color * );
544561 if (!parse_color (in , cout )) {
545- snprintf (err_buf , 1024 , "failure: expected color, got: %s" , in );
562+ snprintf (err_buf , 1024 ,
563+ "failure: expected color, got: %s" , in );
546564 return err_buf ;
547565 }
548566
@@ -553,7 +571,8 @@ static char *parse_args(const char *fmt, size_t argc, char **argv, ...)
553571 long iout = strtol (in , & end , 0 );
554572 * out = iout ;
555573 if (* end != '\0' ) {
556- snprintf (err_buf , 1024 , "failure: expected number, got: %s" , in );
574+ snprintf (err_buf , 1024 ,
575+ "failure: expected number, got: %s" , in );
557576 return err_buf ;
558577 }
559578 break ;
0 commit comments