Skip to content

Commit

Permalink
support for v5.5.640 style version numbers
Browse files Browse the repository at this point in the history
p4raw-id: //depot/utfperl@4705
  • Loading branch information
Gurusamy Sarathy committed Dec 24, 1999
1 parent c63481e commit a7cb1f9
Show file tree
Hide file tree
Showing 13 changed files with 242 additions and 79 deletions.
4 changes: 2 additions & 2 deletions configpm
Expand Up @@ -17,7 +17,7 @@ my $glossary = $ARGV[1] || 'Porting/Glossary';


open CONFIG, ">$config_pm" or die "Can't open $config_pm: $!\n";
$myver = $];
$myver = 0+$];

print CONFIG <<'ENDOFBEG_NOQ', <<"ENDOFBEG";
package Config;
Expand All @@ -39,7 +39,7 @@ sub import {

ENDOFBEG_NOQ
\$] == $myver
or die "Perl lib version ($myver) doesn't match executable version (\$])";
or die "Perl lib version ($myver) doesn't match executable version (" . 0+\$] . ")";

# This file was created by configpm when Perl was built. Any changes
# made to this file will be lost the next time perl is built.
Expand Down
4 changes: 0 additions & 4 deletions embedvar.h
Expand Up @@ -191,7 +191,6 @@
#define PL_StdIO (PERL_GET_INTERP->IStdIO)
#define PL_amagic_generation (PERL_GET_INTERP->Iamagic_generation)
#define PL_an (PERL_GET_INTERP->Ian)
#define PL_archpat_auto (PERL_GET_INTERP->Iarchpat_auto)
#define PL_argvgv (PERL_GET_INTERP->Iargvgv)
#define PL_argvout_stack (PERL_GET_INTERP->Iargvout_stack)
#define PL_argvoutgv (PERL_GET_INTERP->Iargvoutgv)
Expand Down Expand Up @@ -456,7 +455,6 @@
#define PL_StdIO (vTHX->IStdIO)
#define PL_amagic_generation (vTHX->Iamagic_generation)
#define PL_an (vTHX->Ian)
#define PL_archpat_auto (vTHX->Iarchpat_auto)
#define PL_argvgv (vTHX->Iargvgv)
#define PL_argvout_stack (vTHX->Iargvout_stack)
#define PL_argvoutgv (vTHX->Iargvoutgv)
Expand Down Expand Up @@ -858,7 +856,6 @@
#define PL_StdIO (aTHXo->interp.IStdIO)
#define PL_amagic_generation (aTHXo->interp.Iamagic_generation)
#define PL_an (aTHXo->interp.Ian)
#define PL_archpat_auto (aTHXo->interp.Iarchpat_auto)
#define PL_argvgv (aTHXo->interp.Iargvgv)
#define PL_argvout_stack (aTHXo->interp.Iargvout_stack)
#define PL_argvoutgv (aTHXo->interp.Iargvoutgv)
Expand Down Expand Up @@ -1124,7 +1121,6 @@
#define PL_IStdIO PL_StdIO
#define PL_Iamagic_generation PL_amagic_generation
#define PL_Ian PL_an
#define PL_Iarchpat_auto PL_archpat_auto
#define PL_Iargvgv PL_argvgv
#define PL_Iargvout_stack PL_argvout_stack
#define PL_Iargvoutgv PL_argvoutgv
Expand Down
6 changes: 2 additions & 4 deletions gv.c
Expand Up @@ -812,10 +812,8 @@ Perl_gv_fetchpv(pTHX_ const char *nambeg, I32 add, I32 sv_type)
case ']':
if (len == 1) {
SV *sv = GvSV(gv);
(void)SvUPGRADE(sv, SVt_PVNV);
sv_setpv(sv, PL_patchlevel);
(void)sv_2nv(sv);
SvREADONLY_on(sv);
GvSV(gv) = SvREFCNT_inc(PL_patchlevel);
SvREFCNT_dec(sv);
}
break;
}
Expand Down
3 changes: 1 addition & 2 deletions intrpvar.h
Expand Up @@ -25,7 +25,7 @@ PERLVAR(Iwarnhook, SV *)

