--- ray/src/rt/editline.c 1994/10/26 10:04:12 2.2 +++ ray/src/rt/editline.c 2003/07/27 22:12:03 2.7 @@ -1,15 +1,20 @@ -/* Copyright (c) 1987 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: editline.c,v 2.7 2003/07/27 22:12:03 schorsch Exp $"; #endif - /* * editline.c - routine for editing raw input for rview. * - * 10/5/88 + * External symbols declared in driver.h */ +#include "copyright.h" + +#include + +#include "color.h" + +#include "driver.h" + #define iscntrl(c) ((c) < ' ') #define isblank(c) ((c) == ' ') #define iserase(c) ((c) == '\b' || (c) == 127) @@ -17,9 +22,11 @@ static char SCCSid[] = "$SunId$ LBL"; #define iskill(c) ((c) == 'U'-'@' || (c) == 'X'-'@') +void editline(buf, c_get, s_put) /* edit input line */ char *buf; -int (*c_get)(), (*s_put)(); +int (*c_get)(); +void (*s_put)(); { static char erases[] = "\b \b"; static char obuf[4]; @@ -63,25 +70,32 @@ int (*c_get)(), (*s_put)(); } -#include "driver.h" - static char mybuf[512]; +void tocombuf(b, d) /* add command(s) to my buffer */ register char *b; register struct driver *d; { register char *cp; + char *comstart; for (cp = mybuf; *cp; cp++) ; - while (*cp++ = *b) - if (*b++ == '\n') + comstart = cp; + while ( (*cp++ = *b) ) + if (cp >= mybuf+sizeof(mybuf)) { + *comstart = '\0'; + return; /* what should I do about this? */ + } else if (*b++ == '\n') { d->inpready++; + comstart = cp; + } } +int fromcombuf(b, d) /* get command from my buffer */ char *b; struct driver *d; @@ -99,7 +113,7 @@ struct driver *d; /* send it as reply */ strcpy(b, mybuf); d->inpready--; - /* get next command */ + /* advance commands */ strcpy(mybuf, cp); return(1); }