pcre2grep: remove JFRIEDL_DEBUG obsoleted code (#49)
Still uses the already obsoleted PCRE1 API
Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
diff --git a/src/pcre2grep.c b/src/pcre2grep.c
index 72ab2cc..2335d0d 100644
--- a/src/pcre2grep.c
+++ b/src/pcre2grep.c
@@ -208,14 +208,6 @@
/* Jeffrey Friedl has some debugging requirements that are not part of the
regular code. */
-#ifdef JFRIEDL_DEBUG
-static int S_arg = -1;
-static unsigned int jfriedl_XR = 0; /* repeat regex attempt this many times */
-static unsigned int jfriedl_XT = 0; /* replicate text this many times */
-static const char *jfriedl_prefix = "";
-static const char *jfriedl_postfix = "";
-#endif
-
static const char *colour_string = "1;31";
static const char *colour_option = NULL;
static const char *dee_option = NULL;
@@ -481,9 +473,6 @@
{ OP_PATLIST, N_INCLUDE_DIR,&include_dir_patdata, "include-dir=pattern","include matching directories when recursing" },
{ OP_FILELIST, N_EXCLUDE_FROM,&exclude_from_data, "exclude-from=path", "read exclude list from file" },
{ OP_FILELIST, N_INCLUDE_FROM,&include_from_data, "include-from=path", "read include list from file" },
-#ifdef JFRIEDL_DEBUG
- { OP_OP_NUMBER, 'S', &S_arg, "jeffS", "replace matched (sub)string with X" },
-#endif
{ OP_NODATA, 's', NULL, "no-messages", "suppress error messages" },
{ OP_NODATA, 't', NULL, "total-count", "print total count of matching lines" },
{ OP_NODATA, 'u', NULL, "utf", "use UTF mode" },
@@ -2680,56 +2669,6 @@
}
}
- /* Extra processing for Jeffrey Friedl's debugging. */
-
-#ifdef JFRIEDL_DEBUG
- if (jfriedl_XT || jfriedl_XR)
- {
-# include <sys/time.h>
-# include <time.h>
- struct timeval start_time, end_time;
- struct timezone dummy;
- int i;
-
- if (jfriedl_XT)
- {
- unsigned long newlen = length * jfriedl_XT + strlen(jfriedl_prefix) + strlen(jfriedl_postfix);
- const char *orig = ptr;
- ptr = malloc(newlen + 1);
- if (!ptr) {
- printf("out of memory");
- pcre2grep_exit(2);
- }
- endptr = ptr;
- strcpy(endptr, jfriedl_prefix); endptr += strlen(jfriedl_prefix);
- for (i = 0; i < jfriedl_XT; i++) {
- strncpy(endptr, orig, length);
- endptr += length;
- }
- strcpy(endptr, jfriedl_postfix); endptr += strlen(jfriedl_postfix);
- length = newlen;
- }
-
- if (gettimeofday(&start_time, &dummy) != 0)
- perror("bad gettimeofday");
-
-
- for (i = 0; i < jfriedl_XR; i++)
- match = (pcre_exec(patterns->compiled, patterns->hint, ptr, length, 0,
- PCRE2_NOTEMPTY, offsets, offset_size) >= 0);
-
- if (gettimeofday(&end_time, &dummy) != 0)
- perror("bad gettimeofday");
-
- double delta = ((end_time.tv_sec + (end_time.tv_usec / 1000000.0))
- -
- (start_time.tv_sec + (start_time.tv_usec / 1000000.0)));
-
- printf("%s TIMER[%.4f]\n", match ? "MATCH" : "FAIL", delta);
- return 0;
- }
-#endif
-
/* We come back here after a match when only_matching_count is non-zero, in
order to find any further matches in the same line. This applies to
--only-matching, --file-offsets, and --line-offsets. */
@@ -2984,22 +2923,6 @@
if (printname != NULL) fprintf(stdout, "%s:", printname);
if (number) fprintf(stdout, "%lu:", linenumber);
- /* This extra option, for Jeffrey Friedl's debugging requirements,
- replaces the matched string, or a specific captured string if it exists,
- with X. When this happens, colouring is ignored. */
-
-#ifdef JFRIEDL_DEBUG
- if (S_arg >= 0 && S_arg < mrc)
- {
- int first = S_arg * 2;
- int last = first + 1;
- FWRITE_IGNORE(ptr, 1, offsets[first], stdout);
- fprintf(stdout, "X");
- FWRITE_IGNORE(ptr + offsets[last], 1, linelength - offsets[last], stdout);
- }
- else
-#endif
-
/* In multiline mode, or if colouring, we have to split the line(s) up
and search for further matches, but not of course if the line is a
non-match. In multiline mode this is necessary in case there is another
@@ -3974,29 +3897,6 @@
}
}
- /* Jeffrey Friedl's debugging harness uses these additional options which
- are not in the right form for putting in the option table because they use
- only one hyphen, yet are more than one character long. By putting them
- separately here, they will not get displayed as part of the help() output,
- but I don't think Jeffrey will care about that. */
-
-#ifdef JFRIEDL_DEBUG
- else if (strcmp(argv[i], "-pre") == 0) {
- jfriedl_prefix = argv[++i];
- continue;
- } else if (strcmp(argv[i], "-post") == 0) {
- jfriedl_postfix = argv[++i];
- continue;
- } else if (strcmp(argv[i], "-XT") == 0) {
- sscanf(argv[++i], "%d", &jfriedl_XT);
- continue;
- } else if (strcmp(argv[i], "-XR") == 0) {
- sscanf(argv[++i], "%d", &jfriedl_XR);
- continue;
- }
-#endif
-
-
/* One-char options; many that have no data may be in a single argument; we
continue till we hit the last one or one that needs data. */
@@ -4059,7 +3959,7 @@
/* If the option type is OP_OP_STRING or OP_OP_NUMBER(S), it's an option that
either has a value or defaults to something. It cannot have data in a
separate item. At the moment, the only such options are "colo(u)r",
- "only-matching", and Jeffrey Friedl's special -S debugging option. */
+ and "only-matching". */
if (*option_data == 0 &&
(op->type == OP_OP_STRING || op->type == OP_OP_NUMBER ||
@@ -4075,12 +3975,6 @@
only_matching_last = add_number(0, only_matching_last);
if (only_matching == NULL) only_matching = only_matching_last;
break;
-
-#ifdef JFRIEDL_DEBUG
- case 'S':
- S_arg = 0;
- break;
-#endif
}
continue;
}
@@ -4361,19 +4255,6 @@
/* Check the values for Jeffrey Friedl's debugging options. */
-#ifdef JFRIEDL_DEBUG
-if (S_arg > 9)
- {
- fprintf(stderr, "pcre2grep: bad value for -S option\n");
- return 2;
- }
-if (jfriedl_XT != 0 || jfriedl_XR != 0)
- {
- if (jfriedl_XT == 0) jfriedl_XT = 1;
- if (jfriedl_XR == 0) jfriedl_XR = 1;
- }
-#endif
-
/* If use_jit is set, check whether JIT is available. If not, do not try
to use JIT. */