Hi Branden, On Sat, Nov 04 2017 at 09:46:57 PM, "G. Branden Robinson" <g.branden.robin...@gmail.com> wrote: > 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"), > so: > > $ 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)
Strange. At the time I've made the changes in preconv I've tested version 0.0.1, and thus I've put this version as minimal acceptable version in groff.m4. I don't remember having encountered any problem, but now if I uninstall my 0.0.6 version and install 0.0.1 instead I reproduce the same problem. Maybe I haven't tested correctly at that time. >> 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. Looks correct, please commit. Regards, Bertrand Garrigues