From: Nicholas Clark Date: Wed, 5 Sep 2001 20:54:24 +0000 (+0100) Subject: Re: [ID 20010825.006] -DCRIPPLED_CC is broken X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6e9d10810a2ec27ec94fd014e5dbab341c35afb1;p=p5sagit%2Fp5-mst-13.2.git Re: [ID 20010825.006] -DCRIPPLED_CC is broken Message-ID: <20010905205424.C25120@plum.flirble.org> p4raw-id: //depot/perl@11892 --- diff --git a/embed.h b/embed.h index 08749c2..47ae070 100644 --- a/embed.h +++ b/embed.h @@ -639,8 +639,10 @@ #define sv_2iv Perl_sv_2iv #define sv_2mortal Perl_sv_2mortal #define sv_2nv Perl_sv_2nv +#define sv_2pv Perl_sv_2pv #define sv_2pvutf8 Perl_sv_2pvutf8 #define sv_2pvbyte Perl_sv_2pvbyte +#define sv_pvn_nomg Perl_sv_pvn_nomg #define sv_2uv Perl_sv_2uv #define sv_iv Perl_sv_iv #define sv_uv Perl_sv_uv @@ -655,6 +657,8 @@ #define sv_catpvf Perl_sv_catpvf #define sv_vcatpvf Perl_sv_vcatpvf #define sv_catpv Perl_sv_catpv +#define sv_catpvn Perl_sv_catpvn +#define sv_catsv Perl_sv_catsv #define sv_chop Perl_sv_chop #define sv_clean_all Perl_sv_clean_all #define sv_clean_objs Perl_sv_clean_objs @@ -687,6 +691,7 @@ #define sv_peek Perl_sv_peek #define sv_pos_u2b Perl_sv_pos_u2b #define sv_pos_b2u Perl_sv_pos_b2u +#define sv_pvn_force Perl_sv_pvn_force #define sv_pvutf8n_force Perl_sv_pvutf8n_force #define sv_pvbyten_force Perl_sv_pvbyten_force #define sv_reftype Perl_sv_reftype @@ -706,6 +711,7 @@ #define sv_setref_pvn Perl_sv_setref_pvn #define sv_setpv Perl_sv_setpv #define sv_setpvn Perl_sv_setpvn +#define sv_setsv Perl_sv_setsv #define sv_taint Perl_sv_taint #define sv_tainted Perl_sv_tainted #define sv_unmagic Perl_sv_unmagic @@ -825,6 +831,7 @@ #define sv_pv Perl_sv_pv #define sv_pvutf8 Perl_sv_pvutf8 #define sv_pvbyte Perl_sv_pvbyte +#define sv_utf8_upgrade Perl_sv_utf8_upgrade #define sv_utf8_downgrade Perl_sv_utf8_downgrade #define sv_utf8_encode Perl_sv_utf8_encode #define sv_utf8_decode Perl_sv_utf8_decode @@ -2153,8 +2160,10 @@ #define sv_2iv(a) Perl_sv_2iv(aTHX_ a) #define sv_2mortal(a) Perl_sv_2mortal(aTHX_ a) #define sv_2nv(a) Perl_sv_2nv(aTHX_ a) +#define sv_2pv(a,b) Perl_sv_2pv(aTHX_ a,b) #define sv_2pvutf8(a,b) Perl_sv_2pvutf8(aTHX_ a,b) #define sv_2pvbyte(a,b) Perl_sv_2pvbyte(aTHX_ a,b) +#define sv_pvn_nomg(a,b) Perl_sv_pvn_nomg(aTHX_ a,b) #define sv_2uv(a) Perl_sv_2uv(aTHX_ a) #define sv_iv(a) Perl_sv_iv(aTHX_ a) #define sv_uv(a) Perl_sv_uv(aTHX_ a) @@ -2168,6 +2177,8 @@ #define sv_bless(a,b) Perl_sv_bless(aTHX_ a,b) #define sv_vcatpvf(a,b,c) Perl_sv_vcatpvf(aTHX_ a,b,c) #define sv_catpv(a,b) Perl_sv_catpv(aTHX_ a,b) +#define sv_catpvn(a,b,c) Perl_sv_catpvn(aTHX_ a,b,c) +#define sv_catsv(a,b) Perl_sv_catsv(aTHX_ a,b) #define sv_chop(a,b) Perl_sv_chop(aTHX_ a,b) #define sv_clean_all() Perl_sv_clean_all(aTHX) #define sv_clean_objs() Perl_sv_clean_objs(aTHX) @@ -2200,6 +2211,7 @@ #define sv_peek(a) Perl_sv_peek(aTHX_ a) #define sv_pos_u2b(a,b,c) Perl_sv_pos_u2b(aTHX_ a,b,c) #define sv_pos_b2u(a,b) Perl_sv_pos_b2u(aTHX_ a,b) +#define sv_pvn_force(a,b) Perl_sv_pvn_force(aTHX_ a,b) #define sv_pvutf8n_force(a,b) Perl_sv_pvutf8n_force(aTHX_ a,b) #define sv_pvbyten_force(a,b) Perl_sv_pvbyten_force(aTHX_ a,b) #define sv_reftype(a,b) Perl_sv_reftype(aTHX_ a,b) @@ -2218,6 +2230,7 @@ #define sv_setref_pvn(a,b,c,d) Perl_sv_setref_pvn(aTHX_ a,b,c,d) #define sv_setpv(a,b) Perl_sv_setpv(aTHX_ a,b) #define sv_setpvn(a,b,c) Perl_sv_setpvn(aTHX_ a,b,c) +#define sv_setsv(a,b) Perl_sv_setsv(aTHX_ a,b) #define sv_taint(a) Perl_sv_taint(aTHX_ a) #define sv_tainted(a) Perl_sv_tainted(aTHX_ a) #define sv_unmagic(a,b) Perl_sv_unmagic(aTHX_ a,b) @@ -2331,6 +2344,7 @@ #define sv_pv(a) Perl_sv_pv(aTHX_ a) #define sv_pvutf8(a) Perl_sv_pvutf8(aTHX_ a) #define sv_pvbyte(a) Perl_sv_pvbyte(aTHX_ a) +#define sv_utf8_upgrade(a) Perl_sv_utf8_upgrade(aTHX_ a) #define sv_utf8_downgrade(a,b) Perl_sv_utf8_downgrade(aTHX_ a,b) #define sv_utf8_encode(a) Perl_sv_utf8_encode(aTHX_ a) #define sv_utf8_decode(a) Perl_sv_utf8_decode(aTHX_ a) diff --git a/embed.pl b/embed.pl index 915baff..c303c01 100755 --- a/embed.pl +++ b/embed.pl @@ -1720,9 +1720,10 @@ Apd |IO* |sv_2io |SV* sv Apd |IV |sv_2iv |SV* sv Apd |SV* |sv_2mortal |SV* sv Apd |NV |sv_2nv |SV* sv -Aop |char* |sv_2pv |SV* sv|STRLEN* lp +Ap |char* |sv_2pv |SV* sv|STRLEN* lp Apd |char* |sv_2pvutf8 |SV* sv|STRLEN* lp Apd |char* |sv_2pvbyte |SV* sv|STRLEN* lp +Ap |char* |sv_pvn_nomg |SV* sv|STRLEN* lp Apd |UV |sv_2uv |SV* sv Apd |IV |sv_iv |SV* sv Apd |UV |sv_uv |SV* sv @@ -1737,8 +1738,8 @@ Apd |SV* |sv_bless |SV* sv|HV* stash Afpd |void |sv_catpvf |SV* sv|const char* pat|... Ap |void |sv_vcatpvf |SV* sv|const char* pat|va_list* args Apd |void |sv_catpv |SV* sv|const char* ptr -Aopd |void |sv_catpvn |SV* sv|const char* ptr|STRLEN len -Aopd |void |sv_catsv |SV* dsv|SV* ssv +Apd |void |sv_catpvn |SV* sv|const char* ptr|STRLEN len +Apd |void |sv_catsv |SV* dsv|SV* ssv Apd |void |sv_chop |SV* sv|char* ptr pd |I32 |sv_clean_all pd |void |sv_clean_objs @@ -1773,7 +1774,7 @@ Apd |SV* |sv_newref |SV* sv Ap |char* |sv_peek |SV* sv Apd |void |sv_pos_u2b |SV* sv|I32* offsetp|I32* lenp Apd |void |sv_pos_b2u |SV* sv|I32* offsetp -Aopd |char* |sv_pvn_force |SV* sv|STRLEN* lp +Apd |char* |sv_pvn_force |SV* sv|STRLEN* lp Apd |char* |sv_pvutf8n_force|SV* sv|STRLEN* lp Apd |char* |sv_pvbyten_force|SV* sv|STRLEN* lp Apd |char* |sv_reftype |SV* sv|int ob @@ -1794,7 +1795,7 @@ Apd |SV* |sv_setref_pvn |SV* rv|const char* classname|char* pv \ |STRLEN n Apd |void |sv_setpv |SV* sv|const char* ptr Apd |void |sv_setpvn |SV* sv|const char* ptr|STRLEN len -Aopd |void |sv_setsv |SV* dsv|SV* ssv +Apd |void |sv_setsv |SV* dsv|SV* ssv Apd |void |sv_taint |SV* sv Apd |bool |sv_tainted |SV* sv Apd |int |sv_unmagic |SV* sv|int type @@ -1925,7 +1926,7 @@ Apd |char* |sv_2pvbyte_nolen|SV* sv Apd |char* |sv_pv |SV *sv Apd |char* |sv_pvutf8 |SV *sv Apd |char* |sv_pvbyte |SV *sv -Aopd |STRLEN |sv_utf8_upgrade|SV *sv +Apd |STRLEN |sv_utf8_upgrade|SV *sv ApdM |bool |sv_utf8_downgrade|SV *sv|bool fail_ok Apd |void |sv_utf8_encode |SV *sv ApdM |bool |sv_utf8_decode |SV *sv diff --git a/global.sym b/global.sym index ee9f7b8..ab477a0 100644 --- a/global.sym +++ b/global.sym @@ -211,8 +211,11 @@ Perl_op_null Perl_load_module Perl_vload_module Perl_looks_like_number +Perl_grok_bin +Perl_grok_hex Perl_grok_number Perl_grok_numeric_radix +Perl_grok_oct Perl_markstack_grow Perl_mess Perl_vmess @@ -395,6 +398,7 @@ Perl_sv_2nv Perl_sv_2pv Perl_sv_2pvutf8 Perl_sv_2pvbyte +Perl_sv_pvn_nomg Perl_sv_2uv Perl_sv_iv Perl_sv_uv diff --git a/pod/perlapi.pod b/pod/perlapi.pod index dc7f320..0c76cff 100644 --- a/pod/perlapi.pod +++ b/pod/perlapi.pod @@ -559,6 +559,56 @@ respectively. =for hackers Found in file op.h +=item grok_bin + +converts a string representing a binary number to numeric form. + +On entry I and I<*len> give the string to scan, I<*flags> gives +conversion flags, and I should be NULL or a pointer to an NV. +The scan stops at the end of the string, or the first invalid character. +On return I<*len> is set to the length scanned string, and I<*flags> gives +output flags. + +If the value is <= UV_MAX it is returned as a UV, the output flags are clear, +and nothing is written to I<*result>. If the value is > UV_MAX C +returns UV_MAX, sets C in the output flags, +and writes the value to I<*result> (or the value is discarded if I +is NULL). + +The hex number may optinally be prefixed with "0b" or "b". If +C is set in I<*flags> on entry then the binary +number may use '_' characters to separate digits. + + UV grok_bin(char* start, STRLEN* len, I32* flags, NV *result) + +=for hackers +Found in file numeric.c + +=item grok_hex + +converts a string representing a hex number to numeric form. + +On entry I and I<*len> give the string to scan, I<*flags> gives +conversion flags, and I should be NULL or a pointer to an NV. +The scan stops at the end of the string, or the first non-hex-digit character. +On return I<*len> is set to the length scanned string, and I<*flags> gives +output flags. + +If the value is <= UV_MAX it is returned as a UV, the output flags are clear, +and nothing is written to I<*result>. If the value is > UV_MAX C +returns UV_MAX, sets C in the output flags, +and writes the value to I<*result> (or the value is discarded if I +is NULL). + +The hex number may optinally be prefixed with "0x" or "x". If +C is set in I<*flags> on entry then the hex +number may use '_' characters to separate digits. + + UV grok_hex(char* start, STRLEN* len, I32* flags, NV *result) + +=for hackers +Found in file numeric.c + =item grok_number Recognise (or not) a number. The type of the number is returned @@ -593,6 +643,14 @@ Scan and skip for a numeric decimal separator (radix). =for hackers Found in file numeric.c +=item grok_oct + + + UV grok_oct(char* start, STRLEN* len, I32* flags, NV *result) + +=for hackers +Found in file numeric.c + =item GvSV Return the SV from the GV. @@ -1870,6 +1928,33 @@ L. =for hackers Found in file scope.h +=item scan_bin + +For backwards compatibility. Use C instead. + + NV scan_bin(char* start, STRLEN len, STRLEN* retlen) + +=for hackers +Found in file numeric.c + +=item scan_hex + +For backwards compatibility. Use C instead. + + NV scan_hex(char* start, STRLEN len, STRLEN* retlen) + +=for hackers +Found in file numeric.c + +=item scan_oct + +For backwards compatibility. Use C instead. + + NV scan_oct(char* start, STRLEN len, STRLEN* retlen) + +=for hackers +Found in file numeric.c + =item sharedsv_find Tries to find if a given SV has a shared backend, either by @@ -2183,22 +2268,22 @@ version which guarantees to evaluate sv only once. =for hackers Found in file sv.h -=item SvIVx +=item SvIVX -Coerces the given SV to an integer and returns it. Guarantees to evaluate -sv only once. Use the more efficent C otherwise. +Returns the raw value in the SV's IV slot, without checks or conversions. +Only use when you are sure SvIOK is true. See also C. - IV SvIVx(SV* sv) + IV SvIVX(SV* sv) =for hackers Found in file sv.h -=item SvIVX +=item SvIVx -Returns the raw value in the SV's IV slot, without checks or conversions. -Only use when you are sure SvIOK is true. See also C. +Coerces the given SV to an integer and returns it. Guarantees to evaluate +sv only once. Use the more efficent C otherwise. - IV SvIVX(SV* sv) + IV SvIVx(SV* sv) =for hackers Found in file sv.h @@ -2507,21 +2592,21 @@ Like C, but converts sv to uft8 first if necessary. =for hackers Found in file sv.h -=item SvPVx +=item SvPVX -A version of C which guarantees to evaluate sv only once. +Returns a pointer to the physical string in the SV. The SV must contain a +string. - char* SvPVx(SV* sv, STRLEN len) + char* SvPVX(SV* sv) =for hackers Found in file sv.h -=item SvPVX +=item SvPVx -Returns a pointer to the physical string in the SV. The SV must contain a -string. +A version of C which guarantees to evaluate sv only once. - char* SvPVX(SV* sv) + char* SvPVx(SV* sv, STRLEN len) =for hackers Found in file sv.h diff --git a/proto.h b/proto.h index 9b9c4c1..769145a 100644 --- a/proto.h +++ b/proto.h @@ -706,6 +706,7 @@ PERL_CALLCONV NV Perl_sv_2nv(pTHX_ SV* sv); PERL_CALLCONV char* Perl_sv_2pv(pTHX_ SV* sv, STRLEN* lp); PERL_CALLCONV char* Perl_sv_2pvutf8(pTHX_ SV* sv, STRLEN* lp); PERL_CALLCONV char* Perl_sv_2pvbyte(pTHX_ SV* sv, STRLEN* lp); +PERL_CALLCONV char* Perl_sv_pvn_nomg(pTHX_ SV* sv, STRLEN* lp); PERL_CALLCONV UV Perl_sv_2uv(pTHX_ SV* sv); PERL_CALLCONV IV Perl_sv_iv(pTHX_ SV* sv); PERL_CALLCONV UV Perl_sv_uv(pTHX_ SV* sv); diff --git a/sv.c b/sv.c index f31855b..9f9d105 100644 --- a/sv.c +++ b/sv.c @@ -6721,6 +6721,19 @@ Perl_sv_pvn(pTHX_ SV *sv, STRLEN *lp) return sv_2pv(sv, lp); } +/* For -DCRIPPLED_CC only. See also C. + */ + +char * +Perl_sv_pvn_nomg(pTHX_ register SV *sv, STRLEN *lp) +{ + if (SvPOK(sv)) { + *lp = SvCUR(sv); + return SvPVX(sv); + } + return sv_2pv_flags(sv, lp, 0); +} + /* =for apidoc sv_pvn_force diff --git a/sv.h b/sv.h index e43d29a..c5b82c2 100644 --- a/sv.h +++ b/sv.h @@ -922,6 +922,8 @@ otherwise. #define SvPV_force(sv, lp) sv_pvn_force(sv, &lp) #define SvPV(sv, lp) sv_pvn(sv, &lp) #define SvPV_nolen(sv) sv_pv(sv) +#define SvPV_nomg(sv, lp) sv_pvn_nomg(sv, &lp) +#define SvPV_force_flags(sv, lp, flags) sv_pvn_force_flags(sv, &lp, flags) #define SvPVutf8_force(sv, lp) sv_pvutf8n_force(sv, &lp) #define SvPVutf8(sv, lp) sv_pvutf8n(sv, &lp) @@ -949,6 +951,14 @@ otherwise. #define SvUV(sv) SvUVx(sv) #define SvTRUE(sv) SvTRUEx(sv) +/* flag values for sv_*_flags functions */ +#define SV_IMMEDIATE_UNREF 1 +#define SV_GMAGIC 2 + +#define sv_pvn_force_nomg(sv, lp) sv_pvn_force_flags(sv, lp, 0) +#define sv_utf8_upgrade_nomg(sv) sv_utf8_upgrade_flags(sv, 0) +#define sv_catpvn_nomg(dsv, sstr, slen) sv_catpvn_flags(dsv, sstr, slen, 0) + #ifndef CRIPPLED_CC /* redefine some things to more efficient inlined versions */ @@ -962,29 +972,28 @@ otherwise. #undef SvNV #define SvNV(sv) (SvNOK(sv) ? SvNVX(sv) : sv_2nv(sv)) -/* flag values for sv_*_flags functions */ -#define SV_IMMEDIATE_UNREF 1 -#define SV_GMAGIC 2 - #define sv_setsv_macro(dsv, ssv) sv_setsv_flags(dsv, ssv, SV_GMAGIC) #define sv_setsv_nomg(dsv, ssv) sv_setsv_flags(dsv, ssv, 0) #define sv_catsv_macro(dsv, ssv) sv_catsv_flags(dsv, ssv, SV_GMAGIC) #define sv_catsv_nomg(dsv, ssv) sv_catsv_flags(dsv, ssv, 0) #define sv_catpvn_macro(dsv, sstr, slen) sv_catpvn_flags(dsv, sstr, slen, SV_GMAGIC) -#define sv_catpvn_nomg(dsv, sstr, slen) sv_catpvn_flags(dsv, sstr, slen, 0) #define sv_2pv_macro(sv, lp) sv_2pv_flags(sv, lp, SV_GMAGIC) #define sv_2pv_nomg(sv, lp) sv_2pv_flags(sv, lp, 0) #define sv_pvn_force_macro(sv, lp) sv_pvn_force_flags(sv, lp, SV_GMAGIC) -#define sv_pvn_force_nomg(sv, lp) sv_pvn_force_flags(sv, lp, 0) #define sv_utf8_upgrade_macro(sv) sv_utf8_upgrade_flags(sv, SV_GMAGIC) -#define sv_utf8_upgrade_nomg(sv) sv_utf8_upgrade_flags(sv, 0) -/* function style also available for bincompat */ +/* function style also available for sourcecompat */ +#undef sv_setsv #define sv_setsv(dsv, ssv) sv_setsv_macro(dsv, ssv) +#undef sv_catsv #define sv_catsv(dsv, ssv) sv_catsv_macro(dsv, ssv) +#undef sv_catpvn #define sv_catpvn(dsv, sstr, slen) sv_catpvn_macro(dsv, sstr, slen) +#undef sv_2pv #define sv_2pv(sv, lp) sv_2pv_macro(sv, lp) +#undef sv_pvn_force #define sv_pvn_force(sv, lp) sv_pvn_force_macro(sv, lp) +#undef sv_utf8_upgrade #define sv_utf8_upgrade(sv) sv_utf8_upgrade_macro(sv) #undef SvPV