Jspice3
inpgtok.c File Reference
#include "spice.h"
#include "inpdefs.h"
#include "iferrmsg.h"
#include "misc.h"
Include dependency graph for inpgtok.c:

Go to the source code of this file.

Macros

#define issep(c)   ((c)==' '||(c)=='\t'||(c)=='='||(c)=='('||(c)==')'||(c)==',')
 

Functions

int INPgetTok (char **line, char **token, int gobble)
 

Macro Definition Documentation

#define issep (   c)    ((c)==' '||(c)=='\t'||(c)=='='||(c)=='('||(c)==')'||(c)==',')

Definition at line 17 of file inpgtok.c.

Function Documentation

int INPgetTok ( char **  line,
char **  token,
int  gobble 
)

Definition at line 20 of file inpgtok.c.

25 {
26  char *point;
27 
28  /* scan along throwing away garbage characters */
29  for (point = *line; *point != '\0'; point++) {
30  if (issep(*point)) continue;
31  break;
32  }
33 
34  /* mark beginning of token */
35  *line = point;
36 
37  /* now find all good characters */
38  for (point = *line; *point != '\0'; point++) {
39  if (issep(*point)) break;
40  }
41  *token = (char *)tmalloc(1 + point - *line);
42  if (!*token)
43  return (E_NOMEM);
44  (void) strncpy(*token,*line,point - *line);
45  *(*token + (point - *line)) = '\0';
46  *line = point;
47 
48  /* gobble garbage to next token */
49  for ( ; **line != '\0'; (*line)++) {
50  if (**line == ' ') continue;
51  if (**line == '\t') continue;
52  if ((**line == '=') && gobble) continue;
53  if ((**line == ',') && gobble) continue;
54  break;
55  }
56  /* printf("found token (%s) and rest of line (%s)\n",*token,*line); */
57  return (OK);
58 }
#define OK
Definition: iferrmsg.h:17
char * tmalloc()
Definition: fteinp.h:14
#define E_NOMEM
Definition: iferrmsg.h:27
#define issep(c)
Definition: inpgtok.c:17