PennMUSH Community
Show
Ignore:
Timestamp:
06/12/07 15:21:47 (1 year ago)
Author:
shawnw
Message:

1.8.3p3

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • 1.8.3/trunk/src/funufun.c

    r846 r919  
    2323 
    2424void 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); 
    2727 
    2828/* ARGSUSED */ 
     
    3232  p = args[0]; 
    3333  process_expression(buff, bp, &p, executor, caller, enactor, PE_DEFAULT, 
    34              PT_DEFAULT, pe_info); 
     34                     PT_DEFAULT, pe_info); 
     35
     36 
     37/* ARGSUSED */ 
     38FUNCTION(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); 
    3564} 
    3665 
     
    4574  p = args[0]; 
    4675  process_expression(buff, bp, &p, executor, caller, enactor, PE_DEFAULT, 
    47             PT_DEFAULT, pe_info); 
     76                     PT_DEFAULT, pe_info); 
    4877 
    4978  restore_global_regs("localize", saver); 
     
    6493  p = args[0]; 
    6594  process_expression(name, &s, &p, executor, caller, enactor, PE_DEFAULT, 
    66             PT_DEFAULT, pe_info); 
     95                     PT_DEFAULT, pe_info); 
    6796  *s = '\0'; 
    6897 
     
    73102     */ 
    74103    if (((obj = match_thing(executor, name)) == NOTHING) 
    75    || !controls(executor, obj)) 
     104        || !controls(executor, obj)) 
    76105      obj = executor; 
    77106  } else { 
     
    80109     */ 
    81110    if (((obj = match_thing(executor, name)) == NOTHING) 
    82    || (!controls(executor, obj) && !See_All(executor))) 
     111        || (!controls(executor, obj) && !See_All(executor))) 
    83112      obj = executor; 
    84113  } 
     
    86115  p = args[1]; 
    87116  process_expression(buff, bp, &p, obj, executor, enactor, PE_DEFAULT, 
    88             PT_DEFAULT, pe_info); 
     117                     PT_DEFAULT, pe_info); 
    89118} 
    90119 
     
    100129 * \param enactor enactor. 
    101130 * \param pe_info pointer to structure for process_expression data. 
     131 * \param extra_flags extra PE_ flags to pass in (PE_USERFN or 0). 
    102132 */ 
    103133void 
    104134do_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) 
    107138{ 
    108139  int j; 
     
    110141  char *tbuf; 
    111142  char const *tp; 
    112   int pe_flags = PE_DEFAULT
     143  int pe_flags = PE_DEFAULT | extra_flags
    113144  int old_args = 0; 
    114145 
     
    119150  /* copy the appropriate args into the stack */ 
    120151  if (nargs > 10) 
    121     nargs = 10;            /* maximum ten args */ 
     152    nargs = 10;                 /* maximum ten args */ 
    122153  for (j = 0; j < nargs; j++) 
    123154    global_eval_context.wenv[j] = args[j]; 
     
    133164    pe_flags |= PE_DEBUG; 
    134165  process_expression(buff, bp, &tp, obj, executor, enactor, pe_flags, 
    135             PT_DEFAULT, pe_info); 
     166                     PT_DEFAULT, pe_info); 
    136167  free(tbuf); 
    137168 
     
    225256  sp = args[0]; 
    226257  process_expression(mstr, &dp, &sp, executor, caller, enactor, 
    227             PE_DEFAULT, PT_DEFAULT, pe_info); 
     258                     PE_DEFAULT, PT_DEFAULT, pe_info); 
    228259  *dp = '\0'; 
    229260  parse_attrib(executor, mstr, &thing, &attrib); 
     
    235266    xargs = NULL; 
    236267    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"); 
    239269      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'; 
    246276      } 
    247277    } 
     
    249279      save_global_regs("uldefault.save", preserve); 
    250280    do_userfn(buff, bp, thing, attrib, nargs - 2, xargs, 
    251          executor, caller, enactor, pe_info); 
     281              executor, caller, enactor, pe_info, 0); 
    252282    if (called_as[1] == 'L') 
    253283      restore_global_regs("uldefault.save", preserve); 
     
    256286    if (nargs > 2) { 
    257287      for (i = 0; i < nargs - 2; i++) 
    258    mush_free(xargs[i], "udefault"); 
     288        mush_free(xargs[i], "udefault"); 
    259289      mush_free(xargs, "udefault.xargs"); 
    260290    } 
     
    267297    save_global_regs("uldefault.save", preserve); 
    268298  process_expression(buff, bp, &sp, executor, caller, enactor, 
    269             PE_DEFAULT, PT_DEFAULT, pe_info); 
     299                     PE_DEFAULT, PT_DEFAULT, pe_info); 
    270300  if (called_as[1] == 'L') 
    271301    restore_global_regs("uldefault.save", preserve); 
     
    294324    } 
    295325    do_userfn(buff, bp, zone, attrib, nargs - 1, args + 1, executor, caller, 
    296          enactor, pe_info); 
     326              enactor, pe_info, 0); 
    297327    return; 
    298328  } else if (attrib || !Can_Examine(executor, zone)) {