Branch: Tag:

2001-04-18

2001-04-18 04:57:34 by Martin Stjernholm <mast@lysator.liu.se>

Added type argument to <set>. The default type is still t_any, but since
it now handle literals it's essentially equivalent to t_text for constant
strings. Fixed bug where <set ... from="var.foo"/> complained about
nonexsting from variable when its value is zero.

Rev: server/modules/tags/rxmltags.pike:1.222

7:   #define _rettext id->misc->defines[" _rettext"]   #define _ok id->misc->defines[" _ok"]    - constant cvs_version = "$Id: rxmltags.pike,v 1.221 2001/04/05 11:24:55 kuntri Exp $"; + constant cvs_version = "$Id: rxmltags.pike,v 1.222 2001/04/18 04:57:34 mast Exp $";   constant thread_safe = 1;   constant language = roxen->language;   
329:    if (args->from) {    // Append the value of another entity variable.    mixed from=RXML.user_get_var(args->from, args->scope); -  if(!from) parse_error("From variable doesn't exist.\n"); +  if(!from) parse_error("From variable %O doesn't exist.\n", args->from);    if (value)    value+=from;    else
487:    inherit RXML.Tag;    constant name = "set";    mapping(string:RXML.Type) req_arg_types = ([ "variable": RXML.t_text(RXML.PEnt) ]); +  mapping(string:RXML.Type) opt_arg_types = ([ "type": RXML.t_type(RXML.PEnt) ]);    RXML.Type content_type = RXML.t_any (RXML.PXml);    array(RXML.Type) result_types = ({RXML.t_nil}); // No result.       class Frame {    inherit RXML.Frame; -  array do_return(RequestID id) { -  if (args->value) { -  // Set an entity variable to a value. -  if(args->split && stringp(args->value)) -  RXML.user_set_var(args->variable, args->value/args->split, args->scope); -  else -  RXML.user_set_var(args->variable, args->value, args->scope); -  return 0; +  +  array do_enter (RequestID id) +  { +  if (args->type) content_type = args->type (RXML.PXml);    } -  +  +  array do_return(RequestID id) { +  if (args->value) content = args->value; +  else {    if (args->expr) {    // Set an entity variable to an evaluated expression.    mixed val;
511:    }    if (args->from) {    // Copy a value from another entity variable. -  mixed from=RXML.user_get_var(args->from, args->scope); -  if(!from) run_error("From variable doesn't exist.\n"); +  mixed from; +  if (zero_type (from = RXML.user_get_var(args->from, args->scope))) +  run_error("From variable doesn't exist.\n");    RXML.user_set_var(args->variable, from, args->scope);    return 0;    } -  +  }    -  args->value = content || RXML.nil; -  if(args->split && stringp(args->value)) -  RXML.user_set_var(args->variable, args->value/args->split, args->scope); +  // Set an entity variable to a value. +  if(args->split && stringp(content)) +  RXML.user_set_var(args->variable, content/args->split, args->scope);    else -  RXML.user_set_var(args->variable, args->value, args->scope); +  RXML.user_set_var(args->variable, content, args->scope);    return 0;    }    }