r318: *** empty log message ***
[ctsim.git] / libctgraphics / pol.cpp
index 1d1a13ab31470cd7bb71fdf560204a3d87cbdfb5..9c0e4278b61b951e7490d9c9e0981eaddcaccfed 100644 (file)
@@ -6,7 +6,7 @@
 **  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
@@ -54,7 +54,6 @@ const unsigned int POL::NUMCMD = (sizeof(POL::cmdlist) / sizeof (struct POL::Key
 
 POL::POL()
 {
-  bp = 0;
   currentf = -1;\r
   m_bTrace = false;
   init();
@@ -832,9 +831,10 @@ POL::usefile (int source, char *fn)
     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) {
@@ -898,11 +898,13 @@ POL::inchar()
 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);
@@ -916,22 +918,21 @@ POL::getch (FILE *fp)
   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
@@ -941,7 +942,9 @@ POL::get_inputline (FILE *fp)
 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
 }