- Timestamp:
- Apr 21, 2007 6:22:16 PM (18 years ago)
- Location:
- trunk/src/ash-messup
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/ash-messup/Makefile.kmk
r881 r882 59 59 $(PATH_TARGET)/builtins.c \ 60 60 $(PATH_TARGET)/init.c \ 61 $(PATH_TARGET)/nodes.c 61 $(PATH_TARGET)/nodes.c \ 62 \ 63 shinstance.c \ 64 shthread.c \ 65 shfile.c 62 66 kmk_ash_SOURCES.linux = \ 63 67 sys_signame.c \ … … 114 118 #$(eval $(def_copy_generated))) 115 119 116 kmk_ash_INCS += generated 120 kmk_ash_INCS += generated 121 kmk_ash_DEFS += HAVE_SYS_CDEFS_H 117 122 118 123 include $(PATH_KBUILD)/footer.kmk -
trunk/src/ash-messup/alias.c
r809 r882 54 54 #include "options.h" /* XXX for argptr (should remove?) */ 55 55 #include "var.h" 56 57 #define ATABSIZE 39 58 59 struct alias *atab[ATABSIZE]; 60 61 STATIC void setalias(char *, char *); 62 STATIC int unalias(char *); 63 STATIC struct alias **hashalias(char *); 56 #include "shinstance.h" 57 58 /*#define ATABSIZE 39 59 60 struct alias *atab[ATABSIZE];*/ 61 62 STATIC void setalias(shinstance *, char *, char *); 63 STATIC int unalias(shinstance *, char *); 64 STATIC struct alias **hashalias(shinstance *, char *); 64 65 65 66 STATIC 66 67 void 67 setalias( char *name, char *val)68 setalias(shinstance *psh, char *name, char *val) 68 69 { 69 70 struct alias *ap, **app; 70 71 71 app = hashalias( name);72 app = hashalias(psh, name); 72 73 for (ap = *app; ap; ap = ap->next) { 73 74 if (equal(name, ap->name)) { … … 117 118 118 119 STATIC int 119 unalias( char *name)120 unalias(shinstance *psh, char *name) 120 121 { 121 122 struct alias *ap, **app; 122 123 123 app = hashalias( name);124 app = hashalias(psh, name); 124 125 125 126 for (ap = *app; ap; app = &(ap->next), ap = ap->next) { … … 150 151 151 152 #ifdef mkinit 152 MKINIT void rmaliases( void);153 MKINIT void rmaliases(shinstance *psh); 153 154 154 155 SHELLPROC { 155 rmaliases( );156 rmaliases(psh); 156 157 } 157 158 #endif 158 159 159 160 void 160 rmaliases( void)161 rmaliases(shinstance *psh) 161 162 { 162 163 struct alias *ap, *tmp; … … 165 166 INTOFF; 166 167 for (i = 0; i < ATABSIZE; i++) { 167 ap = atab[i];168 atab[i] = NULL;168 ap = psh->atab[i]; 169 psh->atab[i] = NULL; 169 170 while (ap) { 170 171 ckfree(ap->name); … … 179 180 180 181 struct alias * 181 lookupalias( char *name, int check)182 { 183 struct alias *ap = *hashalias( name);182 lookupalias(shinstance *psh, char *name, int check) 183 { 184 struct alias *ap = *hashalias(psh, name); 184 185 185 186 for (; ap; ap = ap->next) { … … 195 196 196 197 char * 197 get_alias_text( char *name)198 get_alias_text(shinstance *psh, char *name) 198 199 { 199 200 struct alias *ap; 200 201 201 ap = lookupalias( name, 0);202 ap = lookupalias(psh, name, 0); 202 203 if (ap == NULL) 203 204 return NULL; … … 209 210 */ 210 211 int 211 aliascmd( int argc, char **argv)212 aliascmd(shinstance *psh, int argc, char **argv) 212 213 { 213 214 char *n, *v; … … 219 220 220 221 for (i = 0; i < ATABSIZE; i++) 221 for (ap = atab[i]; ap; ap = ap->next) {222 for (ap = psh->atab[i]; ap; ap = ap->next) { 222 223 if (*ap->name != '\0') { 223 out1fmt( "alias %s=", ap->name);224 print_quoted( ap->val);225 out1c( '\n');224 out1fmt(psh, "alias %s=", ap->name); 225 print_quoted(psh, ap->val); 226 out1c(psh, '\n'); 226 227 } 227 228 } … … 230 231 while ((n = *++argv) != NULL) { 231 232 if ((v = strchr(n+1, '=')) == NULL) { /* n+1: funny ksh stuff */ 232 if ((ap = lookupalias( n, 0)) == NULL) {233 outfmt( out2, "alias: %s not found\n", n);233 if ((ap = lookupalias(psh, n, 0)) == NULL) { 234 outfmt(psh->out2, "alias: %s not found\n", n); 234 235 ret = 1; 235 236 } else { 236 out1fmt( "alias %s=", n);237 print_quoted( ap->val);238 out1c( '\n');237 out1fmt(psh, "alias %s=", n); 238 print_quoted(psh, ap->val); 239 out1c(psh, '\n'); 239 240 } 240 241 } else { 241 242 *v++ = '\0'; 242 setalias( n, v);243 setalias(psh, n, v); 243 244 } 244 245 } … … 248 249 249 250 int 250 unaliascmd( int argc, char **argv)251 unaliascmd(shinstance *psh, int argc, char **argv) 251 252 { 252 253 int i; 253 254 254 while ((i = nextopt( "a")) != '\0') {255 while ((i = nextopt(psh, "a")) != '\0') { 255 256 if (i == 'a') { 256 rmaliases( );257 rmaliases(psh); 257 258 return (0); 258 259 } 259 260 } 260 for (i = 0; * argptr;argptr++)261 i = unalias( *argptr);261 for (i = 0; *psh->argptr; psh->argptr++) 262 i = unalias(psh, *psh->argptr); 262 263 263 264 return (i); … … 265 266 266 267 STATIC struct alias ** 267 hashalias( char *p)268 hashalias(shinstance *psh, char *p) 268 269 { 269 270 unsigned int hashval; … … 272 273 while (*p) 273 274 hashval+= *p++; 274 return & atab[hashval % ATABSIZE];275 } 275 return &psh->atab[hashval % ATABSIZE]; 276 } -
trunk/src/ash-messup/main.c
r881 r882 308 308 309 309 INTOFF; 310 if ((fd = shfile_open( psh, name, O_RDONLY)) >= 0)310 if ((fd = shfile_open(&psh->fdtab, name, O_RDONLY)) >= 0) 311 311 setinputfd(psh, fd, 1); 312 312 INTON; -
trunk/src/ash-messup/shfile.h
r881 r882 25 25 */ 26 26 27 #ifndef ___shfile_h___ 28 #define ___shfile_h___ 27 29 28 30 #include "shtypes.h" … … 49 51 50 52 51 int shfile_open(shinstance *, const char *, unsigned); 53 int shfile_open(shfdtab *, const char *, unsigned); 54 int shfile_close(shfdtab *pfdtab, unsigned fd); 52 55 56 #endif 57 -
trunk/src/ash-messup/shinstance.h
r881 r882 137 137 /* builtins.h */ 138 138 139 /* alias.c */ 140 #define ATABSIZE 39 141 struct alias *atab[ATABSIZE]; 142 139 143 } shinstance; 140 144 -
trunk/src/ash-messup/shthread.h
r881 r882 25 25 */ 26 26 27 #ifndef ___shthread_h___ 28 #define ___shthread_h___ 27 29 28 30 #include <sys/types.h> … … 37 39 void shthread_set_shell(struct shinstance *); 38 40 struct shinstance *shthread_get_shell(void); 41 42 #endif 43
Note:
See TracChangeset
for help on using the changeset viewer.