ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/editline.c
(Generate patch)

Comparing ray/src/rt/editline.c (file contents):
Revision 1.4 by greg, Fri Feb 9 09:14:47 1990 UTC vs.
Revision 2.8 by schorsch, Tue Mar 30 16:13:01 2004 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1987 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   *  editline.c - routine for editing raw input for rview.
6   *
7 < *      10/5/88
7 > *  External symbols declared in driver.h
8   */
9  
10 + #include "copyright.h"
11 +
12 + #include <stdio.h>
13 + #include <string.h>
14 +
15 + #include "color.h"
16 +
17 + #include "driver.h"
18 +
19   #define iscntrl(c)      ((c) < ' ')
20   #define isblank(c)      ((c) == ' ')
21   #define iserase(c)      ((c) == '\b' || (c) == 127)
# Line 17 | Line 23 | static char SCCSid[] = "$SunId$ LBL";
23   #define iskill(c)       ((c) == 'U'-'@' || (c) == 'X'-'@')
24  
25  
26 < editline(buf, c_get, s_put)     /* edit input line */
27 < char  *buf;
28 < int  (*c_get)(), (*s_put)();
26 > extern void
27 > editline(       /* edit input line */
28 >        char  *buf,
29 >        dr_getchf_t *c_get,
30 >        dr_comoutf_t *s_put
31 > )
32   {
33          static char  erases[] = "\b \b";
34          static char  obuf[4];
# Line 63 | Line 72 | int  (*c_get)(), (*s_put)();
72   }
73  
74  
66 #include  "driver.h"
67
75   static char  mybuf[512];
76  
77  
78 < char *
79 < getcombuf(d)                            /* return buffer for my command */
80 < struct driver  *d;
78 > void
79 > tocombuf(b, d)                          /* add command(s) to my buffer */
80 > register char  *b;
81 > register struct driver  *d;
82   {
83 <        d->inpready++;
84 <        return(mybuf+strlen(mybuf));
83 >        register char  *cp;
84 >        char  *comstart;
85 >
86 >        for (cp = mybuf; *cp; cp++)
87 >                ;
88 >        comstart = cp;
89 >        while ( (*cp++ = *b) )
90 >                if (cp >= mybuf+sizeof(mybuf)) {
91 >                        *comstart = '\0';
92 >                        return;         /* what should I do about this? */
93 >                } else if (*b++ == '\n') {
94 >                        d->inpready++;
95 >                        comstart = cp;
96 >                }
97   }
98  
99  
100 + int
101   fromcombuf(b, d)                        /* get command from my buffer */
102   char  *b;
103   struct driver  *d;
# Line 94 | Line 115 | struct driver  *d;
115                                                  /* send it as reply */
116          strcpy(b, mybuf);
117          d->inpready--;
118 <                                                /* get next command */
118 >                                                /* advance commands */
119          strcpy(mybuf, cp);
120          return(1);
121   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines