** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: pol.cpp,v 1.7 2000/12/27 20:09:19 kevin Exp $
+** $Id: pol.cpp,v 1.8 2000/12/29 15:45:06 kevin Exp $
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
POL::POL()
{
- bp = 0;
currentf = -1;\r
m_bTrace = false;
init();
sys_error (ERR_SEVERE, "files nested too deeply");
return;
}
-
- bp = 0; /* clear any pushed back input */
-
+ \r
+ while (! m_stackPushBackInput.empty())\r
+ m_stackPushBackInput.pop();\r
+
if (source == P_USE_STR) {
filep[currentf] = NULL;
} else if (source == P_USE_FILE) {
int
POL::getch (FILE *fp)
{
- int c;
-
- if (bp > 0)
- return (buf[--bp]);
-
+ int c;\r
+ if (m_stackPushBackInput.size() > 0) {\r
+ c = m_stackPushBackInput.top();\r
+ m_stackPushBackInput.pop();\r
+ return c;\r
+ }\r
+
if (fp == NULL) {
if ((c = inputline[lineptr]) == EOS)
return (EOF);
return (c);
}
-/* push character back on input */
+// push character back on input
void
POL::ungetch (int c)
{
- if (bp > BUFSIZE)
- sys_error (ERR_SEVERE, "too many characters pushed back [ungetch]");
- else
- buf[bp++] = c;
+ m_stackPushBackInput.push (c);\r
}
int
POL::get_inputline (FILE *fp)
{
- lineptr = 0;
- bp = 0;
+ while (! m_stackPushBackInput.empty())\r
+ m_stackPushBackInput.pop();\r
+\r
+ lineptr = 0;\r
if (fgets (inputline, MAXLINE, fp) == NULL)
return (EOF);
else
void
POL::set_inputline (const char* const line)
{
- lineptr = 0;
- bp = 0;
+ while (! m_stackPushBackInput.empty())\r
+ m_stackPushBackInput.pop();\r
+\r
strncpy (inputline, line, MAXLINE);
+ lineptr = 0;\r
}