diff --git a/libpaper-2.1.1.tar.gz b/libpaper-2.1.1.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..d3f9d43bc2d3923a53956897bc058c4d1a9db24a Binary files /dev/null and b/libpaper-2.1.1.tar.gz differ diff --git a/libpaper-file-leak.patch b/libpaper-file-leak.patch deleted file mode 100644 index 47b878bebc290c10fdb667c7156733c7eb212d96..0000000000000000000000000000000000000000 --- a/libpaper-file-leak.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff -up libpaper-1.1.24+nmu5/lib/paper.c.file-leak libpaper-1.1.24+nmu5/lib/paper.c ---- libpaper-1.1.24+nmu5/lib/paper.c.file-leak 2018-03-09 16:21:01.028345956 +0100 -+++ libpaper-1.1.24+nmu5/lib/paper.c 2018-03-09 16:40:57.824279357 +0100 -@@ -140,7 +140,7 @@ char* systempapername(void) { - char* paperstr; - char* paperenv; - const char* paperdef; -- FILE* ps; -+ FILE* ps = NULL; - struct stat statbuf; - const struct paper* pp; - int c; -@@ -224,6 +224,9 @@ PAPERSIZEVAR, fall-back to the old behav - } - } - -+ if (ps) -+ fclose(ps); -+ - paperdef = defaultpapername(); - paperstr = malloc((strlen(paperdef) + 1) * sizeof(char)); - diff --git a/libpaper-useglibcfallback.patch b/libpaper-useglibcfallback.patch deleted file mode 100644 index 1216055ed9014c69a0a89535db949d6e70282283..0000000000000000000000000000000000000000 --- a/libpaper-useglibcfallback.patch +++ /dev/null @@ -1,80 +0,0 @@ -diff -up libpaper-1.1.24+nmu3/lib/paper.c.useglibcfallback libpaper-1.1.24+nmu3/lib/paper.c ---- libpaper-1.1.24+nmu3/lib/paper.c.useglibcfallback 2010-04-24 08:12:11.000000000 -0400 -+++ libpaper-1.1.24+nmu3/lib/paper.c 2014-04-22 15:58:33.120039001 -0400 -@@ -20,6 +20,9 @@ - - #include - -+#include -+#include -+ - #include "paper.h" - - struct paper { -@@ -108,6 +111,27 @@ in PAPERCONFVAR, fall-back to the old be - } - - const char* defaultpapername(void) { -+#if defined(LC_PAPER) && defined(_GNU_SOURCE) -+ -+#define NL_PAPER_GET(x) \ -+ ((union { char *string; unsigned int word; })nl_langinfo(x)).word -+ -+#define PT_TO_MM(v) (unsigned int)((v * 2.54 * 10 / 72) + 0.5) -+ -+ const struct paper* pp; -+ -+ unsigned int w = NL_PAPER_GET(_NL_PAPER_WIDTH); -+ unsigned int h = NL_PAPER_GET(_NL_PAPER_HEIGHT); -+ -+ for (pp = paperfirst(); pp; pp = papernext(pp)) { -+ if ( -+ PT_TO_MM(pp->pswidth) == w && -+ PT_TO_MM(pp->psheight) == h -+ ) { -+ return pp->name; -+ } -+ } -+#endif - return PAPERSIZE; - } - -diff -up libpaper-1.1.24+nmu3/man/paperconf.1.in.useglibcfallback libpaper-1.1.24+nmu3/man/paperconf.1.in ---- libpaper-1.1.24+nmu3/man/paperconf.1.in.useglibcfallback 2014-04-22 15:58:33.121038995 -0400 -+++ libpaper-1.1.24+nmu3/man/paperconf.1.in 2014-04-22 16:00:15.973428376 -0400 -@@ -48,10 +48,12 @@ looking in order at the - .B @PAPERSIZEVAR@ - environment variable, at the contents of the file specified by the - .B @PAPERCONFVAR@ --environment variable, at the contents of -+environment variable, at the contents of the file - .B @PAPERCONF@ --or by using --.B letter -+, consulting the values controlled by the -+.B LC_PAPER -+locale setting, or by using -+.B @PAPERSIZE@ - as a fall-back value if none of the other alternatives are successful. - By default, width and height of the paper are printed in PostScript points. - .SH OPTIONS -diff -up libpaper-1.1.24+nmu3/src/paperconf.c.useglibcfallback libpaper-1.1.24+nmu3/src/paperconf.c ---- libpaper-1.1.24+nmu3/src/paperconf.c.useglibcfallback 2012-05-03 15:05:12.000000000 -0400 -+++ libpaper-1.1.24+nmu3/src/paperconf.c 2014-04-22 15:58:33.121038995 -0400 -@@ -13,6 +13,7 @@ - #include - - #include -+#include - - - /* needed for GNU/Hurd */ -@@ -99,6 +100,8 @@ int main(int argc, char** argv) - - const char* progname; - -+ setlocale(LC_ALL, ""); -+ - progname = strrchr(*argv, '/'); - if (progname) { - ++progname; diff --git a/libpaper.spec b/libpaper.spec index 78f87a5bba117f110da9b82c701bbf4964a7620a..497b535e921038aa1fdcff1e5a290c65d69c43f7 100644 --- a/libpaper.spec +++ b/libpaper.spec @@ -1,12 +1,11 @@ Name: libpaper -Version: 1.1.29 +Version: 2.1.1 Release: 1 Summary: Library for handling paper characteristics License: GPLv2 -URL: http://packages.qa.debian.org/libp/libpaper.html -Source0: http://ftp.debian.org/debian/pool/main/libp/libpaper/%{name}_%{version}.tar.gz -Patch0: libpaper-useglibcfallback.patch -Patch1: libpaper-file-leak.patch +URL: https://github.com/rrthomas/libpaper +Source0: https://github.com/rrthomas/libpaper/archive/v%{version}/%{name}-%{version}.tar.gz +Source1: localepaper.c BuildRequires: gcc, libtool, gettext, gawk @@ -32,6 +31,7 @@ Man pages and other related documents for libpaper. %prep %autosetup -n %{name}-%{version} -p1 libtoolize +cp %{SOURCE1} src/ %build touch AUTHORS NEWS @@ -42,29 +42,38 @@ automake -a %disable_rpath %make_build +# localepaper +pushd src +%{__cc} %{optflags} -I.. -Ilibgnu -o localepaper localepaper.c libgnu/.libs/libgnupaper.a %{_hardening_ldflags} +popd + %install %make_install rm $RPM_BUILD_ROOT%{_libdir}/*.la mkdir -p $RPM_BUILD_ROOT%{_sysconfdir} -echo '# Simply write the paper name. See papersize(5) for possible values' > $RPM_BUILD_ROOT%{_sysconfdir}/papersize -mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/libpaper.d +#echo '# Simply write the paper name. See papersize(5) for possible values' > $RPM_BUILD_ROOT%{_sysconfdir}/papersize +#mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/libpaper.d +%if 0 for i in cs da de es fr gl hu it ja nl pt_BR sv tr uk vi; do mkdir -p $RPM_BUILD_ROOT%{_datadir}/locale/$i/LC_MESSAGES/; msgfmt debian/po/$i.po -o $RPM_BUILD_ROOT%{_datadir}/locale/$i/LC_MESSAGES/%{name}.mo; done %find_lang %{name} +%endif + +mkdir %{buildroot}%{_libexecdir} +install -m0755 src/localepaper %{buildroot}%{_libexecdir} %ldconfig_scriptlets -%files -f %{name}.lang +%files %doc ChangeLog README %license COPYING -%config(noreplace) %{_sysconfdir}/papersize -%dir %{_sysconfdir}/libpaper.d +%config(noreplace) %{_sysconfdir}/paperspecs +%{_libdir}/libpaper.so.2* +%{_bindir}/paper %{_bindir}/paperconf -%{_libdir}/libpaper.so.1.1.2 -%{_libdir}/libpaper.so.1 -%{_sbindir}/paperconfig +%{_libexecdir}/localepaper %files devel %{_includedir}/paper.h @@ -73,10 +82,11 @@ done %files help %{_mandir}/man1/* %{_mandir}/man5/* -%{_mandir}/man8/* -%{_mandir}/man3/* %changelog +* Tue Jul 30 2024 dillon chen - 2.1.1-1 +- upgrade to 2.1.1 + * Fri Jul 14 2023 fuanan - 1.1.29-1 - update version to 1.1.29 diff --git a/libpaper_1.1.29.tar.gz b/libpaper_1.1.29.tar.gz deleted file mode 100644 index b193ccdfda179d52c4bbb3f9ba6102efa5a2e981..0000000000000000000000000000000000000000 Binary files a/libpaper_1.1.29.tar.gz and /dev/null differ diff --git a/localepaper.c b/localepaper.c new file mode 100644 index 0000000000000000000000000000000000000000..78404a3707fcc491656063686e0066a43f717695 --- /dev/null +++ b/localepaper.c @@ -0,0 +1,44 @@ +/* + * localepaper: print the dimensions in mm of the current locale's + * paper size, if possible. + * + * Based on a patch by Caolan McNamara: + * http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=481213 + * + * Copyright (C) Reuben Thomas , 2013. + * + * Copying and distribution of this file, with or without modification, + * are permitted in any medium without royalty provided the copyright + * notice and this notice are preserved. + */ + +#include + +#include +#include +#include +#if defined LC_PAPER && defined _GNU_SOURCE +#include +#endif + +#include "progname.h" + +int main(int argc, char *argv[]) +{ + set_program_name(argv[0]); + argc = argc; /* Avoid a compiler warning. */ + +#if defined LC_PAPER && defined _GNU_SOURCE + setlocale(LC_ALL, ""); + +#define NL_PAPER_GET(x) \ + ((union { char *string; unsigned word; })nl_langinfo(x)).word + + printf("%d %d\n", NL_PAPER_GET(_NL_PAPER_WIDTH), NL_PAPER_GET(_NL_PAPER_HEIGHT)); + return EXIT_SUCCESS; + +#else + printf("%s: locale paper size information is not supported on this system", program_name); + return EXIT_FAILURE; +#endif +}