r41026 - in /branches/upstream/libxml-bare-perl/current: Bare.pm Bare.xs Changes META.yml Makefile.PL parser.c

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Thu Jul 30 20:39:04 UTC 2009


Author: jawnsy-guest
Date: Thu Jul 30 20:38:56 2009
New Revision: 41026

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=41026
Log:
[svn-upgrade] Integrating new upstream version, libxml-bare-perl (0.44)

Modified:
    branches/upstream/libxml-bare-perl/current/Bare.pm
    branches/upstream/libxml-bare-perl/current/Bare.xs
    branches/upstream/libxml-bare-perl/current/Changes
    branches/upstream/libxml-bare-perl/current/META.yml
    branches/upstream/libxml-bare-perl/current/Makefile.PL
    branches/upstream/libxml-bare-perl/current/parser.c

Modified: branches/upstream/libxml-bare-perl/current/Bare.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-bare-perl/current/Bare.pm?rev=41026&op=diff
==============================================================================
--- branches/upstream/libxml-bare-perl/current/Bare.pm (original)
+++ branches/upstream/libxml-bare-perl/current/Bare.pm Thu Jul 30 20:38:56 2009
@@ -8,7 +8,7 @@
 @ISA = qw(Exporter DynaLoader);
 
 
-$VERSION = "0.43";
+$VERSION = "0.44";
 
 
 use vars qw($VERSION *AUTOLOAD);
@@ -552,7 +552,7 @@
   my ( $objs, $name, $pad, $level, $pdex ) = @_;
   
   $level  = 0  if( !$level );
-  $pad    = '' if(  $level == 1 );
+  $pad    = '' if(  $level <= 2 );
   my $xml = '';
   my $att = '';
   my $imm = 1;
