diff options
author | Marius Bakke <[email protected]> | 2022-07-06 22:45:54 +0200 |
---|---|---|
committer | Marius Bakke <[email protected]> | 2022-07-16 23:25:17 +0200 |
commit | 12e77c03bcc41c143157d12d75d9b8a94457019d (patch) | |
tree | 5a53b7b03e025680af6a953ff4b1c885967d0d39 /gnu/packages/patches/libpaper-invalid-paperspecs.patch | |
parent | 397147aaad2e5d357479c0ff3ac3042432e320ae (diff) |
gnu: libpaper: Update to 1.2.1.
* gnu/packages/ghostscript.scm (libpaper): Update to 1.2.1.
[source]: Switch to currently maintained fork.
[home-page]: Likewise.
[arguments]: Remove #:phases. Add "--enable-relocatable" to #:configure-flags.
[native-inputs]: Remove AUTOMAKE. Add HELP2MAN.
[outputs]: Add "debug".
* gnu/packages/tex.scm (texlive-bin)[arguments]: Add phase to patch test
expected test result with libpaper 1.2.
* gnu/packages/patches/libpaper-free-systempapername.patch,
gnu/packages/patches/libpaper-free-xdg-config-home.patch,
gnu/packages/patches/libpaper-invalid-paperspecs.patch: New files.
* gnu/local.mk (dist_patch_DATA): Adjust accordingly.
Diffstat (limited to 'gnu/packages/patches/libpaper-invalid-paperspecs.patch')
-rw-r--r-- | gnu/packages/patches/libpaper-invalid-paperspecs.patch | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/gnu/packages/patches/libpaper-invalid-paperspecs.patch b/gnu/packages/patches/libpaper-invalid-paperspecs.patch new file mode 100644 index 0000000000..29f1ca64a3 --- /dev/null +++ b/gnu/packages/patches/libpaper-invalid-paperspecs.patch @@ -0,0 +1,97 @@ +Handle invalid paper specifications. + +Taken from upstream: + + https://github.com/rrthomas/libpaper/commit/24bcaa54e2813683404e3e13a4fedd47f3e4d614 + +diff --git a/lib/libpaper.c.in.in b/lib/libpaper.c.in.in +index 19e3332..c68a936 100644 +--- a/lib/libpaper.c.in.in ++++ b/lib/libpaper.c.in.in +@@ -164,10 +164,8 @@ const struct paper *papernext(const struct paper *paper) + } + + /* Constructor. */ +-static int readspecs(struct paper **papers_list, const char *specsfile, struct paper **last) { +- paper_lineno = 0; +- free(paper_specsfile); +- paper_specsfile = strdup(specsfile); ++static int readspecs(struct paper **papers_list, const char *specsfile, struct paper **last, size_t *lineno) { ++ *lineno = 0; + char *old_locale = setlocale(LC_ALL, NULL); + if (old_locale != NULL) + old_locale = strdup(old_locale); +@@ -178,7 +176,7 @@ static int readspecs(struct paper **papers_list, const char *specsfile, struct p + struct paper *prev = *papers_list, *p; + size_t n; + char *l; +- for (paper_lineno = 1, l = NULL; getline(&l, &n, ps) > 0; prev = p, paper_lineno++) { ++ for (*lineno = 1, l = NULL; getline(&l, &n, ps) > 0; prev = p, (*lineno)++) { + char *saveptr; + char *name = gettok(l, &saveptr); + char *wstr = gettok(NULL, &saveptr), *hstr = gettok(NULL, &saveptr); +@@ -350,6 +348,8 @@ int paperinit(void) + return PAPER_OK; + initialized = true; + ++ int ret = PAPER_OK; ++ + /* Read system paperspecs. */ + struct paper *system_papers = NULL; + sysconfdir = alloc_relocate("@sysconfdir@"); +@@ -357,12 +357,9 @@ int paperinit(void) + char *system_paperspecs = mfile_name_concat(sysconfdir, PAPERSPECS_FILENAME, NULL); + if (system_paperspecs == NULL) + return PAPER_NOMEM; +- int ret = readspecs(&system_papers, system_paperspecs, NULL); +- free(system_paperspecs); +- if (ret != PAPER_OK) { +- paperdone(); +- return ret; +- } ++ ret = readspecs(&system_papers, system_paperspecs, NULL, &paper_lineno); ++ free(paper_specsfile); ++ paper_specsfile = system_paperspecs; + } + + /* Set default paper to first system paper, if any. */ +@@ -381,11 +378,15 @@ int paperinit(void) + char *user_paperspecs = mfile_name_concat(xdg_config_home, PAPERSPECS_FILENAME, NULL); + struct paper *last_paper = NULL; + if (user_paperspecs != NULL) { +- int ret = readspecs(&papers, user_paperspecs, &last_paper); +- free(user_paperspecs); +- if (ret != PAPER_OK) { +- paperdone(); +- return ret; ++ size_t user_lineno; ++ int user_ret = readspecs(&papers, user_paperspecs, &last_paper, &user_lineno); ++ if (ret == PAPER_OK) { ++ ret = user_ret; ++ free(user_paperspecs); ++ } else if (paper_lineno == 0) { ++ free(paper_specsfile); ++ paper_specsfile = user_paperspecs; ++ paper_lineno = user_lineno; + } + } + +@@ -395,13 +396,16 @@ int paperinit(void) + default_paper = papers; + + /* Concatenate system papers to user papers. */ +- last_paper->next = system_papers; ++ if (last_paper != NULL) ++ last_paper->next = system_papers; ++ else ++ last_paper = system_papers; + } + + if (papers == NULL) /* System papers are all we have. */ + papers = system_papers; + +- return PAPER_OK; ++ return ret; + } + + /* Shut down the library. */ |