[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] gnu: Add rofi.
From: |
Danny Milosavljevic |
Subject: |
Re: [PATCH] gnu: Add rofi. |
Date: |
Tue, 24 May 2016 08:55:02 +0200 |
On Mon, 23 May 2016 00:28:26 -0400
Leo Famulari <address@hidden> wrote:
> The failing test (helper_expand) seems to fail when it can't find
> `which`.
The failing test is test/helper-expand.c and it tries to do this:
int main ( int argc, char ** argv )
{
cmd_set_arguments ( argc, argv );
if ( setlocale ( LC_ALL, "" ) == NULL ) {
fprintf ( stderr, "Failed to set locale.\n" );
return EXIT_FAILURE;
}
/**
* 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 );
// Test is relative path is preserved.
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 );
// See if user paths get expanded in full path.
str = rofi_expand_path ( "~/" ); <----- oh oh
const char *hd = g_get_home_dir ();
TASSERT ( strcmp ( str, hd ) == 0 );
g_free ( str );
str = rofi_expand_path ( "~root/" ); <--- oh oh
TASSERT ( str[0] == '/' );
g_free ( str );
}
And rofi_expand_path does
char *rofi_expand_path ( const char *input )
{
char **str = g_strsplit ( input, G_DIR_SEPARATOR_S, -1 );
for ( unsigned int i = 0; str && str[i]; i++ ) {
// Replace ~ with current user homedir.
if ( str[i][0] == '~' && str[i][1] == '\0' ) {
g_free ( str[i] );
str[i] = g_strdup ( g_get_home_dir () ); <----------- oh oh
}
// If other user, ask getpwnam.
else if ( str[i][0] == '~' ) {
struct passwd *p = getpwnam ( &( str[i][1] ) ); <---------- oh oh
if ( p != NULL ) {
g_free ( str[i] );
str[i] = g_strdup ( p->pw_dir );
}
}
else if ( i == 0 ) {
char * s = str[i];
if ( input[0] == G_DIR_SEPARATOR ) {
str[i] = g_strdup_printf ( "%s%s", G_DIR_SEPARATOR_S, s );
g_free ( s );
}
}
}
char *retv = g_build_filenamev ( str );
g_strfreev ( str );
return retv;
}
What should we do about it?
The "which" part is just rofi trying to find out whether it has been checked
out from git or expanded from a release tarball.
- [PATCH] gnu: Add rofi., Danny Milosavljevic, 2016/05/20
- Re: [PATCH] gnu: Add rofi., Leo Famulari, 2016/05/23
- Re: [PATCH] gnu: Add rofi.,
Danny Milosavljevic <=
- Re: [PATCH] gnu: Add rofi., Leo Famulari, 2016/05/24
- [PATCH v2] * gnu/packages/xdisorg.scm (rofi): New variable., Danny Milosavljevic, 2016/05/25
- Re: [PATCH v2] * gnu/packages/xdisorg.scm (rofi): New variable., Leo Famulari, 2016/05/27
- [PATCH v3] gnu: Add rofi., Danny Milosavljevic, 2016/05/27
- Re: [PATCH v3] gnu: Add rofi., Leo Famulari, 2016/05/27
- Re: [PATCH v3] gnu: Add rofi., Danny Milosavljevic, 2016/05/27
- Re: [PATCH v3] gnu: Add rofi., Leo Famulari, 2016/05/31