--- ray/src/rt/editline.c 1991/11/12 17:09:16 2.1 +++ ray/src/rt/editline.c 2003/02/25 02:47:22 2.5 @@ -1,15 +1,18 @@ -/* 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.5 2003/02/25 02:47:22 greg Exp $"; #endif - /* * editline.c - routine for editing raw input for rview. * - * 10/5/88 + * External symbols declared in driver.h */ +#include "copyright.h" + +#include "color.h" + +#include "driver.h" + #define iscntrl(c) ((c) < ' ') #define isblank(c) ((c) == ' ') #define iserase(c) ((c) == '\b' || (c) == 127) @@ -17,9 +20,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,20 +68,32 @@ int (*c_get)(), (*s_put)(); } -#include "driver.h" - static char mybuf[512]; -char * -getcombuf(d) /* return buffer for my command */ -struct driver *d; +void +tocombuf(b, d) /* add command(s) to my buffer */ +register char *b; +register struct driver *d; { - d->inpready++; - return(mybuf+strlen(mybuf)); + register char *cp; + char *comstart; + + for (cp = mybuf; *cp; cp++) + ; + 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; @@ -94,7 +111,7 @@ struct driver *d; /* send it as reply */ strcpy(b, mybuf); d->inpready--; - /* get next command */ + /* advance commands */ strcpy(mybuf, cp); return(1); }