Changeset 1217 in kBuild for trunk/src/kash
- Timestamp:
- Oct 7, 2007 9:47:15 PM (17 years ago)
- Location:
- trunk/src/kash
- Files:
-
- 6 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 } -
trunk/src/kash/arith_lex.l
r809 r1217 35 35 */ 36 36 37 #ifdef HAVE_SYS_CDEFS_H 38 #include <sys/cdefs.h> 39 #endif 37 #if 0 40 38 #ifndef lint 41 #if 042 39 static char sccsid[] = "@(#)arith_lex.l 8.3 (Berkeley) 5/4/95"; 43 40 #else 44 41 __RCSID("$NetBSD: arith_lex.l,v 1.13 2005/03/21 22:37:09 dsl Exp $"); 42 #endif /* not lint */ 45 43 #endif 46 #endif /* not lint */47 44 48 #include <unistd.h>49 45 #include "arith.h" 50 46 #include "error.h" 51 47 #include "expand.h" 52 48 #include "var.h" 49 #include "shinstance.h" 53 50 54 51 extern int yylval; 52 extern shinstance *arith_psh; 55 53 extern char *arith_buf, *arith_startbuf; 56 54 #undef YY_INPUT … … 65 63 0[0-7]* { yylval = strtol(yytext, 0, 0); return(ARITH_NUM); } 66 64 [1-9][0-9]* { yylval = strtol(yytext, 0, 0); return(ARITH_NUM); } 67 [A-Za-z_][A-Za-z_0-9]* { char *v = lookupvar( yytext);65 [A-Za-z_][A-Za-z_0-9]* { char *v = lookupvar(arith_psh, yytext); 68 66 if (v) { 69 67 yylval = strtol(v, &v, 0); … … 71 69 return ARITH_NUM; 72 70 } 73 error( "arith: syntax error: \"%s\"", arith_startbuf);71 error(arith_psh, "arith: syntax error: \"%s\"", arith_startbuf); 74 72 } 75 73 "(" { return(ARITH_LPAREN); } … … 95 93 "~" { return(ARITH_BNOT); } 96 94 "!" { return(ARITH_NOT); } 97 . { error( "arith: syntax error: \"%s\"", arith_startbuf); }95 . { error(arith_psh, "arith: syntax error: \"%s\"", arith_startbuf); } 98 96 %% 99 97 -
trunk/src/kash/bltin/test.c
r1214 r1217 25 25 #include <stdarg.h> 26 26 27 #include "shell.h" 27 28 #include "error.h" 28 29 #include "shinstance.h" -
trunk/src/kash/error.h
r1214 r1217 38 38 #define ___error_h 39 39 40 #include "shtypes.h" 40 41 #include <stdarg.h> 41 42 -
trunk/src/kash/expand.c
r1214 r1217 388 388 if (quotes) 389 389 rmescapes(psh, p+2); 390 result = arith(p +2);390 result = arith(psh, p+2); 391 391 fmtstr(p, 12, "%d", result); 392 392 -
trunk/src/kash/expand.h
r1203 r1217 38 38 #define ___expand_h 39 39 40 #include "shtypes.h" 41 40 42 struct strlist { 41 43 struct strlist *next; … … 70 72 71 73 /* From arith.y */ 72 int arith( const char *);74 int arith(struct shinstance *, const char *); 73 75 int expcmd(struct shinstance *, int , char **); 74 76 void arith_lex_reset(void);
Note:
See TracChangeset
for help on using the changeset viewer.