@@ -561,18 +561,21 @@
   my @dex = sort { 
     my $oba = $objs->{ $a };
     my $obb = $objs->{ $b };
-    if( !$oba ) { return 0; }
-    if( !$obb ) { return 0; }
+    my $posa = 0;
+    my $posb = 0;
+    if( !$oba ) { $posa = 0; }
+    if( !$obb ) { $posb = 0; }
     $oba = $oba->[0] if( ref( $oba ) eq 'ARRAY' );
     $obb = $obb->[0] if( ref( $obb ) eq 'ARRAY' );
-    if( ref( $oba ) eq 'HASH' && ref( $obb ) eq 'HASH' ) {
-      my $posa = $oba->{'_pos'}*1;
-      my $posb = $obb->{'_pos'}*1;
+    if( ref( $oba ) eq 'HASH' ) {
+      $posa = $oba->{'_pos'};
       if( !$posa ) { $posa = 0; }
+    }
+    if( ref( $obb ) eq 'HASH' ) {
+      $posb = $obb->{'_pos'};
       if( !$posb ) { $posb = 0; }
-      return $posa <=> $posb;
-    }
-    return 0;
+    }
+    return $posa <=> $posb;
   } keys %$objs;
   for my $i ( @dex ) {
     my $obj  = $objs->{ $i } || '';
@@ -621,8 +624,15 @@
   my $pad2 = $imm ? '' : $pad;
   my $cr = $imm ? '' : "\n";
   if( substr( $name, 0, 1 ) ne '_' ) {
-    if( $name ) { $xml = $pad . '<' . $name . $att . '>' . $cr . $xml . $pad2 . '</' . $name . '>'; }
-    return $xml."\n" if( $level );
+    if( $name ) {
+      if( $xml ) {
+        $xml = $pad . '<' . $name . $att . '>' . $cr . $xml . $pad2 . '</' . $name . '>';
+      }
+      else {
+        $xml = $pad . '<' . $name . $att . ' />';
+      }
+    }
+    return $xml."\n" if( $level > 1 );
     return $xml;
   }
   return '';
@@ -653,18 +663,18 @@
   my @dex = sort { 
     my $oba = $objs->{ $a };
     my $obb = $objs->{ $b };
-    if( !$oba ) { return 0; }
-    if( !$obb ) { return 0; }
+    my ( $posa, $posb );
+    if( !$oba ) { $posa = 0; }
+    if( !$obb ) { $posb = 0; }
     $oba = $oba->[0] if( ref( $oba ) eq 'ARRAY' );
     $obb = $obb->[0] if( ref( $obb ) eq 'ARRAY' );
     if( ref( $oba ) eq 'HASH' && ref( $obb ) eq 'HASH' ) {
-      my $posa = $oba->{'_pos'}*1;
-      my $posb = $obb->{'_pos'}*1;
+      $posa = $oba->{'_pos'};
+      $posb = $obb->{'_pos'};
       if( !$posa ) { $posa = 0; }
       if( !$posb ) { $posb = 0; }
-      return $posa <=> $posb;
-    }
-    return 0;
+    }
+    return $posa <=> $posb;
   } keys %$objs;
   
   if( $objs->{'_cdata'} ) {

Modified: branches/upstream/libxml-bare-perl/current/Bare.xs
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-bare-perl/current/Bare.xs?rev=41026&op=diff
==============================================================================
--- branches/upstream/libxml-bare-perl/current/Bare.xs (original)
+++ branches/upstream/libxml-bare-perl/current/Bare.xs Thu Jul 30 20:38:56 2009
@@ -39,6 +39,7 @@
   if( !length ) {
     if( curnode->vallen ) {
       SV * sv = newSVpvn( curnode->value, curnode->vallen );
+      SvUTF8_on(sv);
       hv_store( output, "value", 5, sv, vhash );
       if( curnode->type ) {
         SV *svi = newSViv( 1 );
@@ -47,12 +48,14 @@
     }
     if( curnode->comlen ) {
       SV * sv = newSVpvn( curnode->comment, curnode->comlen );
+      SvUTF8_on(sv);
       hv_store( output, "comment", 7, sv, chash );
     }
   }
   else {
     if( curnode->vallen ) {
       SV *sv = newSVpvn( curnode->value, curnode->vallen );
+      SvUTF8_on(sv);
       hv_store( output, "value", 5, sv, vhash );
       if( curnode->type ) {
         SV *svi = newSViv( 1 );
@@ -61,6 +64,7 @@
     }
     if( curnode->comlen ) {
       SV *sv = newSVpvn( curnode->comment, curnode->comlen );
+      SvUTF8_on(sv);
       hv_store( output, "comment", 7, sv, chash );
     }
     
@@ -97,13 +101,12 @@
         if( SvTYPE( SvRV(*cur) ) == SVt_PVHV ) {
           AV *newarray = newAV();
           SV *newarrayref = newRV_noinc( (SV *) newarray );
-          
           SV *newref = newRV( (SV *) SvRV( *cur ) );
-          
+          SV *ob;
           hv_delete( output, curnode->name, curnode->namelen, 0 );
           hv_store( output, curnode->name, curnode->namelen, newarrayref, 0 );
           av_push( newarray, newref );
-          SV *ob = cxml2obj();
+          ob = cxml2obj();
           av_push( newarray, ob );
         }
         else {
@@ -126,6 +129,7 @@
       hv_store( output, curatt->name, curatt->namelen, atthref, 0 );
       
       attval = newSVpvn( curatt->value, curatt->vallen );
+      SvUTF8_on(attval);
       hv_store( atth, "value", 5, attval, vhash );
       attatt = newSViv( 1 );
       hv_store( atth, "_att", 4, attatt, ahash );
@@ -141,23 +145,27 @@
   int numatts = curnode->numatt;
   SV *attval;
   SV *attatt;
-    
+  HV *output;
+  SV *outputref;
+  
   int length = curnode->numchildren;
   if( ( length + numatts ) == 0 ) {
     if( curnode->vallen ) {
       SV * sv = newSVpvn( curnode->value, curnode->vallen );
+      SvUTF8_on(sv);
       return sv;
     }
     return newSViv( 1 ); //&PL_sv_undef;
   }
   
-  HV *output = newHV();
-  SV *outputref = newRV( (SV *) output );
+  output = newHV();
+  outputref = newRV( (SV *) output );
   
   if( length ) {
     curnode = curnode->firstchild;
     for( i = 0; i < length; i++ ) {
       SV *namesv = newSVpvn( curnode->name, curnode->namelen );
+      SvUTF8_on(namesv);
       
       SV **cur = hv_fetch( output, curnode->name, curnode->namelen, 0 );
       
@@ -209,6 +217,7 @@
           STRLEN len;
           char *ptr = SvPV(*cur, len);
           SV *newsv = newSVpvn( ptr, len );
+          SvUTF8_on(newsv);
           
           av_push( newarray, newsv );
           hv_delete( output, curnode->name, curnode->namelen, 0 );
@@ -225,6 +234,7 @@
     curatt = curnode->firstatt;
     for( i = 0; i < numatts; i++ ) {
       attval = newSVpvn( curatt->value, curatt->vallen );
+      SvUTF8_on(attval);
       hv_store( output, curatt->name, curatt->namelen, attval, 0 );
       if( i != ( numatts - 1 ) ) curatt = curatt->next;
     }
@@ -273,6 +283,10 @@
 c_parsefile(filename)
   char * filename
   CODE:
+    char *data;
+    unsigned long len;
+    FILE *handle;
+    
     PERL_HASH(vhash, "value", 5);
     PERL_HASH(ahash, "_att", 4);
     PERL_HASH(chash, "comment", 7);
@@ -280,9 +294,7 @@
     PERL_HASH(ihash, "_i", 2 );
     PERL_HASH(zhash, "_z", 2 );
     PERL_HASH(cdhash, "_cdata", 6 );
-    char *data;
-    unsigned long len;
-    FILE *handle;
+    
     handle = fopen(filename,"r");
     
     fseek( handle, 0, SEEK_END );

Modified: branches/upstream/libxml-bare-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-bare-perl/current/Changes?rev=41026&op=diff
==============================================================================
--- branches/upstream/libxml-bare-perl/current/Changes (original)
+++ branches/upstream/libxml-bare-perl/current/Changes Thu Jul 30 20:38:56 2009
@@ -1,4 +1,11 @@
 XML::Bare Changelog
+
+0.44
+  - Self closing nodes now printed by xml function
+  - UTF8 Handling fixed; thanks go to Nigel Metheringham for the fix
+    recommendation as well as the test files
+  - Static linking has been fixed
+  - 'cc' now used properly in cases where 'gcc' is absent
 
 0.43 ( 3-17-09 )
   - Fixed newly broken add_node problem from 0.42

Modified: branches/upstream/libxml-bare-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-bare-perl/current/META.yml?rev=41026&op=diff
==============================================================================
--- branches/upstream/libxml-bare-perl/current/META.yml (original)
+++ branches/upstream/libxml-bare-perl/current/META.yml Thu Jul 30 20:38:56 2009
@@ -1,22 +1,16 @@
 --- #YAML:1.0
-name:               XML-Bare
-version:            0.43
-abstract:           A minimal XML parser / schema checker / pretty-printer using C internally.
-author:
+name:                XML-Bare
+version:             0.44
+abstract:            A minimal XML parser / schema checker / pretty-printer using C internally.
+license:             perl
+author:              
     - David Helkowski <cpan at codechild.com>
-license:            perl
-distribution_type:  module
-configure_requires:
-    ExtUtils::MakeMaker:  0
-requires:
-    Carp:        0
-    DynaLoader:  0
-    Exporter:    0
-no_index:
-    directory:
-        - t
-        - inc
-generated_by:       ExtUtils::MakeMaker version 6.48
+generated_by:        ExtUtils::MakeMaker version 6.44
+distribution_type:   module
+requires:     
+    Carp:                          0
+    DynaLoader:                    0
+    Exporter:                      0
 meta-spec:
-    url:      http://module-build.sourceforge.net/META-spec-v1.4.html
-    version:  1.4
+    url:     http://module-build.sourceforge.net/META-spec-v1.3.html
+    version: 1.3

Modified: branches/upstream/libxml-bare-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-bare-perl/current/Makefile.PL?rev=41026&op=diff
==============================================================================
--- branches/upstream/libxml-bare-perl/current/Makefile.PL (original)
+++ branches/upstream/libxml-bare-perl/current/Makefile.PL Thu Jul 30 20:38:56 2009
@@ -8,11 +8,15 @@
                PREREQ_PM    => { Carp => 0, Exporter => 0, DynaLoader => 0 },
                #OPTIMIZE     => '-O3 -msse2 -march=pentium4 --omit-frame-pointer',
              );
+my $cc = getcc();
+if( $cc ) {
+  push( @basics, CC => $cc );
+}
 if( $ExtUtils::MakeMaker::VERSION >= 6.31 ) {
   push( @basics, LICENSE => 'perl' );
 }
 
-if( $^O eq 'MSWin32' && !has_cc() ) {
+if( $^O eq 'MSWin32' && !$cc ) {
   gen_msvc(); # special case for msvc
 }
 elsif( $^O eq 'darwin' ) {
@@ -24,14 +28,19 @@
 sub gen_msvc {
   require Config;
   my $libpath = Config->{'archlibexp'};
-  my $ver = $]*1000; # correct for possibile division problems
-  my ($major,$minor,$sub) = unpack("AA3xA3","$ver");
-  $major *= 1; $minor *= 1; $sub *= 1;
+  my $ver = $]*1000000;
+  my $sub = $ver % 1000;
+  $ver -= $sub;
+  $ver /= 1000;
+  my $minor = $ver % 1000;
+  $ver -= $minor;
+  my $major = $ver / 1000;
   WriteMakefile( @basics,
     CCFLAGS   => "/MT /DWIN32 /TP /DNOSTRING",
     LIBS      => ["$libpath\\core\\perl$major$minor.lib"],
     OBJECT    => 'Bare.o parser.o',
-    LDDLFLAGS => '/DLL',
+    LDDLFLAGS => '/DLL /NODEFAULTLIB:libcmt',
+    #OPTIMIZE  => '-Zl -DNDEBUG -O1', # Because -MD is included by default BLEH
   );
 }
 sub gen_cc {
@@ -53,13 +62,33 @@
     LDDLFLAGS => '',
   );
 }
-sub has_cc {
+sub getcc {
   my $div = (substr($ENV{'PATH'},0,1) eq '/') ? ':' : ';';
   my @path = split($div,$ENV{'PATH'});
   foreach my $dir ( @path ) {
-    return 1 if( -e "$dir/cc" ||
-                 -e "$dir/gcc" ||
-                 -e "$dir/cc.exe" ||
-                 -e "$dir/gcc.exe" ); }
+    return 'gcc' if( -e "$dir/gcc" || -e "$dir/gcc.exe" ); # prefer gcc
+    return 'cc'  if( -e "$dir/cc"  || -e "$dir/cc.exe"  );
+  }               
   return 0;
 }
+
+# The following are hacks to force static linking and so remove need for msvcr## dll
+package MY;
+
+sub cflags {
+  my $res = shift->SUPER::cflags( @_ );
+  if( $^O eq 'MSWin32' ) {
+    $res =~ s/-O1/-O2/g;
+    $res =~ s/-MD/-MT/g;
+  }
+  return $res;
+}
+
+sub const_loadlibs {
+  my $res = shift->SUPER::const_loadlibs( @_ );
+  if( $^O eq 'MSWin32' ) {
+    $res =~ s/msvcrt\.lib/libcmt\.lib/gi;
+  }
+  return $res;
+}
+

Modified: branches/upstream/libxml-bare-perl/current/parser.c
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-bare-perl/current/parser.c?rev=41026&op=diff
==============================================================================
--- branches/upstream/libxml-bare-perl/current/parser.c (original)
+++ branches/upstream/libxml-bare-perl/current/parser.c Thu Jul 30 20:38:56 2009
@@ -81,6 +81,7 @@
     char   *cpos          = &xmlin[0];
     int    pos            = 0;
     int    res            = 0;
+    int    dent;
     register int let;
     
     #ifdef DEBUG
@@ -151,18 +152,6 @@
       cpos++;
       goto val_x;
       
-    outside:
-      #ifdef DEBUG
-      printf("outside: %c\n", *cpos);
-      #endif
-      if( *cpos == '<' ) {
-        tagname_len = 0; // for safety
-        cpos++;
-        goto name_1;
-      }
-      cpos++;
-      goto outside;
-      
     comment_1dash:
       cpos++;
       let = *cpos;
@@ -244,8 +233,6 @@
       let = *cpos;
       if( !let ) goto done;
       switch( let ) {
-        case 0:
-          goto done;
         case ' ':
         case 0x0d:
         case 0x0a:
@@ -316,8 +303,21 @@
           goto name_gap;//actually goto error
       }
         
+    att_name1:
+      #ifdef DEBUG
+      printf("attname1: %c\n", *cpos);
+      #endif
+      let = *cpos;
+      switch( *cpos ) {
+        case 0: goto done;
+        case 0x27:
+          cpos++;
+          attname = cpos;
+          attname_len = 0;
+          goto att_nameqs;
+      }
       attname = cpos;
-      attname_len = 1; // this really is needed... don't remove it
+      attname_len = 1;
       cpos++;
       goto att_name;
       
@@ -337,7 +337,9 @@
       // we have another attribute name, so continue
         
     att_name:
-      
+      #ifdef DEBUG
+      printf("attname: %c\n", *cpos);
+      #endif
       let = *cpos;
       switch( let ) {
         case 0: goto done;
@@ -376,6 +378,37 @@
       attname_len++;
       cpos++;
       goto att_name;
+      
+    att_nameqs:
+      #ifdef DEBUG
+      printf("nameqs: %c\n", *cpos);
+      #endif
+      let = *cpos;
+      switch( let ) {
+        case 0: goto done;
+        case 0x27:
+          cpos++;
+          goto att_nameqsdone;
+      }
+      attname_len++;
+      cpos++;
+      goto att_nameqs;
+      
+    att_nameqsdone:
+      #ifdef DEBUG
+      printf("nameqsdone: %c\n", *cpos);
+      #endif
+      let = *cpos;
+      switch( let ) {
+        case 0: goto done;
+        case '=':
+          attval_len = 0;
+          curatt = nodec_addattr( curnode, attname, attname_len );
+          attname_len = 0;
+          cpos++;
+          goto att_eq1;
+      }
+      goto att_nameqsdone;
       
     att_eq1:
       let = *cpos;
@@ -397,6 +430,9 @@
         case 0x27: // '
           cpos++;
           goto att_quots;
+        case '`':
+          cpos++;
+          goto att_tick;
         case '>':
           cpos++;
           goto val_1;
@@ -482,7 +518,24 @@
         cpos++;
         goto att_quots;
       }
-    
+      
+    att_tick:
+      let = *cpos;
+      if( !let ) goto done;
+      if( let == '`' ) {
+        if( attval_len ) {
+          curatt->value = attval;
+          curatt->vallen = attval_len;
+          attval_len = 0;
+        }
+        cpos++;
+        goto name_gap;
+      }
+      if( !attval_len ) attval = cpos;
+      attval_len++;
+      cpos++;
+      goto att_tick;
+      
     ename_1:
       let = *cpos;
       if( !let ) goto done;
@@ -543,6 +596,484 @@
       #endif
       return root;
 }
+
+struct utfchar {
+  char high;
+  char low;
+};
+
+/*struct nodec* parserc_parse_utf16( struct parserc *self, short *xmlin ) {
+    char  *tagname, *attname, *attval, *val;
+    struct nodec *root    = new_nodec();
+    int    tagname_len    = 0;
+    int    attname_len    = 0;
+    int    attval_len     = 0;
+    struct nodec *curnode = root;
+    struct nodec *temp;
+    struct attc  *curatt  = NULL;
+    short  *cpos          = &xmlin[0];
+    int    pos            = 0;
+    int    res            = 0;
+    short  let;
+    
+    #ifdef DEBUG
+    printf("Entry to C Parser\n");
+    #endif
+    
+    val_1:
+      #ifdef DEBUG
+      printf("val_1: %c\n", *cpos);
+      #endif
+      let = *cpos;
+      switch( let ) {
+        case 0:   goto done;
+        case '<': goto val_x;
+      }
+      if( !curnode->numvals ) {
+        curnode->value = cpos;
+        curnode->vallen = 1;
+      }
+      curnode->numvals++;
+      cpos++;
+      
+    val_x:
+      #ifdef DEBUG
+      printf("val_x: %c\n", *cpos);
+      #endif
+      let = *cpos;
+      switch( let ) {
+        case 0:
+          goto done;
+        case '<':
+          switch( *(cpos+1) ) {
+            case '!':
+              if( *(cpos+2) == '[' ) { // <![
+                //if( !strncmp( cpos+3, "CDATA", 5 ) ) {
+                if( *(cpos+3) == 'C' &&
+                    *(cpos+4) == 'D' &&
+                    *(cpos+5) == 'A' &&
+                    *(cpos+6) == 'T' &&
+                    *(cpos+7) == 'A'    ) {
+                  cpos += 9;
+                  curnode->type = 1;
+                  goto cdata;
+                }
+                else {
+                  cpos++; cpos++;
+                  goto val_x;//actually goto error...
+                }
+              }
+              else if( *(cpos+2) == '-' && // <!--
+                *(cpos+3) == '-' ) {
+                  cpos += 4;
+                  goto comment;
+              }
+              else {
+                cpos++;
+                goto bang;
+              }
+            case '?':
+              cpos+=2;
+              goto pi;
+          }
+          tagname_len = 0; // for safety
+          cpos++;
+          goto name_1;
+      }
+      if( curnode->numvals == 1 ) curnode->vallen++;
+      cpos++;
+      goto val_x;
+      
+    outside:
+      #ifdef DEBUG
+      printf("outside: %c\n", *cpos);
+      #endif
+      if( *cpos == '<' ) {
+        tagname_len = 0; // for safety
+        cpos++;
+        goto name_1;
+      }
+      cpos++;
+      goto outside;
+      
+    comment_1dash:
+      cpos++;
+      let = *cpos;
+      if( let == '-' ) goto comment_2dash;
+      goto comment_x;
+      
+    comment_2dash:
+      cpos++;
+      let = *cpos;
+      if( let == '>' ) {
+        cpos++;
+        goto val_1;
+      }
+      goto comment_x;
+      
+    comment:
+      let = *cpos;
+      switch( let ) {
+        case 0:   goto done;
+        case '-': goto comment_1dash;
+      }
+      if( !curnode->numcoms ) {
+        curnode->comment = cpos;
+        curnode->comlen = 1;
+      }
+      curnode->numcoms++;
+      cpos++;
+    
+    comment_x:
+      let = *cpos;
+      switch( let ) {
+        case 0: goto done;
+        case '-': goto comment_1dash;
+      }
+      if( curnode->numcoms == 1 ) curnode->comlen++;
+      cpos++;
+      goto comment_x;
+      
+    pi:
+      let = *cpos;
+      if( !let ) goto done;
+      if( let == '?' && *(cpos+1) == '>' ) {
+        cpos += 2;
+        goto val_1;
+      }
+      cpos++;
+      goto pi;
+
+    bang:
+      let = *cpos;
+      if( !let ) goto done;
+      if( let == '>' ) {
+        cpos++;
+        goto val_1;
+      }
+      cpos++;
+      goto bang;
+    
+    cdata:
+      let = *cpos;
+      if( !let ) goto done;
+      if( let == ']' && *(cpos+1) == ']' && *(cpos+2) == '>' ) {
+        cpos += 3;
+        goto val_1;
+      }
+      if( !curnode->numvals ) {
+        curnode->value = cpos;
+        curnode->vallen = 0;
+        curnode->numvals = 1;
+      }
+      if( curnode->numvals == 1 ) curnode->vallen++;
+      cpos++;
+      goto cdata;
+      
+    name_1:
+      #ifdef DEBUG
+      printf("name_1: %c\n", *cpos);
+      #endif
+      let = *cpos;
+      if( !let ) goto done;
+      switch( let ) {
+        case ' ':
+        case 0x0d:
+        case 0x0a:
+          cpos++;
+          goto name_1;
+        case '/': // regular closing tag
+          tagname_len = 0; // needed to reset
+          cpos++;
+          goto ename_1;
+      }
+      tagname       = cpos;
+      tagname_len   = 1;
+      cpos++;
+      goto name_x;
+      
+    name_x:
+      #ifdef DEBUG
+      printf("name_x: %c\n", *cpos);
+      #endif
+      let = *cpos;
+      switch( let ) {
+        case 0:
+          goto done;
+        case ' ':
+        case 0x0d:
+        case 0x0a:
+          curnode     = nodec_addchildr( curnode, tagname, tagname_len );
+          attname_len = 0;
+          cpos++;
+          goto name_gap;
+        case '>':
+          curnode     = nodec_addchildr( curnode, tagname, tagname_len );
+          cpos++;
+          goto val_1;
+        case '/': // self closing
+          temp = nodec_addchildr( curnode, tagname, tagname_len );
+          temp->z = cpos +1 - xmlin;
+          tagname_len            = 0;
+          cpos+=2;
+          goto val_1;
+      }
+      
+      tagname_len++;
+      cpos++;
+      goto name_x;
+          
+    name_gap:
+      let = *cpos;
+      switch( *cpos ) {
+        case 0:
+          goto done;
+        case ' ':
+        case 0x0d:
+        case 0x0a:
+          cpos++;
+          goto name_gap;
+        case '>':
+          cpos++;
+          goto val_1;
+        case '/': // self closing
+          curnode->z = cpos+1-xmlin;
+          curnode = curnode->parent;
+          if( !curnode ) goto done;
+          cpos+=2; // am assuming next char is >
+          goto val_1;
+        case '=':
+          cpos++;
+          goto name_gap;//actually goto error
+      }
+        
+      attname = cpos;
+      attname_len = 1; // this really is needed... don't remove it
+      cpos++;
+      goto att_name;
+      
+    att_space:
+      let = *cpos;
+      switch( let ) {
+        case 0: goto done;
+        case ' ':
+        case 0x0d:
+        case 0x0a:
+          cpos++;
+          goto att_space;
+        case '=':
+          cpos++;
+          goto att_eq1;
+      }
+      // we have another attribute name, so continue
+        
+    att_name:
+      
+      let = *cpos;
+      switch( let ) {
+        case 0: goto done;
+        case '/': // self closing     !! /> is assumed !!
+          curatt = nodec_addattr( curnode, attname, attname_len );
+          attname_len            = 0;
+          
+          curnode->z = cpos+1-xmlin;
+          curnode = curnode->parent;
+          if( !curnode ) goto done;
+          cpos += 2;
+          goto val_1;
+        case ' ':
+          if( *(cpos+1) == '=' ) {
+            cpos++;
+            goto att_name;
+          }
+          curatt = nodec_addattr( curnode, attname, attname_len );
+          attname_len = 0;
+          cpos++;
+          goto att_space;
+        case '>':
+          curatt = nodec_addattr( curnode, attname, attname_len );
+          attname_len = 0;
+          cpos++;
+          goto val_1;
+        case '=':
+          attval_len = 0;
+          curatt = nodec_addattr( curnode, attname, attname_len );
+          attname_len = 0;
+          cpos++;
+          goto att_eq1;
+      }
+      
+      if( !attname_len ) attname = cpos;
+      attname_len++;
+      cpos++;
+      goto att_name;
+      
+    att_eq1:
+      let = *cpos;
+      switch( let ) {
+        case 0:
+          goto done;
+        case '/': // self closing
+          if( *(cpos+1) == '>' ) {
+            curnode->z = cpos+1-xmlin;
+            curnode = curnode->parent;
+            if( !curnode ) goto done;
+            cpos+=2;
+            goto att_eq1;
+          }
+          break;
+        case '"':
+          cpos++;
+          goto att_quot;
+        case 0x27: // '
+          cpos++;
+          goto att_quots;
+        case '>':
+          cpos++;
+          goto val_1;
+        case ' ':
+          cpos++;
+          goto att_eq1;
+      }  
+      if( !attval_len ) attval = cpos;
+      attval_len++;
+      cpos++;
+      goto att_eqx;
+      
+    att_eqx:
+      let = *cpos;
+      switch( let ) {
+        case 0:
+          goto done;
+        case '/': // self closing
+          if( *(cpos+1) == '>' ) {
+            curnode->z = cpos+1-xmlin;
+            curnode = curnode->parent;
+            if( !curnode ) goto done;
+            curatt->value = attval;
+            curatt->vallen = attval_len;
+            attval_len    = 0;
+            cpos += 2;
+            goto val_1;
+          }
+          break;
+        case '>':
+          curatt->value = attval;
+          curatt->vallen = attval_len;
+          attval_len    = 0;
+          cpos++;
+          goto val_1;
+        case ' ':
+          curatt->value = attval;
+          curatt->vallen = attval_len;
+          attval_len    = 0;
+          cpos++;
+          goto name_gap;
+      }
+      
+      if( !attval_len ) attval = cpos;
+      attval_len++;
+      cpos++;
+      goto att_eqx;
+      
+    att_quot:
+      let = *cpos;
+      if( !let ) goto done;
+      if( let == '"' ) {
+        if( attval_len ) {
+          curatt->value = attval;
+          curatt->vallen = attval_len;
+          attval_len = 0;
+        }
+        cpos++;
+        goto name_gap;
+      }
+      else {
+        if( !attval_len ) attval = cpos;
+        attval_len++;
+        cpos++;
+        goto att_quot;
+      }
+      
+    att_quots:
+      let = *cpos;
+      if( !let ) goto done;
+      if( let == 0x27 ) {
+        if( attval_len ) {
+          curatt->value = attval;
+          curatt->vallen = attval_len;
+          attval_len = 0;
+        }
+        cpos++;
+        goto name_gap;
+      }
+      else {
+        if( !attval_len ) attval = cpos;
+        attval_len++;
+        cpos++;
+        goto att_quots;
+      }
+    
+    ename_1:
+      let = *cpos;
+      if( !let ) goto done;
+      
+      if( let == '>' ) {
+        curnode->namelen = tagname_len;
+        curnode->z = cpos-xmlin;
+        curnode = curnode->parent; // jump up
+        if( !curnode ) goto done;
+        tagname_len++;
+        cpos++;
+        root->err = -1;
+        goto error;
+      }
+      tagname       = cpos;
+      tagname_len   = 1;
+      cpos++;
+      // continue
+      
+    ename_x: // ending name
+      let = *cpos;
+      if( !let ) goto done;
+      if( let == '>' ) {
+        //curnode->namelen = tagname_len;
+        
+        if( curnode->namelen != tagname_len ) {
+          goto error;
+        }
+        if( res = dh_memcmp( curnode->name, tagname, tagname_len ) ) {
+          cpos -= tagname_len;
+          cpos += res - 1;
+          goto error;
+        }
+        curnode->z = cpos-xmlin;
+        curnode = curnode->parent; // jump up
+        if( !curnode ) goto done;
+        tagname_len++;
+        cpos++;
+        
+        goto val_1;
+      }
+      tagname_len++;
+      cpos++;
+      goto ename_x;
+    error:
+      root->err = - ( int ) ( cpos - &xmlin[0] );
+      self->pcurnode = root;
+      //root->err = 1;
+      return root;
+    done:
+      #ifdef DEBUG
+      printf("done\n", *cpos);
+      #endif
+      self->pcurnode = root;
+      self->pcurnode->curchild = self->pcurnode->firstchild;
+      #ifdef DEBUG
+      printf("returning\n", *cpos);
+      #endif
+      return root;
+}*/
 
 struct nodec *nodec_addchildr(  struct nodec *self, char *newname, int newnamelen ) {//, char *newval, int newvallen, int newtype ) {
   struct nodec *newnode = new_nodecp( self );




More information about the Pkg-perl-cvs-commits mailing list