#ifdef HAVE_REGEX_H
#include <regex.h>
#endif
-#ifdef HAVE_REGEXP_H
-#include <regexp.h>
-#endif
-#ifdef HAVE_RX_H
-#include <rx.h>
-#endif
#include "config.h"
static bool ErrorMessage =
false; /* Set to true if an error message has been displayed */
-#ifndef NO_REGEX
+#ifdef POSIX_REGEX
+#define WITH_REGEX
+#define RE_COMP(p) regcomp(&Re_pat, (p), REG_NOSUB)
+#define BAD_COMP(f) ((f) != 0)
+#define RE_EXEC(p) (regexec(&Re_pat, (p), 0, NULL, 0) == 0)
+
+static regex_t Re_pat;
+#else
+#define NO_REGEX
+#endif /* POSIX_REGEX */
+
+#ifdef WITH_REGEX
static bool Match = false; /* dump fortunes matching a pattern */
#endif
static STRFILE Noprob_tbl; /* sum of data for all no prob files */
-#ifdef POSIX_REGEX
-#define RE_COMP(p) regcomp(&Re_pat, (p), REG_NOSUB)
-#define BAD_COMP(f) ((f) != 0)
-#define RE_EXEC(p) (regexec(&Re_pat, (p), 0, NULL, 0) == 0)
-
-static regex_t Re_pat;
-#else
-#define NO_REGEX
-#endif /* POSIX_REGEX */
-
#ifdef WITH_RECODE
static RECODE_REQUEST request;
static RECODE_OUTER outer;
(void)fprintf(stderr, "%s", "D");
#endif /* DEBUG */
(void)fprintf(stderr, "%s", "f");
-#ifndef NO_REGEX
+#ifdef WITH_REGEX
(void)fprintf(stderr, "%s", "i");
-#endif /* NO_REGEX */
+#endif
(void)fprintf(stderr, "%s", "l");
#ifndef NO_OFFENSIVE
(void)fprintf(stderr, "%s", "o");
#endif
(void)fprintf(stderr, "%s", "sw]");
-#ifndef NO_REGEX
+#ifdef WITH_REGEX
(void)fprintf(stderr, "%s", " [-m pattern]");
-#endif /* NO_REGEX */
+#endif
(void)fprintf(stderr, "%s", " [-n number] [ [#%] file/directory/all]\n");
exit(1);
}
}
}
-#ifndef NO_REGEX
+#ifdef WITH_REGEX
/*
* conv_pat:
* Convert the pattern to an ignore-case equivalent.
*sp = '\0';
return new_buf;
}
-#endif /* NO_REGEX */
+#endif
/*
* do_malloc:
{
bool ignore_case = false;
-#ifndef NO_REGEX
+#ifdef WITH_REGEX
char *pat = NULL;
+#endif
-#endif /* NO_REGEX */
int ch;
#ifdef DEBUG
/* if (Debug >= 1)
* print_list(File_list, 0); */
#endif /* DEBUG */
+
/* If (Find_files) print_list() moved to main */
-#ifndef NO_REGEX
+#ifdef WITH_REGEX
if (pat)
{
if (ignore_case)
free(pat);
}
}
-#endif /* NO_REGEX */
+#endif
}
/*
}
}
-#ifndef NO_REGEX
+#ifdef WITH_REGEX
/*
* maxlen_in_list
* Return the maximum fortune len in the file list.
return Found_one;
/* NOTREACHED */
}
-#endif /* NO_REGEX */
+#endif
static void display(FILEDESC *fp)
{
free(crequest);
#endif
-#ifndef NO_REGEX
+#ifdef WITH_REGEX
if (Match)
{
exit_code = (find_matches() != 0);
goto cleanup;
}
#endif
+
init_prob();
if (Find_files)
{