本文整理汇总了C++中GETC函数的典型用法代码示例。如果您正苦于以下问题:C++ GETC函数的具体用法?C++ GETC怎么用?C++ GETC使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GETC函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: getnum
static int getnum(int *chp, ftnlen *val)
{
register int ch, sign;
register ftnlen x;
while(GETC(ch) <= ' ' && ch >= 0);
if (ch == '-') {
sign = 1;
GETC(ch);
}
else {
sign = 0;
if (ch == '+')
GETC(ch);
}
x = ch - '0';
if (x < 0 || x > 9)
return 115;
while(GETC(ch) >= '0' && ch <= '9')
x = 10*x + ch - '0';
while(ch <= ' ' && ch >= 0)
GETC(ch);
if (ch == EOF)
return EOF;
*val = sign ? -x : x;
*chp = ch;
return 0;
}
开发者ID:barak,项目名称:f2c-1,代码行数:28,代码来源:rsne.c
示例2: getline_alloc
/* lifted from img.c Should be put somewhere common? JPNP*/
static char *
getline_alloc(FILE *fh, size_t ilen)
{
int ch;
size_t i = 0;
size_t len = ilen;
char *buf = xosmalloc(len);
if (!buf) return NULL;
ch = GETC(fh);
while (ch != '\n' && ch != '\r' && ch != EOF) {
buf[i++] = ch;
if (i == len - 1) {
char *p;
len += len;
p = xosrealloc(buf, len);
if (!p) {
osfree(buf);
return NULL;
}
buf = p;
}
ch = GETC(fh);
}
if (ch == '\n' || ch == '\r') {
int otherone = ch ^ ('\n' ^ '\r');
ch = GETC(fh);
/* if it's not the other eol character, put it back */
if (ch != otherone) ungetc(ch, fh);
}
buf[i++] = '\0';
return buf;
}
开发者ID:Cavewhere,项目名称:survex,代码行数:34,代码来源:extend.c
示例3: l_C
int
l_C()
{ int ch;
if(lcount>0) return(0);
ltype=0;
for(GETC(ch);isblnk(ch);GETC(ch));
if(ch==',')
{ lcount=1;
return(0);
}
if(ch=='/')
{ lquit=1;
return(0);
}
if(ch!='(')
{ if(fscanf(cf,"%d",&lcount)!=1) {
if(!feof(cf)) err(elist->cierr,112,"no rep")
else err(elist->cierr,(EOF),"lread");
}
if(GETC(ch)!='*')
{ ungetc(ch,cf);
if(!feof(cf)) err(elist->cierr,112,"no star")
else err(elist->cierr,(EOF),"lread");
}
if(GETC(ch)!='(')
{ ungetc(ch,cf);
return(0);
}
}
开发者ID:Scarletts,项目名称:LiteBSD,代码行数:29,代码来源:lread.c
示例4: l_L
static int
l_L(Void)
{
int ch, rv, sawdot;
if(f__lcount>0)
return(0);
f__lcount = 1;
f__ltype=0;
GETC(ch);
if(isdigit(ch))
{
rd_count(ch);
if(GETC(ch)!='*') {
if(!f__cf || !feof(f__cf)) {
errfl(f__elist->cierr,112,"no star");
}
else {
err(f__elist->cierr,(EOF),"lread");
}
}
GETC(ch);
}
sawdot = 0;
if(ch == '.') {
sawdot = 1;
GETC(ch);
}
switch(ch)
{
case 't':
case 'T':
if (nml_read && Lfinish(ch, sawdot, &rv))
return rv;
f__lx=1;
break;
case 'f':
case 'F':
if (nml_read && Lfinish(ch, sawdot, &rv))
return rv;
f__lx=0;
break;
default:
if(isblnk(ch) || issep(ch) || ch==EOF)
{ (void) Ungetc(ch,f__cf);
return(0);
}
if (nml_read > 1) {
Ungetc(ch,f__cf);
f__lquit = 2;
return 0;
}
errfl(f__elist->cierr,112,"logical");
}
f__ltype=TYLONG;
while(!issep(GETC(ch)) && ch!=EOF);
Ungetc(ch, f__cf);
return(0);
}
开发者ID:cran,项目名称:rioja,代码行数:59,代码来源:lread.c
示例5: getC
/*
* getC to read skipping the comments from the file.
*
* Each comment returns a newline or EOF
*
* Reading strings normal getc is used!
*/
static int getC(tpLspObject pLSP,
FILE *f){
int ch;
if( (ch=GETC(f)) == ';' )
while( (ch=GETC(f)) != '\n' && ch != EOF )
;
return ch;
}
开发者ID:ScriptBasic,项目名称:ScriptBasic,代码行数:16,代码来源:lsp.c
示例6: l_R
int
l_R()
{ double a,b,c,d;
int i,ch,sign=0,da,db,dc;
a=b=c=d=0;
da=db=dc=0;
if(lcount>0) return(0);
ltype=0;
for(GETC(ch);isblnk(ch);GETC(ch));
if(ch==',')
{ lcount=1;
return(0);
}
if(ch=='/')
{ lquit=1;
return(0);
}
ungetc(ch,cf);
da=rd_int(&a);
if(da== -1) sign=da;
if(GETC(ch)!='*')
{ ungetc(ch,cf);
db=1;
b=a;
a=1;
}
else
db=rd_int(&b);
if(GETC(ch)!='.')
{ dc=c=0;
ungetc(ch,cf);
}
else dc=rd_int(&c);
if(isexp(GETC(ch))) db=rd_int(&d);
else
{ ungetc(ch,cf);
d=0;
}
lcount=a;
if(!db && !dc)
return(0);
if(db && b<0)
{ sign=1;
b = -b;
}
for(i=0;i<dc;i++) c/=10;
b=b+c;
for(i=0;i<d;i++) b *= 10;
for(i=0;i< -d;i++) b /= 10;
if(sign) b = -b;
ltype=TYLONG;
lx=b;
return(0);
}
开发者ID:Scarletts,项目名称:LiteBSD,代码行数:54,代码来源:lread.c
示例7: kgdb_recv
/*
* Receive a packet.
*/
static int
kgdb_recv(u_char *bp, int maxlen)
{
u_char *p;
int c, csum;
int len;
do {
p = bp;
csum = len = 0;
while ((c = GETC()) != KGDB_START)
;
while ((c = GETC()) != KGDB_END && len < maxlen) {
c &= 0x7f;
csum += c;
*p++ = c;
len++;
}
csum &= 0xff;
*p = '\0';
if (len >= maxlen) {
PUTC(KGDB_BADP);
continue;
}
csum -= digit2i(GETC()) * 16;
csum -= digit2i(GETC());
if (csum == 0) {
PUTC(KGDB_GOODP);
/* Sequence present? */
if (bp[2] == ':') {
PUTC(bp[0]);
PUTC(bp[1]);
len -= 3;
kgdb_copy(bp + 3, bp, len);
}
break;
}
PUTC(KGDB_BADP);
} while (1);
#ifdef DEBUG_KGDB
printf("kgdb_recv: %s\n", bp);
#endif
return (len);
}
开发者ID:ajinkya93,项目名称:OpenBSD,代码行数:51,代码来源:kgdb_stub.c
示例8: SKIPWS
static ZZJSON *parse_value(ZZJSON_CONFIG *config) {
ZZJSON *retval = NULL;
int c;
SKIPWS();
c = GETC();
UNGETC(c);
switch (c) {
case '"': retval = parse_string2(config); break;
case '0': case '1': case '2': case '3': case '4': case '5':
case '6': case '7': case '8': case '9': case '-':
retval = parse_number(config); break;
case '{': retval = parse_object(config); break;
case '[': retval = parse_array(config); break;
case 't': retval = parse_true(config); break;
case 'f': retval = parse_false(config); break;
case 'n': retval = parse_null(config); break;
}
if (!retval) {
ERROR("value: invalid value");
return retval;
}
return retval;
}
开发者ID:1stMaster,项目名称:syslinux,代码行数:26,代码来源:zzjson_parse.c
示例9: wordcount
void
wordcount(FILE_TYPE file, long *result)
{
int c;
long linec, wordc, charc;
int inword = 0;
linec = wordc = charc = 0;
while ((c = GETC(file)) != EOF) {
charc++;
if (c == '\n')
linec++;
if (isspace(c)) {
if (inword)
inword = 0;
} else {
if (!inword) {
inword = 1;
wordc++;
}
}
}
result[0] = linec;
result[1] = wordc;
result[2] = charc;
}
开发者ID:krichter722,项目名称:gfarm,代码行数:27,代码来源:gfwc.c
示例10: Lfinish
Lfinish(int ch, int dot, int *rvp)
#endif
{
char *s, *se;
static char what[] = "namelist input";
s = nmLbuf + 2;
se = nmLbuf + sizeof(nmLbuf) - 1;
*s++ = ch;
while(!issep(GETC(ch)) && ch!=EOF) {
if (s >= se) {
nmLbuf_ovfl:
return *rvp = err__fl(f__elist->cierr,131,what);
}
*s++ = ch;
if (ch != '=')
continue;
if (dot)
return *rvp = err__fl(f__elist->cierr,112,what);
got_eq:
*s = 0;
nmL_getc_save = l_getc;
l_getc = nmL_getc;
nmL_ungetc_save = l_ungetc;
l_ungetc = nmL_ungetc;
nmLbuf[1] = *(nmL_next = nmLbuf) = ',';
*rvp = f__lcount = 0;
return 1;
}
if (dot)
goto done;
for(;;) {
if (s >= se)
goto nmLbuf_ovfl;
*s++ = ch;
if (!isblnk(ch))
break;
if (GETC(ch) == EOF)
goto done;
}
if (ch == '=')
goto got_eq;
done:
Ungetc(ch, f__cf);
return 0;
}
开发者ID:cran,项目名称:rioja,代码行数:46,代码来源:lread.c
示例11: scanerror
/* scanerror -- called for lexical errors */
static void scanerror(char *s) {
int c;
/* TODO: check previous character? rc's last hack? */
while ((c = GETC()) != '\n' && c != EOF)
;
goterror = TRUE;
yyerror(s);
}
开发者ID:aredridel,项目名称:es-shell,代码行数:9,代码来源:token.c
示例12: rd_int
int
rd_int(double *x)
{ int ch,sign=0,i;
double y;
i=0;
y=0;
if(GETC(ch)=='-') sign = -1;
else if(ch=='+') sign=0;
else ungetc(ch,cf);
while(isdigit(GETC(ch)))
{ i++;
y=10*y+ch-'0';
}
ungetc(ch,cf);
if(sign) y = -y;
*x = y;
return(y!=0?i:sign);
}
开发者ID:Scarletts,项目名称:LiteBSD,代码行数:18,代码来源:lread.c
示例13: getfds
static Boolean getfds(int fd[2], int c, int default0, int default1) {
int n;
fd[0] = default0;
fd[1] = default1;
if (c != '[') {
UNGETC(c);
return TRUE;
}
if ((unsigned int) (n = GETC() - '0') > 9) {
scanerror("expected digit after '['");
return FALSE;
}
while ((unsigned int) (c = GETC() - '0') <= 9)
n = n * 10 + c;
fd[0] = n;
switch (c += '0') {
case '=':
if ((unsigned int) (n = GETC() - '0') > 9) {
if (n != ']' - '0') {
scanerror("expected digit or ']' after '='");
return FALSE;
}
fd[1] = CLOSED;
} else {
while ((unsigned int) (c = GETC() - '0') <= 9)
n = n * 10 + c;
if (c != ']' - '0') {
scanerror("expected ']' after digit");
return FALSE;
}
fd[1] = n;
}
break;
case ']':
break;
default:
scanerror("expected '=' or ']' after digit");
return FALSE;
}
return TRUE;
}
开发者ID:aredridel,项目名称:es-shell,代码行数:44,代码来源:token.c
示例14: getpw
int
getpw(uid_t uid, char buf[])
{
int n, c;
char *bp;
FILE *fp;
rmutex_t *lk;
if (pwf == NULL) {
fp = fopen(PASSWD, "rF");
lmutex_lock(&_pwlock);
if (pwf == NULL) {
if ((pwf = fp) == NULL) {
lmutex_unlock(&_pwlock);
return (1);
}
fp = NULL;
}
lmutex_unlock(&_pwlock);
if (fp != NULL) /* someone beat us to it */
(void) fclose(fp);
}
FLOCKFILE(lk, pwf);
_rewind_unlocked(pwf);
for (;;) {
bp = buf;
while ((c = GETC(pwf)) != '\n') {
if (c == EOF) {
FUNLOCKFILE(lk);
return (1);
}
*bp++ = (char)c;
}
*bp = '\0';
bp = buf;
n = 3;
while (--n)
while ((c = *bp++) != ':')
if (c == '\n') {
FUNLOCKFILE(lk);
return (1);
}
while ((c = *bp++) != ':')
if (isdigit(c))
n = n*10+c-'0';
else
continue;
if (n == uid) {
FUNLOCKFILE(lk);
return (0);
}
}
}
开发者ID:NanXiao,项目名称:illumos-joyent,代码行数:55,代码来源:getpw.c
示例15: getname
static int getname(register char *s, int slen)
{
register char *se = s + slen - 1;
register int ch;
GETC(ch);
if (!(*s++ = Alpha[ch & 0xff])) {
if (ch != EOF)
ch = 115;
errfl(f__elist->cierr, ch, "namelist read");
}
while(*s = Alphanum[GETC(ch) & 0xff])
if (s < se)
s++;
if (ch == EOF)
err(f__elist->cierr, EOF, "namelist read");
if (ch > ' ')
Ungetc(ch,f__cf);
return *s = 0;
}
开发者ID:barak,项目名称:f2c-1,代码行数:20,代码来源:rsne.c
示例16: rd_count
rd_count(register int ch)
#endif
{
if (ch < '0' || ch > '9')
return 1;
f__lcount = ch - '0';
while(GETC(ch) >= '0' && ch <= '9')
f__lcount = 10*f__lcount + ch - '0';
Ungetc(ch,f__cf);
return f__lcount <= 0;
}
开发者ID:cran,项目名称:rioja,代码行数:11,代码来源:lread.c
示例17: fail
static int
fail(int st)
{
int c;
while((c=GETC()) >= 0 && c != '\n')
;
if(c == '\n')
UNGETC(c);
setstate(st);
return Terror;
}
开发者ID:lufia,项目名称:wf,代码行数:12,代码来源:lex.c
示例18: process
void process (struct iop *io) {
while (1) {
int c = GETC (io);
if (c == EOF) break;
usleep (3000);
PUTC (io, c);
FLUSH (io);
}
if (io->fd == -1) {
PUTC (io, '\n');
}
}
开发者ID:apk,项目名称:bases,代码行数:12,代码来源:slocat.c
示例19: skip
static int
skip(char *s)
{
int n, c;
n = 0;
while((c=GETC()) >= 0 && strchr(s, c))
n++;
if(c != Beof)
UNGETC(c);
return n;
}
开发者ID:lufia,项目名称:wf,代码行数:12,代码来源:lex.c
示例20: read_some
int
read_some(char *buf, int n, int start_ch, int copy)
/* if copy is not 0 then copy characters to stdout while scanning
to find start_ch. When you find it, read n characters into buf,
return the number of characters read into buf, but these characters
MUST be free of start_ch.
*/
{ int ch;
int prev = 0;
while (1)
{ ch =GETC(stdin);
if (ch == EOF) return -1;
if (copy) {putc(ch,stdout);
if (prev == '\n' && ch == '{')
{ fprintf(stderr,"Error(at char %d):found \\n{ inside section to copy\n",pos) ;
exit(1);}
prev = ch;
}
AGAIN:
if (ch == start_ch)
{ int i = 0;
while (i < n)
{ ch = GETC(stdin);
if (ch == EOF) return i;
if (copy) {putc(ch,stdout);
if (prev == '\n' && ch == '{')
{ fprintf(stderr,"Error(at char %d):found \\n{ inside section to copy",pos) ;
exit(1);}
prev = ch;
}
if (ch == start_ch) goto AGAIN;
buf[i++] = ch;
}
return i;
}}}
开发者ID:great90,项目名称:gcl,代码行数:38,代码来源:grab_defs.c
注:本文中的GETC函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论