/* switches */
PERLVAR(Iminus_c, bool)
PERLVARA(Ipatchlevel,10,char)
PERLVAR(Ipatchlevel, SV *)
PERLVAR(Ilocalpatches, char **)
PERLVARI(Isplitstr, char *, " ")
PERLVAR(Ipreprocess, bool)
Expand Down Expand Up @@ -170,7 +170,6 @@ PERLVAR(Isys_intern, struct interp_intern)
/* more statics moved here */
PERLVARI(Igeneration, int, 100) /* from op.c */
PERLVAR(IDBcv, CV *) /* from perl.c */
PERLVAR(Iarchpat_auto, char*) /* from perl.c */

PERLVARI(Iin_clean_objs,bool, FALSE) /* from sv.c */
PERLVARI(Iin_clean_all, bool, FALSE) /* from sv.c */
Expand Down
2 changes: 0 additions & 2 deletions objXSUB.h
Expand Up @@ -48,8 +48,6 @@
#define PL_amagic_generation (*Perl_Iamagic_generation_ptr(aTHXo))
#undef PL_an
#define PL_an (*Perl_Ian_ptr(aTHXo))
#undef PL_archpat_auto
#define PL_archpat_auto (*Perl_Iarchpat_auto_ptr(aTHXo))
#undef PL_argvgv
#define PL_argvgv (*Perl_Iargvgv_ptr(aTHXo))
#undef PL_argvout_stack
Expand Down
4 changes: 2 additions & 2 deletions patchlevel.h
Expand Up @@ -5,7 +5,7 @@

#define PERL_REVISION 5 /* age */
#define PERL_VERSION 5 /* epoch */
#define PERL_SUBVERSION 63 /* generation */
#define PERL_SUBVERSION 640 /* generation */

/* Compatibility across versions: MakeMaker will install add-on
modules in a directory with the PERL_APIVERSION version number.
Expand All @@ -18,7 +18,7 @@
See INSTALL for how this works.
*/
#define PERL_APIVERSION 5.00563 /* Adjust manually as needed. */
#define PERL_APIVERSION 5.00564 /* Adjust manually as needed. */

#define __PATCHLEVEL_H_INCLUDED__
#endif
Expand Down
69 changes: 37 additions & 32 deletions perl.c
Expand Up @@ -204,14 +204,29 @@ perl_construct(pTHXx)
init_i18nl10n(1);
SET_NUMERIC_STANDARD();

{
U8 *s;
PL_patchlevel = NEWSV(0,4);
SvUPGRADE(PL_patchlevel, SVt_PVNV);
if (PERL_REVISION > 127 || PERL_VERSION > 127 || PERL_SUBVERSION > 127)
SvGROW(PL_patchlevel,24);
s = (U8*)SvPVX(PL_patchlevel);
s = uv_to_utf8(s, (UV)PERL_REVISION);
s = uv_to_utf8(s, (UV)PERL_VERSION);
s = uv_to_utf8(s, (UV)PERL_SUBVERSION);
*s = '\0';
SvCUR_set(PL_patchlevel, s - (U8*)SvPVX(PL_patchlevel));
SvPOK_on(PL_patchlevel);
SvNVX(PL_patchlevel) = (NV)PERL_REVISION
+ ((NV)PERL_VERSION / (NV)1000)
#if defined(PERL_SUBVERSION) && PERL_SUBVERSION > 0
sprintf(PL_patchlevel, "%7.5f", (double) PERL_REVISION
+ ((double) PERL_VERSION / (double) 1000)
+ ((double) PERL_SUBVERSION / (double) 100000));
#else
sprintf(PL_patchlevel, "%5.3f", (double) PERL_REVISION +
((double) PERL_VERSION / (double) 1000));
+ ((NV)PERL_SUBVERSION / (NV)1000000)
#endif
;
SvNOK_on(PL_patchlevel); /* dual valued */
SvUTF8_on(PL_patchlevel);
SvREADONLY_on(PL_patchlevel);
}

