/[suikacvs]/markup/html/whatpm/Whatpm/HTML.pm.src
Suika

Diff of /markup/html/whatpm/Whatpm/HTML.pm.src

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.170 by wakaba, Sat Sep 13 12:25:44 2008 UTC revision 1.174 by wakaba, Sun Sep 14 06:32:49 2008 UTC
# Line 561  sub parse_byte_stream ($$$$;$$) { Line 561  sub parse_byte_stream ($$$$;$$) {
561    my $char_onerror = sub {    my $char_onerror = sub {
562      my (undef, $type, %opt) = @_;      my (undef, $type, %opt) = @_;
563      !!!parse-error (layer => 'encode',      !!!parse-error (layer => 'encode',
564                      %opt, type => $type,                      line => $self->{line}, column => $self->{column} + 1,
565                      line => $self->{line}, column => $self->{column} + 1);                      %opt, type => $type);
566      if ($opt{octets}) {      if ($opt{octets}) {
567        ${$opt{octets}} = "\x{FFFD}"; # relacement character        ${$opt{octets}} = "\x{FFFD}"; # relacement character
568      }      }
# Line 618  sub parse_byte_stream ($$$$;$$) { Line 618  sub parse_byte_stream ($$$$;$$) {
618  sub parse_char_string ($$$;$$) {  sub parse_char_string ($$$;$$) {
619    #my ($self, $s, $doc, $onerror, $get_wrapper) = @_;    #my ($self, $s, $doc, $onerror, $get_wrapper) = @_;
620    my $self = shift;    my $self = shift;
   require utf8;  
621    my $s = ref $_[0] ? $_[0] : \($_[0]);    my $s = ref $_[0] ? $_[0] : \($_[0]);
622    open my $input, '<' . (utf8::is_utf8 ($$s) ? ':utf8' : ''), $s;    require Whatpm::Charset::DecodeHandle;
623      my $input = Whatpm::Charset::DecodeHandle::CharString->new ($s);
624    if ($_[3]) {    if ($_[3]) {
625      $input = $_[3]->($input);      $input = $_[3]->($input);
626    }    }
# Line 689  sub parse_char_stream ($$$;$) { Line 689  sub parse_char_stream ($$$;$) {
689               (0x007F <= $self->{next_char} and $self->{next_char} <= 0x009F) or               (0x007F <= $self->{next_char} and $self->{next_char} <= 0x009F) or
690               (0xD800 <= $self->{next_char} and $self->{next_char} <= 0xDFFF) or               (0xD800 <= $self->{next_char} and $self->{next_char} <= 0xDFFF) or
691               (0xFDD0 <= $self->{next_char} and $self->{next_char} <= 0xFDDF) or               (0xFDD0 <= $self->{next_char} and $self->{next_char} <= 0xFDDF) or
692    ## ISSUE: U+FDE0-U+FDEF are not excluded
693               {               {
694                0xFFFE => 1, 0xFFFF => 1, 0x1FFFE => 1, 0x1FFFF => 1,                0xFFFE => 1, 0xFFFF => 1, 0x1FFFE => 1, 0x1FFFF => 1,
695                0x2FFFE => 1, 0x2FFFF => 1, 0x3FFFE => 1, 0x3FFFF => 1,                0x2FFFE => 1, 0x2FFFF => 1, 0x3FFFE => 1, 0x3FFFF => 1,
# Line 713  sub parse_char_stream ($$$;$) { Line 714  sub parse_char_stream ($$$;$) {
714    $self->{prev_char} = [-1, -1, -1];    $self->{prev_char} = [-1, -1, -1];
715    $self->{next_char} = -1;    $self->{next_char} = -1;
716    
717      $self->{read_until} = sub {
718        #my ($scalar, $specials_range, $offset) = @_;
719        my $specials_range = $_[1];
720        return 0 if defined $self->{next_next_char};
721        my $count = $input->manakai_read_until
722           ($_[0],
723            qr/(?![$specials_range\x{FDD0}-\x{FDDF}\x{FFFD}-\x{FFFF}\x{1FFFE}\x{1FFFF}\x{2FFFE}\x{2FFFF}\x{3FFFE}\x{3FFFF}\x{4FFFE}\x{4FFFF}\x{5FFFE}\x{5FFFF}\x{6FFFE}\x{6FFFF}\x{7FFFE}\x{7FFFF}\x{8FFFE}\x{8FFFF}\x{9FFFE}\x{9FFFF}\x{AFFFE}\x{AFFFF}\x{BFFFE}\x{BFFFF}\x{CFFFE}\x{CFFFF}\x{DFFFE}\x{DFFFF}\x{EFFFE}\x{EFFFF}\x{FFFFE}\x{FFFFF}])[\x20-\x7E\xA0-\x{D7FF}\x{E000}-\x{10FFFD}]/,
724            $_[2]);
725            ## NOTE: We need to exclude U+FFFD, otherwise reported line/column
726            ## of unassigned/illegal code point error would be wrong.
727        if ($count) {
728          $self->{column} += $count;
729          $self->{column_prev} += $count;
730          $self->{prev_char} = [-1, -1, -1];
731          $self->{next_char} = -1;
732        }
733        return $count;
734      }; # $self->{read_until}
735    
736    my $onerror = $_[2] || sub {    my $onerror = $_[2] || sub {
737      my (%opt) = @_;      my (%opt) = @_;
738      my $line = $opt{token} ? $opt{token}->{line} : $opt{line};      my $line = $opt{token} ? $opt{token}->{line} : $opt{line};
# Line 1009  sub _get_next_token ($) { Line 1029  sub _get_next_token ($) {
1029                     data => chr $self->{next_char},                     data => chr $self->{next_char},
1030                     line => $self->{line}, column => $self->{column},                     line => $self->{line}, column => $self->{column},
1031                    };                    };
1032          $self->{read_until}->($token->{data}, q[-!<>&], length $token->{data});
1033    
1034        ## Stay in the data state        ## Stay in the data state
1035        !!!next-input-character;        !!!next-input-character;
1036    
# Line 1723  sub _get_next_token ($) { Line 1745  sub _get_next_token ($) {
1745        } else {        } else {
1746          !!!cp (100);          !!!cp (100);
1747          $self->{current_attribute}->{value} .= chr ($self->{next_char});          $self->{current_attribute}->{value} .= chr ($self->{next_char});
1748            $self->{read_until}->($self->{current_attribute}->{value},
1749                                  q["&],
1750                                  length $self->{current_attribute}->{value});
1751    
1752          ## Stay in the state          ## Stay in the state
1753          !!!next-input-character;          !!!next-input-character;
1754          redo A;          redo A;
# Line 1770  sub _get_next_token ($) { Line 1796  sub _get_next_token ($) {
1796        } else {        } else {
1797          !!!cp (106);          !!!cp (106);
1798          $self->{current_attribute}->{value} .= chr ($self->{next_char});          $self->{current_attribute}->{value} .= chr ($self->{next_char});
1799            $self->{read_until}->($self->{current_attribute}->{value},
1800                                  q['&],
1801                                  length $self->{current_attribute}->{value});
1802    
1803          ## Stay in the state          ## Stay in the state
1804          !!!next-input-character;          !!!next-input-character;
1805          redo A;          redo A;
# Line 1852  sub _get_next_token ($) { Line 1882  sub _get_next_token ($) {
1882            !!!cp (116);            !!!cp (116);
1883          }          }
1884          $self->{current_attribute}->{value} .= chr ($self->{next_char});          $self->{current_attribute}->{value} .= chr ($self->{next_char});
1885            $self->{read_until}->($self->{current_attribute}->{value},
1886                                  q["'=& >],
1887                                  length $self->{current_attribute}->{value});
1888    
1889          ## Stay in the state          ## Stay in the state
1890          !!!next-input-character;          !!!next-input-character;
1891          redo A;          redo A;
# Line 1996  sub _get_next_token ($) { Line 2030  sub _get_next_token ($) {
2030        } else {        } else {
2031          !!!cp (126);          !!!cp (126);
2032          $self->{current_token}->{data} .= chr ($self->{next_char}); # comment          $self->{current_token}->{data} .= chr ($self->{next_char}); # comment
2033            $self->{read_until}->($self->{current_token}->{data},
2034                                  q[>],
2035                                  length $self->{current_token}->{data});
2036    
2037          ## Stay in the state.          ## Stay in the state.
2038          !!!next-input-character;          !!!next-input-character;
2039          redo A;          redo A;
# Line 2230  sub _get_next_token ($) { Line 2268  sub _get_next_token ($) {
2268        } else {        } else {
2269          !!!cp (147);          !!!cp (147);
2270          $self->{current_token}->{data} .= chr ($self->{next_char}); # comment          $self->{current_token}->{data} .= chr ($self->{next_char}); # comment
2271            $self->{read_until}->($self->{current_token}->{data},
2272                                  q[-],
2273                                  length $self->{current_token}->{data});
2274    
2275          ## Stay in the state          ## Stay in the state
2276          !!!next-input-character;          !!!next-input-character;
2277          redo A;          redo A;
# Line 2595  sub _get_next_token ($) { Line 2637  sub _get_next_token ($) {
2637          !!!cp (190);          !!!cp (190);
2638          $self->{current_token}->{public_identifier} # DOCTYPE          $self->{current_token}->{public_identifier} # DOCTYPE
2639              .= chr $self->{next_char};              .= chr $self->{next_char};
2640            $self->{read_until}->($self->{current_token}->{public_identifier},
2641                                  q[">],
2642                                  length $self->{current_token}->{public_identifier});
2643    
2644          ## Stay in the state          ## Stay in the state
2645          !!!next-input-character;          !!!next-input-character;
2646          redo A;          redo A;
# Line 2631  sub _get_next_token ($) { Line 2677  sub _get_next_token ($) {
2677          !!!cp (194);          !!!cp (194);
2678          $self->{current_token}->{public_identifier} # DOCTYPE          $self->{current_token}->{public_identifier} # DOCTYPE
2679              .= chr $self->{next_char};              .= chr $self->{next_char};
2680            $self->{read_until}->($self->{current_token}->{public_identifier},
2681                                  q['>],
2682                                  length $self->{current_token}->{public_identifier});
2683    
2684          ## Stay in the state          ## Stay in the state
2685          !!!next-input-character;          !!!next-input-character;
2686          redo A;          redo A;
# Line 2767  sub _get_next_token ($) { Line 2817  sub _get_next_token ($) {
2817          !!!cp (210);          !!!cp (210);
2818          $self->{current_token}->{system_identifier} # DOCTYPE          $self->{current_token}->{system_identifier} # DOCTYPE
2819              .= chr $self->{next_char};              .= chr $self->{next_char};
2820            $self->{read_until}->($self->{current_token}->{system_identifier},
2821                                  q[">],
2822                                  length $self->{current_token}->{system_identifier});
2823    
2824          ## Stay in the state          ## Stay in the state
2825          !!!next-input-character;          !!!next-input-character;
2826          redo A;          redo A;
# Line 2803  sub _get_next_token ($) { Line 2857  sub _get_next_token ($) {
2857          !!!cp (214);          !!!cp (214);
2858          $self->{current_token}->{system_identifier} # DOCTYPE          $self->{current_token}->{system_identifier} # DOCTYPE
2859              .= chr $self->{next_char};              .= chr $self->{next_char};
2860            $self->{read_until}->($self->{current_token}->{system_identifier},
2861                                  q['>],
2862                                  length $self->{current_token}->{system_identifier});
2863    
2864          ## Stay in the state          ## Stay in the state
2865          !!!next-input-character;          !!!next-input-character;
2866          redo A;          redo A;
# Line 2863  sub _get_next_token ($) { Line 2921  sub _get_next_token ($) {
2921          redo A;          redo A;
2922        } else {        } else {
2923          !!!cp (221);          !!!cp (221);
2924            my $s = '';
2925            $self->{read_until}->($s, q[>], 0);
2926    
2927          ## Stay in the state          ## Stay in the state
2928          !!!next-input-character;          !!!next-input-character;
2929          redo A;          redo A;
# Line 2891  sub _get_next_token ($) { Line 2952  sub _get_next_token ($) {
2952        } else {        } else {
2953          !!!cp (221.4);          !!!cp (221.4);
2954          $self->{current_token}->{data} .= chr $self->{next_char};          $self->{current_token}->{data} .= chr $self->{next_char};
2955            $self->{read_until}->($self->{current_token}->{data},
2956                                  q<]>,
2957                                  length $self->{current_token}->{data});
2958    
2959          ## Stay in the state.          ## Stay in the state.
2960          !!!next-input-character;          !!!next-input-character;
2961          redo A;          redo A;
# Line 7774  sub set_inner_html ($$$;$) { Line 7839  sub set_inner_html ($$$;$) {
7839      };      };
7840      $p->{prev_char} = [-1, -1, -1];      $p->{prev_char} = [-1, -1, -1];
7841      $p->{next_char} = -1;      $p->{next_char} = -1;
7842        
7843        $p->{read_until} = sub {
7844          ## TODO: ...
7845          return 0;
7846        }; # $p->{read_until};
7847    
7848      my $ponerror = $onerror || sub {      my $ponerror = $onerror || sub {
7849        my (%opt) = @_;        my (%opt) = @_;
7850        my $line = $opt{line};        my $line = $opt{line};

Legend:
Removed from v.1.170  
changed lines
  Added in v.1.174

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24