Accepting request 85391 from M17N
- implemented FATE#312586 - Add locales support for groff papersize * the default papersize is now determined from system locale (LC_PAPER) * /etc/papersize is no longer owned by the groff package OBS-URL: https://build.opensuse.org/request/show/85391 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/groff?expand=0&rev=35
This commit is contained in:
commit
b0ec2f484c
96
0001-locale-support-in-papersize-definition.patch
Normal file
96
0001-locale-support-in-papersize-definition.patch
Normal file
@ -0,0 +1,96 @@
|
||||
From 15c71e2588058f20169440c0add955a527144c7a Mon Sep 17 00:00:00 2001
|
||||
From: Michal Vyskocil <mvyskocil@suse.cz>
|
||||
Date: Mon, 26 Sep 2011 13:23:56 +0200
|
||||
Subject: [PATCH] locale support in papersize definition
|
||||
|
||||
The papersize definition in groff_font(5) has been extended by new
|
||||
keyword "locale". In this mode groff determine the paper size from
|
||||
LC_PAPER variable.
|
||||
|
||||
The algorithm is simple - there is a small static list of countries
|
||||
using letter based on territory language information page [1] (CLDR
|
||||
2.0). If the LC_PAPER contains the country code (for instance _CL -
|
||||
Chile), letter dimmensions are used. Otherwise a4.
|
||||
|
||||
[1] http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/territory_language_information.html
|
||||
[2] http://wiki.services.openoffice.org/wiki/DefaultPaperSize
|
||||
---
|
||||
src/include/paper.h | 4 ++--
|
||||
src/libs/libgroff/paper.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 44 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/include/paper.h b/src/include/paper.h
|
||||
index 73e070c..f5a8039 100644
|
||||
--- a/src/include/paper.h
|
||||
+++ b/src/include/paper.h
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
papersize_init();
|
||||
} _papersize_init;
|
||||
|
||||
-// A0-A7, B0-B7, C0-C7, D0-D7, 8 American paper sizes, 1 special size */
|
||||
-#define NUM_PAPERSIZES 4*8 + 8 + 1
|
||||
+// A0-A7, B0-B7, C0-C7, D0-D7, 8 American paper sizes, 1 special size and the locale */
|
||||
+#define NUM_PAPERSIZES 4*8 + 8 + 1 + 1
|
||||
|
||||
extern paper papersizes[];
|
||||
diff --git a/src/libs/libgroff/paper.cpp b/src/libs/libgroff/paper.cpp
|
||||
index 27a7c8c..42dea69 100644
|
||||
--- a/src/libs/libgroff/paper.cpp
|
||||
+++ b/src/libs/libgroff/paper.cpp
|
||||
@@ -58,6 +58,46 @@ static void add_american_paper(const char *name, int idx,
|
||||
papersizes[idx].width = width;
|
||||
}
|
||||
|
||||
+static int is_letter(const char* variable) {
|
||||
+
|
||||
+ // CLDR 1.8.1 http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/territory_la
|
||||
+ // http://wiki.services.openoffice.org/wiki/DefaultPaperSize
|
||||
+ #define COUNTRIES 13
|
||||
+ static const char* countries[COUNTRIES] = {
|
||||
+ "_BZ", "_CA", "CL", "CO", "CR", "GT", "MX", "NI", "PA", "PH", "PR", "SV", "US",
|
||||
+ };
|
||||
+
|
||||
+ if (! variable) {
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ for (int i = 0; i != COUNTRIES; i++) {
|
||||
+ if (strstr(variable, countries[i])) {
|
||||
+ return 1;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void add_locale_paper(int idx) {
|
||||
+ char * lc_paper;
|
||||
+ double l = 297/25.4;
|
||||
+ double w = 210/25.4;
|
||||
+
|
||||
+ //XXX: setlocale(LC_PAPER, NULL) does not work
|
||||
+ // at least on glibc 2.14
|
||||
+ lc_paper = setlocale(LC_PAPER, "");
|
||||
+
|
||||
+ if (is_letter(lc_paper)) {
|
||||
+ l = 11;
|
||||
+ w = 8.5;
|
||||
+ }
|
||||
+
|
||||
+ add_american_paper("locale", idx, l, w);
|
||||
+
|
||||
+}
|
||||
+
|
||||
int papersize_init::initialised = 0;
|
||||
|
||||
papersize_init::papersize_init()
|
||||
@@ -80,4 +120,6 @@ papersize_init::papersize_init()
|
||||
add_american_paper("monarch", 39, 7.5, 3.875);
|
||||
// this is an ISO format, but it easier to use add_american_paper
|
||||
add_american_paper("dl", 40, 220/25.4, 110/25.4);
|
||||
+ // the format from locale
|
||||
+ add_locale_paper(41);
|
||||
}
|
||||
--
|
||||
1.7.6.3
|
||||
|
86
0002-documentation-for-the-locale-keyword.patch
Normal file
86
0002-documentation-for-the-locale-keyword.patch
Normal file
@ -0,0 +1,86 @@
|
||||
From d4f65688290a2362af9a66ecb3ae93beb591fbf9 Mon Sep 17 00:00:00 2001
|
||||
From: Michal Vyskocil <mvyskocil@suse.cz>
|
||||
Date: Thu, 29 Sep 2011 09:19:01 +0200
|
||||
Subject: [PATCH] documentation for the locale keyword
|
||||
|
||||
---
|
||||
doc/groff.texinfo | 28 +++++++++++++++++++++++++++-
|
||||
man/groff_font.man | 8 +++++++-
|
||||
2 files changed, 34 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/doc/groff.texinfo b/doc/groff.texinfo
|
||||
index 7b09e0f..1cff7b4 100644
|
||||
--- a/doc/groff.texinfo
|
||||
+++ b/doc/groff.texinfo
|
||||
@@ -16530,7 +16530,7 @@ types @code{A0}-@code{A7}, @code{B0}-@code{B7}, @code{C0}-@code{C7},
|
||||
significant for @var{string} if it holds predefined paper types.
|
||||
Alternatively, @var{string} can be a file name (e.g.@:
|
||||
@file{/etc/papersize}); if the file can be opened, @code{groff} reads
|
||||
-the first line and tests for the above paper sizes. Finally,
|
||||
+the first line and tests for the above paper sizes. Or,
|
||||
@var{string} can be a custom paper size in the format
|
||||
@code{@var{length},@var{width}} (no spaces before and after the comma).
|
||||
Both @var{length} and @var{width} must have a unit appended; valid
|
||||
@@ -16540,6 +16540,32 @@ which starts with a digit is always treated as a custom paper format.
|
||||
@code{papersize} sets both the vertical and horizontal dimension of the
|
||||
output medium.
|
||||
|
||||
+Finally, @var{string} can be a keyword @code{locale}. In this case groff will
|
||||
+determine the default paper size from the country code of @code{LC_PAPER}. For
|
||||
+most of combinations (including @code{LC_PAPER=C} or @code{POSIX}) a4 is used.
|
||||
+In case of countries listed in Common Language Data Repository 2.0 of Unicode
|
||||
+Consorcium - US (@code{US}), Canada (@code{CA}), Belize (@code{BZ}), Chile
|
||||
+(@code{CL}), Colombia (@code{CO}), Costa Rica (@code{CR}), El Salvador
|
||||
+(@code{SV}), Guatemala (@code{GT}), Panama (@code{PA}), Philippines
|
||||
+(@code{PH}), Puerto Rico (@code{PR}), Mexico (@code{MX}), Nicaragua (@code{NI})
|
||||
+and the Venezula (@code{VE}) size letter is used. The value of @code{LC_PAPER}
|
||||
+is usually derived from @code{LANG} or @code{LC_ALL} and needs to be changed
|
||||
+only if your main locale does not match the expected default paper size. Then
|
||||
+you need to put the correct LC_PAPER variable into your environment.
|
||||
+
|
||||
+@example
|
||||
+@group
|
||||
+# the locale keyword is in devpts
|
||||
+shell> grep papersize /usr/share/groff/current/font/devps/DESC
|
||||
+papersize locale
|
||||
+# default locale is US producing a letter papersize
|
||||
+shell> locale | grep LC_PAPER
|
||||
+LC_PAPER="en_US.UTF-8"
|
||||
+# let's use a4 (German default) in this case
|
||||
+shell> LC_PAPER=de_DE.UTF-8 groff -Tps ...
|
||||
+@end group
|
||||
+@end example
|
||||
+
|
||||
More than one argument can be specified; @code{groff} scans from left to
|
||||
right and uses the first valid paper specification.
|
||||
|
||||
diff --git a/man/groff_font.man b/man/groff_font.man
|
||||
index 64bd212..29a7136 100644
|
||||
--- a/man/groff_font.man
|
||||
+++ b/man/groff_font.man
|
||||
@@ -150,7 +150,7 @@ can be a file name (e.g.\& `/etc/papersize'); if the file can be opened,
|
||||
.B groff
|
||||
reads the first line and tests for the above paper sizes.
|
||||
.
|
||||
-Finally,
|
||||
+or,
|
||||
.I string
|
||||
can be a custom paper size in the format
|
||||
.IB length , width
|
||||
@@ -172,7 +172,13 @@ format.
|
||||
.B papersize
|
||||
sets both the vertical and horizontal dimension of the output medium.
|
||||
.
|
||||
+Finally
|
||||
+.I string
|
||||
+can be a keyword locale, so
|
||||
+.B groff
|
||||
+will determine the papersize from system locale (LC_PAPER).
|
||||
.IP
|
||||
+.
|
||||
More than one argument can be specified;
|
||||
.B groff
|
||||
scans from left to right and uses the first valid paper specification.
|
||||
--
|
||||
1.7.6.3
|
||||
|
63
groff-force-locale-usage.patch
Normal file
63
groff-force-locale-usage.patch
Normal file
@ -0,0 +1,63 @@
|
||||
Index: groff-1.21/font/devdvi/Makefile.sub
|
||||
===================================================================
|
||||
--- groff-1.21.orig/font/devdvi/Makefile.sub 2011-09-29 10:18:51.000000000 +0200
|
||||
+++ groff-1.21/font/devdvi/Makefile.sub 2011-09-29 10:20:09.299489369 +0200
|
||||
@@ -16,8 +16,8 @@
|
||||
DESC: DESC.in
|
||||
cat $(srcdir)/DESC.in >DESC
|
||||
if test "$(PAGE)" = A4; then \
|
||||
- echo "papersize /etc/papersize a4" >>DESC; \
|
||||
+ echo "papersize /etc/papersize locale a4" >>DESC; \
|
||||
else \
|
||||
- echo "papersize /etc/papersize letter" >>DESC; \
|
||||
+ echo "papersize /etc/papersize locale letter" >>DESC; \
|
||||
fi
|
||||
test -z '$(DVIPRINT)' || echo print '$(DVIPRINT)' >>DESC
|
||||
Index: groff-1.21/font/devlbp/Makefile.sub
|
||||
===================================================================
|
||||
--- groff-1.21.orig/font/devlbp/Makefile.sub 2011-09-29 10:18:51.000000000 +0200
|
||||
+++ groff-1.21/font/devlbp/Makefile.sub 2011-09-29 10:20:25.060031676 +0200
|
||||
@@ -13,9 +13,9 @@
|
||||
-rm -f DESC
|
||||
cat $(srcdir)/DESC.in >>DESC
|
||||
if test "$(PAGE)" = A4; then \
|
||||
- echo "papersize /etc/papersize a4" >>DESC; \
|
||||
+ echo "papersize /etc/papersize locale a4" >>DESC; \
|
||||
else \
|
||||
- echo "papersize /etc/papersize letter" >>DESC; \
|
||||
+ echo "papersize /etc/papersize locale letter" >>DESC; \
|
||||
fi
|
||||
test -z '$(LBPPRINT)' || echo print '$(LBPPRINT)' >>DESC
|
||||
|
||||
Index: groff-1.21/font/devlj4/Makefile.sub
|
||||
===================================================================
|
||||
--- groff-1.21.orig/font/devlj4/Makefile.sub 2011-09-29 10:18:51.000000000 +0200
|
||||
+++ groff-1.21/font/devlj4/Makefile.sub 2011-09-29 10:20:35.332386890 +0200
|
||||
@@ -30,9 +30,9 @@
|
||||
echo "unitwidth `expr 7620000 / $(LJ4RES)`" >>DESC
|
||||
cat $(srcdir)/DESC.in >>DESC
|
||||
if test "$(PAGE)" = A4; then \
|
||||
- echo "papersize /etc/papersize a4" >>DESC; \
|
||||
+ echo "papersize /etc/papersize locale a4" >>DESC; \
|
||||
else \
|
||||
- echo "papersize /etc/papersize letter" >>DESC; \
|
||||
+ echo "papersize /etc/papersize locale letter" >>DESC; \
|
||||
fi
|
||||
test -z '$(LJ4PRINT)' || echo print '$(LJ4PRINT)' >>DESC
|
||||
|
||||
Index: groff-1.21/font/devps/Makefile.sub
|
||||
===================================================================
|
||||
--- groff-1.21.orig/font/devps/Makefile.sub 2011-09-29 10:18:51.000000000 +0200
|
||||
+++ groff-1.21/font/devps/Makefile.sub 2011-09-29 10:20:45.194727208 +0200
|
||||
@@ -40,9 +40,9 @@
|
||||
cat $(srcdir)/DESC.in >DESC
|
||||
echo broken $(BROKEN_SPOOLER_FLAGS) >>DESC
|
||||
if test "$(PAGE)" = A4; then \
|
||||
- echo "papersize /etc/papersize a4" >>DESC; \
|
||||
+ echo "papersize /etc/papersize locale a4" >>DESC; \
|
||||
else \
|
||||
- echo "papersize /etc/papersize letter" >>DESC; \
|
||||
+ echo "papersize /etc/papersize locale letter" >>DESC; \
|
||||
fi
|
||||
test -z '$(PSPRINT)' || echo print '$(PSPRINT)' >>DESC
|
||||
|
@ -1,3 +1,10 @@
|
||||
-------------------------------------------------------------------
|
||||
Thu Sep 29 08:09:33 UTC 2011 - mvyskocil@suse.cz
|
||||
|
||||
- implemented FATE#312586 - Add locales support for groff papersize
|
||||
* the default papersize is now determined from system locale (LC_PAPER)
|
||||
* /etc/papersize is no longer owned by the groff package
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Sep 22 12:50:27 UTC 2011 - mvyskocil@suse.cz
|
||||
|
||||
|
19
groff.spec
19
groff.spec
@ -41,6 +41,14 @@ Patch5: groff-1.21-CVE-2009-5044.patch
|
||||
#http://cvsweb.openwall.com/cgi/cvsweb.cgi/Owl/packages/groff/groff-1.20.1-owl-tmp.diff?rev=1.2;content-type=text%2Fplain
|
||||
Patch6: groff-1.21-CVE-2009-5080.patch
|
||||
Patch7: groff-1.21-CVE-2009-5081.patch
|
||||
#PATCH-FIX-OPENSUSE: FATE#312586
|
||||
#sent upstream http://lists.gnu.org/archive/html/bug-groff/2011-09/msg00002.html
|
||||
#so they would be available on next release of groff
|
||||
Patch8: 0001-locale-support-in-papersize-definition.patch
|
||||
Patch9: 0002-documentation-for-the-locale-keyword.patch
|
||||
# change the papersize definition to force the locale usage
|
||||
# it can be supressed by /etc/papersize if needed
|
||||
Patch10: groff-force-locale-usage.patch
|
||||
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
BuildRequires: gcc-c++
|
||||
@ -91,7 +99,10 @@ programs store their man pages in either /usr/share/man/ or
|
||||
%patch4 -p1 -b .deunicode
|
||||
%patch5 -p1 -b .CVE-2009-5044
|
||||
%patch6 -p1 -b .CVE-2009-5080
|
||||
%patch7 -p1 -b .CVE-2009-5081
|
||||
%patch7 -p1
|
||||
%patch8 -p1 -b .locale
|
||||
%patch9 -p1 -b .locale
|
||||
%patch10 -p1 -b .force-locale
|
||||
|
||||
%build
|
||||
PATH=$PWD/src/roff/troff:$PWD/src/preproc/pic:$PWD/src/preproc/eqn:$PWD/src/preproc/tbl:$PWDsrc/preproc/refer:$PWD/src/preproc/soelim:$PATH
|
||||
@ -106,6 +117,7 @@ export PATH GROFF_COMMAND_PREFIX GROFF_FONT_PATH GROFF_TMAC_PATH
|
||||
export CFLAGS="-fno-strict-aliasing"
|
||||
export CXXFLAGS="-fno-strict-aliasing"
|
||||
%{configure}
|
||||
ulimit -c unlimited
|
||||
%{__make}
|
||||
pushd doc
|
||||
%{__make}
|
||||
@ -125,10 +137,6 @@ popd
|
||||
%{__ln_s} -f eqn %{buildroot}%{_bindir}/geqn
|
||||
%{__ln_s} -f tbl %{buildroot}%{_bindir}/gtbl
|
||||
|
||||
%{__install} -d -m 0755 %{buildroot}%{_sysconfdir}
|
||||
echo "a4" > %{buildroot}%{_sysconfdir}/papersize
|
||||
%{__chmod} 0644 %{buildroot}%{_sysconfdir}/papersize
|
||||
|
||||
# install profiles to disable the use of ANSI colour sequences by default:
|
||||
%{__install} -d -m 0755 %{buildroot}/%{_sysconfdir}/profile.d
|
||||
%{__install} -m 644 %{SOURCE3} %{SOURCE4} %{buildroot}/%{_sysconfdir}/profile.d/
|
||||
@ -153,7 +161,6 @@ rm -rf %{buildroot}
|
||||
%doc %{_infodir}/groff*
|
||||
%doc %{_mandir}/man?/*
|
||||
%{_bindir}/*
|
||||
%config(noreplace) %verify(not md5 size mtime) %{_sysconfdir}/papersize
|
||||
%config %{_sysconfdir}/profile.d/zzz-%{name}.*sh
|
||||
%{_datadir}/%{name}
|
||||
%{_libexecdir}/%{name}
|
||||
|
Loading…
Reference in New Issue
Block a user