* substitute '~' with HOME or '~username' with username's home dir
*
*/
-char *
+void
expand_tilde(char **filename)
{
if (!filename || !(*filename))
- return NULL;
+ return;
/*
* WIN32 doesn't use tilde expansion for file names. Also, it uses tilde
}
#endif
- return *filename;
+ return;
}
extern bool standard_strings(void);
extern const char *session_username(void);
-extern char *expand_tilde(char **filename);
+extern void expand_tilde(char **filename);
#endif /* COMMON_H */
char rc_file[MAXPGPATH];
char my_exec_path[MAXPGPATH];
char etc_path[MAXPGPATH];
- char *envrc;
+ char *envrc = getenv("PSQLRC");
find_my_exec(argv0, my_exec_path);
get_etc_path(my_exec_path, etc_path);
snprintf(rc_file, MAXPGPATH, "%s/%s", etc_path, SYSPSQLRC);
process_psqlrc_file(rc_file);
- envrc = getenv("PSQLRC");
-
if (envrc != NULL && strlen(envrc) > 0)
{
- expand_tilde(&envrc);
- process_psqlrc_file(envrc);
+ /* might need to free() this */
+ char *envrc_alloc = pg_strdup(envrc);
+
+ expand_tilde(&envrc_alloc);
+ process_psqlrc_file(envrc_alloc);
}
else if (get_home_path(home))
{