Fixed two long-standing locale bugs.
[p5sagit/p5-mst-13.2.git] / perl.h
diff --git a/perl.h b/perl.h
index 73f1dc6..7ef9432 100644 (file)
--- a/perl.h
+++ b/perl.h
@@ -150,7 +150,7 @@ class CPerlObj;
 #else
 #  define START_EXTERN_C 
 #  define END_EXTERN_C 
-#  define EXTERN_C
+#  define EXTERN_C extern
 #endif
 
 #ifdef OP_IN_REGISTER
@@ -327,8 +327,6 @@ register struct op *Perl_op asm(stringify(OP_IN_REGISTER));
 #  endif
 #endif
 
-#include "iperlsys.h"
-
 #ifdef USE_NEXT_CTYPE
 
 #if NX_CURRENT_COMPILER_RELEASE >= 500
@@ -1504,34 +1502,33 @@ typedef pthread_key_t   perl_key;
 #ifdef PERL_IMPLICIT_CONTEXT
 #  ifdef USE_THREADS
 struct perl_thread;
-#    define pTHX struct perl_thread *thr
-#    define pTHX_ pTHX,
-#    define _pTHX ,pTHX
-#    define aTHX thr
-#    define aTHX_ aTHX,
-#    define _aTHX ,aTHX
-#    define dTHX pTHX = (struct perl_thread *)SvPVX(PL_thrsv)
-#    define dTHR dNOOP
+#    define pTHX       register struct perl_thread *thr
+#    define aTHX       thr
+#    define dTHXa(a)   pTHX = (struct perl_thread *)a
+#    define dTHX       dTHXa(SvPVX(PL_thrsv))
+#    define dTHR       dNOOP
 #  else
 #    define MULTIPLICITY
-#    define pTHX PerlInterpreter *my_perl
-#    define pTHX_ pTHX,
-#    define _pTHX ,pTHX
-#    define aTHX my_perl
-#    define aTHX_ aTHX,
-#    define _aTHX ,aTHX
-#    define dTHX pTHX = PL_curinterp
+#    define pTHX       register PerlInterpreter *my_perl
+#    define aTHX       my_perl
+#    define dTHXa(a)   pTHX = (PerlInterpreter *)a
+#    define dTHX       dTHXa(PL_curinterp)
 #  endif
+#  define pTHX_                pTHX,
+#  define _pTHX                ,pTHX
+#  define aTHX_                aTHX,
+#  define _aTHX                ,aTHX
 #endif
 
 #ifndef pTHX
-#  define pTHX void
+#  define pTHX         void
 #  define pTHX_
 #  define _pTHX
 #  define aTHX
 #  define aTHX_
 #  define _aTHX
-#  define dTHX dNOOP
+#  define dTHXa(a)     dNOOP
+#  define dTHX         dNOOP
 #endif
 
 #define WITH_THX(s) STMT_START { dTHX; s; } STMT_END
@@ -1568,6 +1565,11 @@ typedef I32 (*filter_t) (pTHX_ int, SV *, int);
 #define FILTER_DATA(idx)          (AvARRAY(PL_rsfp_filters)[idx])
 #define FILTER_ISREADER(idx)      (idx >= AvFILLp(PL_rsfp_filters))
 
+#ifdef WIN32
+#include "win32.h"
+#endif
+
+#include "iperlsys.h"
 #include "regexp.h"
 #include "sv.h"
 #include "util.h"
@@ -1753,7 +1755,7 @@ Gid_t getegid (void);
 #define DEBUG_o(a) if (PL_debug & 16)  a
 #define DEBUG_c(a) if (PL_debug & 32)  a
 #define DEBUG_P(a) if (PL_debug & 64)  a
-#  if defined(PERL_OBJECT) || defined(PERL_IMPLICIT_CONTEXT)
+#  if defined(PERL_OBJECT)
 #    define DEBUG_m(a) if (PL_debug & 128)     a
 #  else
 #    define DEBUG_m(a) if (PL_curinterp && PL_debug & 128)     a
@@ -1930,17 +1932,10 @@ typedef Sighandler_t Sigsave_t;
 #endif
 
 
-/*
- * These need prototyping here because <proto.h> isn't
- * included until after runops is initialised.
- */
-
-#ifndef PERL_OBJECT
+#ifdef PERL_OBJECT
+typedef int (CPerlObj::*runops_proc_t) (void);
+#else
 typedef int (*runops_proc_t) (pTHX);
