From d631f4025c7d956388a8f990dbf1f5ddc4c22abe Mon Sep 17 00:00:00 2001 From: "Philip.Hazel" Date: Tue, 12 Aug 2014 17:41:11 +0000 Subject: [PATCH] Remove save/load from pcre2test, as they will not be implemented just yet (if at all). --- doc/pcre2test.1 | 95 +-------------- src/pcre2test.c | 272 ++++--------------------------------------- testdata/testinput2 | 2 - testdata/testoutput2 | 6 - 4 files changed, 26 insertions(+), 349 deletions(-) diff --git a/doc/pcre2test.1 b/doc/pcre2test.1 index f50510e..7f7cdc4 100644 --- a/doc/pcre2test.1 +++ b/doc/pcre2test.1 @@ -1,4 +1,4 @@ -.TH PCRE2TEST 1 "07 August 2014" "PCRE 10.00" +.TH PCRE2TEST 1 "12 August 2014" "PCRE 10.00" .SH NAME pcre2test - a program for testing Perl-compatible regular expressions. .SH SYNOPSIS @@ -231,12 +231,6 @@ included in the library. This effect can also be obtained by the use of \fB#pattern\fP; the difference is that \fB#forbid_utf\fP cannot be unset, and the automatic options are not displayed in pattern information, to avoid cluttering up test output. -.sp - #load -.sp -Load a pre-compiled pattern that has been saved in a file. This command must be -followed immediately by any subject lines that are to be matched by the -pattern. .sp #pattern .sp @@ -435,7 +429,6 @@ about the pattern: bsr=[anycrlf|unicode] specify \eR handling /B bincode show binary code without lengths debug same as info,fullbincode - flipbytes flip endianness fullbincode show binary code with lengths /I info show info about compiled pattern hex pattern is coded in hexadecimal @@ -446,7 +439,6 @@ about the pattern: parens_nest_limit= set maximum parentheses depth perlcompat lock out non-Perl modifiers posix use the POSIX API - save= save compiled pattern stackguard= test the stackguard feature tables=[0|1|2] select internal tables use_length use the pattern's length @@ -492,18 +484,6 @@ The \fBinfo\fP modifier requests information about the compiled pattern information is obtained from the \fBpcre2_pattern_info()\fP function. . . -.SS "Changing byte order" -.rs -.sp -The \fBflipbytes\fP modifier causes \fBpcre2test\fP to flip the byte order of -the 2-byte and 4-byte fields in the compiled pattern. This facility is for -testing the feature that allows PCRE2 to use patterns that were compiled on a -host with a different endianness. This feature is not available when the POSIX -interface is being used, that is, when the \fBposix\fP pattern modifier is -specified. See also the section about saving and reloading compiled patterns -below. -. -. .SS "Specifying a pattern in hex" .rs .sp @@ -1139,77 +1119,6 @@ characters. . . . -.SH "SAVING AND RELOADING COMPILED PATTERNS" -.rs -.sp -FIXME FIXME -The facilities described in this section are not available when the POSIX -interface to PCRE is being used, that is, when the \fB/P\fP pattern modifier is -specified. -.P -When the POSIX interface is not in use, you can cause \fBpcre2test\fP to write a -compiled pattern to a file, by following the modifiers with > and a file name. -For example: -.sp - /pattern/im >/some/file -.sp -See the -.\" HREF -\fBpcreprecompile\fP -.\" -documentation for a discussion about saving and re-using compiled patterns. -Note that if the pattern was successfully studied with JIT optimization, the -JIT data cannot be saved. -.P -The data that is written is binary. The first eight bytes are the length of the -compiled pattern data followed by the length of the optional study data, each -written as four bytes in big-endian order (most significant byte first). If -there is no study data (either the pattern was not studied, or studying did not -return any data), the second length is zero. The lengths are followed by an -exact copy of the compiled pattern. If there is additional study data, this -(excluding any JIT data) follows immediately after the compiled pattern. After -writing the file, \fBpcre2test\fP expects to read a new pattern. -.P -A saved pattern can be reloaded into \fBpcre2test\fP by specifying < and a file -name instead of a pattern. There must be no space between < and the file name, -which must not contain a < character, as otherwise \fBpcre2test\fP will -interpret the line as a pattern delimited by < characters. For example: -.sp - re> flags = PCRE_EXTRA_STUDY_DATA; - - psd = (pcre_study_data *)(((char *)extra) + sizeof(pcre_extra)); - extra->study_data = psd; - - if (fread(psd, 1, true_study_size, f) != true_study_size) - { - FAIL_READ: - fprintf(outfile, "Failed to read data from %s\n", p); - if (extra != NULL) - { - PCRE_FREE_STUDY(extra); - } - new_free(re); - fclose(f); - continue; - } - fprintf(outfile, "Study data loaded from %s\n", p); - do_study = 1; /* To get the data output if requested */ - } - else fprintf(outfile, "No study data\n"); - - /* Flip the necessary bytes. */ - if (do_flip) - { - int rc; - PCRE_PATTERN_TO_HOST_BYTE_ORDER(rc, re, extra, NULL); - if (rc == PCRE_ERROR_BADMODE) - { - uint32_t flags_in_host_byte_order; - if (REAL_PCRE_MAGIC(re) == MAGIC_NUMBER) - flags_in_host_byte_order = REAL_PCRE_FLAGS(re); - else - flags_in_host_byte_order = swap_uint32(REAL_PCRE_FLAGS(re)); - /* Simulate the result of the function call below. */ - fprintf(outfile, "Error %d from pcre%s_fullinfo(%d)\n", rc, - test_mode == PCRE32_MODE ? "32" : test_mode == PCRE16_MODE ? "16" : "", - PCRE_INFO_OPTIONS); - fprintf(outfile, "Running in %d-bit mode but pattern was compiled in " - "%d-bit mode\n", test_mode, 8 * (flags_in_host_byte_order & test_mode_MASK)); - new_free(re); - fclose(f); - continue; - } - } - - /* Need to know if UTF-8 for printing data strings. */ - - if (new_info(re, NULL, PCRE_INFO_OPTIONS, &get_options) < 0) - { - new_free(re); - fclose(f); - continue; - } - use_utf = (get_options & PCRE_UTF8) != 0; - - fclose(f); - goto SHOW_INFO; - } - -#endif /* FIXME */ - - } - else { fprintf(outfile, "** Unknown command: %s", buffer); @@ -3619,7 +3464,6 @@ if ((pat_patctl.control & CTL_POSIX) != 0) if (pat_patctl.stackguard_test != 0) prmsg(&msg, "stackguard"); if (timeit > 0) prmsg(&msg, "timing"); if (pat_patctl.jit != 0) prmsg(&msg, "JIT"); - if (pat_patctl.save[0] != 0) prmsg(&msg, "save"); if ((pat_patctl.options & ~POSIX_SUPPORTED_COMPILE_OPTIONS) != 0) { @@ -3779,74 +3623,6 @@ if ((pat_patctl.control & CTL_ANYINFO) != 0) if (rc != PR_OK) return rc; } - -#ifdef FIXME - -/* If the '>' option was present, we write out the regex to a file, and -that is all. The first 8 bytes of the file are the regex length and then -the study length, in big-endian order. */ - -if (to_file != NULL) - { - FILE *f = fopen((char *)to_file, "wb"); - if (f == NULL) - { - fprintf(outfile, "Unable to open %s: %s\n", to_file, strerror(errno)); - } - else - { - uint8_t sbuf[8]; - -/* Extract the size for possible writing before possibly flipping it, -and remember the store that was got. */ - -true_size = REAL_PCRE_SIZE(re); - - if (do_flip) regexflip(re, extra); - sbuf[0] = (uint8_t)((true_size >> 24) & 255); - sbuf[1] = (uint8_t)((true_size >> 16) & 255); - sbuf[2] = (uint8_t)((true_size >> 8) & 255); - sbuf[3] = (uint8_t)((true_size) & 255); - sbuf[4] = (uint8_t)((true_study_size >> 24) & 255); - sbuf[5] = (uint8_t)((true_study_size >> 16) & 255); - sbuf[6] = (uint8_t)((true_study_size >> 8) & 255); - sbuf[7] = (uint8_t)((true_study_size) & 255); - - if (fwrite(sbuf, 1, 8, f) < 8 || - fwrite(re, 1, true_size, f) < true_size) - { - fprintf(outfile, "Write error on %s: %s\n", to_file, strerror(errno)); - } - else - { - fprintf(outfile, "Compiled pattern written to %s\n", to_file); - - /* If there is study data, write it. */ - - if (extra != NULL) - { - if (fwrite(extra->study_data, 1, true_study_size, f) < - true_study_size) - { - fprintf(outfile, "Write error on %s: %s\n", to_file, - strerror(errno)); - } - else fprintf(outfile, "Study data written to %s\n", to_file); - } - } - fclose(f); - } - - new_free(re); - if (extra != NULL) - { - PCRE_FREE_STUDY(extra); - } - continue; /* With next regex */ - } - -#endif /* FIXME */ - return PR_OK; } diff --git a/testdata/testinput2 b/testdata/testinput2 index dde243d..20b198c 100644 --- a/testdata/testinput2 +++ b/testdata/testinput2 @@ -1391,8 +1391,6 @@ "<(\w+)/?>(.)*"Igms \n\n\nPartner der LCO\nde\nPartner der LINEAS Consulting\nGmbH\nLINEAS Consulting GmbH Hamburg\nPartnerfirmen\n30 days\nindex,follow\n\nja\n3\nPartner\n\n\nLCO\nLINEAS Consulting\n15.10.2003\n\n\n\n\nDie Partnerfirmen der LINEAS Consulting\nGmbH\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\=jitstack=1024 -/^a/I,flipbytes - /line\nbreak/I this is a line\nbreak line one\nthis is a line\nbreak in the second line diff --git a/testdata/testoutput2 b/testdata/testoutput2 index 136a33e..497885b 100644 --- a/testdata/testoutput2 +++ b/testdata/testoutput2 @@ -5373,12 +5373,6 @@ Subject length lower bound = 7 2: \x0a 3: seite -/^a/I,flipbytes -Capturing subpattern count = 0 -Compile options: -Overall options: anchored -Subject length lower bound = 1 - /line\nbreak/I Capturing subpattern count = 0 Contains explicit CR or LF match