void-packages/srcpkgs/foobillard++/patches/data-dir.patch
Érico Rolim 4ad43e8df1 foobillard++: fix location of data directory.
Remove the code that it uses to guess the data directory and simply
default to /usr/share/foobillardplus. Without this, the program panics
at launch (it was likely panicking ever since it was updated, given that
the sed command for src/language.c no longer had any effect).

At the moment, the game more often that not segfaults at launch on musl,
but I'm not marking it broken because it's been in the repos for a long
time already. If anyone complains, we can try to fix the issue then
(extremely likely to be a race condition; maybe tries to pthread_join a
dead thread?).

Also xlint.

Fixes #27598
2021-01-01 21:17:04 -03:00

43 lines
1.3 KiB
Diff

diff --git src/sys_stuff.c src/sys_stuff.c
index 8f65f6b..7b905cf 100644
--- src/sys_stuff.c
+++ src/sys_stuff.c
@@ -756,37 +756,18 @@ void sys_main_loop(void) {
* Find the program's "data" directory and chdir into it *
***********************************************************************/
-static char data_dir[512];
+static char data_dir[512] = "/usr/share/foobillardplus";
void enter_data_dir() {
int success = 1;
#ifdef POSIX
- char proc_exe[20];
- char *slash_pos;
#endif
do {
success = 0;
#ifdef POSIX
- snprintf(proc_exe, sizeof(proc_exe), "/proc/%d/exe", getpid());
- if (readlink(proc_exe, data_dir, sizeof(data_dir)) < 0) {
- perror("readlink failed");
- break;
- }
-
- // Remove program name
- slash_pos = strrchr(data_dir, '/');
- if (!slash_pos) break;
- *slash_pos = '\0';
-
- // Go one dir up
- slash_pos = strrchr(data_dir, '/');
- if (!slash_pos) break;
-
- // Add "/data"
- strncpy(slash_pos, "/data", sizeof(data_dir) - (slash_pos - data_dir));
#else
/* ### TODO ### Get the working directory of the program
* Mac OS X: _NSGetExecutablePath() (man 3 dyld)