-int Perl_runops_standard (pTHX);
-#ifdef DEBUGGING
-int Perl_runops_debug (pTHX);
-#endif
 #endif
 
 /* _ (for $_) must be first in the following list (DEFSV requires it) */
@@ -1971,6 +1966,8 @@ extern char **    environ;        /* environment variables supplied via exec */
 #  endif
 #endif
 
+START_EXTERN_C
+
 /* handy constants */
 EXTCONST char PL_warn_uninit[]
   INIT("Use of uninitialized value");
@@ -2229,6 +2226,8 @@ EXTCONST char* PL_block_type[];
 #endif
 #endif
 
+END_EXTERN_C
+
 /*****************************************************************************/
 /* This lexer/parser stuff is currently global since yacc is hard to reenter */
 /*****************************************************************************/
@@ -2284,6 +2283,7 @@ enum {            /* pass one of these to get_vtbl */
 
                                /* Note: the lowest 8 bits are reserved for
                                   stuffing into op->op_private */
+#define HINT_PRIVATE_MASK      0x000000ff
 #define HINT_INTEGER           0x00000001
 #define HINT_STRICT_REFS       0x00000002
 /* #define HINT_notused4       0x00000004 */
@@ -2347,10 +2347,6 @@ typedef struct exitlistentry {
 #ifdef PERL_OBJECT
 extern "C" CPerlObj* perl_alloc (IPerlMem*, IPerlEnv*, IPerlStdIO*, IPerlLIO*, IPerlDir*, IPerlSock*, IPerlProc*);
 
-#ifdef PERL_OBJECT
-typedef int (CPerlObj::*runops_proc_t) (void);
-#endif  /* PERL_OBJECT */
-
 #undef EXT
 #define EXT
 #undef EXTCONST
@@ -2479,7 +2475,9 @@ END_EXTERN_C
 #define PERLVARIC(var,type,init) EXTCONST type PL_##var INIT(init);
 
 #ifndef PERL_GLOBAL_STRUCT
+START_EXTERN_C
 #include "perlvars.h"
+END_EXTERN_C
 #endif
 
 #ifndef MULTIPLICITY
@@ -2520,17 +2518,7 @@ PERLVAR(object_compatibility[30],        char)
 #undef PERLVARI
 #undef PERLVARIC
 
-#if defined(HASATTRIBUTE) && defined(WIN32) && !defined(CYGWIN32)
-/*
- * This provides a layer of functions and macros to ensure extensions will
- * get to use the same RTL functions as the core.
- * It has to go here or #define of printf messes up __attribute__
- * stuff in proto.h  
- */
-#ifndef PERL_OBJECT
-#  include <win32iop.h>
-#endif  /* PERL_OBJECT */
-#endif /* WIN32 */
+START_EXTERN_C
 
 #ifdef DOINIT
 
@@ -2736,6 +2724,8 @@ EXTCONST char * PL_AMG_names[NofAMmeth] = {
 EXTCONST char * PL_AMG_names[NofAMmeth];
 #endif /* def INITAMAGIC */
 
+END_EXTERN_C
+
 struct am_table {
   long was_ok_sub;
   long was_ok_am;
@@ -2827,10 +2817,22 @@ typedef struct am_table_short AMTS;
            set_numeric_local();                \
     } STMT_END
 
+#define IS_NUMERIC_RADIX(c)    \
+       ((PL_hints & HINT_LOCALE) && \
+         PL_numeric_radix && (c) == PL_numeric_radix)
+
+#define RESTORE_NUMERIC_LOCAL()                if ((PL_hints & HINT_LOCALE) && PL_numeric_standard) SET_NUMERIC_LOCAL()
+#define RESTORE_NUMERIC_STANDARD()     if ((PL_hints & HINT_LOCALE) && PL_numeric_local) SET_NUMERIC_STANDARD()
+#define Atof(s)                                Perl_my_atof(s)
+
 #else /* !USE_LOCALE_NUMERIC */
 
-#define SET_NUMERIC_STANDARD()  /**/
-#define SET_NUMERIC_LOCAL()     /**/
+#define SET_NUMERIC_STANDARD()         /**/
+#define SET_NUMERIC_LOCAL()            /**/
+#define IS_NUMERIC_RADIX(c)            (0)
+#define RESTORE_NUMERIC_LOCAL()                /**/
+#define RESTORE_NUMERIC_STANDARD()     /**/
+#define Atof(s)                                atof(s)
 
 #endif /* !USE_LOCALE_NUMERIC */