- Better the encoding guess by looking at current locale. (#212154)

This commit is contained in:
Akira TAGOH 2007-01-23 12:25:25 +00:00
parent a055aa27e2
commit c0d5660983
3 changed files with 75 additions and 30 deletions

37
paps-0.6.6-langinfo.patch Normal file
View File

@ -0,0 +1,37 @@
diff -pruN paps-0.6.6.orig/src/paps.c paps-0.6.6/src/paps.c
--- paps-0.6.6.orig/src/paps.c 2007-01-23 18:56:04.000000000 +0900
+++ paps-0.6.6/src/paps.c 2007-01-23 18:59:15.000000000 +0900
@@ -25,6 +25,7 @@
#include <pango/pangoft2.h>
#include "libpaps.h"
#include <errno.h>
+#include <langinfo.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -324,6 +325,9 @@ int main(int argc, char *argv[])
int max_width = 0, w;
GIConv cvh = NULL;
+ /* Set locale from environment. */
+ setlocale(LC_ALL, "");
+
/* Prerequisite when using glib. */
g_type_init();
@@ -451,6 +455,15 @@ int main(int argc, char *argv[])
g_object_unref (G_OBJECT (fontmap));
}
+ if (encoding == NULL)
+ {
+ encoding = g_strdup(nl_langinfo(CODESET));
+ if (!strcmp(encoding, "UTF-8"))
+ {
+ g_free(encoding);
+ encoding = NULL;
+ }
+ }
if (encoding != NULL)
{
cvh = g_iconv_open ("UTF-8", encoding);

View File

@ -1,7 +1,7 @@
diff -ruN paps-0.6.6.orig/configure.in paps-0.6.6/configure.in
diff -pruN paps-0.6.6.orig/configure.in paps-0.6.6/configure.in
--- paps-0.6.6.orig/configure.in 2006-04-28 04:41:36.000000000 +0900
+++ paps-0.6.6/configure.in 2006-09-30 03:13:29.000000000 +0900
@@ -7,4 +7,17 @@
+++ paps-0.6.6/configure.in 2007-01-23 19:36:35.000000000 +0900
@@ -7,4 +7,17 @@ AC_LANG_C
AC_PROG_CC
AM_PROG_LIBTOOL
@ -19,10 +19,10 @@ diff -ruN paps-0.6.6.orig/configure.in paps-0.6.6/configure.in
+AC_SUBST(CUPS_LIBS)
+
AC_OUTPUT(Makefile src/Makefile doc/Makefile)
diff -ruN paps-0.6.6.orig/src/Makefile.am paps-0.6.6/src/Makefile.am
--- paps-0.6.6.orig/src/Makefile.am 2006-09-30 03:13:05.000000000 +0900
+++ paps-0.6.6/src/Makefile.am 2006-09-30 03:13:29.000000000 +0900
@@ -5,10 +5,10 @@
diff -pruN paps-0.6.6.orig/src/Makefile.am paps-0.6.6/src/Makefile.am
--- paps-0.6.6.orig/src/Makefile.am 2007-01-23 19:07:52.000000000 +0900
+++ paps-0.6.6/src/Makefile.am 2007-01-23 19:36:35.000000000 +0900
@@ -5,10 +5,10 @@ libpaps_a_inc_HEADERS = libpaps.h
libpaps_a_incdir = $(includedir)
bin_PROGRAMS = paps
@ -35,10 +35,10 @@ diff -ruN paps-0.6.6.orig/src/Makefile.am paps-0.6.6/src/Makefile.am
paps_DEPENDENCIES = $(noinst_LIBRARIES)
EXTRA_DIST = test_libpaps.c paps.1
diff -ruN paps-0.6.6.orig/src/paps.c paps-0.6.6/src/paps.c
--- paps-0.6.6.orig/src/paps.c 2006-09-30 03:13:05.000000000 +0900
+++ paps-0.6.6/src/paps.c 2006-09-30 03:16:10.000000000 +0900
@@ -31,6 +31,7 @@
diff -pruN paps-0.6.6.orig/src/paps.c paps-0.6.6/src/paps.c
--- paps-0.6.6.orig/src/paps.c 2007-01-23 19:07:52.000000000 +0900
+++ paps-0.6.6/src/paps.c 2007-01-23 19:35:33.000000000 +0900
@@ -32,6 +32,7 @@
#include <time.h>
#include <locale.h>
#include <wchar.h>
@ -46,7 +46,7 @@ diff -ruN paps-0.6.6.orig/src/paps.c paps-0.6.6/src/paps.c
#define BUFSIZE 1024
#define DEFAULT_FONT_FAMILY "Monospace"
@@ -84,9 +85,11 @@
@@ -85,9 +86,11 @@ typedef struct {
gboolean do_separation_line;
gboolean do_draw_contour;
gboolean do_wordwrap;
@ -58,7 +58,7 @@ diff -ruN paps-0.6.6.orig/src/paps.c paps-0.6.6/src/paps.c
} page_layout_t;
typedef struct {
@@ -313,8 +316,8 @@
@@ -314,8 +317,8 @@ int main(int argc, char *argv[])
int num_pages = 1;
int gutter_width = 40;
int total_gutter_width;
@ -69,15 +69,16 @@ diff -ruN paps-0.6.6.orig/src/paps.c paps-0.6.6/src/paps.c
int do_tumble = -1; /* -1 means not initialized */
int do_duplex = -1;
gchar *paps_header = NULL;
@@ -323,12 +326,124 @@
@@ -324,6 +327,8 @@ int main(int argc, char *argv[])
int header_sep = 20;
int max_width = 0, w;
GIConv cvh = NULL;
+ gboolean cups_mode = FALSE;
+ gchar *page_owner = NULL;
/* Prerequisite when using glib. */
g_type_init();
/* Set locale from environment. */
setlocale(LC_ALL, "");
@@ -333,6 +338,118 @@ int main(int argc, char *argv[])
g_option_context_add_main_entries(ctxt, entries, NULL);
@ -133,11 +134,12 @@ diff -ruN paps-0.6.6.orig/src/paps.c paps-0.6.6/src/paps.c
+ }
+
+ if ((val = cupsGetOption("landscape", num_options, options)) != NULL) {
+ if (g_ascii_strcasecmp(val, "no") != 0 &&
+ g_ascii_strcasecmp(val, "off") != 0 &&
+ g_ascii_strcasecmp(val, "false") != 0) {
+ /* XXX: need to support other orientations? */
+ do_landscape = TRUE;
+ if (g_ascii_strcasecmp(val, "no") &&
+ g_ascii_strcasecmp(val, "off") &&
+ g_ascii_strcasecmp(val, "false")) {
+ /* We don't need to process the documentation for orientation support.
+ * pstops certainly does. (#222137)
+ */
+ }
+ }
+ /* XXX: need to support orientation-requested? */
@ -178,8 +180,9 @@ diff -ruN paps-0.6.6.orig/src/paps.c paps-0.6.6/src/paps.c
+ }
+ if (getenv("CHARSET") != NULL) {
+ char *charset = getenv("CHARSET");
+ // Map CUPS charset names to real ones.
+ // http://cups.org/newsgroups.php?s9797+gcups.general+v9797+T1
+ /* Map CUPS charset names to real ones.
+ * http://cups.org/newsgroups.php?s9797+gcups.general+v9797+T1
+ */
+ if (!g_ascii_strcasecmp(charset, "windows-932"))
+ charset = "WINDOWS-31J";
+ if (g_ascii_strcasecmp(charset, "utf-8") &&
@ -194,7 +197,7 @@ diff -ruN paps-0.6.6.orig/src/paps.c paps-0.6.6/src/paps.c
/* Parse command line */
if (!g_option_context_parse(ctxt, &argc, &argv, &error))
{
@@ -355,6 +470,8 @@
@@ -359,6 +476,8 @@ int main(int argc, char *argv[])
IN = stdin;
}
title = filename_in;
@ -203,7 +206,7 @@ diff -ruN paps-0.6.6.orig/src/paps.c paps-0.6.6/src/paps.c
paps = paps_new();
pango_context = paps_get_pango_context (paps);
@@ -373,8 +490,10 @@
@@ -377,8 +496,10 @@ int main(int argc, char *argv[])
pango_context_set_font_description (pango_context, font_description);
/* Page layout */
@ -216,7 +219,7 @@ diff -ruN paps-0.6.6.orig/src/paps.c paps-0.6.6/src/paps.c
if (num_columns == 1)
total_gutter_width = 0;
@@ -435,6 +554,8 @@
@@ -439,6 +560,8 @@ int main(int argc, char *argv[])
page_layout.pango_dir = pango_dir;
page_layout.filename = filename_in;
page_layout.header_font_desc = header_font_desc;
@ -225,7 +228,7 @@ diff -ruN paps-0.6.6.orig/src/paps.c paps-0.6.6/src/paps.c
/* calculate x-coordinate scale */
if (cpi > 0.0L)
@@ -571,6 +692,12 @@
@@ -584,6 +707,12 @@ split_text_into_paragraphs (PangoContext
if (wc == (gunichar)-1)
{
fprintf (stderr, "%s: Invalid character in input\n", g_get_prgname ());
@ -238,7 +241,7 @@ diff -ruN paps-0.6.6.orig/src/paps.c paps-0.6.6/src/paps.c
wc = 0;
}
if (!*p || !wc || wc == '\n' || wc == '\f')
@@ -784,6 +911,7 @@
@@ -810,6 +939,7 @@ void print_postscript_header(FILE *OUT,
int orientation = page_layout->page_width > page_layout->page_height;
int bb_page_width = page_layout->page_width;
int bb_page_height = page_layout->page_height;
@ -246,7 +249,7 @@ diff -ruN paps-0.6.6.orig/src/paps.c paps-0.6.6/src/paps.c
/* Keep bounding box non-rotated to make ggv happy */
if (orientation)
@@ -793,12 +921,20 @@
@@ -819,12 +949,20 @@ void print_postscript_header(FILE *OUT,
bb_page_height = tmp;
}
@ -268,7 +271,7 @@ diff -ruN paps-0.6.6.orig/src/paps.c paps-0.6.6/src/paps.c
"%%%%BeginProlog\n"
"%%%%Orientation: %s\n"
"/papsdict 1 dict def\n"
@@ -848,8 +984,10 @@
@@ -874,8 +1012,10 @@ void print_postscript_header(FILE *OUT,
title,
bb_page_width,
bb_page_height,

View File

@ -26,6 +26,7 @@ Patch8: paps-0.6.6-wordwrap.patch
Patch9: paps-0.6.6-cpilpi.patch
Patch10: paps-0.6.6-exitcode.patch
Patch11: paps-0.6.6-fix-wcswidth.patch
Patch12: paps-0.6.6-langinfo.patch
Patch50: paps-cups.patch
Summary: Plain Text to PostScript converter
@ -47,6 +48,7 @@ paps is a PostScript converter from plain text file using Pango.
%patch9 -p1 -b .cpilpi
%patch10 -p1 -b .exitcode
%patch11 -p1 -b .wcswidth
%patch12 -p1 -b .langinfo
%patch50 -p1 -b .cups
aclocal
automake
@ -80,6 +82,9 @@ rm -rf $RPM_BUILD_ROOT
%changelog
* Tue Jan 23 2007 Akira TAGOH <tagoh@redhat.com>
- Better the encoding guess by looking at current locale. (#212154)
* Mon Dec 4 2006 Akira TAGOH <tagoh@redhat.com> - 0.6.6-17
- Fix a segfault on non-printable character. (#216296)