+/*
+ * A modified version of 'strtok'. This version skips \ sequences.
+ */
+
+char *expect_strtok (s, term)
+char *s, *term;
+ {
+ static char *str = "";
+ static int escape_flag = 0;
+ char *result;
+/*
+ * If a string was specified then do initial processing.
+ */
+ if (s)
+ {
+ str = s;
+ escape_flag = 0;
+ }
+
+ result = (char *) 0;
+ while (*str)
+ {
+/*
+ * Look for the terminator sequence.
+ * If the escape flag is set then this character is not the terminator.
+ * We assume that term does not contain the backslash character.
+ */
+ if (escape_flag || strchr (term, *str) == (char *) 0)
+ {
+ if (result == (char *) 0)
+ {
+ result = str;
+ }
+
+ if (escape_flag || *str == '\\')
+ {
+ escape_flag = !escape_flag;
+ }
+
+ ++str;
+ continue;
+ }
+/*
+ * This is the terminator. If we have a string then this is the end of the
+ * scan operation.
+ */
+ *str++ = '\0';
+ if (result)
+ {
+ break;
+ }
+ }
+ return (result);
+ }
+