From a5a7ead5d24805eb5cc9ba9e81acc41c2971fda4 Mon Sep 17 00:00:00 2001
From: erg <devnull@localhost>
Date: Fri, 8 Apr 2005 20:45:33 +0000
Subject: [PATCH] Update with new lefty, fixing many bugs and supporting new
 features

---
 cmd/lefty/code.c     | 50 ++++++++++-------------
 cmd/lefty/code.h     | 94 +++++++++++++++++++++++++++++---------------
 cmd/lefty/colors.txt |  1 +
 3 files changed, 85 insertions(+), 60 deletions(-)

diff --git a/cmd/lefty/code.c b/cmd/lefty/code.c
index f083bf48b..0e92b87ba 100644
--- a/cmd/lefty/code.c
+++ b/cmd/lefty/code.c
@@ -14,8 +14,7 @@
 *              AT&T Research, Florham Park NJ             *
 **********************************************************/
 
-
-/* Lefteris Koutsofios - AT&T Bell Laboratories */
+/* Lefteris Koutsofios - AT&T Labs Research */
 
 #include "common.h"
 #include "code.h"
@@ -28,36 +27,32 @@ int cbufn, cbufi;
 
 static int Cstringoffset;
 
-void Cinit(void)
-{
+void Cinit (void) {
     Code_t c;
 
-    cbufp = Marrayalloc((long) CBUFINCR * CBUFSIZE);
+    cbufp = Marrayalloc ((long) CBUFINCR * CBUFSIZE);
     cbufn = CBUFINCR;
     cbufi = 0;
     Cstringoffset = (char *) &c.u.s[0] - (char *) &c + 1;
     /* the + 1 above accounts for the null character */
 }
 
-void Cterm(void)
-{
-    Marrayfree(cbufp);
+void Cterm (void) {
+    Marrayfree (cbufp);
     cbufp = NULL;
     cbufn = cbufi = 0;
 }
 
-void Creset(void)
-{
+void Creset (void) {
     cbufi = 0;
 }
 
-int Cnew(Ctype_t ctype)
-{
+int Cnew (int ctype) {
     int i;
 
     if (cbufi >= cbufn) {
-	cbufp = Marraygrow(cbufp, (long) (cbufn + CBUFINCR) * CBUFSIZE);
-	cbufn += CBUFINCR;
+        cbufp = Marraygrow (cbufp, (long) (cbufn + CBUFINCR) * CBUFSIZE);
+        cbufn += CBUFINCR;
     }
     i = cbufi++;
     cbufp[i].ctype = ctype;
@@ -65,13 +60,12 @@ int Cnew(Ctype_t ctype)
     return i;
 }
 
-int Cinteger(long i)
-{
+int Cinteger (long i) {
     int j;
 
     if (cbufi >= cbufn) {
-	cbufp = Marraygrow(cbufp, (long) (cbufn + CBUFINCR) * CBUFSIZE);
-	cbufn += CBUFINCR;
+        cbufp = Marraygrow (cbufp, (long) (cbufn + CBUFINCR) * CBUFSIZE);
+        cbufn += CBUFINCR;
     }
     j = cbufi++;
     cbufp[j].ctype = C_INTEGER;
@@ -80,13 +74,12 @@ int Cinteger(long i)
     return j;
 }
 
-int Creal(double d)
-{
+int Creal (double d) {
     int i;
 
     if (cbufi >= cbufn) {
-	cbufp = Marraygrow(cbufp, (long) (cbufn + CBUFINCR) * CBUFSIZE);
-	cbufn += CBUFINCR;
+        cbufp = Marraygrow (cbufp, (long) (cbufn + CBUFINCR) * CBUFSIZE);
+        cbufn += CBUFINCR;
     }
     i = cbufi++;
     cbufp[i].ctype = C_REAL;
@@ -95,19 +88,18 @@ int Creal(double d)
     return i;
 }
 
-int Cstring(char *s)
-{
+int Cstring (char *s) {
     int i, size, incr;
 
-    size = (strlen(s) + Cstringoffset + CBUFSIZE - 1) / CBUFSIZE;
+    size = (strlen (s) + Cstringoffset + CBUFSIZE - 1) / CBUFSIZE;
     if (cbufi + size > cbufn) {
-	incr = size > CBUFINCR ? size : CBUFINCR;
-	cbufp = Marraygrow(cbufp, (long) (cbufn + incr) * CBUFSIZE);
-	cbufn += incr;
+        incr = size > CBUFINCR ? size : CBUFINCR;
+        cbufp = Marraygrow (cbufp, (long) (cbufn + incr) * CBUFSIZE);
+        cbufn += incr;
     }
     i = cbufi, cbufi += size;
     cbufp[i].ctype = C_STRING;
-    strcpy((char *) &cbufp[i].u.s[0], s);
+    strcpy ((char *) &cbufp[i].u.s[0], s);
     cbufp[i].next = C_NULL;
     return i;
 }
diff --git a/cmd/lefty/code.h b/cmd/lefty/code.h
index a3d473519..90341511b 100644
--- a/cmd/lefty/code.h
+++ b/cmd/lefty/code.h
@@ -18,8 +18,7 @@
 extern "C" {
 #endif
 
-
-/* Lefteris Koutsofios - AT&T Bell Laboratories */
+/* Lefteris Koutsofios - AT&T Labs Research */
 
 #ifndef _CODE_H
 #define _CODE_H
@@ -27,26 +26,58 @@ extern "C" {
 
 #define C_ISSTMT(ct) (ct >= C_STMT && ct <= C_RETURN)
 
-    typedef enum {
-	C_CODE, C_ASSIGN, C_INTEGER, C_REAL, C_STRING, C_OR, C_AND,
-	C_EQ, C_NE, C_LT, C_LE, C_GT, C_GE, C_PLUS, C_MINUS, C_MUL,
-	C_DIV, C_MOD, C_UMINUS, C_NOT, C_PEXPR, C_FCALL, C_GVAR, C_LVAR,
-	C_PVAR, C_FUNCTION, C_TCONS, C_DECL, C_STMT, C_IF, C_WHILE,
-	C_FOR, C_FORIN, C_BREAK, C_CONTINUE, C_RETURN, C_INTERNAL,
-	C_ARGS, C_NOP, C_SIZE
-    } Ctype_t;
+#define C_CODE      0
+#define C_ASSIGN    1
+#define C_INTEGER   2
+#define C_REAL      3
+#define C_STRING    4
+#define C_OR        5
+#define C_AND       6
+#define C_EQ        7
+#define C_NE        8
+#define C_LT        9
+#define C_LE       10
+#define C_GT       11
+#define C_GE       12
+#define C_PLUS     13
+#define C_MINUS    14
+#define C_MUL      15
+#define C_DIV      16
+#define C_MOD      17
+#define C_UMINUS   18
+#define C_NOT      19
+#define C_PEXPR    20
+#define C_FCALL    21
+#define C_GVAR     22
+#define C_LVAR     23
+#define C_PVAR     24
+#define C_FUNCTION 25
+#define C_TCONS    26
+#define C_DECL     27
+#define C_STMT     28
+#define C_IF       29
+#define C_WHILE    30
+#define C_FOR      31
+#define C_FORIN    32
+#define C_BREAK    33
+#define C_CONTINUE 34
+#define C_RETURN   35
+#define C_INTERNAL 36
+#define C_ARGS     37
+#define C_NOP      38
+#define C_SIZE     39
 
-    typedef struct Code_t {
-	Ctype_t ctype;
-	int next;
-	union {
-	    char s[1];
-	    double d;
-	    long i;
-	    int fp;
-	    void *o;
-	} u;
-    } Code_t;
+typedef struct Code_t {
+    int ctype;
+    int next;
+    union {
+        char s[1];
+        double d;
+        long i;
+        int fp;
+        void *o;
+    } u;
+} Code_t;
 #define C_CODESIZE sizeof (Code_t)
 
 #define Cgetstring(i) (char *) &cbufp[i].u.s[0]
@@ -59,18 +90,19 @@ extern "C" {
 #define Csetobject(a, b) cbufp[a].u.o = b
 #define Csetreal(a, b) cbufp[a].u.d = b
 
-    extern Code_t *cbufp;
-    extern int cbufn, cbufi;
+extern Code_t *cbufp;
+extern int cbufn, cbufi;
 
-    void Cinit(void);
-    void Cterm(void);
-    void Creset(void);
-    int Cnew(Ctype_t);
-    int Cinteger(long);
-    int Creal(double);
-    int Cstring(char *);
-#endif				/* _CODE_H */
+void Cinit (void);
+void Cterm (void);
+void Creset (void);
+int Cnew (int);
+int Cinteger (long);
+int Creal (double);
+int Cstring (char *);
+#endif /* _CODE_H */
 
 #ifdef __cplusplus
 }
 #endif
+
diff --git a/cmd/lefty/colors.txt b/cmd/lefty/colors.txt
index de049b3dd..61f98eec5 100644
--- a/cmd/lefty/colors.txt
+++ b/cmd/lefty/colors.txt
@@ -651,4 +651,5 @@ colorname_t colornames[] = {
 {"yellow3",205,205,0},
 {"yellow4",139,139,0},
 {"yellowgreen",154,205,50},
+{"pastelblue",153,153,255},
 };
-- 
2.40.0