** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: pol.cpp,v 1.8 2000/12/29 15:45:06 kevin Exp $
+** $Id: pol.cpp,v 1.9 2001/01/02 16:02:13 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
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
******************************************************************************/
-#include "ct.h"\r
+#include "ct.h"
#include <math.h>
#include <stdio.h>
#include <ctype.h>
};
const unsigned int POL::NUMCMD = (sizeof(POL::cmdlist) / sizeof (struct POL::KeywordCodeList));
-\r
+
POL::POL()
{
- currentf = -1;\r
+ currentf = -1;
m_bTrace = false;
init();
}
meta.ter = PERCENT;
meta.inb = LBRACK;
- m_bNewlineIsEOC = true;\r
+ m_bNewlineIsEOC = true;
m_szSkipChars[0] = EOS;
token.ready = false; // no token read yet
}
-\r
+
/* addSkipWord (w)
*
*/
void
POL::addSkipChar (int c)
-{\r
- int n = strlen (m_szSkipChars);\r
- if (n < MAXSKIPCHAR) {\r
- m_szSkipChars[n] = c;\r
- m_szSkipChars[n+1] = 0;\r
+{
+ int n = strlen (m_szSkipChars);
+ if (n < MAXSKIPCHAR) {
+ m_szSkipChars[n] = c;
+ m_szSkipChars[n+1] = 0;
}
}
//
// tok() looks for these user defined tokens. If it finds one,
// it stores the tokens code in the token structure and returns TT_USERTOK
-void\r
+void
POL::addKeyword (const char* const str, int code)
{
usertable.installKeywordCode (str, code);
return (false);
}
-bool\r
+bool
POL::readFloat (double *n, double typecode, bool boundcode, double bb1, double bb2)
{
tok (&token);
return (skipSingleToken (term));
}
-void \r
+void
POL::reader()
{
while (skipTokens())
}
s[i] = EOS;
}
-\r
+
bool
POL::readText (char *str, int lim)
while ((c = inchar()) == BLANK || c == TAB)
;
ungetch (c);
- if (c == EOF) {\r
- str[0] = 0;\r
- return false;\r
- }\r
- \r
+ if (c == EOF) {
+ str[0] = 0;
+ return false;
+ }
+
int i;
for (i = 0; i < lim && (c = inchar()) != EOF && c != NEWLINE; i++)
str[i] = c;
ungetch (c);
- str[i] = 0;\r
- \r
+ str[i] = 0;
+
return true;
}
sys_error (ERR_SEVERE, "files nested too deeply");
return;
}
- \r
- while (! m_stackPushBackInput.empty())\r
- m_stackPushBackInput.pop();\r
+
+ while (! m_stackPushBackInput.empty())
+ m_stackPushBackInput.pop();
if (source == P_USE_STR) {
filep[currentf] = NULL;
int
POL::getch (FILE *fp)
{
- int c;\r
- if (m_stackPushBackInput.size() > 0) {\r
- c = m_stackPushBackInput.top();\r
- m_stackPushBackInput.pop();\r
- return c;\r
- }\r
+ int c;
+ if (m_stackPushBackInput.size() > 0) {
+ c = m_stackPushBackInput.top();
+ m_stackPushBackInput.pop();
+ return c;
+ }
if (fp == NULL) {
if ((c = inputline[lineptr]) == EOS)
void
POL::ungetch (int c)
{
- m_stackPushBackInput.push (c);\r
+ m_stackPushBackInput.push (c);
}
int
POL::get_inputline (FILE *fp)
{
- while (! m_stackPushBackInput.empty())\r
- m_stackPushBackInput.pop();\r
-\r
- lineptr = 0;\r
+ while (! m_stackPushBackInput.empty())
+ m_stackPushBackInput.pop();
+
+ lineptr = 0;
if (fgets (inputline, MAXLINE, fp) == NULL)
return (EOF);
else
void
POL::set_inputline (const char* const line)
{
- while (! m_stackPushBackInput.empty())\r
- m_stackPushBackInput.pop();\r
-\r
+ while (! m_stackPushBackInput.empty())
+ m_stackPushBackInput.pop();
+
strncpy (inputline, line, MAXLINE);
- lineptr = 0;\r
+ lineptr = 0;
}