Theo Buehler <t...@math.ethz.ch> writes:

> On Tue, Mar 14, 2017 at 09:35:37AM +0100, Reinhold Straub wrote:
>> ok?
>> 
>> On 06.03.17 18:18, Reinhold Straub wrote:
>> > Hi all,
>> > 
>> > pdfgrep has been updated to v. 2.0.1
>> > 
>> > It has a new option: --cache, which needs additional dependencies and some 
>> > modification to the pledge(2) syscalls.
>> > 
>> > Most of our previous patches have been accepted upstream.
>
> Thanks. Your patch didn't apply cleanly, so I regenerated it, see below.
> Apply with 'patch -E'.
>
> Your diff looks good and the port builds fine and all tests pass.
> However, I ran into the following problem with any pdf file:
>
> $ LC_CTYPE=en_US.UTF-8 pdfgrep RFC /tmp/slides.pdf
> terminate called after throwing an instance of 'std::runtime_error'
>   what():  locale::facet::_S_create_c_locale name not valid
> Abort trap (core dumped)
>
> This is new, the old port works fine in the UTF-8 locale.
>
> Unsurprisingly, the problem is the locale call in src/pdfgrep.cc
>
>    434                // Set locale to user-preference. If this locale is an 
> UTF-8 locale, the
>    435                // regex-functions regcomp/regexec become unicode 
> aware, which means
>    436                // e.g. that '.' will match a unicode character, not a 
> single byte.
>    437                locale::global(locale(""));
>
> commenting it out works around the problem. I have no idea what the
> proper fix is.

I don't think a proper fix is possible.  I had suggested a "fix" for
libstdc++v3 in base.

  http://marc.info/?l=openbsd-ports&m=148154492428992&w=2

Maybe silencing this assertion in libestdc++ is the sanest way to deal
with this.  Or you could just comment the call to

  locale::global(locale(""));

Our locale support is limited anyway...

> FWIW here's the backtrace which isn't that useful thanks to the Dwarf
> Error:

egdb should perform better.

