A few more variables renamed, relating to the "system" charset vs UTF-8

pathname issue. Plug a memory leak.
This commit is contained in:
Tor Lillqvist
2000-08-12 07:45:56 +00:00
parent 33f56c79b0
commit 8421d02a4c

View File

@ -1752,16 +1752,16 @@ cmpl_is_a_completion (PossibleCompletion* pc)
static CompletionState* static CompletionState*
cmpl_init_state (void) cmpl_init_state (void)
{ {
gchar *getcwd_buf; gchar *sys_getcwd_buf;
gchar *utf8_cwd; gchar *utf8_cwd;
CompletionState *new_state; CompletionState *new_state;
new_state = g_new (CompletionState, 1); new_state = g_new (CompletionState, 1);
/* g_get_current_dir() returns a GSystemCodepageString */ /* g_get_current_dir() returns a string in the "system" charset */
getcwd_buf = g_get_current_dir (); sys_getcwd_buf = g_get_current_dir ();
utf8_cwd = g_filename_to_utf8 (getcwd_buf); utf8_cwd = g_filename_to_utf8 (sys_getcwd_buf);
g_free (getcwd_buf); g_free (sys_getcwd_buf);
tryagain: tryagain:
@ -1783,7 +1783,7 @@ tryagain:
if (!new_state->reference_dir) if (!new_state->reference_dir)
{ {
/* Directories changing from underneath us, grumble */ /* Directories changing from underneath us, grumble */
strcpy (getcwd_buf, G_DIR_SEPARATOR_S); strcpy (utf8_cwd, G_DIR_SEPARATOR_S);
goto tryagain; goto tryagain;
} }
@ -2051,10 +2051,10 @@ open_ref_dir (gchar *text_to_complete,
else else
{ {
/* If no possible candidates, use the cwd */ /* If no possible candidates, use the cwd */
gchar *curdir = g_get_current_dir (); gchar *sys_curdir = g_get_current_dir ();
gchar *utf8_curdir = g_filename_to_utf8 (curdir); gchar *utf8_curdir = g_filename_to_utf8 (sys_curdir);
g_free (curdir); g_free (sys_curdir);
new_dir = open_dir (utf8_curdir, cmpl_state); new_dir = open_dir (utf8_curdir, cmpl_state);
@ -2229,7 +2229,7 @@ open_new_dir (gchar *dir_name,
if (stat_subdirs) if (stat_subdirs)
{ {
/* Here we know path->str is a GSystemCodepageString */ /* Here we know path->str is a "system charset" string */
if (stat (path->str, &ent_sbuf) >= 0 && S_ISDIR (ent_sbuf.st_mode)) if (stat (path->str, &ent_sbuf) >= 0 && S_ISDIR (ent_sbuf.st_mode))
sent->entries[i].is_dir = TRUE; sent->entries[i].is_dir = TRUE;
else else
@ -2536,17 +2536,17 @@ correct_parent (CompletionDir *cmpl_dir,
static gchar* static gchar*
find_parent_dir_fullname (gchar* dirname) find_parent_dir_fullname (gchar* dirname)
{ {
gchar *orig_dir; gchar *sys_orig_dir;
gchar *result; gchar *result;
gchar *sys_cwd; gchar *sys_cwd;
gchar *sys_dirname; gchar *sys_dirname;
orig_dir = g_get_current_dir (); sys_orig_dir = g_get_current_dir ();
sys_dirname = g_filename_from_utf8 (dirname); sys_dirname = g_filename_from_utf8 (dirname);
if (chdir (sys_dirname) != 0 || chdir ("..") != 0) if (chdir (sys_dirname) != 0 || chdir ("..") != 0)
{ {
g_free (sys_dirname); g_free (sys_dirname);
g_free (sys_orig_dir)
cmpl_errno = errno; cmpl_errno = errno;
return NULL; return NULL;
} }
@ -2556,13 +2556,14 @@ find_parent_dir_fullname (gchar* dirname)
result = g_filename_to_utf8 (sys_cwd); result = g_filename_to_utf8 (sys_cwd);
g_free (sys_cwd); g_free (sys_cwd);
if (chdir (orig_dir) != 0) if (chdir (sys_orig_dir) != 0)
{ {
cmpl_errno = errno; cmpl_errno = errno;
g_free (sys_orig_dir)
return NULL; return NULL;
} }
g_free (orig_dir); g_free (sys_orig_dir);
return result; return result;
} }