pike.git / src / modules / Parser / xml.cmod

version» Context lines:

pike.git/src/modules/Parser/xml.cmod:1:   /* -*- c -*-   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information.   */    + #include "config.h"   #include "global.h"    - #ifdef HAVE_CONFIG_H - #include "config.h" - #endif /* HAVE_CONFIG_H */ -  +    #include "pike_macros.h"   #include "stralloc.h"   #include "object.h"   #include "interpret.h"   #include "mapping.h"   #include "program.h"   #include "array.h"   #include "builtin_functions.h"   #include "module_support.h"   #include "operators.h"
pike.git/src/modules/Parser/xml.cmod:312:    if(c>=0x30A1 && c<=0x30FA) return 1;    if(c>=0x3105 && c<=0x312C) return 1;    break;       default:    if(c>=0xAC00 && c<=0xD7A3) return 1;    }    return 0;   }    - static INLINE int isIdeographic(INT32 c) + static inline int isIdeographic(INT32 c)   {    if(c>=0x4E00 && c<=0x9FA5) return 1;    if(c==0x3007) return 1;    if(c>=0x3021 && c<=0x3029) return 1;    return 0;   }    - static INLINE int isLetter(INT32 c) + static inline int isLetter(INT32 c)   {    return isBaseChar(c) || isIdeographic(c);   }         static int isCombiningChar(INT32 c)   {    switch(c>>8)    {    case 0x03:
pike.git/src/modules/Parser/xml.cmod:466:    break;       case 0x30:    if(c>=0x302A && c<=0x302F) return 1;    if(c==0x3099) return 1;    if(c==0x309A) return 1;    }    return 0;   }    - static INLINE int isDigit(INT32 c) + static inline int isDigit(INT32 c)   {    switch(c>>8)    {    case 0x00:    return c>=0x0030 && c<=0x0039;       case 0x06:    if(c>=0x0660 && c<=0x0669) return 1;    if(c>=0x06F0 && c<=0x06F9) return 1;    break;
pike.git/src/modules/Parser/xml.cmod:505:    if(c>=0x0CE6 && c<=0x0CEF) return 1;    break;       case 0x0d:    if(c>=0x0D66 && c<=0x0D6F) return 1;    break;       case 0x0e:    if(c>=0x0E50 && c<=0x0E59) return 1;    if(c>=0x0ED0 && c<=0x0ED9) return 1; +  break;       case 0x0f:    if(c>=0x0F20 && c<=0x0F29) return 1; -  +  break;    }    return 0;   }      static int isExtender(INT32 c)   {    switch(c)    {    case 0x00B7:    case 0x02D0:
pike.git/src/modules/Parser/xml.cmod:542:    case 0x309E:       case 0x30FC:    case 0x30FD:    case 0x30FE:    return 1;    }    return 0;   }    - static INLINE int isSpace(INT32 c) + static inline int isSpace(INT32 c)   {    switch(c)    {    case 0x20:    case 0x09:    case 0x0d:    case 0x0a:    return 1;    }    return 0;   }    - static INLINE int isNameChar(INT32 c) + static inline int isNameChar(INT32 c)   {    return isLetter(c) || isDigit(c) ||    c=='.' || c=='-' || c=='_' || c==':' ||    isCombiningChar(c) || isExtender(c);   }    - static INLINE int isFirstNameChar(INT32 c) + static inline int isFirstNameChar(INT32 c)   {    return isLetter(c) || c=='_' || c==':';   }    - static INLINE int isHexChar(INT32 c) + static inline int isHexChar(INT32 c)   {    switch(c)    {    case '0': return 0;    case '1': return 1;    case '2': return 2;    case '3': return 3;    case '4': return 4;    case '5': return 5;    case '6': return 6;
pike.git/src/modules/Parser/xml.cmod:595:    case 'e': case 'E': return 14;    case 'f': case 'F': return 15;    default: return -1;    }   }      #define ISWRAP(X) \   void PIKE_CONCAT(f_,X) (INT32 args) \   { \    INT_TYPE i; \ -  get_all_args(#X, args, "%i", &i); \ +  get_all_args(NULL, args, "%i", &i); \    pop_n_elems(args); \    push_int( X (i) ); \   }         ISWRAP(isBaseChar)   ISWRAP(isIdeographic)   ISWRAP(isLetter)   ISWRAP(isCombiningChar)   ISWRAP(isDigit)   ISWRAP(isExtender)   ISWRAP(isSpace)   ISWRAP(isNameChar)   ISWRAP(isFirstNameChar)   ISWRAP(isHexChar)      #ifdef VERBOSE_XMLDEBUG   #define IF_XMLDEBUG(X) X -  + #define XMLDEBUGUSE(X) X   #ifndef PIKE_DEBUG   #define PIKE_DEBUG   #endif   #else   #define IF_XMLDEBUG(X) -  + #define XMLDEBUGUSE(X) UNUSED(X)   #endif      #ifdef PIKE_DEBUG   #define IF_PIKEDEBUG(X) X   #else   #define IF_PIKEDEBUG(X)   #endif         /*! @class Simple    */   PIKECLASS Simple   {    PIKEVAR mapping entities flags ID_PROTECTED|ID_PRIVATE;    PIKEVAR mapping attributes flags ID_PROTECTED|ID_PRIVATE;    PIKEVAR mapping is_cdata flags ID_PROTECTED|ID_PRIVATE;    CVAR int flags;       DECLARE_STORAGE    -  /* Forward decl. */ -  static int Simple_Context_program_fun_num; -  +     struct xmlinput    {    struct xmlinput *next;    PCHARP datap;    ptrdiff_t len;    ptrdiff_t pos;    struct mapping *callbackinfo;    struct pike_string *to_free;    struct pike_string *entity;    };
pike.git/src/modules/Parser/xml.cmod:704:    /*"function(string,string,mapping,array|string,mapping(string:mixed),mixed...:0=mixed)"*/      #define PARSETYPE \    tOr(tFuncV(tStr tStr tOr(CALLBACKTYPE, tVoid), tMix, tArr(tVar(0))), \    tFuncV(tStr tOr(CALLBACKTYPE, tVoid), tMix, tArr(tVar(0))))    /* "function(string," CALLBACKTYPE ",mixed...:array(0))" */       /*! @decl array parse(string xml, string context, @    *! function cb, mixed ... extra_args)    *! @decl array parse(string xml, function cb, mixed ... extra_args) -  *! -  *! @note -  *! The @[context] argument was introduced in Pike 7.8. +     */ -  PIKEFUN array parse(string s, string|function cb, mixed ... extra_args) +  PIKEFUN array parse(string s, string|function cb, mixed ... UNUSED)    rawtype PARSETYPE;    {    int d;       /* Move cb and extras one step to make place for flags. */    for (d = 1; d < args; d++) {    sp[1-d] = sp[-d];    }    d = 1-args;    if (TYPEOF(*cb) == T_STRING) {
pike.git/src/modules/Parser/xml.cmod:742:    Pike_error("Unexpected return value from Parser.XML.Low.Context().\n");    }    apply(Pike_sp[-1].u.object, "parse_xml", 0);    stack_swap();    pop_stack();    }       /*! @decl mixed parse_dtd(string dtd, string context, @    *! function cb, mixed ... extras)    *! @decl mixed parse_dtd(string dtd, function cb, mixed ... extras) -  *! -  *! @note -  *! The @[context] argument was introduced in Pike 7.8. +     */ -  PIKEFUN mixed parse_dtd(string s, string|function cb, mixed ... extras) +  PIKEFUN mixed parse_dtd(string s, string|function cb, mixed ... UNUSED)    rawtype PARSETYPE;    {    int d;       /* Move cb and extras one step to make place for flags. */    for (d=1; d < args; d++) {    sp[1-d] = sp[-d];    }    d = 1-args;    if (TYPEOF(*cb) == T_STRING) {
pike.git/src/modules/Parser/xml.cmod:783:    apply(Pike_sp[-1].u.object, "parse_dtd", 0);    stack_swap();    pop_stack();    }       PIKEFUN void set_attribute_cdata(string tag, string attr)    {    push_int(1); args++;    assign_svalue(mapping_mapping_lookup(THIS->is_cdata,    sp-args, sp+1-args, 1), sp+2-args); -  pop_n_elems(args); -  push_undefined(); +     }       PIKEFUN mapping(string:int(0..1)) get_tag_attribute_cdata(string tag)    {    struct svalue *s = low_mapping_lookup(THIS->is_cdata, sp-1);    if (s && TYPEOF(*s) == T_MAPPING) {    struct mapping *m = copy_mapping(s->u.mapping);    pop_stack();    push_mapping(m);    } else {    pop_stack();    push_undefined();    }    }       PIKEFUN void set_default_attribute(string tag, string attr, string val)    {    assign_svalue(mapping_mapping_lookup(THIS->attributes,    sp-args, sp+1-args, 1), sp+2-args); -  pop_n_elems(args); -  push_undefined(); +     }       PIKEFUN mapping(string:string) get_default_attributes(string tag)    {    struct svalue *s = low_mapping_string_lookup(THIS->attributes, tag);    if (s && TYPEOF(*s) == T_MAPPING) {    struct mapping *m = copy_mapping(s->u.mapping);    pop_n_elems(args);    push_mapping(m);    } else {    pop_n_elems(args); -  push_mapping(allocate_mapping(10)); +  push_mapping(allocate_mapping(0));    }    }       /*! @decl string lookup_entity(string entity)    *!    *! @returns    *! Returns the verbatim expansion of the entity. -  *! -  *! @note -  *! Added in Pike 7.7. +     */    PIKEFUN string lookup_entity(string entity)    {    struct svalue *s = NULL;    if (THIS->entities) {    s = low_mapping_lookup(THIS->entities, sp-args);    }    pop_n_elems(args);    if (s) {    push_svalue(s);
pike.git/src/modules/Parser/xml.cmod:865:    */    PIKEFUN void define_entity_raw(string entity, string raw)    {    if(!THIS->entities)    {    f_aggregate_mapping(2);    THIS->entities=sp[-1].u.mapping;    sp--;    }else{    mapping_insert(THIS->entities, sp-2, sp-1); -  pop_n_elems(args); +     } -  push_undefined(); +     }       /*! @decl void define_entity(string entity, string s, @    *! function cb, mixed ... extras)    *!    *! Define an entity or an SMEG.    *!    *! @param entity    *! Entity name, or SMEG name (if preceeded by a @expr{"%"@}).    *!
pike.git/src/modules/Parser/xml.cmod:920:    }       /*! @decl void allow_rxml_entities(int(0..1) yes_no)    */    PIKEFUN void allow_rxml_entities(int(0..1) yes_no)    {    if (!yes_no)    THIS->flags &= ~ALLOW_RXML_ENTITIES;    else    THIS->flags |= ALLOW_RXML_ENTITIES; -  pop_n_elems(args); -  push_int(0); +     }       /*! @decl void compat_allow_errors(string version)    *!    *! Set whether the parser should allow certain errors for    *! compatibility with earlier versions. @[version] can be:    *!    *! @string    *! @value "7.2"    *! Allow more data after the root element.    *! @value "7.6"    *! Allow multiple and invalidly placed "<?xml ... ?>" and    *! "<!DOCTYPE ... >" declarations (invalid "<?xml ... ?>"    *! declarations are otherwise treated as normal PI:s). Allow    *! "<![CDATA[ ... ]]>" outside the root element. Allow the root    *! element to be absent.    *! @endstring    *!    *! @[version] can also be zero to enable all error checks.    */ -  PIKEFUN void compat_allow_errors(string|void version) +  PIKEFUN void compat_allow_errors(void|string version)    { -  if (args < 1) -  SIMPLE_TOO_FEW_ARGS_ERROR ("XML->compat_allow_errors", 1); -  +     if (!version) {    THIS->flags &= ~(COMPAT_ALLOW_7_2_ERRORS|COMPAT_ALLOW_7_6_ERRORS);    } else if (version == MK_STRING("7.2")) {    THIS->flags |= COMPAT_ALLOW_7_2_ERRORS|COMPAT_ALLOW_7_6_ERRORS;    } else if (version == MK_STRING("7.6")) {    THIS->flags &= ~COMPAT_ALLOW_7_2_ERRORS;    THIS->flags |= COMPAT_ALLOW_7_6_ERRORS;    } else {    Pike_error ("Got unknown version string.\n");    } -  -  pop_n_elems(args); -  push_int(0); +     }          INIT    { -  push_constant_text("lt"); push_constant_text("&#60;"); -  push_constant_text("gt"); push_constant_text(">"); -  push_constant_text("amp"); push_constant_text("&#38;"); -  push_constant_text("apos"); push_constant_text("'"); -  push_constant_text("quot"); push_constant_text("\""); +  push_static_text("lt"); push_static_text("&#60;"); +  push_static_text("gt"); push_static_text(">"); +  push_static_text("amp"); push_static_text("&#38;"); +  push_static_text("apos"); push_static_text("'"); +  push_static_text("quot"); push_static_text("\"");       f_aggregate_mapping(10);    THIS->entities=sp[-1].u.mapping;    sp--;    dmalloc_touch_svalue(sp);       f_aggregate_mapping(0);    THIS->attributes=sp[-1].u.mapping;    sp--;    dmalloc_touch_svalue(sp);
pike.git/src/modules/Parser/xml.cmod:1024:    if (i->entity) \    free_string(i->entity); \    if(i->to_free) \    free_string(i->to_free); \    if(i->callbackinfo) \    free_mapping(i->callbackinfo); \    THIS->input = i->next; \    really_free_xmlinput(i); \    IF_XMLDEBUG(if (THIS->input) \    fprintf(stderr, \ -  "ptr=%p len=%d pos=%d to_free=%p\n", \ +  "ptr=%p len=%ld pos=%ld to_free=%p\n", \    THIS->input->datap.ptr, \    THIS->input->len, \    THIS->input->pos, \    THIS->input->to_free)); \    } while(0)       INIT    {    THIS->input = NULL;    SET_SVAL(THIS->func, PIKE_T_INT, NUMBER_UNDEFINED, integer, 0);
pike.git/src/modules/Parser/xml.cmod:1064:   #define XML_ADD_INTEGER_CONSTANT(X) add_integer_constant(#X, X, 0)    XML_ADD_INTEGER_CONSTANT(ALLOW_RXML_ENTITIES);    XML_ADD_INTEGER_CONSTANT(COMPAT_ALLOW_7_2_ERRORS);    XML_ADD_INTEGER_CONSTANT(COMPAT_ALLOW_7_6_ERRORS);    XML_ADD_INTEGER_CONSTANT(ALLOW_PESMEG_EVERYWHERE);    }      #define PEEK(X) \    ( IF_PIKEDEBUG(((X) > THIS->input->len)? \    (Pike_fatal("PEEK out of bounds (%ld/%ld)\n", \ -  PTRDIFF_T_TO_LONG(X), \ -  PTRDIFF_T_TO_LONG(THIS->input->len)), 0):) \ +  (long)(X), (long)THIS->input->len), 0):) \    INDEX_PCHARP(THIS->input->datap, X) )      #define SAFE_PEEK(X) ((THIS->input && ((X)>=THIS->input->len)) ? 0 : PEEK(X))      #define POKE(X,Y) string_builder_putchar(&X,Y)      #define XMLEOF() (!THIS->input || (THIS->input->len <= 0))      #ifdef PIKE_DEBUG   #define CHECK_INPUT(INPUT) do { \    if ((INPUT)->len < 0) { \    Pike_fatal("Negative input length: %"PRINTPTRDIFFT"d\n", (INPUT)->len); \    } \    } while(0)   #else /* !PIKE_DEBUG */   #define CHECK_INPUT(INPUT)   #endif /* PIKE_DEBUG */       - static inline int xmlread(int z, int UNUSED(line)) + static inline int xmlread(int z, int XMLDEBUGUSE(line))   {    int popped=0;    THIS->input->pos += z; -  IF_XMLDEBUG(fprintf(stderr,"Step(%d) (at %d) to %d/%d '%c%c%c%c'\n", +  IF_XMLDEBUG(fprintf(stderr,"Step(%d) (at %d) to %ld/%ld '%c%c%c%c'\n",    z,    line,    THIS->input->pos,    THIS->input->len,    SAFE_PEEK(0),    SAFE_PEEK(1),    SAFE_PEEK(2),    SAFE_PEEK(3)));    THIS->input->len-=z;    INC_PCHARP(THIS->input->datap, z);
pike.git/src/modules/Parser/xml.cmod:1115:      #define SIMPLE_READ_ATTVALUE(X) simple_read_system_attvalue(X)   #define SIMPLE_READ_SYSTEMLITERAL() simple_read_system_literal()   #define SIMPLE_READ_PUBIDLITERAL() simple_read_pubid_literal()   #define SIMPLE_READNAME() simple_readname()   #define SIMPLE_READNAME_PERIOD() simple_readname_period()   #define SIMPLE_READNMTOKEN() simple_readnmtoken()      static void sys(void);   static int low_parse_dtd(void); - static void free_xmldata(void); +    static void simple_readname(void);   static int simple_readname_period(void);   static void simple_read_system_literal(void);   static void simple_read_pubid_literal(void);   static int low_parse_xml(struct pike_string *end);   static void xmlerror(char *desc, struct pike_string *tag_name);      #define XMLERROR(desc) do {xmlerror(desc,NULL); READ (1);} while (0)   #define XMLERROR_STAY(desc) xmlerror(desc,NULL)    - #define VOIDIFY(X) do { struct svalue *save_sp=sp; \ -  X; \ -  pop_n_elems(sp-save_sp); \ -  }while(0); -  +    #define SKIPSPACE() \    do { while((!XMLEOF()) && (SMEG(), isSpace(PEEK(0)))) READ(1); }while(0)      #define SKIPSPACE_NO_SMEG() \    do { while((!XMLEOF()) && isSpace(PEEK(0))) READ(1); }while(0)      #define SKIPTO(X) \    do { while( (!XMLEOF()) && (PEEK(0) != (X))) READ(1); }while(0)      static int gobble(char *s)
pike.git/src/modules/Parser/xml.cmod:1225:         #define END_STRING(STR) \    check_stack(1); \    UNSET_ONERROR(tmp_ ## STR); \    push_string(finish_string_builder(&STR)); \    }while(0)      #define STRIP_SPACES() do { \    IF_XMLDEBUG(fprintf(stderr,"STRIPPING SPACES (%s)\n",sp[-1].u.string->str)); \ -  push_constant_text("\n"); \ -  push_constant_text("\r"); \ -  push_constant_text("\t"); \ -  f_aggregate(3); \ -  push_constant_text(" "); \ -  push_constant_text(" "); \ -  push_constant_text(" "); \ -  f_aggregate(3); \ -  f_replace(3); \ -  push_constant_text(" "); \ -  o_divide(); \ -  push_empty_string(); \ -  f_aggregate(1); \ -  o_subtract(); \ -  push_constant_text(" "); \ -  o_multiply(); \ +  f_string_normalize_space(1); \    IF_XMLDEBUG(fprintf(stderr,"SPACES STRIPPED (%s)\n",sp[-1].u.string->str)); \    } while(0)         #define READ_CHAR_REF(X) do { \    /* Character reference */ \    INT32 num=0; \    \    READ(1); \    if(PEEK(0)=='x') \
pike.git/src/modules/Parser/xml.cmod:1284:   #define PARSE_REF(ATTR,PARSE_RECURSIVELY) do { \    /* Entity reference */ \    struct xmlinput *i; \    /* Ensure that we aren't already parsing this ref. */ \    for (i = THIS->input; i; i = i->next) { \    if (i->entity == sp[-1].u.string) { \    XMLERROR("Recursive entity reference definition."); \    break; \    } \    } \ -  if (i) continue; \ +  if (i) break; \    \    /* lookup entry in mapping and parse it recursively */ \    /* Generate error if entity is not defined */ \    { \    struct pike_string *name=0; \    struct mapping *callbackinfo; \    ONERROR tmp3,tmp4; \    \    copy_shared_string(name, sp[-1].u.string); \    SET_ONERROR(tmp3, do_free_string, name); \
pike.git/src/modules/Parser/xml.cmod:1315:    \    do { \    if(UNSAFE_IS_ZERO(sp-1)) \    { \    pop_stack(); \    if(index_shared_string(name,0)=='%') \    { \    push_constant_text("%"); \    ref_push_string(name); \    push_int(1); \ -  push_int(0x7fffffff); \ -  o_range(); \ +  o_range2(RANGE_LOW_FROM_BEG|RANGE_HIGH_OPEN); \    }else{ \    push_constant_text("&"); \    ref_push_string(name); \    } \    push_constant_text("in_attribute"); \    push_int(ATTR); \    f_aggregate_mapping(2); /* attributes */ \    push_int(0); /* no data */ \    very_low_sys(callbackinfo); \    if(TYPEOF(sp[-1]) != T_STRING) \
pike.git/src/modules/Parser/xml.cmod:1613:    push_constant_text("%");    ref_push_string(name);    f_aggregate_mapping(0);    push_int(0); /* no data */    very_low_sys(callbackinfo);    }       if(TYPEOF(sp[-1]) == T_STRING)    {    struct pike_string *s=sp[-1].u.string; -  IF_XMLDEBUG(fprintf(stderr, "ptr=%p len=%d pos=%d to_free=%p\n", +  IF_XMLDEBUG(fprintf(stderr, "ptr=%p len=%ld pos=%ld to_free=%p\n",    THIS->input->datap.ptr, THIS->input->len,    THIS->input->pos, THIS->input->to_free));       /* PUSH(s) */    {    i = new_string_xmlinput(s);    i->next = THIS->input;    THIS->input = i;    CHECK_INPUT(THIS->input);    THIS->input->callbackinfo = callbackinfo;
pike.git/src/modules/Parser/xml.cmod:1668:    return;    }    switch(PEEK(0))    {    case '&':    READ_REFERENCE(1,(*X), read_attvalue(X, 0,1));    break;       case 0x0d:    if (!keepspace && PEEK(1)==0x0a) READ(1); /* cr/lf */ +  /* FALLTHRU */    case 0x20:    case 0x0a:    case 0x09:    READ(1);    POKE(*X, 0x20);    break;       default:    POKE(*X, PEEK(0));    READ(1);
pike.git/src/modules/Parser/xml.cmod:1701:    XMLERROR_STAY("End of file while looking for end of pubid.");    break;    }    if(PEEK(0)==Y)    {    READ(1);    break;    }    switch(PEEK(0))    { -  case 0x0d: if(PEEK(1)==0x0a) READ(1); +  case 0x0d: if(PEEK(1)==0x0a) READ(1); /* FALLTHRU */    case 0x20:    case 0x0a:    case 0x09:    READ(1);    POKE(*X, 0x20);    break;       default:    POKE(*X, PEEK(0));    READ(1);
pike.git/src/modules/Parser/xml.cmod:1745:    READ_PEREFERENCE(1,(*X), read_entityvalue(X, 0));    break;       case 0x0d: if(PEEK(1)==0x0a) READ(1);   #if 0    case 0x20:    case 0x0a:    case 0x09:    POKE(*X, 0x20);    READ(1); -  break; +    #endif -  +  break;      #if 0    case '&':    READ_REFERENCE(1,(*X), read_entityvalue(X, 0));    break;   #else    case '&':    if(PEEK(1)=='#')    {    READ(1);    READ_CHAR_REF((*X));    break;    }   #endif -  +  /* FALLTHRU */       default:    POKE(*X, PEEK(0));    READ(1);    }    }    if (Y)    XMLERROR_STAY("End of file while looking for end of entity value.");   }   
pike.git/src/modules/Parser/xml.cmod:1973:    while(1)    {    read_choice_seq_or_name(0);    num++;    SKIPSPACE();       switch(PEEK(0))    {    case 0:    XMLERROR_STAY("End of xml while reading ELEMENT declaration."); +  /* FALLTHRU */       default:    XMLERROR("Expected | or ,"); -  +  break;       case ')':    READ(1);   #if 0    if(num == 1)    {    /* We could be nice about this.... Naaahhh :) /Hubbe */    XMLERROR("Choice or sequence list with only one entry.\n");    }    else
pike.git/src/modules/Parser/xml.cmod:2213:    push_constant_text("NDATA");    SKIPSPACE();    SIMPLE_READNAME();    SKIPSPACE();    }    f_aggregate_mapping(attributes*2);    push_int(0); /* no data */    SYS();    break;    } +  /* FALLTHRU */       default:    not_system:    /* FIXME, DTD's are IGNORED! */    XMLERROR("Unexpected data in <!ENTITY");    SKIPTO('>');    }       SKIPSPACE();    if(PEEK(0)!='>')
pike.git/src/modules/Parser/xml.cmod:2370:    }    if(PEEK(0)!=')')    XMLERROR("Expected ')' after enumeration.");    READ(1);    break;    }   #ifdef PIKE_DEBUG    if(sp<save)    Pike_fatal("Stack underflow.\n");   #endif -  f_aggregate(DO_NOT_WARN(sp - save)); +  f_aggregate(sp - save);    SKIPSPACE();    save=sp;    switch(PEEK(0))    {    case '#':    switch(PEEK(1))    {    case 'R':    if(PEEK(2)=='E' &&    PEEK(3)=='Q' &&
pike.git/src/modules/Parser/xml.cmod:2419:    PEEK(3)=='X' &&    PEEK(4)=='E' &&    PEEK(5)=='D')    {    READ(6);    push_constant_text("#FIXED");    SKIPSPACE();    goto comefrom_fixed;    }    +  /* FALLTHRU */ +     default:    bad_defaultdecl:    XMLERROR("Bad default declaration.");    break;    }    break;       default:    push_empty_string();   
pike.git/src/modules/Parser/xml.cmod:2486:    push_svalue(save-4);    push_svalue(save-2);    apply_external(1,    f_Simple_set_attribute_cdata_fun_num, 2);    pop_stack();    }   #ifdef PIKE_DEBUG    if(sp<save)    Pike_fatal("Stack underflow.\n");   #endif -  f_aggregate(DO_NOT_WARN(sp - save)); +  f_aggregate(sp - save);    f_aggregate(2);    assign_lvalue(sp-3, sp-1);    pop_n_elems(2);    }    push_int(0); /* No data */    SYS();    break;    }    goto unknown_entry_in_dtd;   
pike.git/src/modules/Parser/xml.cmod:2526:    read_system:       push_constant_text("SYSTEM");    SIMPLE_READ_SYSTEMLITERAL();    n++;    }    f_aggregate_mapping(n*2);    break;       } +  /* FALLTHRU */       case 'S':    if(GOBBLE("SYSTEM")) goto read_system; -  +  /* FALLTHRU */ +     default:    XMLERROR("Expected PUBLIC or SYSTEM, found something else.");    push_int(0);       }    SKIPSPACE();    if(PEEK(0)!='>')    XMLERROR("Missing '>' in <!NOTATION.");    READ(1);    push_int(0); /* no data */
pike.git/src/modules/Parser/xml.cmod:2683:    done=really_low_parse_dtd();    THIS->flags = old_flags;      #ifdef PIKE_DEBUG    if(sp<save_sp)    Pike_fatal("Stack underflow.\n");   #endif   #ifdef VERBOSE_XMLDEBUG    fprintf(stderr,"Exiting low_parse_dtd %p %p\n",sp,save_sp);   #endif -  f_aggregate(DO_NOT_WARN(sp - save_sp)); +  f_aggregate(sp - save_sp);   #ifdef VERBOSE_XMLDEBUG    fprintf(stderr,"Exiting low_parse_dtd done\n");   #endif    /* There is now one value on the stack */    return done;   }      #define DOC_BEGINNING 0   #define DOC_GOT_DOCTYPE 1   #define DOC_IN_ROOT_ELEM 2
pike.git/src/modules/Parser/xml.cmod:2852:    }else{    POKE(cdata, PEEK(0));    READ(1);    }    }    READ(3);    END_STRING(cdata);    SYS();    break;    } +  /* FALLTHRU */       default:    XMLERROR("Invalid entry.");    break;       case 'D': /* DOCTYPE? */   /* fprintf(stderr,"FOO: %c%c%c%c\n",    SAFE_PEEK(3),SAFE_PEEK(4),SAFE_PEEK(5),SAFE_PEEK(6)); */    if(PEEK(3)!='O' ||    PEEK(4)!='C' ||
pike.git/src/modules/Parser/xml.cmod:3110:    struct svalue *save_sp=sp;    BEGIN_STRING(text);    end=very_low_parse_xml(end,&text, 0);    INTERMISSION(text);    END_STRING(text);    pop_stack();   #ifdef PIKE_DEBUG    if(sp<save_sp)    Pike_fatal("Stack underflow.\n");   #endif -  f_aggregate(DO_NOT_WARN(sp - save_sp)); +  f_aggregate(sp - save_sp);    /* There is now one value on the stack */    return !!end;   }       /*! @decl mixed parse_xml()    */    PIKEFUN mixed parse_xml()    {    if (!THIS->input) {    push_undefined();
pike.git/src/modules/Parser/xml.cmod:3173:    *! @param context    *! Optional context used to refer to the inserted string.    *! This is typically an URL, but may also be an entity    *! (preceeded by an @expr{"&"@}) or a SMEG reference    *! (preceeded by a @expr{"%"@}).    *! Not used by the XML parser as such, but is simply    *! passed into the callbackinfo mapping as    *! the field @expr{"context"@} where it can be useful    *! for eg resolving relative URLs when parsing DTDs,    *! or for determining where errors occur. -  *! -  *! @note -  *! The @[context] argument was introduced in Pike 7.8. +     */    PIKEFUN void push_string(string s, string|void context)    {    struct xmlinput *i = new_string_xmlinput(s);       i->next = THIS->input;    THIS->input = i;       if (i->next) {    UPDATE_LOCATION(i->next->pos, i->next->callbackinfo);    i->callbackinfo = copy_mapping(i->next->callbackinfo); -  push_constant_text("previous"); +  push_static_text("previous");    ref_push_mapping(i->next->callbackinfo);    mapping_insert(i->callbackinfo, sp-2, sp-1); -  pop_n_elems(2); +     } else {    THIS->input->callbackinfo = allocate_mapping(0);    }    if (context) {    mapping_string_insert_string(THIS->input->callbackinfo,    MK_STRING("context"), context);    }    CHECK_INPUT(THIS->input); -  +     pop_n_elems(args); -  push_undefined(); +     }       /*! @decl void create(string s, string context, int flags, @    *! function cb, mixed ... extra_args)    *! @decl void create(string s, int flags, @    *! function cb, mixed ... extra_args)    *!    *! @param s    *! @param context    *! These two arguments are passed along to @[push_string()].    *!    *! @param flags    *! Parser flags.    *!    *! @param cb    *! Callback function. This function gets called at various    *! stages during the parsing. -  *! -  *! @note -  *! The @[context] argument was introduced in Pike 7.8. +     */    PIKEFUN void create(string s, string|int flags, int|function cb,    mixed ... extra_args)    rawtype tOr(tFuncV(tString tInt CALLBACKTYPE, tMix, tVoid),    tFuncV(tString tString tInt CALLBACKTYPE, tMix, tVoid));    {    if (TYPEOF(*flags) == T_STRING) {    /* We have a context argument.    * Advance the other parameters, and type check.    */    flags++;    if (TYPEOF(*flags) != T_INT) { -  SIMPLE_BAD_ARG_ERROR("create", 3, "int"); +  SIMPLE_ARG_TYPE_ERROR("create", 3, "int");    }    if (args < 4) {    wrong_number_of_args_error("create", args, 4);    }    cb++;    f_aggregate(args-4);    args = 5;    } else {    f_aggregate(args-3);    args = 4;
pike.git/src/modules/Parser/xml.cmod:3276:    */      /*! @decl string autoconvert(string xml)    */   PIKEFUN string autoconvert(string s)    optflags OPT_TRY_OPTIMIZE;   {    INT32 e;    struct string_builder b;    -  pop_n_elems(args-1); -  +     if(!s->size_shift)    {    int pos = 0;    if (STR0(s)[2] && STR0(s)[3]) {    switch((STR0(s)[0]<<8) | STR0(s)[1])    {    case 0xfffe: /* UTF-16, little-endian */    {    struct pike_string *t=begin_shared_string(s->len);    IF_XMLDEBUG(fprintf(stderr,"UTF-16, little endian detected.\n"));    for(e=0;e<s->len;e+=1) t->str[e]=s->str[e^1];    pop_stack();    push_string(end_shared_string(t));    } -  /* FALL_THROUGH */ +  /* FALLTHRU */       case 0xfeff: /* UTF-16, big-endian */    IF_XMLDEBUG(fprintf(stderr,"UTF-16, big endian detected.\n"));    push_int(2); -  push_int(0x7fffffff); -  o_range(); +  o_range2(RANGE_LOW_FROM_BEG|RANGE_HIGH_OPEN);    f_unicode_to_string(1);    return;       case 0xefbb: /* UTF-8 */ -  if (STR0(s)[3] != 0xbf) break; +  if (STR0(s)[2] != 0xbf) break;    IF_XMLDEBUG(fprintf(stderr, "UTF-8 detected.\n"));    push_int(3); -  push_int(0x7fffffff); -  o_range(); +  o_range2(RANGE_LOW_FROM_BEG|RANGE_HIGH_OPEN);    f_utf8_to_string(1);    return;    }    }       switch((STR0(s)[0]<<24) | (STR0(s)[1]<<16) | (STR0(s)[2]<<8) | STR0(s)[3])    {    case 0x0000feff:    pos = 4; -  /* FALL_THROUGH */ +  /* FALLTHRU */    case 0x0000003c: /* UCS4 1234 byte order (big endian) */    IF_XMLDEBUG(fprintf(stderr,"UCS4(1234) detected.\n"));    init_string_builder(&b,4);    for(e=pos;e<s->len;e+=4)    string_builder_putchar(&b,    (STR0(s)[e+0]<<24) | (STR0(s)[e+1]<<16) | (STR0(s)[e+2]<<8) | STR0(s)[e+3]);    pop_stack();    push_string(finish_string_builder(&b));    return;       case 0xfffe0000:    pos = 4; -  /* FALL_THROUGH */ +  /* FALLTHRU */    case 0x3c000000: /* UCS4 4321 byte order (little endian)*/    IF_XMLDEBUG(fprintf(stderr,"UCS4(4321) detected.\n"));    init_string_builder(&b,4);    for(e=pos;e<s->len;e+=4)    string_builder_putchar(&b,    (STR0(s)[e+3]<<24) | (STR0(s)[e+2]<<16) | (STR0(s)[e+1]<<8) | STR0(s)[e+0]);    pop_stack();    push_string(finish_string_builder(&b));    return;       case 0x0000fffe:    pos = 4; -  /* FALL_THROUGH */ +  /* FALLTHRU */    case 0x00003c00: /* UCS4 2143 byte order */    IF_XMLDEBUG(fprintf(stderr,"UCS4(2143) detected.\n"));    init_string_builder(&b,4);    for(e=pos;e<s->len;e+=4)    string_builder_putchar(&b,    (STR0(s)[e+1]<<24) | (STR0(s)[e+0]<<16) | (STR0(s)[e+3]<<8) | STR0(s)[e+2]);    pop_stack();    push_string(finish_string_builder(&b));    return;       case 0xfeff0000:    pos = 4; -  /* FALL_THROUGH */ +  /* FALLTHRU */    case 0x003c0000: /* UCS4 3412 byte order */    IF_XMLDEBUG(fprintf(stderr,"UCS4(3412) detected.\n"));    init_string_builder(&b,4);    for(e=pos;e<s->len;e+=4)    string_builder_putchar(&b,    (STR0(s)[e+2]<<24) | (STR0(s)[e+3]<<16) | (STR0(s)[e+0]<<8) | STR0(s)[e+1]);    pop_stack();    push_string(finish_string_builder(&b));    return;   
pike.git/src/modules/Parser/xml.cmod:3386:    case 0x3c3f786d: /* ASCII? UTF-8? ISO-8859? */    {    int encstart;       IF_XMLDEBUG(fprintf(stderr,"Extended ASCII detected (assuming UTF8).\n"));    pos = 5;    /* <?xml. version */    while(isSpace(STR0(s)[pos])) pos++;       /* "autoconvert: <?xml .version */ -  if(MEMCMP(STR0(s)+pos,"version",7)) break; +  if(memcmp(STR0(s)+pos,"version",7)) break;    pos+=7;       /* <?xml version. = "1.0" */    while(isSpace(STR0(s)[pos])) pos++;       /* <?xml version .= "1.0" */    if(STR0(s)[pos]!='=') break;    pos++;       /* <?xml version =. "1.0" */
pike.git/src/modules/Parser/xml.cmod:3419:    while(STR0(s)[pos] && STR0(s)[pos]!='\"') pos++;    pos++;    }else{    break; /* No encoding detected */    }       /* <?xml version = "1.0". encoding="encname" */    while(isSpace(STR0(s)[pos])) pos++;       /* <?xml version = "1.0" .encoding="encname" */ -  if(MEMCMP("encoding",STR0(s)+pos,8)) break; +  if(memcmp("encoding",STR0(s)+pos,8)) break;    pos+=8;       /* <?xml version = "1.0" encoding. ="encname" */    while(isSpace(STR0(s)[pos])) pos++;       /* <?xml version = "1.0" encoding .="encname" */    if(STR0(s)[pos]!='=') break;    pos++;       /* <?xml version = "1.0" encoding =. "encname" */
pike.git/src/modules/Parser/xml.cmod:3448:    }    else if(STR0(s)[pos]=='"')    {    pos++;    while(STR0(s)[pos] && STR0(s)[pos]!='\"') pos++;    }else{    break; /* No encoding detected */    }    /* <?xml version = "1.0" encoding = "encname." */    -  push_constant_text("Charset.decoder"); +  push_static_text("Charset.decoder");    APPLY_MASTER("resolv",1);    push_string(make_shared_binary_string0(STR0(s)+encstart,    pos-encstart));    f_call_function(2); -  push_constant_text("feed"); +  push_static_text("feed");    f_index(2);    stack_swap();    f_call_function(2); -  push_constant_text("drain"); +  push_static_text("drain");    f_index(2);    f_call_function(1);    return;    }       case 0x4c6fa794: /* EBCDIC */    IF_XMLDEBUG(fprintf(stderr,"EBCDIC detected.\n"));    Pike_error("XML: EBCDIC not supported yet.\n");    }    }
pike.git/src/modules/Parser/xml.cmod:3480:   }      /*! @endmodule    */      /*! @endmodule    */      void init_parser_xml(void)   { -  push_text("location"); +  push_static_text("location");    location_string_svalue=sp[-1];    sp--;       INIT;       ADD_FUNCTION("isbasechar",f_isBaseChar,tFunc(tInt,tInt),0);    ADD_FUNCTION("isidographic",f_isIdeographic,tFunc(tInt,tInt),0);    ADD_FUNCTION("isletter",f_isLetter,tFunc(tInt,tInt),0);    ADD_FUNCTION("iscombiningchar",f_isCombiningChar,tFunc(tInt,tInt),0);    ADD_FUNCTION("isdigit",f_isDigit,tFunc(tInt,tInt),0);