1.1 --- a/src/lxpaths.c Sun Jun 28 12:07:21 2009 +0000
1.2 +++ b/src/lxpaths.c Sat Mar 03 15:52:59 2012 +1000
1.7 -#include <wordexp.h>
1.9 #include <glib/gstrfuncs.h>
1.10 #include <glib/gutils.h>
1.14 gchar *get_expanded_path( const gchar *input )
1.17 - if( input == NULL ) {
1.18 + char result[PATH_MAX];
1.23 + e = result+sizeof(result)-1;
1.26 + if( input == NULL )
1.31 + return g_strdup(input); /* expansion too long */
1.37 + const char *q = s;
1.38 + while( *q != '}' ) {
1.40 + return g_strdup(input); /* unterminated variable */
1.44 + char *tmp = g_strndup(s, (q-s));
1.46 + char *value = getenv(tmp);
1.48 + if( value != NULL ) {
1.49 + int len = strlen(value);
1.51 + return g_strdup(input);
1.54 + } /* Else, empty string */
1.56 + const char *q = s;
1.57 + while( isalnum(*q) || *q == '_' ) {
1.63 + char *tmp = g_strndup(s,q-s);
1.65 + char *value = getenv(tmp);
1.67 + if( value != NULL ) {
1.68 + int len = strlen(value);
1.70 + return g_strdup(input);
1.76 + } else if( c == '\\' ) {
1.87 - memset(&we,0,sizeof(we));
1.88 - int result = wordexp(input, &we, WRDE_NOCMD);
1.89 - if( result != 0 || we.we_wordc == 0 ) {
1.90 - /* On failure, return the original input unchanged */
1.91 - return g_strdup(input);
1.93 - /* On success, concatenate all 'words' together into a single
1.94 - * space-separated string
1.96 - int length = we.we_wordc, i;
1.97 - gchar *result, *p;
1.99 - for( i=0; i<we.we_wordc; i++ ) {
1.100 - length += strlen(we.we_wordv[i]);
1.102 - p = result = g_malloc(length);
1.103 - for( i=0; i<we.we_wordc; i++ ) {
1.106 - strcpy( p, we.we_wordv[i] );
1.113 + return g_strdup(result);
1.116 gchar *get_absolute_path( const gchar *in_path )
1.118 char tmp[PATH_MAX];