diff --git a/source/dialogs/combi.c b/source/dialogs/combi.c index 8d611a6b..2feb291a 100644 --- a/source/dialogs/combi.c +++ b/source/dialogs/combi.c @@ -58,8 +58,7 @@ static void combi_mode_parse_switchers ( Switcher *sw ) // Make a copy, as strtok will modify it. char *switcher_str = g_strdup ( config.combi_modi ); // Split token on ','. This modifies switcher_str. - for ( char *token = strtok_r ( switcher_str, ",", &savept ); - token != NULL; + for ( char *token = strtok_r ( switcher_str, ",", &savept ); token != NULL; token = strtok_r ( NULL, ",", &savept ) ) { // Resize and add entry. pd->switchers = (Switcher * *) g_realloc ( pd->switchers, @@ -164,9 +163,7 @@ static SwitcherMode combi_mode_result ( int mretv, char **input, unsigned int se for ( unsigned i = 0; i < pd->num_switchers; i++ ) { if ( selected_line >= pd->starts[i] && selected_line < ( pd->starts[i] + pd->lengths[i] ) ) { - return pd->switchers[i]->result ( mretv, - input, - selected_line - pd->starts[i], + return pd->switchers[i]->result ( mretv, input, selected_line - pd->starts[i], pd->switchers[i] ); } } @@ -179,11 +176,8 @@ static int combi_mode_match ( char **tokens, const char *input, for ( unsigned i = 0; i < pd->num_switchers; i++ ) { if ( index >= pd->starts[i] && index < ( pd->starts[i] + pd->lengths[i] ) ) { - return pd->switchers[i]->token_match ( tokens, - input, - case_sensitive, - index - pd->starts[i], - pd->switchers[i] ); + return pd->switchers[i]->token_match ( tokens, input, case_sensitive, + index - pd->starts[i], pd->switchers[i] ); } } abort (); @@ -193,11 +187,9 @@ static const char * combi_mgrv ( unsigned int selected_line, void *sw, int *stat { CombiModePrivateData *pd = ( (Switcher *) sw )->private_data; for ( unsigned i = 0; i < pd->num_switchers; i++ ) { - if ( selected_line >= pd->starts[i] && selected_line < - ( pd->starts[i] + pd->lengths[i] ) ) { + if ( selected_line >= pd->starts[i] && selected_line < ( pd->starts[i] + pd->lengths[i] ) ) { g_free ( pd->cache ); - pd->cache = g_strdup_printf ( "(%s) %s", - pd->switchers[i]->name, + pd->cache = g_strdup_printf ( "(%s) %s", pd->switchers[i]->name, pd->switchers[i]->mgrv ( selected_line - pd->starts[i], (void *) pd->switchers[i], state ) ); return pd->cache; diff --git a/source/dialogs/dmenu.c b/source/dialogs/dmenu.c index d92ed614..1ef5eb2d 100644 --- a/source/dialogs/dmenu.c +++ b/source/dialogs/dmenu.c @@ -98,9 +98,7 @@ static char ** dmenu_mode_get_data ( unsigned int *length, Switcher *sw ) static void parse_pair ( char *input, struct range_pair *item ) { int index = 0; - for ( char *token = strsep ( &input, "-" ); - token != NULL; - token = strsep ( &input, "-" ) ) { + for ( char *token = strsep ( &input, "-" ); token != NULL; token = strsep ( &input, "-" ) ) { if ( index == 0 ) { item->start = item->stop = (unsigned int) strtoul ( token, NULL, 10 ); index++; @@ -119,9 +117,7 @@ static void parse_pair ( char *input, struct range_pair *item ) static void parse_ranges ( char *input, struct range_pair **list, unsigned int *length ) { char *endp; - for ( char *token = strtok_r ( input, ",", &endp ); - token != NULL; - token = strtok_r ( NULL, ",", &endp ) ) { + for ( char *token = strtok_r ( input, ",", &endp ); token != NULL; token = strtok_r ( NULL, ",", &endp ) ) { // Make space. *list = g_realloc ( ( *list ), ( ( *length ) + 1 ) * sizeof ( struct range_pair ) ); // Parse a single pair. @@ -318,8 +314,7 @@ int dmenu_switcher_dialog ( void ) do { unsigned int next_pos = pd->selected_line; - int mretv = menu ( &dmenu_mode, &input, pd->prompt, - &( pd->selected_line ), &next_pos, pd->message ); + int mretv = menu ( &dmenu_mode, &input, pd->prompt, &( pd->selected_line ), &next_pos, pd->message ); // Special behavior. // TODO clean this up! if ( only_selected ) { @@ -327,11 +322,8 @@ int dmenu_switcher_dialog ( void ) * Select item mode. */ restart = 1; - if ( ( mretv & ( MENU_OK | MENU_QUICK_SWITCH ) ) && cmd_list[pd->selected_line] != - NULL ) { - dmenu_output_formatted_line ( pd->format, cmd_list[pd->selected_line], - pd->selected_line, - input ); + if ( ( mretv & ( MENU_OK | MENU_QUICK_SWITCH ) ) && cmd_list[pd->selected_line] != NULL ) { + dmenu_output_formatted_line ( pd->format, cmd_list[pd->selected_line], pd->selected_line, input ); retv = TRUE; if ( ( mretv & MENU_QUICK_SWITCH ) ) { retv = 10 + ( mretv & MENU_LOWER_MASK ); @@ -349,9 +341,7 @@ int dmenu_switcher_dialog ( void ) restart = FALSE; // Normal mode if ( ( mretv & MENU_OK ) && cmd_list[pd->selected_line] != NULL ) { - dmenu_output_formatted_line ( pd->format, cmd_list[pd->selected_line], - pd->selected_line, - input ); + dmenu_output_formatted_line ( pd->format, cmd_list[pd->selected_line], pd->selected_line, input ); if ( ( mretv & MENU_SHIFT ) ) { restart = TRUE; // Move to next line. @@ -372,9 +362,7 @@ int dmenu_switcher_dialog ( void ) } // Quick switch with entry selected. else if ( ( mretv & MENU_QUICK_SWITCH ) && pd->selected_line < UINT32_MAX ) { - dmenu_output_formatted_line ( pd->format, cmd_list[pd->selected_line], - pd->selected_line, - input ); + dmenu_output_formatted_line ( pd->format, cmd_list[pd->selected_line], pd->selected_line, input ); restart = FALSE; retv = 10 + ( mretv & MENU_LOWER_MASK ); diff --git a/source/dialogs/run.c b/source/dialogs/run.c index fe87c935..87e826f2 100644 --- a/source/dialogs/run.c +++ b/source/dialogs/run.c @@ -56,12 +56,9 @@ static inline void execsh ( const char *cmd, int run_in_term ) helper_parse_setup ( config.run_command, &args, &argc, "{cmd}", cmd, NULL ); } GError *error = NULL; - g_spawn_async ( NULL, args, NULL, - G_SPAWN_SEARCH_PATH, - NULL, NULL, NULL, &error ); + g_spawn_async ( NULL, args, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, &error ); if ( error != NULL ) { - char *msg = g_strdup_printf ( "Failed to execute: '%s'\nError: '%s'", cmd, - error->message ); + char *msg = g_strdup_printf ( "Failed to execute: '%s'\nError: '%s'", cmd, error->message ); error_dialog ( msg, FALSE ); g_free ( msg ); // print error. @@ -187,18 +184,14 @@ static char ** get_apps ( unsigned int *length ) path = g_strdup ( getenv ( "PATH" ) ); - for ( const char *dirname = strtok ( path, ":" ); - dirname != NULL; - dirname = strtok ( NULL, ":" ) ) { + for ( const char *dirname = strtok ( path, ":" ); dirname != NULL; dirname = strtok ( NULL, ":" ) ) { DIR *dir = opendir ( dirname ); if ( dir != NULL ) { struct dirent *dent; while ( ( dent = readdir ( dir ) ) != NULL ) { - if ( dent->d_type != DT_REG && - dent->d_type != DT_LNK && - dent->d_type != DT_UNKNOWN ) { + if ( dent->d_type != DT_REG && dent->d_type != DT_LNK && dent->d_type != DT_UNKNOWN ) { continue; } // Skip dot files. @@ -240,9 +233,7 @@ static char ** get_apps ( unsigned int *length ) } // TODO: check this is still fast enough. (takes 1ms on laptop.) if ( ( *length ) > num_favorites ) { - g_qsort_with_data ( &retv[num_favorites], ( *length ) - num_favorites, sizeof ( char* ), - sort_func, - NULL ); + g_qsort_with_data ( &retv[num_favorites], ( *length ) - num_favorites, sizeof ( char* ), sort_func, NULL ); } g_free ( path ); diff --git a/source/dialogs/script.c b/source/dialogs/script.c index 3bb54b1a..915fc602 100644 --- a/source/dialogs/script.c +++ b/source/dialogs/script.c @@ -173,8 +173,7 @@ Switcher *script_switcher_parse_setup ( const char *str ) char *endp = NULL; char *parse = g_strdup ( str ); unsigned int index = 0; - for ( char *token = strtok_r ( parse, ":", &endp ); token != NULL; - token = strtok_r ( NULL, ":", &endp ) ) { + for ( char *token = strtok_r ( parse, ":", &endp ); token != NULL; token = strtok_r ( NULL, ":", &endp ) ) { if ( index == 0 ) { g_strlcpy ( sw->name, token, 32 ); } @@ -197,8 +196,7 @@ Switcher *script_switcher_parse_setup ( const char *str ) return sw; } - fprintf ( stderr, "The script command '%s' has %u options, but needs 2: :