> (gdb) bt
> #0  0x0000069bf4e4dd2a in thrkill () at <stdin>:2
> #1  0x0000069bf4e608f9 in *_libc_abort () at 
> /usr/src/lib/libc/stdlib/abort.c:52
> #2  0x0000069bf87feef5 in __gnu_cxx::__verbose_terminate_handler ()
>     at 
> /usr/obj/ports/gcc-4.9.4/gcc-4.9.4/libstdc++-v3/libsupc++/vterminate.cc:95
> Die: DW_TAG_unspecified_type (abbrev = 26, offset = 139365)
>         has children: FALSE
>         attributes:
>                 DW_AT_name (DW_FORM_strp) string: "decltype(nullptr)"
> Dwarf Error: Cannot find type of die [in module 
> /usr/local/lib/libestdc++.so.17.0]
>
> Index: Makefile
> ===================================================================
> RCS file: /var/cvs/ports/textproc/pdfgrep/Makefile,v
> retrieving revision 1.5
> diff -u -p -r1.5 Makefile
> --- Makefile  15 Jan 2016 19:57:24 -0000      1.5
> +++ Makefile  14 Mar 2017 09:37:14 -0000
> @@ -2,7 +2,7 @@
>  
>  COMMENT =            tool to search text in PDF files
>  
> -DISTNAME =           pdfgrep-1.4.1
> +DISTNAME =           pdfgrep-2.0.1
>  
>  CATEGORIES =         textproc
>  
> @@ -18,11 +18,12 @@ MODGCC4_ARCHS =           *
>  MODGCC4_LANGS =              c++
>  
>  # uses pledge()
> -WANTLIB +=           c m pthread poppler-cpp pcre
> +WANTLIB +=           c m pthread poppler-cpp pcre gcrypt gpg-error
>  
>  MASTER_SITES =               https://pdfgrep.org/download/
>  
> -LIB_DEPENDS =                print/poppler
> +LIB_DEPENDS =                print/poppler \
> +                     security/libgcrypt
>  TEST_DEPENDS =               devel/dejagnu \
>                       print/texlive/base
>  
> Index: distinfo
> ===================================================================
> RCS file: /var/cvs/ports/textproc/pdfgrep/distinfo,v
> retrieving revision 1.3
> diff -u -p -r1.3 distinfo
> --- distinfo  15 Jan 2016 19:42:40 -0000      1.3
> +++ distinfo  14 Mar 2017 09:34:21 -0000
> @@ -1,2 +1,2 @@
> -SHA256 (pdfgrep-1.4.1.tar.gz) = 2wSiEOa7e3fNbFSxfw9v7Q0SOoX5elQbJwc2pdOEDyw=
> -SIZE (pdfgrep-1.4.1.tar.gz) = 151926
> +SHA256 (pdfgrep-2.0.1.tar.gz) = A3DXRLMHLUc4Pb7Sy5yLC2S4PAhNpaiWH41Lx2aelB4=
> +SIZE (pdfgrep-2.0.1.tar.gz) = 187217
> Index: patches/patch-src_pdfgrep_cc
> ===================================================================
> RCS file: /var/cvs/ports/textproc/pdfgrep/patches/patch-src_pdfgrep_cc,v
> retrieving revision 1.1
> diff -u -p -r1.1 patch-src_pdfgrep_cc
> --- patches/patch-src_pdfgrep_cc      15 Jan 2016 19:42:40 -0000      1.1
> +++ patches/patch-src_pdfgrep_cc      14 Mar 2017 10:32:18 -0000
> @@ -1,27 +1,40 @@
> -$OpenBSD: patch-src_pdfgrep_cc,v 1.1 2016/01/15 19:42:40 sthen Exp $
> ---- src/pdfgrep.cc.orig      Wed Sep 16 21:06:49 2015
> -+++ src/pdfgrep.cc   Fri Jan 15 11:39:19 2016
> -@@ -569,6 +569,11 @@ void handle_poppler_errors(const std::string &msg, voi
> - 
> +$OpenBSD$
> +--- src/pdfgrep.cc.orig      Sat Mar  4 09:11:53 2017
> ++++ src/pdfgrep.cc   Tue Mar 14 11:32:03 2017
> +@@ -423,6 +423,12 @@ static void handle_poppler_errors(const string &msg, v
>   int main(int argc, char** argv)
>   {
> -+    if (pledge("stdio rpath tty", NULL) == -1) {
> +     Options options;
> ++
> ++    if (pledge("stdio rpath wpath cpath tty", NULL) == -1) {
>  +            fprintf (stderr, "pdfgrep: pledge\n");
>  +            exit (1);
>  +    }
>  +
> -     init_colors();
> +     init_colors(options.outconf.colors);
>   
> -     enum re_engine_type {
> -@@ -773,6 +778,11 @@ int main(int argc, char** argv)
> -     } else if (context == -2) {
> -             // on non-terminals, always print the whole line
> -             context = -1;
> -+    }
> -+
> -+    if (pledge("stdio rpath", NULL) == -1) {
> +     // Set locale to user-preference. If this locale is an UTF-8 locale, the
> +@@ -649,6 +655,11 @@ int main(int argc, char** argv)
> +     bool color_tty = isatty(STDOUT_FILENO) && getenv("TERM") &&
> +             strcmp(getenv("TERM"), "dumb");
> + 
> ++    if (pledge("stdio rpath wpath cpath", NULL) == -1) {
>  +            fprintf (stderr, "pdfgrep: pledge\n");
>  +            exit (1);
> ++    }
> ++
> +     options.outconf.color =
> +             use_colors == COLOR_ALWAYS
> +             || (use_colors == COLOR_AUTO && color_tty);
> +@@ -689,6 +700,11 @@ int main(int argc, char** argv)
> +                     char *limitstr = getenv("PDFGREP_CACHE_LIMIT");
> +                     unsigned int limit = limitstr ? strtoul(limitstr, NULL, 
> 10) : 200;
> +                     limit_cachesize(options.cache_directory.c_str(), limit);
> ++            }
> ++    } else {
> ++            if (pledge("stdio rpath", NULL) == -1) {
> ++                    fprintf (stderr, "pdfgrep: pledge\n");
> ++                    exit (1);
> +             }
>       }
>   
> -     if (excludes_empty(includes))
> Index: patches/patch-src_regengine_cc
> ===================================================================
> RCS file: patches/patch-src_regengine_cc
> diff -N patches/patch-src_regengine_cc
> --- patches/patch-src_regengine_cc    15 Jan 2016 19:42:40 -0000      1.1
> +++ /dev/null 1 Jan 1970 00:00:00 -0000
> @@ -1,16 +0,0 @@
> -$OpenBSD: patch-src_regengine_cc,v 1.1 2016/01/15 19:42:40 sthen Exp $
> -
> -Convert empty expressions into something that regex(3) will accept.
> -
> ---- src/regengine.cc.orig    Fri Jan 15 19:37:30 2016
> -+++ src/regengine.cc Fri Jan 15 19:38:06 2016
> -@@ -34,6 +34,9 @@ PosixRegex::PosixRegex(const char *pattern, bool case_
> - {
> -     int regex_flags = REG_EXTENDED | (case_insensitive ? REG_ICASE : 0);
> - 
> -+    if (strncmp(pattern, "", 2) == 0) {
> -+            pattern = "()";
> -+    }
> -     int err = regcomp(&this->regex, pattern, regex_flags);
> -     if(err) {
> -             char err_msg[256];
> Index: patches/patch-testsuite_Makefile_in
> ===================================================================
> RCS file: patches/patch-testsuite_Makefile_in
> diff -N patches/patch-testsuite_Makefile_in
> --- patches/patch-testsuite_Makefile_in       15 Jan 2016 19:42:40 -0000      
> 1.1
> +++ /dev/null 1 Jan 1970 00:00:00 -0000
> @@ -1,12 +0,0 @@
> -$OpenBSD: patch-testsuite_Makefile_in,v 1.1 2016/01/15 19:42:40 sthen Exp $
> ---- testsuite/Makefile.in.orig       Tue Sep 29 18:18:42 2015
> -+++ testsuite/Makefile.in    Tue Sep 29 18:18:27 2015
> -@@ -643,7 +643,7 @@ uninstall-am:
> - .PRECIOUS: Makefile
> - 
> - 
> --export DEJAGNU
> -+# export DEJAGNU
> - 
> - # Tell versions [3.59,3.63) of GNU make to not export all variables.
> - # Otherwise a system limit (for SysV at least) may be exceeded.
> Index: patches/patch-testsuite_lib_pdfgrep_exp
> ===================================================================
> RCS file: patches/patch-testsuite_lib_pdfgrep_exp
> diff -N patches/patch-testsuite_lib_pdfgrep_exp
> --- patches/patch-testsuite_lib_pdfgrep_exp   15 Jan 2016 19:42:40 -0000      
> 1.1
> +++ /dev/null 1 Jan 1970 00:00:00 -0000
> @@ -1,12 +0,0 @@
> -$OpenBSD: patch-testsuite_lib_pdfgrep_exp,v 1.1 2016/01/15 19:42:40 sthen 
> Exp $
> ---- testsuite/lib/pdfgrep.exp.orig   Wed Jan 13 15:06:57 2016
> -+++ testsuite/lib/pdfgrep.exp        Wed Jan 13 15:12:42 2016
> -@@ -213,7 +213,7 @@ proc reset_configuration {} {
> - 
> - # The directory where the PDFs will be generated.
> - # NOTE This will frequently be removed, so don't put important data there
> --set pdfdir [exec mktemp --tmpdir -d pdfgrep_tests.XXXXXXXXXX]
> -+set pdfdir [exec mktemp -t -d pdfgrep_tests.XXXXXXXXXX]
> - 
> - 
> - # Delete $pdfdir recursively and create it anew
> Index: patches/patch-testsuite_pdfgrep_tests_exit_status_exp
> ===================================================================
> RCS file: patches/patch-testsuite_pdfgrep_tests_exit_status_exp
> diff -N patches/patch-testsuite_pdfgrep_tests_exit_status_exp
> --- patches/patch-testsuite_pdfgrep_tests_exit_status_exp     15 Jan 2016 
> 19:42:40 -0000      1.1
> +++ /dev/null 1 Jan 1970 00:00:00 -0000
> @@ -1,19 +0,0 @@
> -$OpenBSD: patch-testsuite_pdfgrep_tests_exit_status_exp,v 1.1 2016/01/15 
> 19:42:40 sthen Exp $
> ---- testsuite/pdfgrep.tests/exit_status.exp.orig     Wed Jan 13 15:07:29 2016
> -+++ testsuite/pdfgrep.tests/exit_status.exp  Wed Jan 13 15:10:27 2016
> -@@ -8,7 +8,7 @@ clear_pdfdir
> - set pdf [mkpdf exit-status "foobar"]
> - 
> - pdfgrep foobar $pdf
> --
> -+expect eof
> - expect_exit_status 0
> - 
> - ########################################
> -@@ -40,5 +40,5 @@ clear_pdfdir
> - 
> - # $pdf doesn't exist anymore
> - pdfgrep foobar $pdf
> --
> -+expect eof
> - expect_exit_status 2
> Index: patches/patch-testsuite_pdfgrep_tests_usage_exp
> ===================================================================
> RCS file: patches/patch-testsuite_pdfgrep_tests_usage_exp
> diff -N patches/patch-testsuite_pdfgrep_tests_usage_exp
> --- patches/patch-testsuite_pdfgrep_tests_usage_exp   15 Jan 2016 19:42:40 
> -0000      1.1
> +++ /dev/null 1 Jan 1970 00:00:00 -0000
> @@ -1,12 +0,0 @@
> -$OpenBSD: patch-testsuite_pdfgrep_tests_usage_exp,v 1.1 2016/01/15 19:42:40 
> sthen Exp $
> ---- testsuite/pdfgrep.tests/usage.exp.orig   Wed Jan 13 15:07:55 2016
> -+++ testsuite/pdfgrep.tests/usage.exp        Wed Jan 13 15:11:50 2016
> -@@ -5,7 +5,7 @@ expect {
> -     -re "^Usage: .*" { pass $test }
> -     default { fail $test }
> - }
> --
> -+expect eof
> - expect_exit_status 2
> - 
> - # Also look that nothing is written to stdout
>
<#secure method=pgpmime mode=sign>

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply via email to