Roxen.git / server / etc / modules / RXML.pmod / utils.pmod

version» Context lines:

Roxen.git/server/etc/modules/RXML.pmod/utils.pmod:1:   //! Things that belong elsewhere but can't lie there for various silly   //! reasons. Everything here is considered internal and not part of   //! the RXML.pmod API.   //!   //! E.g. one reason is to avoid circular references in the parser   //! objects when the callbacks are defined in them.   //!   //! Created 2000-01-21 by Martin Stjernholm   //! - //! $Id: utils.pmod,v 1.22 2001/05/19 05:35:15 mast Exp $ + //! $Id: utils.pmod,v 1.23 2001/06/09 00:33:25 mast Exp $      constant short_format_length = 40;      final string format_short (mixed val)   // This one belongs somewhere else..   {    string res = "";       void format_val (mixed val)    {
Roxen.git/server/etc/modules/RXML.pmod/utils.pmod:60:    mixed err = catch {    format_val (val);    return res;    };    if (err) throw (err);    return res + "/.../";   }      final array return_zero (mixed... ignored) {return 0;}   final array return_empty_array (mixed... ignored) {return ({});} + final mapping(string:string) return_empty_mapping (mixed... ignored) +  {return ([]);} + final mapping(string:string) return_help_arg (mixed... ignored) +  {return (["help": "help"]);}    -  + final mixed get_non_nil (RXML.Type type, mixed... vals) + // Returns the single argument in vals that isn't RXML.nil, or + // RXML.nil if all of them are that value. Throws an rxml parse error + // if more than one argument isn't nil. + { +  int pos = -1; +  do +  if (++pos == sizeof (vals)) return RXML.nil; +  while (vals[pos] == RXML.nil); +  mixed res = vals[pos]; +  for (pos++; pos < sizeof (vals); pos++) +  if (vals[pos] != RXML.nil) +  RXML.parse_error ( +  "Cannot append another value %s to non-sequential value of type %s.\n", +  format_short (vals[pos]), type->name); +  return res; + } +    final int(1..1)|string|array free_text_error (object/*(RMXL.PXml)*/ p, string str)   {    sscanf (str, "%[ \t\n\r]", string ws);    if (str != ws)    RXML.parse_error ("Free text %s is not allowed in context of type %s.\n",    format_short (String.trim_all_whites (str)), p->type->name);    return ({});   }      final int(1..1)|string|array unknown_tag_error (object/*(RMXL.PXml)*/ p, string str)
Roxen.git/server/etc/modules/RXML.pmod/utils.pmod:161:    if (type->handle_literals) p->handle_literal();    else if (p->p_code) p->p_code_literal();    mixed value = p->handle_var (    p,    entity,    // No quoting of splice args. FIXME: Add some sort of    // safeguard against splicing in things like "nice><evil    // stuff='...'"?    p->html_context() == "splice_arg" ? RXML.t_string : type);    if (value != RXML.nil) { -  if (type->free_text) return ({value}); +  if (type->free_text && !p->p_code) return ({value});    p->add_value (value);    }    return ({});    }    if (!type->free_text)    RXML.parse_error ("Unknown entity \"&%s;\" not allowed context of type %s.\n",    entity, type->name);    return ({str});   }   
Roxen.git/server/etc/modules/RXML.pmod/utils.pmod:189:    if (type->handle_literals) p->handle_literal();    else if (p->p_code) p->p_code_literal();    mixed value = p->handle_var (    p,    entity,    // No quoting of splice args. FIXME: Add some sort of    // safeguard against splicing in things like "nice><evil    // stuff='...'"?    p->html_context() == "splice_arg" ? RXML.t_string : type);    if (value != RXML.nil) { -  if (type->free_text) return ({value}); +  if (type->free_text && !p->p_code) return ({value});    p->add_value (value);    }    return ({});    }    if (!type->free_text)    RXML.parse_error ("Unknown entity \"&%s;\" not allowed in context of type %s.\n",    entity, type->name);    return ({str});   }