Changeset 919 for 1.8.3/trunk/src/funufun.c
- Timestamp:
- 06/12/07 15:21:47 (1 year ago)
- Files:
-
- 1.8.3/trunk/src/funufun.c (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
1.8.3/trunk/src/funufun.c
r846 r919 23 23 24 24 void do_userfn(char *buff, char **bp, dbref obj, ATTR *attrib, int nargs, 25 char **args, dbref executor, dbref caller, dbref enactor,26 PE_Info *pe_info);25 char **args, dbref executor, dbref caller, dbref enactor, 26 PE_Info *pe_info, int extra_flags); 27 27 28 28 /* ARGSUSED */ … … 32 32 p = args[0]; 33 33 process_expression(buff, bp, &p, executor, caller, enactor, PE_DEFAULT, 34 PT_DEFAULT, pe_info); 34 PT_DEFAULT, pe_info); 35 } 36 37 /* ARGSUSED */ 38 FUNCTION(fun_fn) 39 { 40 /* First argument is name of a function, remaining are arguments 41 * for that function. 42 */ 43 char tbuf[BUFFER_LEN]; 44 char *tp = tbuf; 45 char const *p; 46 int i; 47 if (!args[0] || !*args[0]) 48 return; /* No function name */ 49 /* Evaluate first argument */ 50 p = args[0]; 51 process_expression(tbuf, &tp, &p, executor, caller, 52 enactor, PE_DEFAULT, PT_DEFAULT, pe_info); 53 safe_chr('(', tbuf, &tp); 54 for (i = 1; i < nargs; i++) { 55 if (i > 1) 56 safe_chr(',', tbuf, &tp); 57 safe_strl(args[i], arglens[i], tbuf, &tp); 58 } 59 safe_chr(')', tbuf, &tp); 60 *tp = '\0'; 61 p = tbuf; 62 process_expression(buff, bp, &p, executor, caller, enactor, 63 PE_DEFAULT | PE_BUILTINONLY, PT_DEFAULT, pe_info); 35 64 } 36 65 … … 45 74 p = args[0]; 46 75 process_expression(buff, bp, &p, executor, caller, enactor, PE_DEFAULT, 47 PT_DEFAULT, pe_info);76 PT_DEFAULT, pe_info); 48 77 49 78 restore_global_regs("localize", saver); … … 64 93 p = args[0]; 65 94 process_expression(name, &s, &p, executor, caller, enactor, PE_DEFAULT, 66 PT_DEFAULT, pe_info);95 PT_DEFAULT, pe_info); 67 96 *s = '\0'; 68 97 … … 73 102 */ 74 103 if (((obj = match_thing(executor, name)) == NOTHING) 75 || !controls(executor, obj))104 || !controls(executor, obj)) 76 105 obj = executor; 77 106 } else { … … 80 109 */ 81 110 if (((obj = match_thing(executor, name)) == NOTHING) 82 || (!controls(executor, obj) && !See_All(executor)))111 || (!controls(executor, obj) && !See_All(executor))) 83 112 obj = executor; 84 113 } … … 86 115 p = args[1]; 87 116 process_expression(buff, bp, &p, obj, executor, enactor, PE_DEFAULT, 88 PT_DEFAULT, pe_info);117 PT_DEFAULT, pe_info); 89 118 } 90 119 … … 100 129 * \param enactor enactor. 101 130 * \param pe_info pointer to structure for process_expression data. 131 * \param extra_flags extra PE_ flags to pass in (PE_USERFN or 0). 102 132 */ 103 133 void 104 134 do_userfn(char *buff, char **bp, dbref obj, ATTR *attrib, int nargs, 105 char **args, dbref executor, dbref caller 106 __attribute__ ((__unused__)), dbref enactor, PE_Info *pe_info) 135 char **args, dbref executor, dbref caller 136 __attribute__ ((__unused__)), dbref enactor, PE_Info *pe_info, 137 int extra_flags) 107 138 { 108 139 int j; … … 110 141 char *tbuf; 111 142 char const *tp; 112 int pe_flags = PE_DEFAULT ;143 int pe_flags = PE_DEFAULT | extra_flags; 113 144 int old_args = 0; 114 145 … … 119 150 /* copy the appropriate args into the stack */ 120 151 if (nargs > 10) 121 nargs = 10; /* maximum ten args */152 nargs = 10; /* maximum ten args */ 122 153 for (j = 0; j < nargs; j++) 123 154 global_eval_context.wenv[j] = args[j]; … … 133 164 pe_flags |= PE_DEBUG; 134 165 process_expression(buff, bp, &tp, obj, executor, enactor, pe_flags, 135 PT_DEFAULT, pe_info);166 PT_DEFAULT, pe_info); 136 167 free(tbuf); 137 168 … … 225 256 sp = args[0]; 226 257 process_expression(mstr, &dp, &sp, executor, caller, enactor, 227 PE_DEFAULT, PT_DEFAULT, pe_info);258 PE_DEFAULT, PT_DEFAULT, pe_info); 228 259 *dp = '\0'; 229 260 parse_attrib(executor, mstr, &thing, &attrib); … … 235 266 xargs = NULL; 236 267 if (nargs > 2) { 237 xargs = 238 (char **) mush_malloc((nargs - 2) * sizeof(char *), "udefault.xargs"); 268 xargs = mush_calloc(nargs - 2, sizeof(char *), "udefault.xargs"); 239 269 for (i = 0; i < nargs - 2; i++) { 240 xargs[i] = (char *)mush_malloc(BUFFER_LEN, "udefault");241 dp = xargs[i];242 sp = args[i + 2];243 process_expression(xargs[i], &dp, &sp, executor, caller, enactor,244 PE_DEFAULT, PT_DEFAULT, pe_info);245 *dp = '\0';270 xargs[i] = mush_malloc(BUFFER_LEN, "udefault"); 271 dp = xargs[i]; 272 sp = args[i + 2]; 273 process_expression(xargs[i], &dp, &sp, executor, caller, enactor, 274 PE_DEFAULT, PT_DEFAULT, pe_info); 275 *dp = '\0'; 246 276 } 247 277 } … … 249 279 save_global_regs("uldefault.save", preserve); 250 280 do_userfn(buff, bp, thing, attrib, nargs - 2, xargs, 251 executor, caller, enactor, pe_info);281 executor, caller, enactor, pe_info, 0); 252 282 if (called_as[1] == 'L') 253 283 restore_global_regs("uldefault.save", preserve); … … 256 286 if (nargs > 2) { 257 287 for (i = 0; i < nargs - 2; i++) 258 mush_free(xargs[i], "udefault");288 mush_free(xargs[i], "udefault"); 259 289 mush_free(xargs, "udefault.xargs"); 260 290 } … … 267 297 save_global_regs("uldefault.save", preserve); 268 298 process_expression(buff, bp, &sp, executor, caller, enactor, 269 PE_DEFAULT, PT_DEFAULT, pe_info);299 PE_DEFAULT, PT_DEFAULT, pe_info); 270 300 if (called_as[1] == 'L') 271 301 restore_global_regs("uldefault.save", preserve); … … 294 324 } 295 325 do_userfn(buff, bp, zone, attrib, nargs - 1, args + 1, executor, caller, 296 enactor, pe_info);326 enactor, pe_info, 0); 297 327 return; 298 328 } else if (attrib || !Can_Examine(executor, zone)) {
