mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-01 05:26:00 +01:00
Use g_get_current_dir instead
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
parent
d3612f3c9b
commit
2805cf1f2c
1 changed files with 6 additions and 11 deletions
|
@ -145,21 +145,16 @@ list_files_for_cc(zathura_t* zathura, const char* input, bool check_file_ext, in
|
||||||
/* If the path does not begin with a slash we update the path with the current
|
/* If the path does not begin with a slash we update the path with the current
|
||||||
* working directory */
|
* working directory */
|
||||||
if (strlen(path) == 0 || path[0] != '/') {
|
if (strlen(path) == 0 || path[0] != '/') {
|
||||||
long path_max;
|
char* cwd = g_get_current_dir();
|
||||||
#ifdef PATH_MAX
|
if (cwd == NULL) {
|
||||||
path_max = PATH_MAX;
|
|
||||||
#else
|
|
||||||
path_max = pathconf(path,_PC_PATH_MAX);
|
|
||||||
if (path_max <= 0)
|
|
||||||
path_max = 4096;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
char cwd[path_max];
|
|
||||||
if (getcwd(cwd, path_max) == NULL) {
|
|
||||||
goto error_free;
|
goto error_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* tmp_path = g_strdup_printf("%s/%s", cwd, path);
|
char* tmp_path = g_strdup_printf("%s/%s", cwd, path);
|
||||||
|
g_free(cwd);
|
||||||
|
if (tmp_path == NULL) {
|
||||||
|
goto error_free;
|
||||||
|
}
|
||||||
|
|
||||||
g_free(path);
|
g_free(path);
|
||||||
path = tmp_path;
|
path = tmp_path;
|
||||||
|
|
Loading…
Reference in a new issue