#include <ctype.h>
-#if ( defined BB_GREP || defined BB_FIND || defined BB_SED)
+#if ( defined BB_GREP || defined BB_SED)
/* This also tries to find a needle in a haystack, but uses
* real regular expressions.... The fake regular expression
static char *previous; /* the previous regexp, used when null regexp is given */
+#if defined BB_SED
static char *previous1; /* a copy of the text from the previous substitution for regsub()*/
+#endif
/* These are used to classify or recognize meta-characters */
/* error-handling stuff */
jmp_buf errorhandler;
-#define FAIL(why) fprintf(stderr, why); longjmp(errorhandler, 1)
+#define FAIL(why) do {fprintf(stderr, why); longjmp(errorhandler, 1);} while (0)
if (re->program[1 + 32 * (token - M_CLASS(0)) + (ch >> 3)] & (1 << (ch & 7)))
return 0;
}
- else if (ch == token
- || (ignoreCase==TRUE && isupper(ch) && tolower(ch) == token))
+//fprintf(stderr, "match1: ch='%c' token='%c': ", ch, token);
+ if (ch == token
+ || (ignoreCase==TRUE && tolower(ch) == tolower(token)))
{
+//fprintf(stderr, "match\n");
return 0;
}
+//fprintf(stderr, "no match\n");
return 1;
}
int token;
int peek;
char *build;
- regexp *re;
+ regexp *re; // Ignore compiler whining. If we longjmp, we don't use re anymore.
/* prepare for error handling */