Integrate mainline
[p5sagit/p5-mst-13.2.git] / ext / File / Glob / Glob.xs
index 85ddf02..1bb5fc4 100644 (file)
@@ -4,10 +4,17 @@
 
 #include "bsd_glob.h"
 
-/* XXX: need some thread awareness */
-static int GLOB_ERROR = 0;
+#define MY_CXT_KEY "File::Glob::_guts" XS_VERSION
 
-#include "constants.c"
+typedef struct {
+    int                x_GLOB_ERROR;
+} my_cxt_t;
+
+START_MY_CXT
+
+#define GLOB_ERROR     (MY_CXT.x_GLOB_ERROR)
+
+#include "const-c.inc"
 
 #ifdef WIN32
 #define errfunc                NULL
@@ -20,6 +27,11 @@ errfunc(const char *foo, int bar) {
 
 MODULE = File::Glob            PACKAGE = File::Glob
 
+BOOT:
+{
+    MY_CXT_INIT;
+}
+
 void
 doglob(pattern,...)
     char *pattern
@@ -32,6 +44,8 @@ PREINIT:
     SV *tmp;
 PPCODE:
     {
+       dMY_CXT;
+
        /* allow for optional flags argument */
        if (items > 1) {
            flags = (int) SvIV(ST(1));
@@ -49,10 +63,12 @@ PPCODE:
                                      strlen(pglob.gl_pathv[i])));
            TAINT;
            SvTAINT(tmp);
+           if (pglob.gl_flags & GLOB_UTF8 && !IN_BYTES)
+               SvUTF8_on(tmp);
            PUSHs(tmp);
        }
 
        bsd_globfree(&pglob);
     }
 
-INCLUDE: constants.xs
+INCLUDE: const-xs.inc