inpgettok.c

来自「支持数字元件仿真的SPICE插件」· C语言 代码 · 共 72 行

C
72
字号
/* * Copyright (c) 1985 Thomas L. Quarles */    /* get input token from 'line',      *  and return a pointer to it in 'token'     */#include "prefix.h"#include <string.h>#include <stdio.h>#include "util.h"#ifndef CMS#include "IFerrmsgs.h"#else  /* CMS */#include "IFerrmsg.h"#endif /* CMS */#include "INPdefs.h"#include "suffix.h"RCSID("INPgetTok.c $Revision: 1.1 $ on $Date: 91/04/02 11:56:50 $")intINPgetTok(line,token,gobble)    char ** line;    char ** token;	int gobble; /* eat non-whitespace trash AFTER token? */{    char * point;    /* scan along throwing away garbage characters */    for(point = *line;*point != '\0' ; point++ ) {        if(*point == ' ') continue;        if(*point == '\t') continue;        if(*point == '=') continue;        if(*point == '(') continue;        if(*point == ')') continue;        if(*point == ',') continue;        break;    }    /* mark beginning of token */    *line = point;    /* now find all good characters */    for(point = *line;*point!='\0';point++) {        if(*point == ' ') break;        if(*point == '\t') break;        if(*point == '=') break;        if(*point == '(') break;        if(*point == ')') break;        if(*point == ',') break;    }    *token=(char *)MALLOC(1+point-*line);    if(!*token) return(E_NOMEM);    (void) strncpy(*token,*line,point-*line);    *(*token + (point-*line)) = '\0';    *line = point;    /* gobble garbage to next token */    for( ;**line != '\0' ; (*line)++ ) {        if(**line == ' ') continue;        if(**line == '\t') continue;        if((**line == '=') && gobble) continue;        if((**line == /* (match */')') && gobble) continue;        if((**line == ',') && gobble) continue;#ifdef notdef    /* This is the wrong thing to do for expression-valued parameters. */        if((**line == '(' /* match) */) && gobble) continue;#endif        break;    }    /*printf("found token (%s) and rest of line (%s)\n",*token,*line);*/    return(OK);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?