HTML::Parser 3.40/3.41 and UTF8 on perl 5.8.0

HTML::Parser 3.40/3.41 and UTF8 on perl 5.8.0

am 02.12.2004 00:17:12 von Russell.Reed

The sv_catpvn_utf8_upgrade macro used in hparser.c in versions 3.40 and 3.41
of HTML::Parser doesn't seem to exist in Perl 5.8.0. Can the macro be
replaced, so that the module is compatible with this version of Perl?

Following is a patch to do what I'm requesting, in unified diff format.

Russell Reed
Russell.Reed[at]acxiom.com

--- hparser.c 2004-11-29 07:35:58.000000000 -0600
+++ hparser.c.new 2004-12-01 17:13:08.000000000 -0600
@@ -301,7 +301,13 @@
}
else {
SV *tmp = NULL;
+/* Not defined in Perl 5.8.0
sv_catpvn_utf8_upgrade(p_state->pend_text, beg, end -
beg, tmp);
+*/
+ tmp = sv_2mortal(newSVpvn(beg, end - beg));
+ SvUTF8_off(tmp);
+ sv_utf8_upgrade(tmp);
+ sv_catsv(p_state->pend_text, tmp);
}
#else
sv_catpvn(p_state->pend_text, beg, end - beg);
@@ -640,7 +646,13 @@
}
else {
SV *tmp = NULL;
+/* Not defined in Perl 5.8.0
sv_catpvn_utf8_upgrade(p_state->skipped_text, beg, end -
beg, tmp);
+*/
+ tmp = sv_2mortal(newSVpvn(beg, end - beg));
+ SvUTF8_off(tmp);
+ sv_utf8_upgrade(tmp);
+ sv_catsv(p_state->skipped_text, tmp);
}
#endif
}



************************************************************ **********
The information contained in this communication is
confidential, is intended only for the use of the recipient
named above, and may be legally privileged.
If the reader of this message is not the intended
recipient, you are hereby notified that any dissemination,
distribution, or copying of this communication is strictly
prohibited.
If you have received this communication in error,
please re-send this communication to the sender and
delete the original message or any copy of it from your
computer system. Thank You.

Re: HTML::Parser 3.40/3.41 and UTF8 on perl 5.8.0

am 02.12.2004 12:55:18 von gisle

Reed Russell - rreed writes:

> The sv_catpvn_utf8_upgrade macro used in hparser.c in versions 3.40 and 3.41
> of HTML::Parser doesn't seem to exist in Perl 5.8.0. Can the macro be
> replaced, so that the module is compatible with this version of Perl?

Sure. Applied. I've simpified your patch to be:

Index: hparser.c
============================================================ =======
RCS file: /cvsroot/libwww-perl/html-parser/hparser.c,v
retrieving revision 2.117
diff -u -p -r2.117 hparser.c
--- hparser.c 2 Dec 2004 11:14:59 -0000 2.117
+++ hparser.c 2 Dec 2004 11:50:59 -0000
@@ -300,8 +300,10 @@ report_event(PSTATE* p_state,
sv_catpvn(p_state->pend_text, beg, end - beg);
}
else {
- SV *tmp = NULL;
- sv_catpvn_utf8_upgrade(p_state->pend_text, beg, end - beg, tmp);
+ SV *tmp = newSVpvn(beg, end - beg);
+ sv_utf8_upgrade(tmp);
+ sv_catsv(p_state->pend_text, tmp);
+ SvREFCNT_dec(tmp);
}
#else
sv_catpvn(p_state->pend_text, beg, end - beg);
@@ -639,8 +641,10 @@ IGNORE_EVENT:
#ifdef UNICODE_HTML_PARSER
}
else {
- SV *tmp = NULL;
- sv_catpvn_utf8_upgrade(p_state->skipped_text, beg, end - beg, tmp);
+ SV *tmp = newSVpvn(beg, end - beg);
+ sv_utf8_upgrade(tmp);
+ sv_catsv(p_state->pend_text, tmp);
+ SvREFCNT_dec(tmp);
}
#endif
}