[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Groff] problem with preconv and

From: G. Branden Robinson
Subject: Re: [Groff] problem with preconv and
Date: Sat, 4 Nov 2017 21:46:57 -0400
User-agent: NeoMutt/20170113 (1.7.2)

Hi, Bertrand!

At 2017-11-05T01:12:38+0100, Bertrand Garrigues wrote:
> Which version of `uchardet' do you have on your system?  On mine I have
> version 0.0.6.

Well, that's my problem right there.  I'm running Debian 9 ("Stretch"),

$ dpkg -s libuchardet-dev | grep 0
Source: uchardet (0.0.1-1)
Version: 0.0.1-1+b2
Depends: libuchardet0 (= 0.0.1-1+b2)

> Another thing is that if `uchardet_get_charse' returns NULL we use the
> default encoding, but we could also test that this function returns an
> empty string (which should be your case).

Here's a patch.  I tested it and it appears to work; I no longer get
those warnings from preconv, and both contrib/mom/examples/mom-pdf.pdf
and contrib/mom/examples/sample_docs.pdf look fine in Evince.

diff --git a/src/preproc/preconv/preconv.cpp b/src/preproc/preconv/preconv.cpp
index 97d4feb1..891c1515 100644
--- a/src/preproc/preconv/preconv.cpp
+++ b/src/preproc/preconv/preconv.cpp
@@ -1050,6 +1050,11 @@ detect_file_encoding(FILE *fp)
   if (debug_flag)
     fprintf(stderr, "  charset: %s\n", charset);
   if (charset) {
+    /* uchardet 0.0.1 could return an empty string instead of NULL */
+    if (!charset[0]) {
+      uchardet_delete(ud);
+      return NULL;
+    }
     ret = (char *)calloc(strlen(charset) + 1, 1);
     strcpy(ret, charset);

I'm happy to commit this if it meets with your approval.


Attachment: signature.asc
Description: PGP signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]