+ * Parses a regexp literal from the given buffer.
+ *
+ * Returns a negative value on error, otherwise the amount of consumed
+ * characters from the given buffer.
+ *
+ * Error values:
+ * -1 Unterminated regexp
+ * -2 Invalid escape sequence
+ * -3 Regexp literal too long
+ */
+
+static int
+parse_regexp(const char *buf, struct jp_opcode *op, struct jp_state *s)
+{
+ int len = parse_string(buf, op, s);
+ const char *p;
+
+ if (len >= 2)
+ {
+ op->num = REG_NOSUB | REG_NEWLINE;
+
+ for (p = buf + len; p; p++)
+ {
+ switch (*p)
+ {
+ case 'e':
+ op->num |= REG_EXTENDED;
+ len++;
+ break;
+
+ case 'i':
+ op->num |= REG_ICASE;
+ len++;
+ break;
+
+ case 's':
+ op->num &= ~REG_NEWLINE;
+ len++;
+ break;
+
+ default:
+ return len;
+ }
+ }
+
+ }
+
+ return len;
+}
+
+
+/*