Changeset 1217 for trunk/src/kash/arith.y
- Timestamp:
- Oct 7, 2007, 11:47:15 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kash/arith.y
r809 r1217 34 34 */ 35 35 36 #ifdef HAVE_SYS_CDEFS_H 37 #include <sys/cdefs.h> 38 #endif 36 #if 0 39 37 #ifndef lint 40 #if 041 38 static char sccsid[] = "@(#)arith.y 8.3 (Berkeley) 5/4/95"; 42 39 #else 43 40 __RCSID("$NetBSD: arith.y,v 1.17 2003/09/17 17:33:36 jmmv Exp $"); 41 #endif /* not lint */ 44 42 #endif 45 #endif /* not lint */46 43 47 44 #include <stdlib.h> … … 51 48 #include "output.h" 52 49 #include "memalloc.h" 53 50 #include "shinstance.h" 51 52 shinstance *arith_psh; 54 53 const char *arith_buf, *arith_startbuf; 55 54 … … 117 116 %% 118 117 int 119 arith(s) 120 const char *s; 118 arith(shinstance *psh, const char *s) 121 119 { 122 120 long result; 123 121 122 INTOFF; 123 /* todo lock */ 124 arith_psh = psh; 124 125 arith_buf = arith_startbuf = s; 125 126 INTOFF;127 126 result = yyparse(); 128 127 arith_lex_reset(); /* reprime lex */ 128 arith_psh = NULL; 129 /* todo unlock */ 129 130 INTON; 130 131 … … 137 138 */ 138 139 int 139 expcmd(argc, argv) 140 int argc; 141 char **argv; 140 expcmd(shinstance *psh, int argc, char **argv) 142 141 { 143 142 const char *p; … … 152 151 * concatenate arguments 153 152 */ 154 STARTSTACKSTR( concat);153 STARTSTACKSTR(psh, concat); 155 154 ap = argv + 2; 156 155 for (;;) { 157 156 while (*p) 158 STPUTC( *p++, concat);157 STPUTC(psh, *p++, concat); 159 158 if ((p = *ap++) == NULL) 160 159 break; 161 STPUTC( ' ', concat);160 STPUTC(psh, ' ', concat); 162 161 } 163 STPUTC( '\0', concat);164 p = grabstackstr( concat);162 STPUTC(psh, '\0', concat); 163 p = grabstackstr(psh, concat); 165 164 } 166 165 } else 167 166 p = ""; 168 167 169 i = arith(p );170 171 out1fmt( "%ld\n", i);168 i = arith(psh, p); 169 170 out1fmt(psh, "%ld\n", i); 172 171 return (! i); 173 172 } … … 190 189 191 190 void 192 yyerror(s) 193 const char *s; 194 { 195 191 yyerror(const char *s) 192 { 193 shinstance *psh = arith_psh; 196 194 yyerrok; 197 195 yyclearin; 198 196 arith_lex_reset(); /* reprime lex */ 199 error("arithmetic expression: %s: \"%s\"", s, arith_startbuf); 197 /** @todo unlock */ 198 error(psh, "arithmetic expression: %s: \"%s\"", s, arith_startbuf); 200 199 /* NOTREACHED */ 201 200 }
Note:
See TracChangeset
for help on using the changeset viewer.