#if defined(LOCAL_PATCH_COUNT)
PL_localpatches = local_patches; /* For possible -v */
Expand Down Expand Up @@ -394,6 +409,7 @@ perl_destruct(pTHXx)

Safefree(PL_inplace);
PL_inplace = Nullch;
SvREFCNT_dec(PL_patchlevel);

if (PL_e_script) {
SvREFCNT_dec(PL_e_script);
Expand Down Expand Up @@ -599,7 +615,6 @@ perl_destruct(pTHXx)

/* No SVs have survived, need to clean out */
Safefree(PL_origfilename);
Safefree(PL_archpat_auto);
Safefree(PL_reg_start_tmp);
if (PL_reg_curpm)
Safefree(PL_reg_curpm);
Expand Down Expand Up @@ -1841,13 +1856,8 @@ Perl_moreswitches(pTHX_ char *s)
s++;
return s;
case 'v':
#if defined(PERL_SUBVERSION) && PERL_SUBVERSION > 0
printf("\nThis is perl, version %d.%03d_%02d built for %s",
PERL_REVISION, PERL_VERSION, PERL_SUBVERSION, ARCHNAME);
#else
printf("\nThis is perl, version %s built for %s",
PL_patchlevel, ARCHNAME);
#endif
printf("\nThis is perl, v%"UVuf".%"UVuf".%"UVuf" built for %s",
(UV)PERL_REVISION, (UV)PERL_VERSION, (UV)PERL_SUBVERSION, ARCHNAME);
#if defined(LOCAL_PATCH_COUNT)
if (LOCAL_PATCH_COUNT > 0)
printf("\n(with %d registered patch%s, see perl -V for more detail)",
Expand Down Expand Up @@ -2243,7 +2253,9 @@ sed %s -e \"/^[^#]/b\" \
PL_statbuf.st_mode & (S_ISUID|S_ISGID))
{
/* try again */
PerlProc_execv(Perl_form(aTHX_ "%s/sperl%s", BIN_EXP, PL_patchlevel), PL_origargv);
PerlProc_execv(Perl_form(aTHX_ "%s/sperl"PERL_FS_VER_FMT, BIN_EXP,
(UV)PERL_REVISION, (UV)PERL_VERSION,
(UV)PERL_SUBVERSION), PL_origargv);
Perl_croak(aTHX_ "Can't do setuid\n");
}
#endif
Expand Down Expand Up @@ -2490,7 +2502,9 @@ FIX YOUR KERNEL, PUT A C WRAPPER AROUND THIS SCRIPT, OR USE -u AND UNDUMP!\n");
(void)PerlIO_close(PL_rsfp);
#ifndef IAMSUID
/* try again */
PerlProc_execv(Perl_form(aTHX_ "%s/sperl%s", BIN_EXP, PL_patchlevel), PL_origargv);
PerlProc_execv(Perl_form(aTHX_ "%s/sperl"PERL_FS_VER_FMT, BIN_EXP,
(UV)PERL_REVISION, (UV)PERL_VERSION,
(UV)PERL_SUBVERSION), PL_origargv);
#endif
Perl_croak(aTHX_ "Can't do setuid\n");
}
Expand Down Expand Up @@ -2572,7 +2586,9 @@ FIX YOUR KERNEL, PUT A C WRAPPER AROUND THIS SCRIPT, OR USE -u AND UNDUMP!\n");
#if defined(HAS_FCNTL) && defined(F_SETFD)
fcntl(PerlIO_fileno(PL_rsfp),F_SETFD,0); /* ensure no close-on-exec */
#endif
PerlProc_execv(Perl_form(aTHX_ "%s/perl%s", BIN_EXP, PL_patchlevel), PL_origargv);/* try again */
PerlProc_execv(Perl_form(aTHX_ "%s/perl"PERL_FS_VER_FMT, BIN_EXP,
(UV)PERL_REVISION, (UV)PERL_VERSION,
(UV)PERL_SUBVERSION), PL_origargv);/* try again */
Perl_croak(aTHX_ "Can't do setuid\n");
#endif /* IAMSUID */
#else /* !DOSUID */
Expand Down Expand Up @@ -2969,17 +2985,6 @@ S_incpush(pTHX_ char *p, int addsubdirs)

if (addsubdirs) {
subdir = sv_newmortal();
if (!PL_archpat_auto) {
STRLEN len = (sizeof(ARCHNAME) + strlen(PL_patchlevel)
+ sizeof("//auto"));
New(55, PL_archpat_auto, len, char);
sprintf(PL_archpat_auto, "/%s/%s/auto", ARCHNAME, PL_patchlevel);
#ifdef VMS
for (len = sizeof(ARCHNAME) + 2;
PL_archpat_auto[len] != '\0' && PL_archpat_auto[len] != '/'; len++)
if (PL_archpat_auto[len] == '.') PL_archpat_auto[len] = '_';
#endif
}
}

/* Break at all separators */
Expand Down Expand Up @@ -3025,16 +3030,16 @@ S_incpush(pTHX_ char *p, int addsubdirs)
SvPV(libdir,len));
#endif
/* .../archname/version if -d .../archname/version/auto */
sv_setsv(subdir, libdir);
sv_catpv(subdir, PL_archpat_auto);
Perl_sv_setpvf(aTHX_ subdir, "%_/%s/"PERL_FS_VER_FMT"/auto", libdir,
ARCHNAME, (UV)PERL_REVISION,
(UV)PERL_VERSION, (UV)PERL_SUBVERSION);
if (PerlLIO_stat(SvPVX(subdir), &tmpstatbuf) >= 0 &&
S_ISDIR(tmpstatbuf.st_mode))
av_push(GvAVn(PL_incgv),
newSVpvn(SvPVX(subdir), SvCUR(subdir) - sizeof "auto"));

