Update the documentation of get_sv() to note that it calls Perl_gv_fetchpv(),
authorNicholas Clark <nick@ccl4.org>
Wed, 21 Jan 2009 15:03:03 +0000 (15:03 +0000)
committerNicholas Clark <nick@ccl4.org>
Wed, 21 Jan 2009 17:09:11 +0000 (17:09 +0000)
and hence the 'create' argument is actually 'flags'. Fix core code and
documentation that used TRUE or FALSE to use 0 or GV_ADD.

12 files changed:
embed.fnc
ext/Devel/DProf/DProf.xs
ext/Devel/Peek/Peek.xs
os2/os2.c
perl.c
pod/perl5005delta.pod
pod/perlapi.pod
pod/perlembed.pod
pod/perlguts.pod
proto.h
symbian/symbian_utils.cpp
util.c

index 4d86e98..45d8923 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -772,7 +772,7 @@ Ap  |void   |despatch_signals
 Ap     |OP *   |doref          |NN OP *o|I32 type|bool set_op_ref
 Apd    |SV*    |eval_pv        |NN const char* p|I32 croak_on_error
 Apd    |I32    |eval_sv        |NN SV* sv|I32 flags
-Apd    |SV*    |get_sv         |NN const char* name|I32 create
+Apd    |SV*    |get_sv         |NN const char *name|I32 flags
 Apd    |AV*    |get_av         |NN const char *name|I32 flags
 Apd    |HV*    |get_hv         |NN const char *name|I32 flags
 Apd    |CV*    |get_cv         |NN const char* name|I32 flags
index 469ed22..dd393b5 100644 (file)
@@ -194,17 +194,17 @@ dprof_times(pTHX_ struct tms *t)
     
     if (!g_frequ) {
        if (CheckOSError(DosTmrQueryFreq(&g_frequ)))
-           croak("DosTmrQueryFreq: %s", SvPV_nolen(perl_get_sv("!",TRUE)));
+           croak("DosTmrQueryFreq: %s", SvPV_nolen(perl_get_sv("!",GV_ADD)));
        else
            g_frequ = g_frequ/DPROF_HZ; /* count per tick */
        if (CheckOSError(DosTmrQueryTime(&cnt)))
            croak("DosTmrQueryTime: %s",
-                 SvPV_nolen_const(perl_get_sv("!",TRUE)));
+                 SvPV_nolen_const(perl_get_sv("!",GV_ADD)));
        g_start_cnt = toLongLong(cnt);
     }
 
     if (CheckOSError(DosTmrQueryTime(&cnt)))
-           croak("DosTmrQueryTime: %s", SvPV_nolen(perl_get_sv("!",TRUE)));
+           croak("DosTmrQueryTime: %s", SvPV_nolen(perl_get_sv("!",GV_ADD)));
     t->tms_stime = 0;
     return (t->tms_utime = (toLongLong(cnt) - g_start_cnt)/g_frequ);
 #else          /* !OS2 */
@@ -240,13 +240,13 @@ dprof_times(pTHX_ struct tms *t)
 
     if (!tv0.tv_sec)
         if (gettimeofday(&tv0, NULL) < 0)
-            croak("gettimeofday: %s", SvPV_nolen_const(perl_get_sv("!",TRUE)));
+            croak("gettimeofday: %s", SvPV_nolen_const(perl_get_sv("!",GV_ADD)));
     
     if (getrusage(0, &ru) < 0)
-        croak("getrusage: %s", SvPV_nolen_const(perl_get_sv("!",TRUE)));
+        croak("getrusage: %s", SvPV_nolen_const(perl_get_sv("!",GV_ADD)));
 
     if (gettimeofday(&tv, NULL) < 0)
-        croak("gettimeofday: %s", SvPV_nolen_const(perl_get_sv("!",TRUE)));
+        croak("gettimeofday: %s", SvPV_nolen_const(perl_get_sv("!",GV_ADD)));
 
     t->tms_stime = DPROF_HZ * ru.ru_stime.tv_sec + ru.ru_stime.tv_usec;
     t->tms_utime = DPROF_HZ * ru.ru_utime.tv_sec + ru.ru_utime.tv_usec;
