rpms/paps/devel paps-0.6.6-encoding.patch, NONE, 1.1 paps-0.6.6-segfault.patch, NONE, 1.1 paps.spec, 1.10, 1.11
Akira Tagoh (tagoh)
fedora-extras-commits at redhat.com
Thu May 25 07:49:13 UTC 2006
Author: tagoh
Update of /cvs/extras/rpms/paps/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv26127
Modified Files:
paps.spec
Added Files:
paps-0.6.6-encoding.patch paps-0.6.6-segfault.patch
Log Message:
* Thu May 25 2006 Akira TAGOH <tagoh at redhat.com> - 0.6.6-2
- paps-0.6.6-encoding.patch: support --encoding option to be able to convert
the input file to UTF-8.
- paps-0.6.6-segfault.patch: fixed a possible segfault issue when reading is
failed.
paps-0.6.6-encoding.patch:
--- NEW FILE paps-0.6.6-encoding.patch ---
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-05-25 13:23:07.000000000 +0900
+++ paps-0.6.6/src/paps.c 2006-05-25 14:55:03.000000000 +0900
@@ -105,7 +105,8 @@
/* Information passed in user data when drawing outlines */
GList *split_paragraphs_into_lines (GList *paragraphs);
-static char *read_file (FILE *file);
+static char *read_file (FILE *file,
+ GIConv *handle);
static GList *split_text_into_paragraphs (PangoContext *pango_context,
page_layout_t *page_layout,
int paint_width,
@@ -188,7 +189,7 @@
gboolean do_landscape = FALSE, do_rtl = FALSE, do_justify = FALSE, do_draw_header = FALSE;
int num_columns = 1, font_scale = 12;
int top_margin = 36, bottom_margin = 36, right_margin = 36, left_margin = 36;
- char *font_family = "Monospace";
+ char *font_family = "Monospace", *encoding = NULL;
GOptionContext *ctxt = g_option_context_new("[text file]");
GOptionEntry entries[] = {
{"landscape", 0, 0, G_OPTION_ARG_NONE, &do_landscape, "Landscape output. (Default: portrait)", NULL},
@@ -205,6 +206,7 @@
{"right-margin", 0, 0, G_OPTION_ARG_INT, &right_margin, "Set right margin. (Default: 36)", "NUM"},
{"left-margin", 0, 0, G_OPTION_ARG_INT, &left_margin, "Set left margin. (Default: 36)", "NUM"},
{"header", 0, 0, G_OPTION_ARG_NONE, &do_draw_header, "Draw page header for each page.", NULL},
+ {"encoding", 0, 0, G_OPTION_ARG_STRING, &encoding, "Assume the documentation encoding.", "ENCODING"},
{NULL}
};
GError *error = NULL;
@@ -228,6 +230,7 @@
gchar *paps_header = NULL;
gchar *header_font_desc = "Monospace Bold 12";
int header_sep = 20;
+ GIConv *cvh = NULL;
/* Prerequisite when using glib. */
g_type_init();
@@ -339,7 +342,21 @@
page_layout.filename = filename_in;
page_layout.header_font_desc = header_font_desc;
- text = read_file(IN);
+ if (encoding != NULL)
+ {
+ cvh = g_iconv_open ("UTF-8", encoding);
+ if (cvh == NULL)
+ {
+ fprintf(stderr, "%s: Invalid encoding: %s\n", g_get_prgname (), encoding);
+ exit(-1);
+ }
+ }
+
+ text = read_file(IN, cvh);
+
+ if (encoding != NULL && cvh != NULL)
+ g_iconv_close(cvh);
+
paragraphs = split_text_into_paragraphs(pango_context,
&page_layout,
page_layout.column_width * page_layout.pt_to_pixel,
@@ -373,7 +390,8 @@
/* Read an entire file into a string
*/
static char *
-read_file (FILE *file)
+read_file (FILE *file,
+ GIConv *handle)
{
GString *inbuf;
char *text;
@@ -382,7 +400,9 @@
inbuf = g_string_new (NULL);
while (1)
{
- char *bp = fgets (buffer, BUFSIZE-1, file);
+ char *ib, *ob, obuffer[BUFSIZE * 6], *bp = fgets (buffer, BUFSIZE-1, file);
+ gsize iblen, oblen;
+
if (ferror (file))
{
fprintf(stderr, "%s: Error reading file.\n", g_get_prgname ());
@@ -392,7 +412,19 @@
else if (bp == NULL)
break;
- g_string_append (inbuf, buffer);
+ if (handle != NULL)
+ {
+ ib = bp;
+ iblen = strlen (ib);
+ ob = bp = obuffer;
+ oblen = BUFSIZE * 6 - 1;
+ if (g_iconv (handle, &ib, &iblen, &ob, &oblen) == -1)
+ {
+ fprintf (stderr, "%s: Error while converting strings.\n", g_get_prgname ());
+ return NULL;
+ }
+ }
+ g_string_append (inbuf, bp);
}
fclose (file);
paps-0.6.6-segfault.patch:
--- NEW FILE paps-0.6.6-segfault.patch ---
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-05-25 15:12:02.000000000 +0900
+++ paps-0.6.6/src/paps.c 2006-05-25 15:15:58.000000000 +0900
@@ -453,7 +453,7 @@
GList *result = NULL;
char *last_para = text;
- while (*p)
+ while (p != NULL && *p)
{
wc = g_utf8_get_char (p);
next = g_utf8_next_char (p);
Index: paps.spec
===================================================================
RCS file: /cvs/extras/rpms/paps/devel/paps.spec,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- paps.spec 19 May 2006 10:16:31 -0000 1.10
+++ paps.spec 25 May 2006 07:49:13 -0000 1.11
@@ -1,6 +1,6 @@
Name: paps
Version: 0.6.6
-Release: 1%{?dist}
+Release: 2%{?dist}
License: LGPL
URL: http://paps.sourceforge.net/
@@ -9,6 +9,8 @@
BuildRequires: pango-devel
Patch0: paps-makefile.patch
Patch2: paps-0.6.3-formfeed.patch
+Patch3: paps-0.6.6-encoding.patch
+Patch4: paps-0.6.6-segfault.patch
Summary: Plain Text to PostScript converter
Group: Applications/Publishing
@@ -20,6 +22,8 @@
%setup -q
%patch0 -p1 -b .makefile
%patch2 -p1 -b .formfeed
+%patch3 -p1 -b .encoding
+%patch4 -p1 -b .segfault
aclocal
automake
autoconf
@@ -47,6 +51,12 @@
%changelog
+* Thu May 25 2006 Akira TAGOH <tagoh at redhat.com> - 0.6.6-2
+- paps-0.6.6-encoding.patch: support --encoding option to be able to convert
+ the input file to UTF-8.
+- paps-0.6.6-segfault.patch: fixed a possible segfault issue when reading is
+ failed.
+
* Fri May 19 2006 Akira TAGOH <tagoh at redhat.com> - 0.6.6-1
- New upstream release.
More information about the fedora-extras-commits
mailing list