[Plib-cvs] plib/src/psl psl.cxx,1.4,1.5 psl.h,1.22,1.23 pslCompiler.cxx,1.27,1.28 pslFileIO.cxx,1.5,
Brought to you by:
sjbaker
From: Steve B. <sj...@us...> - 2002-09-27 15:45:10
|
Update of /cvsroot/plib/plib/src/psl In directory usw-pr-cvs1:/tmp/cvs-serv20459/plib/src/psl Modified Files: psl.cxx psl.h pslCompiler.cxx pslFileIO.cxx pslLocal.h Log Message: Added Bernie Bright's XPlane loader. Fixed some more 'gotcha's in PSL. Index: psl.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/psl.cxx,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- psl.cxx 6 Sep 2002 15:07:44 -0000 1.4 +++ psl.cxx 27 Sep 2002 15:45:06 -0000 1.5 @@ -24,8 +24,43 @@ #include "pslLocal.h" -int _pslInitialised = FALSE ; +int _pslInitialised = FALSE ; +char *_pslScriptPath = NULL ; void pslInit () { _pslInitialised = TRUE ; } + +void pslScriptPath ( char *path ) +{ + delete [] _pslScriptPath ; + _pslScriptPath = ulStrDup ( path ) ; +} + + +char* _pslMakeScriptPath ( char* path, const char* fname ) +{ + if ( fname != NULL && fname [ 0 ] != '\0' ) + { + if ( ! ulIsAbsolutePathName ( fname ) && + _pslScriptPath != NULL && _pslScriptPath[0] != '\0' ) + { + strcpy ( path, _pslScriptPath ) ; + strcat ( path, "/" ) ; + strcat ( path, fname ) ; + } + else + strcpy ( path, fname ) ; + + /* Convert backward slashes to forward slashes */ + + for ( char* ptr = path ; *ptr ; ptr ++ ) + if ( *ptr == '\\' ) + *ptr = '/' ; + } + else + path [0] = 0 ; + + return path ; +} + Index: psl.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/psl.h,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- psl.h 22 Sep 2002 20:49:05 -0000 1.22 +++ psl.h 27 Sep 2002 15:45:06 -0000 1.23 @@ -330,6 +330,7 @@ void pslInit () ; +void pslScriptPath ( char *path ) ; void pslSetErrorCallback ( void (*CB) ( pslProgram *, int, char *, int, char * ) ) ; #endif Index: pslCompiler.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCompiler.cxx,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- pslCompiler.cxx 22 Sep 2002 18:25:16 -0000 1.27 +++ pslCompiler.cxx 27 Sep 2002 15:45:06 -0000 1.28 @@ -28,13 +28,16 @@ int pslCompiler::compile ( const char *fname ) { - FILE *fd = fopen ( fname, "ra" ) ; + char filename [ 1024 ] ; + _pslMakeScriptPath ( filename, fname ) ; + + FILE *fd = fopen ( filename, "ra" ) ; if ( fd == NULL ) { perror ( "PSL:" ) ; ulSetError ( UL_WARNING, "PSL: Failed while opening '%s' for reading.", - fname ); + filename ); return FALSE ; } Index: pslFileIO.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslFileIO.cxx,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- pslFileIO.cxx 15 Sep 2002 14:32:53 -0000 1.5 +++ pslFileIO.cxx 27 Sep 2002 15:45:06 -0000 1.6 @@ -120,11 +120,15 @@ void _pslPushDefaultFile ( const char *fname ) { - FILE *fd = fopen ( fname, "ra" ) ; + char filename [ 1024 ] ; + _pslMakeScriptPath ( filename, fname ) ; + + FILE *fd = fopen ( filename, "ra" ) ; if ( fd == NULL ) { - fprintf ( stderr, "PSL: ERROR - Can't open #include'ed file '%s'", fname ) ; + fprintf ( stderr, + "PSL: ERROR - Can't open #include'ed file '%s'", filename ) ; return ; } Index: pslLocal.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslLocal.h,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- pslLocal.h 15 Sep 2002 00:02:51 -0000 1.16 +++ pslLocal.h 27 Sep 2002 15:45:06 -0000 1.17 @@ -59,4 +59,5 @@ #include "pslCompiler.h" #include "pslContext.h" +char* _pslMakeScriptPath ( char* path, const char* fname ) ; |