X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=test-ls-version.c;h=550f1a48675bc7b04d7286b9b771f809a44ca1db;hb=fcf73607913050d246dbcc4f39e7717d0960763f;hp=8880b5e5b8afdfa137ee9cf2d44aa635d314c3cc;hpb=3df4c0d3e4192cb6bb8e9ed7126346ab6aa98043;p=miniexpect.git diff --git a/test-ls-version.c b/test-ls-version.c index 8880b5e..550f1a4 100644 --- a/test-ls-version.c +++ b/test-ls-version.c @@ -28,7 +28,8 @@ #include #include -#include +#define PCRE2_CODE_UNIT_WIDTH 8 +#include #include "miniexpect.h" #include "tests.h" @@ -38,11 +39,11 @@ main (int argc, char *argv[]) { mexp_h *h; int status, r; - pcre *ls_coreutils_re; - pcre *ls_busybox_re; - const int ovecsize = 12; - int ovector[ovecsize]; - const char *version; + pcre2_code *ls_coreutils_re; + pcre2_code *ls_busybox_re; + pcre2_match_data *match_data = pcre2_match_data_create (4, NULL); + PCRE2_UCHAR *version; + PCRE2_SIZE verlen; ls_coreutils_re = test_compile_re ("^ls.* ([.\\d]+)"); /* Busybox doesn't actually recognize the --version option, but @@ -58,19 +59,18 @@ main (int argc, char *argv[]) { 100, ls_coreutils_re }, { 101, ls_busybox_re }, { 0 }, - }, ovector, ovecsize)) { + }, match_data)) { case 100: case 101: /* Get the matched version number. */ - r = pcre_get_substring (h->buffer, ovector, - mexp_get_pcre_error (h), 1, &version); + r = pcre2_substring_get_bynumber (match_data, 1, &version, &verlen); if (r < 0) { fprintf (stderr, "error: PCRE error reading version substring: %d\n", r); exit (EXIT_FAILURE); } - printf ("ls version = %s\n", version); - pcre_free_substring (version); + printf ("ls version = %s\n", (char *) version); + pcre2_substring_free (version); break; case MEXP_EOF: fprintf (stderr, "error: EOF before matching version string\n"); @@ -94,8 +94,9 @@ main (int argc, char *argv[]) exit (EXIT_FAILURE); } - pcre_free (ls_coreutils_re); - pcre_free (ls_busybox_re); + pcre2_code_free (ls_coreutils_re); + pcre2_code_free (ls_busybox_re); + pcre2_match_data_free (match_data); exit (EXIT_SUCCESS); }