mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
Indent.
This commit is contained in:
parent
697abdfdfc
commit
eaa553bfd5
3 changed files with 36 additions and 35 deletions
|
@ -93,7 +93,7 @@ static char **get_dmenu ( FILE *fd, unsigned int *length )
|
|||
break;
|
||||
}
|
||||
}
|
||||
if(retv != NULL ) {
|
||||
if ( retv != NULL ) {
|
||||
retv[( *length ) + 1] = NULL;
|
||||
retv = g_realloc ( retv, ( *length + 1 ) * sizeof ( char* ) );
|
||||
}
|
||||
|
@ -289,20 +289,22 @@ static void dmenu_mode_init ( Mode *sw )
|
|||
}
|
||||
FILE *fd = NULL;
|
||||
str = NULL;
|
||||
if ( find_arg_str ("-input", &str)) {
|
||||
char *estr = rofi_expand_path(str);
|
||||
fd = fopen(str, "r");
|
||||
if(fd == NULL ){
|
||||
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);
|
||||
g_free(msg);
|
||||
g_free(estr);
|
||||
if ( find_arg_str ( "-input", &str ) ) {
|
||||
char *estr = rofi_expand_path ( str );
|
||||
fd = fopen ( str, "r" );
|
||||
if ( fd == NULL ) {
|
||||
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 );
|
||||
g_free ( msg );
|
||||
g_free ( estr );
|
||||
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 )
|
||||
|
@ -361,7 +363,7 @@ int dmenu_switcher_dialog ( void )
|
|||
char **tokens = tokenize ( select, config.case_sensitive );
|
||||
unsigned int i = 0;
|
||||
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;
|
||||
break;
|
||||
}
|
||||
|
@ -372,7 +374,7 @@ int dmenu_switcher_dialog ( void )
|
|||
char **tokens = tokenize ( config.filter ? config.filter : "", config.case_sensitive );
|
||||
unsigned int i = 0;
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -276,7 +276,7 @@ int find_arg_uint ( const char * const key, unsigned int *val )
|
|||
|
||||
char helper_parse_char ( const char *arg )
|
||||
{
|
||||
int len = strlen ( arg );
|
||||
int len = strlen ( arg );
|
||||
// If the length is 1, it is not escaped.
|
||||
if ( len == 1 ) {
|
||||
return arg[0];
|
||||
|
@ -349,16 +349,16 @@ static int fuzzy_token_match ( char **tokens, const char *input, __attribute__(
|
|||
// Do a tokenized match.
|
||||
|
||||
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++ ) {
|
||||
char *t = compk;
|
||||
char *token = tokens[j];
|
||||
|
||||
while ( *t && *token ) {
|
||||
if ( ( g_utf8_get_char(t) == g_utf8_get_char(token) ) ) {
|
||||
token = g_utf8_next_char(token);
|
||||
if ( ( g_utf8_get_char ( t ) == g_utf8_get_char ( token ) ) ) {
|
||||
token = g_utf8_next_char ( token );
|
||||
}
|
||||
t = g_utf8_next_char(t);
|
||||
t = g_utf8_next_char ( t );
|
||||
}
|
||||
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 if root is preserved.
|
||||
char *str = rofi_expand_path("/");
|
||||
TASSERT ( strcmp(str, "/") == 0 );
|
||||
g_free(str);
|
||||
char *str = rofi_expand_path ( "/" );
|
||||
TASSERT ( strcmp ( str, "/" ) == 0 );
|
||||
g_free ( str );
|
||||
// Test is relative path is preserved.
|
||||
str = rofi_expand_path("../AUTHORS");
|
||||
TASSERT ( strcmp(str, "../AUTHORS") == 0 );
|
||||
g_free(str);
|
||||
str = rofi_expand_path ( "../AUTHORS" );
|
||||
TASSERT ( strcmp ( str, "../AUTHORS" ) == 0 );
|
||||
g_free ( str );
|
||||
// Test another one.
|
||||
str = rofi_expand_path("/bin/false");
|
||||
TASSERT ( strcmp(str, "/bin/false") == 0 );
|
||||
g_free(str);
|
||||
str = rofi_expand_path ( "/bin/false" );
|
||||
TASSERT ( strcmp ( str, "/bin/false" ) == 0 );
|
||||
g_free ( str );
|
||||
// See if user paths get expanded in full path.
|
||||
str = rofi_expand_path("~/");
|
||||
const char *hd = g_get_home_dir();
|
||||
TASSERT ( strcmp(str, hd) == 0);
|
||||
g_free(str);
|
||||
str = rofi_expand_path("~root/");
|
||||
str = rofi_expand_path ( "~/" );
|
||||
const char *hd = g_get_home_dir ();
|
||||
TASSERT ( strcmp ( str, hd ) == 0 );
|
||||
g_free ( str );
|
||||
str = rofi_expand_path ( "~root/" );
|
||||
TASSERT ( str[0] == '/' );
|
||||
g_free(str);
|
||||
|
||||
g_free ( str );
|
||||
|
||||
g_strfreev ( list );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue