Skip to content

Commit

Permalink
recovered invoking win_bison from different folders
Browse files Browse the repository at this point in the history
  • Loading branch information
lexxmark committed Sep 19, 2019
1 parent 92479a4 commit 5ea7eb5
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
37 changes: 36 additions & 1 deletion bison/src/files.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,40 @@ unlink_generated_sources (void)
/* Memory allocated by relocate2, to free. */
static char *relocate_buffer = NULL;

extern const char* get_app_path();

char* get_local_pkgdatadir()
{
const char* program_path = 0;
const char* dir = 0;
const char* last_divider = 0;
char* local_pkgdatadir = NULL;
size_t dir_len = 0;
size_t local_pkgdatadir_len = 0;

program_path = dir = get_app_path();

while (*dir)
{
if (*dir == '\\' || *dir == '/')
last_divider = dir;
++dir;
}

if (!last_divider)
return PKGDATADIR;

++last_divider;

dir_len = last_divider - program_path;
local_pkgdatadir_len = dir_len + strlen(PKGDATADIR);
local_pkgdatadir = (char*)malloc((local_pkgdatadir_len + 1) * sizeof(char));
strncpy(local_pkgdatadir, program_path, dir_len);
strcpy(&local_pkgdatadir[dir_len], PKGDATADIR);

return local_pkgdatadir;
}

char const *
pkgdatadir (void)
{
Expand All @@ -420,7 +454,8 @@ pkgdatadir (void)
else
{
char const *cp = getenv ("BISON_PKGDATADIR");
return cp ? cp : relocate2 (PKGDATADIR, &relocate_buffer);
// return cp ? cp : relocate2(PKGDATADIR, &relocate_buffer);
return cp ? cp : (relocate_buffer = get_local_pkgdatadir());
}
}

Expand Down
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
* 2.4.x versions include bison version 2.7
* 2.5.x versions include bison version 3.x

### version 2.5.20
* recovered invoking win_bison from different folders

### version 2.5.19
* upgrade win_bison to version 3.4.1

Expand Down

0 comments on commit 5ea7eb5

Please sign in to comment.