diff options
author | Adam Weinberger <adamw@FreeBSD.org> | 2014-07-22 14:45:40 +0000 |
---|---|---|
committer | Adam Weinberger <adamw@FreeBSD.org> | 2014-07-22 14:45:40 +0000 |
commit | 0246ce141b5d6fc01b87202548d41d3b939db401 (patch) | |
tree | fd81b80b4c9e21f26c7ba66b5918303e91545a33 /games/bsdgames/files/patch-hack_hack.unix.c | |
parent | ac369e6a9fdae8314eda13e4d10e9a4f20f43744 (diff) | |
download | ports-0246ce141b5d6fc01b87202548d41d3b939db401.tar.gz ports-0246ce141b5d6fc01b87202548d41d3b939db401.zip |
Update to 3.8.1. Along with this, savegame data is now in
/usr/local/var/games instead of /var/games. This was necessary
because @sample cannot operate outside of %%PREFIX%%, and
previously the port would overwrite or remove previously
saved games. This is easier, better and more hier(7)ful.
Notes
Notes:
svn path=/head/; revision=362545
Diffstat (limited to 'games/bsdgames/files/patch-hack_hack.unix.c')
-rw-r--r-- | games/bsdgames/files/patch-hack_hack.unix.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/games/bsdgames/files/patch-hack_hack.unix.c b/games/bsdgames/files/patch-hack_hack.unix.c new file mode 100644 index 000000000000..39773be5ba9d --- /dev/null +++ b/games/bsdgames/files/patch-hack_hack.unix.c @@ -0,0 +1,51 @@ +--- hack/hack.unix.c.orig 2014-07-22 09:54:22.000000000 -0400 ++++ hack/hack.unix.c 2014-07-22 10:20:43.000000000 -0400 +@@ -18,7 +18,9 @@ + + #include <sys/types.h> /* for time_t and stat */ + #include <sys/stat.h> ++#include <sys/param.h> + #include <time.h> ++#include <err.h> + + static struct tm *getlt(void); + static bool veryold(int); +@@ -94,13 +96,32 @@ + void + gethdate(const char *name) + { +-/* old version - for people short of space */ +- char *np; ++ char *p, *np, *path; ++ char filename[MAXPATHLEN+1]; + +- name = "/usr/games/hide/hack"; +- if (stat(name, &hbuf)) +- error("Cannot get status of %s.", +- (np = strrchr(name, '/')) ? np + 1 : name); ++ if (strchr(name, '/') != NULL || (p = getenv("PATH")) == NULL) ++ p = ""; ++ np = path = strdup(p); /* Make a copy for strsep. */ ++ if (path == NULL) ++ err(1, NULL); ++ ++ for (;;) { ++ if ((p = strsep(&np, ":")) == NULL) ++ break; ++ if (*p == '\0') /* :: */ ++ (void) strlcpy(filename, name, sizeof filename); ++ else ++ (void) snprintf(filename, sizeof filename, ++ "%s/%s", p, name); ++ ++ if (stat(filename, &hbuf) == 0) { ++ free(path); ++ return; ++ } ++ } ++ error("Cannot get status of %s.", ++ (p = strrchr(name, '/')) ? p+1 : name); ++ free(path); + } + + bool |