INode * REParser::parseCharSequence(std::string::const_iterator & c, const std::string::const_iterator & end) { FinalSequence * ret = 0; if (*c == '^') { ++c; if (c != end && *c == ']') throw std::string("Empty character sequence []"); ret = new FinalNotSequence; } else ret = new FinalOrSequence; while (c != end && *c != ']') { if (*c == '[') { ++c; if (c != end && *c == ':') { ++c; addClassToSequence(c, end, ret); continue ; } else --c; } char rStart = getAChar(c, end); if (*c == '.') { ++c; if (c != end && *c == '.') { ++c; if (c == end) throw std::string("Incomplete character range"); char rEnd = getAChar(c, end); if (rStart >= rEnd) throw std::string("Incorrect character range"); ret->addRange(rStart, rEnd); continue ; } else --c; } ret->addChar(rStart); } if (c == end) throw std::string("Incomplete character sequence"); return ret; }
INode * REParser::getAFinal(std::string::const_iterator & c, const std::string::const_iterator & end) { if (*c == '.') { ++c; return new FinalAny; } return new FinalChar(getAChar(c, end)); }
int gettoken(void) { while ((tval = getAChar()) == REDRAWTOKEN) { redraw(); } if (isdigit(tval)) return (NUMTOKEN); else if (isalpha(tval)) return (ALPHATOKEN); else return (tval); }
gettoken() { while ((tval = getAChar()) == REDRAWTOKEN || tval == SHELLTOKEN) { if (tval == SHELLTOKEN) { #ifdef BSD struct itimerval itv; itv.it_value.tv_sec = 0; itv.it_value.tv_usec = 0; setitimer(ITIMER_REAL, &itv, NULL); #endif #ifdef SYSV int aval; aval = alarm(0); #endif if (fork() == 0) /* child */ { char *shell, *base, *getenv(), *strrchr(); setuid(getuid()); /* turn off setuid bit */ done_screen(); /* run user's favorite shell */ if ((shell = getenv("SHELL")) != NULL) { base = strrchr(shell, '/'); if (base == NULL) base = shell; else base++; execl(shell, base, 0); } else execl(_PATH_BSHELL, "sh", 0); exit(0); /* oops */ } wait(0); #ifdef BSD ioctl(fileno(stdin), TIOCSETP, &tty_new); itv.it_value.tv_sec = 0; itv.it_value.tv_usec = 1; itv.it_interval.tv_sec = sp->update_secs; itv.it_interval.tv_usec = 0; setitimer(ITIMER_REAL, &itv, NULL); #endif #ifdef SYSV ioctl(fileno(stdin), TCSETAW, &tty_new); alarm(aval); #endif } redraw(); } if (isdigit(tval)) return (NUMTOKEN); else if (isalpha(tval)) return (ALPHATOKEN); else return (tval); }