Browse Source

Fix FTBFS of PATH_MAX on GNU/Hurd

Info:
 - https://www.gnu.org/software/hurd/community/gsoc/project_ideas/maxpath.html
 - https://www.gnu.org/software/hurd/hurd/porting/guidelines.html#PATH_MAX_tt_MAX_PATH_tt_MAXPATHL

Quote:
when the __GLIBC__ macro is defined, getcwd() calls can be just
replaced by get_current_dir_name() calls.
pull/880/merge
Roger Shimizu 7 years ago
committed by Max Lv
parent
commit
1397bf133b
1 changed files with 3 additions and 2 deletions
  1. 5
      src/plugin.c

5
src/plugin.c

@ -101,11 +101,12 @@ start_plugin(const char *plugin,
env = cork_env_clone_current(); env = cork_env_clone_current();
const char *path = cork_env_get(env, "PATH"); const char *path = cork_env_get(env, "PATH");
if (path != NULL) { if (path != NULL) {
char cwd[PATH_MAX];
if (!getcwd(cwd, PATH_MAX)) {
char *cwd = get_current_dir_name();
if (cwd) {
size_t path_len = strlen(path) + strlen(cwd) + 2; size_t path_len = strlen(path) + strlen(cwd) + 2;
new_path = ss_malloc(path_len); new_path = ss_malloc(path_len);
snprintf(new_path, path_len, "%s:%s", cwd, path); snprintf(new_path, path_len, "%s:%s", cwd, path);
free(cwd);
} }
} }

Loading…
Cancel
Save