/* .../archname if -d .../archname/auto */
sv_insert(subdir, SvCUR(libdir) + sizeof(ARCHNAME),
strlen(PL_patchlevel) + 1, "", 0);
Perl_sv_setpvf(aTHX_ subdir, "%_/%s/auto", libdir, ARCHNAME);
if (PerlLIO_stat(SvPVX(subdir), &tmpstatbuf) >= 0 &&
S_ISDIR(tmpstatbuf.st_mode))
av_push(GvAVn(PL_incgv),
Expand Down
7 changes: 6 additions & 1 deletion perl.h
Expand Up @@ -1596,7 +1596,12 @@ typedef pthread_key_t perl_key;
#define PERL_EXIT_EXPECTED 0x01

#ifndef MEMBER_TO_FPTR
#define MEMBER_TO_FPTR(name) name
# define MEMBER_TO_FPTR(name) name
#endif

/* format to use for version numbers in file/directory names */
#ifndef PERL_FS_VER_FMT
# define PERL_FS_VER_FMT "%"UVuf".%"UVuf".%"UVuf
#endif

/* This defines a way to flush all output buffers. This may be a
Expand Down
52 changes: 48 additions & 4 deletions pp_ctl.c
Expand Up @@ -2834,10 +2834,54 @@ PP(pp_require)
SV *filter_sub = 0;

sv = POPs;
if (SvNIOKp(sv) && !SvPOKp(sv)) {
if (Atof(PL_patchlevel) + 0.00000999 < SvNV(sv))
DIE(aTHX_ "Perl %s required--this is only version %s, stopped",
SvPV(sv,n_a),PL_patchlevel);
if (SvNIOKp(sv)) {
UV rev, ver, sver;
if (SvPOKp(sv) && SvUTF8(sv)) { /* require v5.6.1 */
I32 len;
U8 *s = (U8*)SvPVX(sv);
U8 *end = (U8*)SvPVX(sv) + SvCUR(sv);
if (s < end) {
rev = utf8_to_uv(s, &len);
s += len;
if (s < end) {
ver = utf8_to_uv(s, &len);
s += len;
if (s < end)
sver = utf8_to_uv(s, &len);
else
sver = 0;
}
else
ver = 0;
}
else
rev = 0;
if (PERL_REVISION < rev
|| (PERL_REVISION == rev
&& (PERL_VERSION < ver
|| (PERL_VERSION == ver
&& PERL_SUBVERSION < sver))))
{
DIE(aTHX_ "Perl v%"UVuf".%"UVuf".%"UVuf" required--this is only version "
"v%"UVuf".%"UVuf".%"UVuf", stopped", rev, ver, sver, PERL_REVISION,
PERL_VERSION, PERL_SUBVERSION);
}
}
else if (!SvPOKp(sv)) { /* require 5.005_03 */
NV n = SvNV(sv);
rev = (UV)n;
ver = (UV)((n-rev)*1000);
sver = (UV)((((n-rev)*1000 - ver) + 0.0009) * 1000);

if ((NV)PERL_REVISION + ((NV)PERL_VERSION/(NV)1000)
+ ((NV)PERL_SUBVERSION/(NV)1000000)
+ 0.00000099 < SvNV(sv))
{
DIE(aTHX_ "Perl v%"UVuf".%"UVuf".%"UVuf" required--this is only version "
"v%"UVuf".%"UVuf".%"UVuf", stopped", rev, ver, sver, PERL_REVISION,
PERL_VERSION, PERL_SUBVERSION);
}
}
RETPUSHYES;
}
name = SvPV(sv, len);
Expand Down
5 changes: 3 additions & 2 deletions sv.c
Expand Up @@ -2655,6 +2655,8 @@ Perl_sv_setsv(pTHX_ SV *dstr, register SV *sstr)
*SvEND(dstr) = '\0';
(void)SvPOK_only(dstr);
}
if (SvUTF8(sstr))
SvUTF8_on(dstr);
/*SUPPRESS 560*/
if (sflags & SVp_NOK) {
SvNOK_on(dstr);
Expand Down Expand Up @@ -6710,7 +6712,7 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags,

/* switches */
PL_minus_c = proto_perl->Iminus_c;
Copy(proto_perl->Ipatchlevel, PL_patchlevel, 10, char);
PL_patchlevel = sv_dup_inc(proto_perl->Ipatchlevel);
PL_localpatches = proto_perl->Ilocalpatches;
PL_splitstr = proto_perl->Isplitstr;
PL_preprocess = proto_perl->Ipreprocess;
Expand Down Expand Up @@ -6850,7 +6852,6 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags,
/* more statics moved here */
PL_generation = proto_perl->Igeneration;
PL_DBcv = cv_dup(proto_perl->IDBcv);
PL_archpat_auto = SAVEPV(proto_perl->Iarchpat_auto);

PL_in_clean_objs = proto_perl->Iin_clean_objs;
PL_in_clean_all = proto_perl->Iin_clean_all;
Expand Down
6 changes: 3 additions & 3 deletions sv.h
Expand Up @@ -373,9 +373,9 @@ struct xpvio {
#define SvNOK_only(sv) (SvOK_off(sv), \
SvFLAGS(sv) |= (SVf_NOK|SVp_NOK))

#define SvUTF8(sv) (SvFLAGS(sv) & SVf_ISUTF8)
#define SvUTF8_on(sv) (SvFLAGS(sv) |= (SVf_ISUTF8))
#define SvUTF8_off(sv) (SvFLAGS(sv) &= ~(SVf_ISUTF8))
#define SvUTF8(sv) (SvFLAGS(sv) & SVf_UTF8)
#define SvUTF8_on(sv) (SvFLAGS(sv) |= (SVf_UTF8))
#define SvUTF8_off(sv) (SvFLAGS(sv) &= ~(SVf_UTF8))

#define SvPOK(sv) (SvFLAGS(sv) & SVf_POK)
#define SvPOK_on(sv) (SvFLAGS(sv) |= (SVf_POK|SVp_POK))
Expand Down

0 comments on commit a7cb1f9

Please sign in to comment.