int _fcmbget(short *len) { static struct Extra extra; register int i, c, n; if(_Fcin.fcleft) { if((c = mbsize(extra.next)) < 0) c = 1; if((_Fcin.fcleft -= c) <=0) { _Fcin.fcptr = (unsigned char*)fcfirst() - _Fcin.fcleft; _Fcin.fcleft = 0; } *len = c; if(c==1) c = *extra.next++; else if(c==0) _Fcin.fcleft = 0; else c = mbchar(extra.next); return(c); } switch(*len = mbsize(_Fcin.fcptr)) { case -1: if(_Fcin._fcfile && (n=(_Fcin.fclast-_Fcin.fcptr)) < MB_LEN_MAX) { memcpy(extra.buff, _Fcin.fcptr, n); _Fcin.fcptr = _Fcin.fclast; for(i=n; i < MB_LEN_MAX+n; i++) { if((extra.buff[i] = fcgetc(c))==0) break; } _Fcin.fcleft = n; extra.next = extra.buff; return(fcmbget(len)); } *len = 1; /* fall through */ case 0: case 1: c=fcget(); break; default: c = mbchar(_Fcin.fcptr); } return(c); }
int _fcmbget(short *len) { int c; *len = mblen((char *)_Fcin.fcptr, MB_CUR_MAX); switch (*len) { case -1: { *len = 1; } // FALLTHRU case 0: case 1: { c = fcget(); break; } default: { c = mb1char((char **)&_Fcin.fcptr); } } return c; }
// // This was originally implemented as a macro: // #define fcgetc(c) (((c = fcget()) || (c = fcfill())), c) // // However, that is an ugly API that causes lots of lint warnings. // int fcgetc() { int c = fcget(); if (!c) c = fcfill(); return c; }