index 0351cc2..68584f7 100644 (file)
@@ -338,9 +338,9 @@ SV *        sv
 I32    lim
 PPCODE:
 {
-    SV *pv_lim_sv = perl_get_sv("Devel::Peek::pv_limit", FALSE);
+    SV *pv_lim_sv = perl_get_sv("Devel::Peek::pv_limit", 0);
     const STRLEN pv_lim = pv_lim_sv ? SvIV(pv_lim_sv) : 0;
-    SV *dumpop = perl_get_sv("Devel::Peek::dump_ops", FALSE);
+    SV *dumpop = perl_get_sv("Devel::Peek::dump_ops", 0);
     const U16 save_dumpindent = PL_dumpindent;
     PL_dumpindent = 2;
     do_sv_dump(0, Perl_debug_log, sv, 0, lim,
@@ -354,9 +354,9 @@ I32 lim
 PPCODE:
 {
     long i;
-    SV *pv_lim_sv = perl_get_sv("Devel::Peek::pv_limit", FALSE);
+    SV *pv_lim_sv = perl_get_sv("Devel::Peek::pv_limit", 0);
     const STRLEN pv_lim = pv_lim_sv ? SvIV(pv_lim_sv) : 0;
-    SV *dumpop = perl_get_sv("Devel::Peek::dump_ops", FALSE);
+    SV *dumpop = perl_get_sv("Devel::Peek::dump_ops", 0);
     const U16 save_dumpindent = PL_dumpindent;
     PL_dumpindent = 2;
 
index 4ebdd50..9448fdc 100644 (file)
--- a/os2/os2.c
+++ b/os2/os2.c
@@ -2072,7 +2072,7 @@ os2error(int rc)
        dTHX;
        ULONG len;
        char *s;
-       int number = SvTRUE(get_sv("OS2::nsyserror", TRUE));
+       int number = SvTRUE(get_sv("OS2::nsyserror", GV_ADD));
 
         if (!(_emx_env & 0x200)) return ""; /* Nop if not OS/2. */
        if (rc == 0)
diff --git a/perl.c b/perl.c
index 95848f1..f808af8 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -2415,21 +2415,22 @@ S_run_body(pTHX_ I32 oldscope)
 
 =for apidoc p||get_sv
 
-Returns the SV of the specified Perl scalar.  If C<create> is set and the
-Perl variable does not exist then it will be created.  If C<create> is not
-set and the variable does not exist then NULL is returned.
+Returns the SV of the specified Perl scalar.  C<flags> are passed to
+C<gv_fetchpv>. If C<GV_ADD> is set and the
+Perl variable does not exist then it will be created.  If C<flags> is zero
+and the variable does not exist then NULL is returned.
 
 =cut
 */
 
 SV*
-Perl_get_sv(pTHX_ const char *name, I32 create)
+Perl_get_sv(pTHX_ const char *name, I32 flags)
 {
     GV *gv;
 
     PERL_ARGS_ASSERT_GET_SV;
 
-    gv = gv_fetchpv(name, create, SVt_PV);
+    gv = gv_fetchpv(name, flags, SVt_PV);
     if (gv)
        return GvSV(gv);
     return NULL;
@@ -3069,7 +3070,7 @@ Perl_moreswitches(pTHX_ const char *s)
                   PL_rs = newSVpvn(&ch, 1);
              }
         }
-        sv_setsv(get_sv("/", TRUE), PL_rs);
+        sv_setsv(get_sv("/", GV_ADD), PL_rs);
         return s + numlen;
     }
     case 'C':
@@ -3590,7 +3591,7 @@ S_init_main_stash(pTHX)
     PL_globalstash = GvHV(gv_fetchpvs("CORE::GLOBAL::", GV_ADDMULTI,
                                      SVt_PVHV));
     /* We must init $/ before switches are processed. */
-    sv_setpvs(get_sv("/", TRUE), "\n");
+    sv_setpvs(get_sv("/", GV_ADD), "\n");
 }
 
 STATIC int
@@ -4563,7 +4564,7 @@ S_init_predump_symbols(pTHX)
     GV *tmpgv;
     IO *io;
 
-    sv_setpvs(get_sv("\"", TRUE), " ");
+    sv_setpvs(get_sv("\"", GV_ADD), " ");
     PL_ofsgv = (GV*)SvREFCNT_inc(gv_fetchpvs(",", GV_ADD|GV_NOTQUAL, SVt_PV));
 
     PL_stdingv = gv_fetchpvs("STDIN", GV_ADD|GV_NOTQUAL, SVt_PVIO);
index 39646b6..6420f87 100644 (file)
@@ -101,7 +101,7 @@ If you see a compiler error that talks about the variable C<thr> not
 being declared (when building a module that has XS code),  you need
 to add C<dTHR;> at the beginning of the block that elicited the error.
 
-The API function C<perl_get_sv("@",FALSE)> should be used instead of
+The API function C<perl_get_sv("@",GV_ADD)> should be used instead of
 directly accessing perl globals as C<GvSV(errgv)>.  The API call is
 backward compatible with existing perls and provides source compatibility
 with threading is enabled.
index 02e5f26..fc51e14 100644 (file)
@@ -3987,13 +3987,14 @@ Found in file universal.c
 =item get_sv
 X<get_sv>
 
-Returns the SV of the specified Perl scalar.  If C<create> is set and the
-Perl variable does not exist then it will be created.  If C<create> is not
-set and the variable does not exist then NULL is returned.
+Returns the SV of the specified Perl scalar.  C<flags> are passed to
+C<gv_fetchpv>. If C<GV_ADD> is set and the
+Perl variable does not exist then it will be created.  If C<flags> is zero
+and the variable does not exist then NULL is returned.
 
 NOTE: the perl_ form of this function is deprecated.
 
