mirror of https://github.com/davatorium/rofi.git
Indent.
This commit is contained in:
parent
697abdfdfc
commit
eaa553bfd5
|
@ -93,7 +93,7 @@ static char **get_dmenu ( FILE *fd, unsigned int *length )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(retv != NULL ) {
|
if ( retv != NULL ) {
|
||||||
retv[( *length ) + 1] = NULL;
|
retv[( *length ) + 1] = NULL;
|
||||||
retv = g_realloc ( retv, ( *length + 1 ) * sizeof ( char* ) );
|
retv = g_realloc ( retv, ( *length + 1 ) * sizeof ( char* ) );
|
||||||
}
|
}
|
||||||
|
@ -289,20 +289,22 @@ static void dmenu_mode_init ( Mode *sw )
|
||||||
}
|
}
|
||||||
FILE *fd = NULL;
|
FILE *fd = NULL;
|
||||||
str = NULL;
|
str = NULL;
|
||||||
if ( find_arg_str ("-input", &str)) {
|
if ( find_arg_str ( "-input", &str ) ) {
|
||||||
char *estr = rofi_expand_path(str);
|
char *estr = rofi_expand_path ( str );
|
||||||
fd = fopen(str, "r");
|
fd = fopen ( str, "r" );
|
||||||
if(fd == NULL ){
|
if ( fd == NULL ) {
|
||||||
char *msg = g_markup_printf_escaped("Failed to open file: <b>%s</b>:\n\t<i>%s</i>", estr, strerror(errno));
|
char *msg = g_markup_printf_escaped ( "Failed to open file: <b>%s</b>:\n\t<i>%s</i>", estr, strerror ( errno ) );
|
||||||
error_dialog (msg,TRUE);
|
error_dialog ( msg, TRUE );
|
||||||
g_free(msg);
|
g_free ( msg );
|
||||||
g_free(estr);
|
g_free ( estr );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
g_free(estr);
|
g_free ( estr );
|
||||||
|
}
|
||||||
|
pd->cmd_list = get_dmenu ( fd == NULL ? stdin : fd, &( pd->cmd_list_length ) );
|
||||||
|
if ( fd != NULL ) {
|
||||||
|
fclose ( fd );
|
||||||
}
|
}
|
||||||
pd->cmd_list = get_dmenu ( fd == NULL?stdin:fd , &( pd->cmd_list_length ) );
|
|
||||||
if(fd != NULL ) fclose(fd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dmenu_token_match ( const Mode *sw, char **tokens, int not_ascii, int case_sensitive, unsigned int index )
|
static int dmenu_token_match ( const Mode *sw, char **tokens, int not_ascii, int case_sensitive, unsigned int index )
|
||||||
|
@ -361,7 +363,7 @@ int dmenu_switcher_dialog ( void )
|
||||||
char **tokens = tokenize ( select, config.case_sensitive );
|
char **tokens = tokenize ( select, config.case_sensitive );
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
for ( i = 0; i < cmd_list_length; i++ ) {
|
for ( i = 0; i < cmd_list_length; i++ ) {
|
||||||
if ( token_match ( tokens, cmd_list[i], !g_str_is_ascii( cmd_list[i] ), config.case_sensitive ) ) {
|
if ( token_match ( tokens, cmd_list[i], !g_str_is_ascii ( cmd_list[i] ), config.case_sensitive ) ) {
|
||||||
pd->selected_line = i;
|
pd->selected_line = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -372,7 +374,7 @@ int dmenu_switcher_dialog ( void )
|
||||||
char **tokens = tokenize ( config.filter ? config.filter : "", config.case_sensitive );
|
char **tokens = tokenize ( config.filter ? config.filter : "", config.case_sensitive );
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
for ( i = 0; i < cmd_list_length; i++ ) {
|
for ( i = 0; i < cmd_list_length; i++ ) {
|
||||||
if ( token_match ( tokens, cmd_list[i], !g_str_is_ascii( cmd_list[i] ), config.case_sensitive ) ) {
|
if ( token_match ( tokens, cmd_list[i], !g_str_is_ascii ( cmd_list[i] ), config.case_sensitive ) ) {
|
||||||
dmenu_output_formatted_line ( pd->format, cmd_list[i], i, config.filter );
|
dmenu_output_formatted_line ( pd->format, cmd_list[i], i, config.filter );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -349,16 +349,16 @@ static int fuzzy_token_match ( char **tokens, const char *input, __attribute__(
|
||||||
// Do a tokenized match.
|
// Do a tokenized match.
|
||||||
|
|
||||||
if ( tokens ) {
|
if ( tokens ) {
|
||||||
char *compk = not_ascii ? token_collate_key ( input, case_sensitive ) : (char *) g_ascii_strdown(input,-1);
|
char *compk = not_ascii ? token_collate_key ( input, case_sensitive ) : (char *) g_ascii_strdown ( input, -1 );
|
||||||
for ( int j = 0; match && tokens[j]; j++ ) {
|
for ( int j = 0; match && tokens[j]; j++ ) {
|
||||||
char *t = compk;
|
char *t = compk;
|
||||||
char *token = tokens[j];
|
char *token = tokens[j];
|
||||||
|
|
||||||
while ( *t && *token ) {
|
while ( *t && *token ) {
|
||||||
if ( ( g_utf8_get_char(t) == g_utf8_get_char(token) ) ) {
|
if ( ( g_utf8_get_char ( t ) == g_utf8_get_char ( token ) ) ) {
|
||||||
token = g_utf8_next_char(token);
|
token = g_utf8_next_char ( token );
|
||||||
}
|
}
|
||||||
t = g_utf8_next_char(t);
|
t = g_utf8_next_char ( t );
|
||||||
}
|
}
|
||||||
match = !( *token );
|
match = !( *token );
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,26 +53,25 @@ int main ( int argc, char ** argv )
|
||||||
* Test some path functions. Not easy as not sure what is right output on travis.
|
* Test some path functions. Not easy as not sure what is right output on travis.
|
||||||
*/
|
*/
|
||||||
// Test if root is preserved.
|
// Test if root is preserved.
|
||||||
char *str = rofi_expand_path("/");
|
char *str = rofi_expand_path ( "/" );
|
||||||
TASSERT ( strcmp(str, "/") == 0 );
|
TASSERT ( strcmp ( str, "/" ) == 0 );
|
||||||
g_free(str);
|
g_free ( str );
|
||||||
// Test is relative path is preserved.
|
// Test is relative path is preserved.
|
||||||
str = rofi_expand_path("../AUTHORS");
|
str = rofi_expand_path ( "../AUTHORS" );
|
||||||
TASSERT ( strcmp(str, "../AUTHORS") == 0 );
|
TASSERT ( strcmp ( str, "../AUTHORS" ) == 0 );
|
||||||
g_free(str);
|
g_free ( str );
|
||||||
// Test another one.
|
// Test another one.
|
||||||
str = rofi_expand_path("/bin/false");
|
str = rofi_expand_path ( "/bin/false" );
|
||||||
TASSERT ( strcmp(str, "/bin/false") == 0 );
|
TASSERT ( strcmp ( str, "/bin/false" ) == 0 );
|
||||||
g_free(str);
|
g_free ( str );
|
||||||
// See if user paths get expanded in full path.
|
// See if user paths get expanded in full path.
|
||||||
str = rofi_expand_path("~/");
|
str = rofi_expand_path ( "~/" );
|
||||||
const char *hd = g_get_home_dir();
|
const char *hd = g_get_home_dir ();
|
||||||
TASSERT ( strcmp(str, hd) == 0);
|
TASSERT ( strcmp ( str, hd ) == 0 );
|
||||||
g_free(str);
|
g_free ( str );
|
||||||
str = rofi_expand_path("~root/");
|
str = rofi_expand_path ( "~root/" );
|
||||||
TASSERT ( str[0] == '/' );
|
TASSERT ( str[0] == '/' );
|
||||||
g_free(str);
|
g_free ( str );
|
||||||
|
|
||||||
|
|
||||||
g_strfreev ( list );
|
g_strfreev ( list );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue