richter 02/01/29 01:13:47
Modified: . Tag: Embperl2c DOM.xs Old.xs ep.h epcfg.h epcomp.c
epdat2.h epinit.c epmain.c epprovider.c eputil.c
Embperl Tag: Embperl2c Object.pm
xsbuilder/maps Tag: Embperl2c ep_structure.map
Log:
eo
Revision Changes Path
No revision
No revision
1.1.2.23 +6 -3 embperl/DOM.xs
Index: DOM.xs
===================================================================
RCS file: /home/cvs/embperl/DOM.xs,v
retrieving revision 1.1.2.22
retrieving revision 1.1.2.23
diff -u -r1.1.2.22 -r1.1.2.23
--- DOM.xs 22 Jan 2002 15:46:22 -0000 1.1.2.22
+++ DOM.xs 29 Jan 2002 09:13:46 -0000 1.1.2.23
@@ -10,7 +10,7 @@
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
-# $Id: DOM.xs,v 1.1.2.22 2002/01/22 15:46:22 richter Exp $
+# $Id: DOM.xs,v 1.1.2.23 2002/01/29 09:13:46 richter Exp $
#
###################################################################################
@@ -61,6 +61,7 @@
STRLEN l ;
char * s ;
PPCODE:
+ RETVAL = NULL ; /* avoid warning */
SvGETMAGIC_P4(sText) ;
s = SV2String (sText, l) ;
Node_replaceChildWithCDATA (CurrApp, DomTree_self(pDomNode -> xDomTree),
pDomNode -> xNode, CurrReq -> Component.nCurrRepeatLevel, s, l, (CurrReq ->
Component.nCurrEscMode & 11)== 3?1 + (CurrReq -> Component.nCurrEscMode & 4):CurrReq
-> Component.nCurrEscMode, 0) ;
@@ -80,6 +81,7 @@
STRLEN l ;
char * s ;
PPCODE:
+ RETVAL = NULL ; /* avoid warning */
SvGETMAGIC_P4(sText) ;
s = SV2String (sText, l) ;
Node_replaceChildWithCDATA (CurrApp, DomTree_self(xDomTree), xOldChild, CurrReq
-> Component.nCurrRepeatLevel, s, l, (CurrReq -> Component.nCurrEscMode & 11)== 3?1 +
(CurrReq -> Component.nCurrEscMode & 4):CurrReq -> Component.nCurrEscMode, 0) ;
@@ -98,6 +100,7 @@
STRLEN l ;
char * s ;
PPCODE:
+ RETVAL = NULL ; /* avoid warning */
SvGETMAGIC_P4(sText) ;
s = SV2String (sText, l) ;
Node_replaceChildWithCDATA (CurrApp, DomTree_self(CurrReq ->
Component.xCurrDomTree), xOldChild, CurrReq -> Component.nCurrRepeatLevel, s, l,
(CurrReq -> Component.nCurrEscMode & 11)== 3?1 + (CurrReq -> Component.nCurrEscMode &
4):CurrReq -> Component.nCurrEscMode, 0) ;
@@ -116,6 +119,7 @@
PREINIT:
SV * sRet ;
PPCODE:
+ RETVAL = NULL ; /* avoid warning */
SvGETMAGIC_P4(sText) ;
sRet = Node_replaceChildWithUrlDATA (CurrReq, pDomNode -> xDomTree, pDomNode ->
xNode, CurrReq -> Component.nCurrRepeatLevel, sText) ;
@@ -129,6 +133,7 @@
PREINIT:
SV * sRet ;
PPCODE:
+ RETVAL = NULL ; /* avoid warning */
SvGETMAGIC_P4(sText) ;
sRet = Node_replaceChildWithUrlDATA (CurrReq, CurrReq ->
Component.xCurrDomTree, xOldChild, CurrReq -> Component.nCurrRepeatLevel, sText) ;
@@ -157,7 +162,6 @@
int nType
SV * sText
PREINIT:
- int xNewParent ;
STRLEN nText ;
char * sT ;
tDomTree * pDomTree ;
@@ -174,7 +178,6 @@
int nType
SV * sText
CODE:
- int xNewParent ;
STRLEN nText ;
char * sT = SV2String (sText, nText) ;
tDomTree * pDomTree = DomTree_self(xDomTree) ;
1.1.2.5 +2 -3 embperl/Attic/Old.xs
Index: Old.xs
===================================================================
RCS file: /home/cvs/embperl/Attic/Old.xs,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- Old.xs 25 Jan 2002 07:04:31 -0000 1.1.2.4
+++ Old.xs 29 Jan 2002 09:13:46 -0000 1.1.2.5
@@ -38,7 +38,6 @@
embperl_GVFile(gv)
SV * gv
CODE:
- char buf[20] ;
RETVAL = "" ;
#ifdef GvFILE
if (gv && SvTYPE(gv) == SVt_PVGV && GvGP (gv))
@@ -105,8 +104,8 @@
PREINIT:
tReq * r = CurrReq ;
int bRestore = 0 ;
- SV * pSaveApacheReqSV ;
#ifdef APACHE
+ SV * pSaveApacheReqSV ;
request_rec * pSaveApacheReq ;
#endif
CODE:
@@ -529,8 +528,8 @@
SV * pApacheReqSV
PREINIT:
int bRestore = 0 ;
- SV * pSaveApacheReqSV ;
#ifdef APACHE
+ SV * pSaveApacheReqSV ;
request_rec * pSaveApacheReq ;
#endif
CODE:
1.27.4.40 +9 -0 embperl/ep.h
Index: ep.h
===================================================================
RCS file: /home/cvs/embperl/ep.h,v
retrieving revision 1.27.4.39
retrieving revision 1.27.4.40
diff -u -r1.27.4.39 -r1.27.4.40
--- ep.h 28 Jan 2002 20:28:34 -0000 1.27.4.39
+++ ep.h 29 Jan 2002 09:13:46 -0000 1.27.4.40
@@ -591,6 +591,15 @@
void ChdirToSource (/*i/o*/ register req * r,
/*in*/ char * sInputfile) ;
+void embperl_SetCWDToFile (/*i/o*/ register req * r,
+ /*in*/ char * sFilename) ;
+char * embperl_File2Abs (/*i/o*/ register req * r,
+ /*in*/ tMemPool * pPool,
+ /*in*/ char * sFilename) ;
+char * embperl_PathSearch (/*i/o*/ register req * r,
+ /*in*/ tMemPool * pPool,
+ /*in*/ char * sFilename) ;
+
/* ---- from epeval.c ----- */
1.1.2.5 +2 -2 embperl/Attic/epcfg.h
Index: epcfg.h
===================================================================
RCS file: /home/cvs/embperl/Attic/epcfg.h,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- epcfg.h 28 Jan 2002 20:28:34 -0000 1.1.2.4
+++ epcfg.h 29 Jan 2002 09:13:46 -0000 1.1.2.5
@@ -5,7 +5,6 @@
EPCFG_STR (ComponentConfig, char *, sPackage, PACKAGE)
EPCFG_INT (ComponentConfig, unsigned, bDebug, DEBUG)
EPCFG_INT (ComponentConfig, unsigned, bOptions, OPTIONS)
-EPCFG_STR (ComponentConfig, char *, sPath, PATH)
EPCFG_INT (ComponentConfig, int , nEscMode, ESCMODE)
EPCFG_STR (ComponentConfig, char *, sCacheKey, CACKE_KEY)
EPCFG_INT (ComponentConfig, unsigned, bCacheKeyOptions, CACHE_KEY_OPTIONS)
@@ -26,6 +25,7 @@
EPCFG_STR(ReqConfig, char *, sFilesMatch, FILESMATCH)
EPCFG_STR(ReqConfig, char *, sDecline, DECLINE)
EPCFG_CHAR(ReqConfig, char , cMultFieldSep, MULTFIELDSEP )
+/*EPCFG_STR (ReqConfig, char *, sPath, PATH) */
#endif
@@ -50,7 +50,7 @@
EPCFG_STR(AppConfig, char *, sMailErrorsTo, MAIL_ERRORS_TO)
EPCFG_STR(AppConfig, char *, sObjectBase, OBJECT_BASE)
EPCFG_STR(AppConfig, char *, sObjectApp, OBJECT_APP)
-EPCFG_STR(AppConfig, char *, sObjectAddpath, OBJECT_ADDPATH)
+/*EPCFG_STR(AppConfig, char *, sObjectAddpath, OBJECT_ADDPATH)*/
EPCFG_STR(AppConfig, char *, sObjectStopdir, OBJECT_STOPDIR)
EPCFG_STR(AppConfig, char *, sObjectFallback, OBJECT_FALLBACK)
EPCFG_STR(AppConfig, char *, sObjectHandlerClass, OBJECT_HANDLER_CLASS)
1.4.2.91 +6 -5 embperl/Attic/epcomp.c
Index: epcomp.c
===================================================================
RCS file: /home/cvs/embperl/Attic/epcomp.c,v
retrieving revision 1.4.2.90
retrieving revision 1.4.2.91
diff -u -r1.4.2.90 -r1.4.2.91
--- epcomp.c 27 Jan 2002 20:04:34 -0000 1.4.2.90
+++ epcomp.c 29 Jan 2002 09:13:46 -0000 1.4.2.91
@@ -9,7 +9,7 @@
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
-# $Id: epcomp.c,v 1.4.2.90 2002/01/27 20:04:34 richter Exp $
+# $Id: epcomp.c,v 1.4.2.91 2002/01/29 09:13:46 richter Exp $
#
###################################################################################*/
@@ -1582,7 +1582,7 @@
if (r -> Component.Config.bDebug & dbgCompile)
lprintf (r -> pApp, "[%d]EPCOMP: Start compiling %s DomTree = %d\n", r ->
pThread -> nPid, sSourcefile, xDomTree) ;
- ChdirToSource (r, sSourcefile) ;
+ /* ChdirToSource (r, sSourcefile) ; */
r -> Component.nPhase = phCompile ;
@@ -1851,13 +1851,14 @@
SetHashValueInt (r, r -> pCleanupPackagesHV, r ->
Component.sCurrPackage, 1) ;
/* --- change working directory --- */
- ChdirToSource (r, sSourcefile) ;
+ /* ChdirToSource (r, sSourcefile) ; */
rc = embperl_Execute2 (r, xSrcDomTree, pCV, pResultDomTree) ;
/* --- restore working directory --- */
- if (r -> Component.sResetDir[0])
+ /*
+ if (r -> Component.sResetDir[0])
{
#ifdef WIN32
_chdrive (r -> Component.nResetDrive) ;
@@ -1866,7 +1867,7 @@
strcpy (r -> Component.sCWD,r -> Component.sResetDir) ;
r -> Component.sResetDir[0] = '\0' ;
}
-
+ */
}
else
*pResultDomTree = 0 ;
1.1.2.19 +6 -11 embperl/Attic/epdat2.h
Index: epdat2.h
===================================================================
RCS file: /home/cvs/embperl/Attic/epdat2.h,v
retrieving revision 1.1.2.18
retrieving revision 1.1.2.19
diff -u -r1.1.2.18 -r1.1.2.19
--- epdat2.h 28 Jan 2002 20:28:34 -0000 1.1.2.18
+++ epdat2.h 29 Jan 2002 09:13:46 -0000 1.1.2.19
@@ -10,7 +10,7 @@
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
-# $Id: epdat2.h,v 1.1.2.18 2002/01/28 20:28:34 richter Exp $
+# $Id: epdat2.h,v 1.1.2.19 2002/01/29 09:13:46 richter Exp $
#
###################################################################################*/
@@ -74,7 +74,6 @@
unsigned bDebug ;
unsigned bOptions ;
int nCleanup ;
- char * sPath ;
int nEscMode ;
int bEP1Compat;
char * sCacheKey ;
@@ -98,6 +97,7 @@
char * sFilesMatch ;
char * sDecline ;
char cMultFieldSep ;
+ AV * pPathAV ;
} tReqConfig ;
typedef struct tReqParam
@@ -131,7 +131,7 @@
char * sMailErrorsTo ;
char * sObjectBase ;
char * sObjectApp ;
- char * sObjectAddpath ;
+ AV * pObjectAddpathAV ;
char * sObjectStopdir ;
char * sObjectFallback ;
char * sObjectHandlerClass ;
@@ -238,14 +238,7 @@
int nInsideSub ; /* Are we inside of a sub? */
int bExit ; /* We should exit the page */
int nPathNdx ; /* gives the index in the path where the
current file is found */
- char sCWD[PATH_MAX] ; /**< Current working directory */
-#ifdef WIN32
- char nCWDDrive ; /**< Current drive */
-#endif
- char sResetDir[PATH_MAX] ; /**< Reset directory to */
-#ifdef WIN32
- char nResetDrive ; /**< Reset drive to */
-#endif
+ char * sCWD ; /**< Current working directory */
bool bEP1Compat ; /* run in Embperl 1.x compatible mode */
int nPhase ; /* which phase of the request we are in */
@@ -364,6 +357,8 @@
AV * pCleanupAV ; /* set all sv's that are conatined in that array to undef
after the whole request */
HV * pCleanupPackagesHV ; /* packages that should be cleaned up at end of
request */
+ char * sInitialCWD ; /**< Reset directory to */
+
/* --- for statistics --- */
clock_t startclock ;
1.1.2.22 +7 -7 embperl/Attic/epinit.c
Index: epinit.c
===================================================================
RCS file: /home/cvs/embperl/Attic/epinit.c,v
retrieving revision 1.1.2.21
retrieving revision 1.1.2.22
diff -u -r1.1.2.21 -r1.1.2.22
--- epinit.c 28 Jan 2002 20:28:34 -0000 1.1.2.21
+++ epinit.c 29 Jan 2002 09:13:46 -0000 1.1.2.22
@@ -10,7 +10,7 @@
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
-# $Id: epinit.c,v 1.1.2.21 2002/01/28 20:28:34 richter Exp $
+# $Id: epinit.c,v 1.1.2.22 2002/01/29 09:13:46 richter Exp $
#
###################################################################################*/
@@ -958,6 +958,9 @@
pApp -> pCurrReq = r ;
sv_setsv(pThread -> pReqRV, r -> _perlsv) ;
+ r -> sInitialCWD = ep_palloc(pPool, MAX_PATH * 2) ;
+ getcwd (r -> sInitialCWD, MAX_PATH * 2 - 1) ;
+
*ppReq = r ;
return ok ;
@@ -1224,7 +1227,7 @@
}
else
{
- if ((rc = OpenOutput (r, c -> Param.sOutputfile)) != ok)
+ if ((rc = OpenOutput (r, embperl_File2Abs(r, pOutput -> pPool, c ->
Param.sOutputfile))) != ok)
return rc ;
}
@@ -1316,10 +1319,7 @@
Embperl__Component__Param_new_init (aTHX_ &c -> Param, SvRV(pPerlParam),
0) ;
}
- getcwd (c->sCWD, sizeof (c->sCWD)-1) ;
-#ifdef WIN32
- c -> nCWDDrive = _getdrive () ;
-#endif
+ c -> sCWD = pPrev?pPrev -> sCWD:r -> sInitialCWD ;
NewEscMode (r, NULL) ;
c -> bEscModeSet = 0 ;
@@ -1354,7 +1354,7 @@
else
*p = '\0' ;
}
- if (!*pParam -> sInputfile)
+ if (!*pParam -> sInputfile || strcmp(pParam -> sInputfile, "*") == 0)
pParam -> sInputfile = r -> Param.sFilename ;
1.75.4.94 +15 -84 embperl/epmain.c
Index: epmain.c
===================================================================
RCS file: /home/cvs/embperl/epmain.c,v
retrieving revision 1.75.4.93
retrieving revision 1.75.4.94
diff -u -r1.75.4.93 -r1.75.4.94
--- epmain.c 28 Jan 2002 20:28:34 -0000 1.75.4.93
+++ epmain.c 29 Jan 2002 09:13:46 -0000 1.75.4.94
@@ -10,7 +10,7 @@
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
-# $Id: epmain.c,v 1.75.4.93 2002/01/28 20:28:34 richter Exp $
+# $Id: epmain.c,v 1.75.4.94 2002/01/29 09:13:46 richter Exp $
#
###################################################################################*/
@@ -194,22 +194,28 @@
{
char * p = NULL ;
char buf[20] = "" ;
- if (!r -> Component.sSourcefile)
- p = "" ;
- if (!p)
- p = strrchr (r -> Component.sSourcefile, '/') ;
+ char * f ;
+ tComponent * c = &r -> Component ;
+ if (!(f = c -> sSourcefile))
+ {
+ c = r -> Component.pPrev ;
+ if (c && !(f = c -> sSourcefile))
+ f = "", p = "" ;
+ }
+ if (f && !p)
+ p = strrchr (f, '/') ;
if (p)
p++ ;
else
{
- p = strrchr (r -> Component.sSourcefile, '\\') ;
+ p = strrchr (f, '\\') ;
if (!p)
- p = r -> Component.sSourcefile ;
+ p = f ;
else
p++ ;
}
- if (r -> Component.nSourceline)
- sprintf (buf, "(%d)", r -> Component.nSourceline) ;
+ if (c && c -> nSourceline)
+ sprintf (buf, "(%d)", c -> nSourceline) ;
pSVLine = newSVpvf ("%s%s:", p, buf) ;
newSVpvf2(pSVLine) ;
}
@@ -1320,70 +1326,6 @@
return rc ;
}
- /* --- change working directory --- */
-
- if (
-#ifdef EP2
- r -> Component.Config.bEP1Compat &&
-#endif
- ((r -> Component.Config.bOptions & optDisableChdir) == 0 && sInputfile != NULL
&& sInputfile != '\0' && !SvROK(r -> Component.Param.pInput)))
- {
- char dir[PATH_MAX];
-#ifdef WIN32
- char drive[_MAX_DRIVE];
- char fname[_MAX_FNAME];
- char ext[_MAX_EXT];
- char * c = sInputfile ;
-
- while (*c)
- { /* convert / to \ */
- if (*c == '/')
- *c = '\\' ;
- c++ ;
- }
-
- r -> Component.nResetDrive = _getdrive () ;
- getcwd (r -> Component.sResetDir, sizeof (r -> Component.sResetDir) - 1) ;
-
- _splitpath(sInputfile, drive, dir, fname, ext );
- _chdrive (drive[0] - 'A' + 1) ;
-#else
- Dirname (sInputfile, dir, sizeof (dir) - 1) ;
- getcwd (r -> Component.sResetDir, sizeof (r -> Component.sResetDir) - 1) ;
-#endif
- if (dir[0])
- {
- if (chdir (dir) < 0)
- lprintf (r -> pApp, "chdir error\n" ) ;
- else
- {
- if (!(dir[0] == '/'
- #ifdef WIN32
- ||
- dir[0] == '\\' ||
- (isalpha(dir[0]) && dir[1] == ':' &&
- (dir[2] == '\\' || dir[2] == '/'))
- #endif
- ))
- {
- strcpy (r -> Component.sCWD,r -> Component.sResetDir) ;
- strcat (r -> Component.sCWD,"/") ;
- strcat (r -> Component.sCWD,dir) ;
- }
- else
- strcpy (r -> Component.sCWD,dir) ;
- }
- }
- else
- r -> Component.Config.bOptions |= optDisableChdir ;
- }
- else
-#ifdef EP2
- if (r -> Component.Config.bEP1Compat)
-#endif
- r -> Component.Config.bOptions |= optDisableChdir ;
-
-
r -> Component.bReqRunning = 1 ;
if ((rc = ProcessFile (r, 0 /*r -> Buf.pFile -> nFilesize*/)) != ok)
@@ -1410,17 +1352,6 @@
Cache_ReleaseContent (r, r -> Component.pOutputCache) ;
#endif
- /* --- restore working directory --- */
- if (r -> Component.sResetDir[0])
- {
-#ifdef WIN32
- _chdrive (r -> Component.nResetDrive) ;
-#endif
- chdir (r -> Component.sResetDir) ;
- strcpy (r -> Component.sCWD,r -> Component.sResetDir) ;
- r -> Component.sResetDir[0] = '\0' ;
- }
-
/* --- reset variables and log end of request --- */
if ((rc = ResetRequest (r, sInputfile)) != ok)
LogError (r, rc) ;
1.1.2.28 +19 -65 embperl/Attic/epprovider.c
Index: epprovider.c
===================================================================
RCS file: /home/cvs/embperl/Attic/epprovider.c,v
retrieving revision 1.1.2.27
retrieving revision 1.1.2.28
diff -u -r1.1.2.27 -r1.1.2.28
--- epprovider.c 27 Jan 2002 20:04:34 -0000 1.1.2.27
+++ epprovider.c 29 Jan 2002 09:13:46 -0000 1.1.2.28
@@ -9,7 +9,7 @@
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
-# $Id: epprovider.c,v 1.1.2.27 2002/01/27 20:04:34 richter Exp $
+# $Id: epprovider.c,v 1.1.2.28 2002/01/29 09:13:46 richter Exp $
#
###################################################################################*/
@@ -299,9 +299,7 @@
epTHX_
int rc ;
tProviderFile * pNew ;
- const char * sFilename ;
- const char * sDir = NULL ;
- char * c ;
+ char * sFilename ;
if ((rc = Provider_New (r, sizeof(tProviderFile), pItem, pProviderClass,
pParam)) != ok)
return rc ;
@@ -309,40 +307,14 @@
pNew = (tProviderFile *)pItem -> pProvider ;
sFilename = GetHashValueStr (aTHX_ pParam, "filename", r ->
Component.Param.sInputfile) ;
-
-#ifdef WIN32
- c = sFilename ;
- while (*c)
- { /* convert / to \ */
- if (*c == '/')
- *c = '\\' ;
- c++ ;
- }
-#endif
-
- /* is it a relative filename? -> append path */
- if (!(sFilename[0] == '/'
-#ifdef WIN32
- ||
- sFilename[0] == '\\' ||
- (isalpha(sFilename[0]) && sFilename[1] == ':' &&
- (sFilename[2] == '\\' || sFilename[2] == '/'))
-#endif
- ))
+ pNew -> sFilename = embperl_PathSearch(r, NULL, sFilename) ;
+ if (!pNew -> sFilename)
{
- int l = strlen (sFilename) + strlen (r -> Component.sCWD) + 2 ;
-
- pNew -> sFilename = malloc (l) ;
- strcpy ((char *)pNew -> sFilename, r -> Component.sCWD) ;
-#ifdef WIN32
- strcat ((char *)pNew -> sFilename, "\\") ;
-#else
- strcat ((char *)pNew -> sFilename, "/") ;
-#endif
- strcat ((char *)pNew -> sFilename, sFilename) ;
+ strncpy (r -> errdat1, sFilename, sizeof (r -> errdat1) - 1) ;
+ return rcNotFound ;
}
- else
- pNew -> sFilename = strdup (sFilename) ;
+
+
pItem -> sExpiresFilename = strdup (pNew -> sFilename) ;
return ok ;
@@ -389,37 +361,18 @@
/*i/o*/ SV * pKey)
{
epTHX_
- const char * sFilename = GetHashValueStr (aTHX_ pParam, "filename", r ->
Component.Param.sInputfile) ;
- const char * sDir = "" ;
- char * c = sFilename ;
-
-#ifdef WIN32
- while (*c)
- { /* convert / to \ */
- if (*c == '/')
- *c = '\\' ;
- c++ ;
- }
-#endif
-
- /* is it a relative filename? -> append path */
- if (!(sFilename[0] == '/'
-#ifdef WIN32
- ||
- sFilename[0] == '\\' ||
- (isalpha(sFilename[0]) && sFilename[1] == ':' &&
- (sFilename[2] == '\\' || sFilename[2] == '/'))
-#endif
- ))
+ const char * sFilename ;
+ const char * sAbsFilename ;
+
+ sFilename = GetHashValueStr (aTHX_ pParam, "filename", r ->
Component.Param.sInputfile) ;
+ sAbsFilename = embperl_PathSearch(r, NULL, (char *)sFilename) ;
+ if (!sAbsFilename)
{
- sDir = r -> Component.sCWD ;
+ strncpy (r -> errdat1, sFilename, sizeof (r -> errdat1) - 1) ;
+ return rcNotFound ;
}
-#ifdef WIN32
- sv_catpvf (pKey, "*file:%s%s%s", sDir, *sDir?"\\":"", sFilename) ;
-#else
- sv_catpvf (pKey, "*file:%s%s%s", sDir, *sDir?"/":"", sFilename) ;
-#endif
+ sv_catpvf (pKey, "*file:%s", sAbsFilename) ;
return ok ;
}
@@ -466,7 +419,8 @@
int rc = ok ;
r -> Component.sSourcefile = (char *)((tProviderFile *)pProvider) -> sFilename ;
-
+ embperl_SetCWDToFile (r, r -> Component.sSourcefile) ;
+
if (!bUseCache)
{
rc = ReadHTML(r, (char *)((tProviderFile *)pProvider) -> sFilename,
&nSize, pData) ;
1.15.4.36 +145 -196 embperl/eputil.c
Index: eputil.c
===================================================================
RCS file: /home/cvs/embperl/eputil.c,v
retrieving revision 1.15.4.35
retrieving revision 1.15.4.36
diff -u -r1.15.4.35 -r1.15.4.36
--- eputil.c 22 Jan 2002 16:52:43 -0000 1.15.4.35
+++ eputil.c 29 Jan 2002 09:13:46 -0000 1.15.4.36
@@ -10,7 +10,7 @@
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
-# $Id: eputil.c,v 1.15.4.35 2002/01/22 16:52:43 richter Exp $
+# $Id: eputil.c,v 1.15.4.36 2002/01/29 09:13:46 richter Exp $
#
###################################################################################*/
@@ -1072,145 +1072,7 @@
}
-/* ------------------------------------------------------------------------- */
-/* */
-/* Dirname */
-/* */
-/* returns dir name of file */
-/* */
-/* ------------------------------------------------------------------------- */
-
-
-
-void Dirname (/*in*/ const char * filename,
- /*out*/ char * dirname,
- /*in*/ int size)
-
- {
- char * p = strrchr (filename, '/') ;
-
- if (p == NULL)
- {
- strncpy (dirname, ".", size) ;
- return ;
- }
-
- if (size - 1 > p - filename)
- size = p - filename ;
-
- strncpy (dirname, filename, size) ;
- dirname[size] = '\0' ;
-
- return ;
- }
-
-#if 0
-
-/* ------------------------------------------------------------------------- */
-/* */
-/* GetSubTextPos */
-/* */
-/* */
-/* in sName = name of sub */
-/* */
-/* returns the position within the file for a given Embperl sub */
-/* */
-/* ------------------------------------------------------------------------- */
-
-
-int GetSubTextPos (/*i/o*/ register req * r,
- /*in*/ const char * sName)
-
- {
- SV ** ppSV ;
- const char * sKey ;
- char sKeyBuf[sizeof (int) + 4] ;
- int l ;
- epTHX_
-
- EPENTRY (Eval) ;
-
- while (isspace(*sName))
- sName++ ;
-
- l = strlen (sName) ;
- while (l > 0 && isspace(sName[l-1]))
- l-- ;
-
- sKey = sName ;
- if (l < sizeof (int))
- { /* right pad name with spaces to make sure name is longer then sizeof (int)
*/
- /* distiguish it from filepos entrys */
- memset (sKeyBuf, ' ', sizeof (sKeyBuf) - 1) ;
- sKeyBuf[sizeof(sKeyBuf) - 1] = '\0' ;
- memcpy (sKeyBuf, sName, l) ;
- sKey = sKeyBuf ;
- l = sizeof(sKeyBuf) - 1 ;
- }
-
-
- ppSV = hv_fetch(r -> Buf.pFile -> pCacheHash, (char *)sKey, l, 0) ;
- if (ppSV == NULL || *ppSV == NULL) /* || SvTYPE (*ppSV) != SVt_IV)*/
- return 0 ;
-
- return SvIV (*ppSV) ;
- }
-
-
-/* ------------------------------------------------------------------------- */
-/* */
-/* SetSubTextPos */
-/* */
-/* */
-/* in sName = name of sub */
-/* in nPos = position within the file for a given Embperl sub */
-/* */
-/* ------------------------------------------------------------------------- */
-
-
-int SetSubTextPos (/*i/o*/ register req * r,
- /*in*/ const char * sName,
- /*in*/ int nPos)
-
- {
- SV ** ppSV ;
- const char * sKey ;
- char sKeyBuf[sizeof (int) + 4] ;
- int l ;
- epTHX_
-
- EPENTRY (Eval) ;
-
- while (isspace(*sName))
- sName++ ;
-
- l = strlen (sName) ;
- while (l > 0 && isspace(sName[l-1]))
- l-- ;
-
- sKey = sName ;
- if (l < sizeof (int))
- { /* right pad name with spaces to make sure name is longer then sizeof (int)
*/
- /* distiguish it from filepos entrys */
- memset (sKeyBuf, ' ', sizeof (sKeyBuf) - 1) ;
- sKeyBuf[sizeof(sKeyBuf) - 1] = '\0' ;
- memcpy (sKeyBuf, sName, l) ;
- sKey = sKeyBuf ;
- l = sizeof(sKeyBuf) - 1 ;
- }
-
-
- ppSV = hv_fetch(r -> Buf.pFile -> pCacheHash, (char *)sKey, l, 1) ;
- if (ppSV == NULL)
- return rcHashError ;
-
- SvREFCNT_dec (*ppSV) ;
- *ppSV = newSViv (nPos) ;
-
- return ok ;
- }
-#endif
#ifdef EP2
@@ -1539,83 +1401,170 @@
return pUID ;
}
+/* ------------------------------------------------------------------------- */
+/* */
+/* dirname */
+/* */
+/* returns dir name of file */
+/* */
+/* ------------------------------------------------------------------------- */
+
+
+
+static void dirname (/*in*/ const char * filename,
+ /*out*/ char * dirname,
+ /*in*/ int size)
+
+ {
+ char * p = strrchr (filename, '/') ;
+
+ if (p == NULL)
+ {
+ strncpy (dirname, ".", size) ;
+ return ;
+ }
+
+ if (size - 1 > p - filename)
+ size = p - filename ;
+
+ strncpy (dirname, filename, size) ;
+ dirname[size] = '\0' ;
+
+ return ;
+ }
+
+
+#ifdef WIN32
+#define isAbsPath(sFilename) \
+ (sFilename[0] == '/' || sFilename[0] == '\\' || \
+ (isalpha(sFilename[0]) && sFilename[1] == ':' && \
+ (sFilename[2] == '\\' || sFilename[2] == '/') \
+ ) \
+ )
+#else
+#define isAbsPath(sFilename) (!(sFilename[0] == '/'))
+#endif
+
/* ---------------------------------------------------------------------------- */
/* */
-/* Change Dir to sourcefile dir */
+/* Make filename absolut */
/* */
/* ---------------------------------------------------------------------------- */
-void ChdirToSource (/*i/o*/ register req * r,
- /*in*/ char * sInputfile)
-
+char * embperl_File2Abs (/*i/o*/ register req * r,
+ /*in*/ tMemPool * pPool,
+ /*in*/ char * sFilename)
{
epTHX_
-
- if ((r -> Component.Config.bOptions & optDisableChdir) == 0 && sInputfile !=
NULL && sInputfile != '\0' &&
- (!r -> Component.Param.pInput || !SvROK(r -> Component.Param.pInput)) && !r ->
Component.sResetDir[0])
- {
- char dir[PATH_MAX];
-#ifdef WIN32
- char drive[_MAX_DRIVE];
- char fname[_MAX_FNAME];
- char ext[_MAX_EXT];
- char * c = sInputfile ;
-
- while (*c)
- { /* convert / to \ */
- if (*c == '/')
- *c = '\\' ;
- c++ ;
- }
+ char * c ;
+ char * sAbsname ;
+
+ if (sFilename == NULL)
+ return NULL ;
- r -> Component.nResetDrive = _getdrive () ;
- getcwd (r -> Component.sResetDir, sizeof (r -> Component.sResetDir) - 1) ;
+#ifdef WIN32
+ c = sFilename ;
+ while (*c)
+ { /* convert / to \ */
+ if (*c == '/')
+ *c = '\\' ;
+ c++ ;
+ }
+#endif
- _splitpath(sInputfile, drive, dir, fname, ext );
- _chdrive (drive[0] - 'A' + 1) ;
+ /* is it a relative filename? -> append path */
+ if (!isAbsPath(sFilename))
+ {
+ int l = strlen (sFilename) + strlen (r -> Component.sCWD) + 2 ;
+
+ sAbsname = pPool?ep_palloc(pPool, l):malloc (l) ;
+ strcpy (sAbsname, r -> Component.sCWD) ;
+#ifdef WIN32
+ strcat (sAbsname, "\\") ;
#else
- Dirname (sInputfile, dir, sizeof (dir) - 1) ;
- getcwd (r -> Component.sResetDir, sizeof (r -> Component.sResetDir) - 1) ;
+ strcat (sAbsname, "/") ;
#endif
- if (dir[0])
- {
- if (chdir (dir) < 0)
- {
- strncpy (r -> errdat1, dir, sizeof(r -> errdat1) - 1) ;
- LogError (r, rcChdirError) ;
- }
- else
- {
- if (!(dir[0] == '/'
- #ifdef WIN32
- ||
- dir[0] == '\\' ||
- (isalpha(dir[0]) && dir[1] == ':' &&
- (dir[2] == '\\' || dir[2] == '/'))
- #endif
- ))
- {
- strcpy (r -> Component.sCWD,r -> Component.sResetDir) ;
- strcat (r -> Component.sCWD,"/") ;
- strcat (r -> Component.sCWD,dir) ;
- }
- else
- strcpy (r -> Component.sCWD,dir) ;
- }
- }
- else
- r -> Component.Config.bOptions |= optDisableChdir ;
- }
+ strcat (sAbsname, sFilename) ;
+ }
else
- r -> Component.Config.bOptions |= optDisableChdir ;
+ sAbsname = pPool?ep_pstrdup (pPool, sFilename):strdup (sFilename) ;
+
+ return sAbsname ;
+ }
+
+
+/* ---------------------------------------------------------------------------- */
+/* */
+/* Change CWD to sourcefile dir */
+/* */
+/* ---------------------------------------------------------------------------- */
+
+void embperl_SetCWDToFile (/*i/o*/ register req * r,
+ /*in*/ char * sFilename)
+
+ {
+ epTHX_
+ char * sAbsFilename ;
+ char * p ;
+
+ if ((r -> Component.Config.bOptions & optDisableChdir) ||
+ sFilename == NULL || *sFilename == '\0' ||
+ r -> Component.Param.pInput)
+ return ;
+
+
+ sAbsFilename = embperl_File2Abs(r, r -> pPool, sFilename) ;
+#ifdef WIN32
+ p = strrchr(sAbsFilename, '\\') ;
+#else
+ p = strrchr(sAbsFilename, '/') ;
+#endif
+ r -> Component.sCWD = sAbsFilename ;
+ *p = '\0' ;
}
+/* ---------------------------------------------------------------------------- */
+/* */
+/* Path serach */
+/* */
+/* ---------------------------------------------------------------------------- */
+
+char * embperl_PathSearch (/*i/o*/ register req * r,
+ /*in*/ tMemPool * pPool,
+ /*in*/ char * sFilename)
+
+ {
+ epTHX_
+ AV *pPathAV = r -> Config.pPathAV ;
+ int i ;
+ struct stat st ;
+ char * fn ;
+ STRLEN l ;
+
+ if (isAbsPath(sFilename) || !pPathAV || AvFILL (pPathAV) < r ->
Component.nPathNdx)
+ return embperl_File2Abs (r, pPool, sFilename) ;
+ for (i = 0 ; i <= AvFILL (pPathAV); i++)
+ {
+#ifdef WIN32
+ fn = ep_pstrcat(r -> pPool, SvPV(*av_fetch (pPathAV, i, 0), l), "\\",
sFilename, NULL) ;
+#else
+ fn = ep_pstrcat(r -> pPool, SvPV(*av_fetch (pPathAV, i, 0), l), "/",
sFilename, NULL) ;
+#endif
+ if (stat (fn, &st) == 0)
+ {
+ r -> Component.nPathNdx = i ;
+ return embperl_File2Abs (r, pPool, sFilename) ;
+ }
+ }
+
+ return NULL ;
+ }
/* ---------------------------------------------------------------------------- */
No revision
No revision
1.1.2.3 +16 -14 embperl/Embperl/Attic/Object.pm
Index: Object.pm
===================================================================
RCS file: /home/cvs/embperl/Embperl/Attic/Object.pm,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- Object.pm 28 Jan 2002 20:28:35 -0000 1.1.2.2
+++ Object.pm 29 Jan 2002 09:13:47 -0000 1.1.2.3
@@ -10,7 +10,7 @@
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
-# $Id: Object.pm,v 1.1.2.2 2002/01/28 20:28:35 richter Exp $
+# $Id: Object.pm,v 1.1.2.3 2002/01/29 09:13:47 richter Exp $
#
###################################################################################
@@ -202,7 +202,7 @@
$directory = dirname ($filename) ;
}
- my $searchpath ;
+ my @searchpath ;
print Embperl::LOG "[$$]Embperl::Object Request Filename: $filename\n" if
($debug);
print Embperl::LOG "[$$]Embperl::Object basename: $basename\n" if ($debug);
@@ -216,7 +216,7 @@
do
{
$fn = "$directory/$basename" ;
- $searchpath .= ";$directory" ;
+ push @searchpath, $directory ;
print Embperl::LOG "[$$]Embperl::Object Check for base: $fn\n" if ($debug);
if (-e $fn)
{
@@ -235,10 +235,10 @@
{
$ldir = $directory ;
$directory = dirname ($directory) ;
- $searchpath .= ";$directory" ;
+ push @searchpath, $directory ;
}
- $searchpath .= ";$addpath" if ($addpath) ;
+ push @searchpath, @$addpath if ($addpath) ;
if (!$found)
{
foreach $ap (@addpath)
@@ -260,7 +260,7 @@
if ($found)
{
print Embperl::LOG "[$$]Embperl::Object Found Base: $fn\n" if ($debug);
- print Embperl::LOG "[$$]Embperl::Object path: $searchpath\n" if ($debug);
+ print Embperl::LOG "[$$]Embperl::Object path: @searchpath\n" if ($debug);
my $basepackage = $packages{$fn} ;
@@ -293,12 +293,13 @@
}
use strict ;
- my $new = 0 ;
+ $r -> config -> path (\@searchpath) ;
+
if (!$package || $fallback)
{
print Embperl::LOG "[$$]Embperl::Object import new file: $filename\n"
if ($debug && !$fallback);
- my $cparam = {%$req, inputfile => $filename, import => 0, 'path' =>
$searchpath } ;
+ my $cparam = {%$req, inputfile => $filename, import => 0 } ;
my $c = $r -> setup_component ($cparam) ;
$c -> run ;
$package = $packages{$filename} = $c -> curr_package ;
@@ -313,16 +314,13 @@
}
use strict ;
- $req -> {'inputfile'} = $ENV{PATH_TRANSLATED} = $fn ;
- $req -> {'bless'} = $package ;
- $req -> {'path'} = $searchpath ;
$r -> param -> filename ($filename) if ($filename ne $fn) ;
+ bless $r, $package ;
if (0) #$req -> {object_app})
{
my $app = Embperl::Req::ExecuteComponent ($r, {'object' => $req ->
{object_app},
'syntax' => 'Perl',
- 'path' => $searchpath,
'param' => [$req],
'debug' => $req -> {debug},
'reqfilename'=> $filename,
@@ -336,12 +334,16 @@
return $status if ($status) ;
}
+ my $cparam = {%$req, inputfile => $fn } ;
+ my $c = $r -> setup_component ($cparam) ;
- return $r -> execute_component ($req) ;
+ $r -> run ;
+ $r -> cleanup ;
+ return &OK ;
}
- $apr -> log_error ("Embperl::Object searched '$searchpath'" . ($addpath?" and
'$addpath' ":'')) if ($apr) ;
+ $apr -> log_error ("Embperl::Object searched '@searchpath'" . ($addpath?" and
'$addpath' ":'')) if ($apr) ;
return &NOT_FOUND ;
}
No revision
No revision
1.1.2.11 +5 -6 embperl/xsbuilder/maps/Attic/ep_structure.map
Index: ep_structure.map
===================================================================
RCS file: /home/cvs/embperl/xsbuilder/maps/Attic/ep_structure.map,v
retrieving revision 1.1.2.10
retrieving revision 1.1.2.11
diff -u -r1.1.2.10 -r1.1.2.11
--- ep_structure.map 28 Jan 2002 20:28:36 -0000 1.1.2.10
+++ ep_structure.map 29 Jan 2002 09:13:47 -0000 1.1.2.11
@@ -25,6 +25,8 @@
! pDomTreeAV | dom_tree_av
pCleanupAV | cleanup_vars
pCleanupPackagesHV | cleanup_packages
+ sInitialCWD | initial_cwd
+
startclock
stsv_count
! MemCheckpoint | mem_checkpoint
@@ -73,7 +75,7 @@
sMailErrorsTo | mail_errors_to
sObjectBase | object_base
sObjectApp | object_app
- sObjectAddpath | object_addpath
+ pObjectAddpathAV | object_addpath
sObjectStopdir | object_stopdir
sObjectFallback | object_fallback
sObjectHandlerClass | object_handler_class
@@ -92,10 +94,7 @@
nInsideSub | inside_sub
bExit | exit
nPathNdx | path_ndx
- sCWD[PATH_MAX] | cwd
-! nCWDDrive | cwddrive
- sResetDir[PATH_MAX] | reset_dir
-! nResetDrive | reset_drive
+ sCWD | cwd
bEP1Compat | ep1_compat
nPhase | phase
sSourcefile | sourcefile
@@ -144,7 +143,6 @@
sPackage | package
bDebug | debug
bOptions | options
- sPath | path
nEscMode | escmode
bEP1Compat | ep1compat
sCacheKey | cache_key
@@ -188,6 +186,7 @@
sFilesMatch | filesmatch
sDecline | decline
cMultFieldSep | mult_field_sep
+ pPathAV | path
new
! private
</tReqConfig>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]