-       SV*     get_sv(const char* name, I32 create)
+       SV*     get_sv(const char *name, I32 flags)
 
 =for hackers
 Found in file perl.c
@@ -7335,7 +7336,7 @@ sidestepping the normal C order of execution. See C<warn>.
 If you want to throw an exception object, assign the object to
 C<$@> and then pass C<NULL> to croak():
 
-   errsv = get_sv("@", TRUE);
+   errsv = get_sv("@", GV_ADD);
    sv_setsv(errsv, exception_object);
    croak(NULL);
 
index a2b76fd..39364eb 100644 (file)
@@ -325,15 +325,15 @@ the first, a C<float> from the second, and a C<char *> from the third.
 
        /** Treat $a as an integer **/
        eval_pv("$a = 3; $a **= 2", TRUE);
-       printf("a = %d\n", SvIV(get_sv("a", FALSE)));
+       printf("a = %d\n", SvIV(get_sv("a", 0)));
 
        /** Treat $a as a float **/
        eval_pv("$a = 3.14; $a **= 2", TRUE);
-       printf("a = %f\n", SvNV(get_sv("a", FALSE)));
+       printf("a = %f\n", SvNV(get_sv("a", 0)));
 
        /** Treat $a as a string **/
        eval_pv("$a = 'rekcaH lreP rehtonA tsuJ'; $a = reverse($a);", TRUE);
-       printf("a = %s\n", SvPV_nolen(get_sv("a", FALSE)));
+       printf("a = %s\n", SvPV_nolen(get_sv("a", 0)));
 
        perl_destruct(my_perl);
        perl_free(my_perl);
@@ -457,7 +457,7 @@ been wrapped here):
      retval = my_eval_sv(command, TRUE);
      SvREFCNT_dec(command);
 
-     *string = get_sv("string", FALSE);
+     *string = get_sv("string", 0);
      return SvIV(retval);
  }
 
index 8231592..6408e87 100644 (file)
@@ -191,7 +191,7 @@ have "magic".  See L<Magic Virtual Tables> later in this document.
 If you know the name of a scalar variable, you can get a pointer to its SV
 by using the following:
 
-    SV*  get_sv("package::varname", FALSE);
+    SV*  get_sv("package::varname", 0);
 
 This returns NULL if the variable does not exist.
 
@@ -667,7 +667,7 @@ to write:
 To create a new Perl variable with an undef value which can be accessed from
 your Perl script, use the following routines, depending on the variable type.
 
-    SV*  get_sv("package::varname", TRUE);
+    SV*  get_sv("package::varname", GV_ADD);
     AV*  get_av("package::varname", GV_ADD);
     HV*  get_hv("package::varname", GV_ADD);
 
@@ -878,7 +878,7 @@ following code:
     extern int  dberror;
     extern char *dberror_list;
 
-    SV* sv = get_sv("dberror", TRUE);
+    SV* sv = get_sv("dberror", GV_ADD);
     sv_setiv(sv, (IV) dberror);
     sv_setpv(sv, dberror_list[dberror]);
     SvIOK_on(sv);
diff --git a/proto.h b/proto.h
index e50ae92..dd927fa 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -2424,7 +2424,7 @@ PERL_CALLCONV I32 Perl_eval_sv(pTHX_ SV* sv, I32 flags)
 #define PERL_ARGS_ASSERT_EVAL_SV       \
        assert(sv)
 
-PERL_CALLCONV SV*      Perl_get_sv(pTHX_ const char* name, I32 create)
+PERL_CALLCONV SV*      Perl_get_sv(pTHX_ const char *name, I32 flags)
                        __attribute__nonnull__(pTHX_1);
 #define PERL_ARGS_ASSERT_GET_SV        \
        assert(name)
index b3eee0b..e6483ef 100644 (file)
@@ -171,7 +171,7 @@ extern "C" {
        } else {
          buf8.Format(_L8("Symbian error %d"), error);
        }
-        SV* sv = Perl_get_sv(aTHX_ "\005", TRUE); /* $^E or ${^OS_ERROR} */
+        SV* sv = Perl_get_sv(aTHX_ "\005", GV_ADD); /* $^E or ${^OS_ERROR} */
         if (!sv)
             return (char*)NullErr;
         sv_setpv(sv, (const char *)buf8.PtrZ());
diff --git a/util.c b/util.c
index 86c06f5..521a8c2 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1454,7 +1454,7 @@ sidestepping the normal C order of execution. See C<warn>.
 If you want to throw an exception object, assign the object to
 C<$@> and then pass C<NULL> to croak():
 
-   errsv = get_sv("@", TRUE);
+   errsv = get_sv("@", GV_ADD);
    sv_setsv(errsv, exception_object);
    croak(NULL);