ifix dirname for glibc - stagit-gopher - A git gopher frontend. (mirror) Err bitreich.org 70 hgit clone git://bitreich.org/stagit-gopher/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/stagit-gopher/ URL:git://bitreich.org/stagit-gopher/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/stagit-gopher/ bitreich.org 70 1Log /scm/stagit-gopher/log.gph bitreich.org 70 1Files /scm/stagit-gopher/files.gph bitreich.org 70 1Refs /scm/stagit-gopher/refs.gph bitreich.org 70 1Tags /scm/stagit-gopher/tag bitreich.org 70 1README /scm/stagit-gopher/file/README.gph bitreich.org 70 1LICENSE /scm/stagit-gopher/file/LICENSE.gph bitreich.org 70 i--- Err bitreich.org 70 1commit 9c7e2c56784e353adf143d887d84c0e967dba7b9 /scm/stagit-gopher/commit/9c7e2c56784e353adf143d887d84c0e967dba7b9.gph bitreich.org 70 1parent 1778cba9794bbe5624db907bda2d065c971405b7 /scm/stagit-gopher/commit/1778cba9794bbe5624db907bda2d065c971405b7.gph bitreich.org 70 hAuthor: Hiltjo Posthuma URL:mailto:hiltjo@codemadness.org bitreich.org 70 iDate: Sat, 26 Dec 2015 12:56:23 +0100 Err bitreich.org 70 i Err bitreich.org 70 ifix dirname for glibc Err bitreich.org 70 i Err bitreich.org 70 iDiffstat: Err bitreich.org 70 i M urmoms.c | 29 +++++++++++++++++++++++++++-- Err bitreich.org 70 i Err bitreich.org 70 i1 file changed, 27 insertions(+), 2 deletions(-) Err bitreich.org 70 i--- Err bitreich.org 70 1diff --git a/urmoms.c b/urmoms.c /scm/stagit-gopher/file/urmoms.c.gph bitreich.org 70 i@@ -140,6 +140,27 @@ xmlencode(FILE *fp, const char *s, size_t len) Err bitreich.org 70 i } Err bitreich.org 70 i } Err bitreich.org 70 i Err bitreich.org 70 i+/* Some implementations of dirname(3) return a pointer to a static Err bitreich.org 70 i+ * internal buffer (OpenBSD). Others modify the contents of `path` (POSIX). Err bitreich.org 70 i+ * This is a wrapper function that is compatible with both versions. Err bitreich.org 70 i+ * The program will error out if dirname(3) failed, this can only happen Err bitreich.org 70 i+ * with the OpenBSD version. */ Err bitreich.org 70 i+char * Err bitreich.org 70 i+xdirname(const char *path) Err bitreich.org 70 i+{ Err bitreich.org 70 i+ char *p, *b; Err bitreich.org 70 i+ Err bitreich.org 70 i+ if (!(p = strdup(path))) Err bitreich.org 70 i+ err(1, "strdup"); Err bitreich.org 70 i+ if (!(b = dirname(p))) Err bitreich.org 70 i+ err(1, "basename"); Err bitreich.org 70 i+ if (!(b = strdup(b))) Err bitreich.org 70 i+ err(1, "strdup"); Err bitreich.org 70 i+ free(p); Err bitreich.org 70 i+ Err bitreich.org 70 i+ return b; Err bitreich.org 70 i+} Err bitreich.org 70 i+ Err bitreich.org 70 i /* Some implementations of basename(3) return a pointer to a static Err bitreich.org 70 i * internal buffer (OpenBSD). Others modify the contents of `path` (POSIX). Err bitreich.org 70 i * This is a wrapper function that is compatible with both versions. Err bitreich.org 70 i@@ -571,12 +592,16 @@ writeblob(git_object *obj, const char *filename, git_off_t filesize) Err bitreich.org 70 i { Err bitreich.org 70 i char fpath[PATH_MAX]; Err bitreich.org 70 i char tmp[PATH_MAX] = ""; Err bitreich.org 70 i- char *p; Err bitreich.org 70 i+ char *d, *p; Err bitreich.org 70 i FILE *fp; Err bitreich.org 70 i Err bitreich.org 70 i snprintf(fpath, sizeof(fpath), "file/%s.html", filename); Err bitreich.org 70 i- if (mkdirp(dirname(fpath))) Err bitreich.org 70 i+ d = xdirname(fpath); Err bitreich.org 70 i+ if (mkdirp(d)) { Err bitreich.org 70 i+ free(d); Err bitreich.org 70 i return 1; Err bitreich.org 70 i+ } Err bitreich.org 70 i+ free(d); Err bitreich.org 70 i Err bitreich.org 70 i p = fpath; Err bitreich.org 70 i while (*p) { Err bitreich.org 70 .