/* xlpeek - peek at a character from a file or stream */ int xlpeek(LVAL fptr) { LVAL lptr, cptr=NULL; int ch; /* check for input from nil */ if (fptr == NIL) ch = EOF; /* otherwise, check for input from a stream */ else if (ustreamp(fptr)) { if ((lptr = gethead(fptr)) == NIL) ch = EOF; else { if (!consp(lptr) || (cptr = car(lptr)) == NIL || !charp(cptr)) xlfail("bad stream"); ch = getchcode(cptr); } } /* otherwise, get the next file character and save it */ else { ch = xlgetc(fptr); setsavech(fptr,ch); } /* return the character */ return (ch); }
/* xcharp - is this a character? */ LVAL xcharp(void) { LVAL arg; arg = xlgetarg(); xllastarg(); return (charp(arg) ? s_true : NIL); }
int atomp(int x){ if(numberp(x) || symbolp(x) || charp(x) || stringp(x) || booleanp(x) || identifierp(x) || IS_SYNCLO(x)) return(1); else return(0); }
/* check an item instance variable */ static LVAL check_item_ivar P2C(int, which, LVAL, value) { int good=0; switch (which) { case 'T': good = (stringp(value) && strlen(getstring(value)) != 0); break; case 'K': good = (charp(value) || value == NIL); break; case 'M': good = (charp(value) || value == NIL || value == s_true); break; case 'S': good = (symbolp(value) || listp(value)); break; case 'A': good = (value == NIL || symbolp(value) || closurep(value) || subrp(value) || (bcclosurep(value))); break; case 'E': good = TRUE; value = (value != NIL) ? s_true : NIL; break; default: xlfail("unknown item instance variable"); } if (! good) xlerror("bad instance variable value", value); return(value); }
/* xlgetc - get a character from a file or stream */ int xlgetc P1C(LVAL, fptr) { LVAL lptr,cptr=NULL; FILEP fp; int ch; /* check for input from nil */ if (fptr == NIL) ch = EOF; /* otherwise, check for input from a stream */ else if (ustreamp(fptr)) { if ((lptr = gethead(fptr)) == NIL) ch = EOF; else { if (!consp(lptr) || (cptr = car(lptr)) == NIL || !charp(cptr)) xlfail("bad stream"); sethead(fptr,lptr = cdr(lptr)); if (lptr == NIL) settail(fptr,NIL); ch = getchcode(cptr); } } /* otherwise, check for a buffered character */ else if ((ch = getsavech(fptr)) != 0) setsavech(fptr,'\0'); /* otherwise, check for terminal input or file input */ else { fp = getfile(fptr); if (fp == CLOSED) /* TAA MOD -- give error */ xlfail("can't read closed stream"); else if (fp == CONSOLE) /* TAA MOD -- revamped for redirecting */ ch = ostgetc(); else { if ((fptr->n_sflags & S_FORREADING) == 0) xlerror("can't read write-only file stream", fptr); if ((fptr->n_sflags & S_READING) == 0) { /* possible direction change*/ if (fptr->n_sflags & S_WRITING) { OSSEEKCUR(fp,0L); } fptr->n_sflags |= S_READING; fptr->n_sflags &= ~S_WRITING; } #ifdef OSAGETC ch = (fptr->n_sflags & S_BINARY) ? OSGETC(fp) : OSAGETC(fp); #else ch = OSGETC(fp); #endif } } /* return the character */ return (ch); }
void main() { FCPartitionDesc dbl("dbl","dbl"); FCPartitionDesc lng("lng","lng"); FCPartitionDesc charp("charp","charp"); FCPartitionDesc date("date","date"); FCPartitionDesc dblx("dblx","dblx"); FCPartitionDesc lngx("lngx","lngx"); FCPartitionDesc charpx("charpx","charpx"); FCPartitionDesc datex("datex","datex"); PDFriend::MakeADouble(dbl); PDFriend::MakeACharPtr(charp); PDFriend::MakeALong(lng); PDFriend::MakeAColDate(date); // test copy constructor.. FCPartitionDesc dbl2(dbl); FCPartitionDesc lng2(lng); FCPartitionDesc charp2(charp); FCPartitionDesc date2(date); dblx = dbl; lngx = lng; charpx = charp; datex = date; cout << "dbl----" << endl << dbl ; cout << "lng----" << endl << lng ; cout << "charp--" << endl << charp ; cout << "date---" << endl << date << endl; cout << "dbl2----" << endl << dbl2 ; cout << "lng2----" << endl << lng2 ; cout << "charp2--" << endl << charp2 ; cout << "date2---" << endl << date2 << endl; cout << "dblx----" << endl << dblx ; cout << "lngx----" << endl << lngx ; cout << "charpx--" << endl << charpx ; cout << "date2x--" << endl << datex << endl; cout << dbl.GetDouble() << endl; cout << charp.GetCharPtr() << endl; cout << lng.GetLong() << endl; cout << date.GetColDate().nMonth << "/" << date.GetColDate().nDay << "/" << date.GetColDate().nYear << endl; }
/* xlgetc - get a character from a file or stream */ int xlgetc(LVAL fptr) { LVAL lptr, cptr=NULL; FILE *fp; int ch; /* check for input from nil */ if (fptr == NIL) ch = EOF; /* otherwise, check for input from a stream */ else if (ustreamp(fptr)) { if ((lptr = gethead(fptr)) == NIL) ch = EOF; else { if (!consp(lptr) || (cptr = car(lptr)) == NIL || !charp(cptr)) xlfail("bad stream"); sethead(fptr,lptr = cdr(lptr)); if (lptr == NIL) settail(fptr,NIL); ch = getchcode(cptr); } } /* otherwise, check for a buffered character */ else if ((ch = getsavech(fptr))) setsavech(fptr,'\0'); /* otherwise, check for terminal input or file input */ else { fp = getfile(fptr); if (fp == stdin || fp == STDERR) ch = ostgetc(); else ch = osagetc(fp); #ifdef DEBUG_INPUT if (read_by_xlisp && ch != -1) { putc(ch, read_by_xlisp); } #endif } /* return the character */ return (ch); }