-- Stephane Soppera (thanks) reported libc stat function fails for paths ending with "\" under win with free VC++ compiler toolkit 2003:
    removed final '/' (BLI_make_file_string changes the '/' to '\\\\' for win) slashes from relevant paths, that should take care of it .  Note: here (linux, glibc, gcc 3.3.3) stat doesn't have this problem.  Also checking if U.pythondir ends with a slash and, if so (as long as its length > 2 to), removing the slash, for the same reason.
-- small cosmetic changes in BPY_menus.c for debug msgs and in header_scripts (added a separator in the Scripts win -> Scripts menu).
This commit is contained in:
2005-03-22 04:28:36 +00:00
parent a8a73e8097
commit a4b5ddb371
5 changed files with 43 additions and 36 deletions

View File

@@ -306,18 +306,28 @@ that dir info is available.
****************************************************************************/
void BPY_post_start_python( void )
{
PyObject *result, *dict;
char dirpath[FILE_MAXDIR];
char *sdir = NULL;
if(U.pythondir[0] != '\0' ) {
char modpath[FILE_MAXDIR];
int upyslen = strlen(U.pythondir);
/* check if user pydir ends with a slash and, if so, remove the slash
* (for eventual implementations of c library's stat function that might
* not like it) */
if (upyslen > 2) { /* avoids doing anything if dir == '//' */
char ending = U.pythondir[upyslen - 1];
if (ending == '/' || ending == '\\')
U.pythondir[upyslen - 1] = '\0';
}
BLI_strncpy(dirpath, U.pythondir, FILE_MAXDIR);
BLI_convertstringcode(dirpath, G.sce, 0);
syspath_append(dirpath); /* append to module search path */
BLI_make_file_string("/", modpath, dirpath, "bpymodules/");
BLI_make_file_string("/", modpath, dirpath, "bpymodules");
if (BLI_exists(modpath)) syspath_append(modpath);
}
@@ -326,25 +336,13 @@ void BPY_post_start_python( void )
syspath_append(sdir);
BLI_make_file_string("/", dirpath, sdir, "bpymodules/");
BLI_make_file_string("/", dirpath, sdir, "bpymodules");
if (BLI_exists(dirpath)) syspath_append(dirpath);
}
BPyMenu_Init( 0 ); /* get dynamic menus (registered scripts) data */
dict = PyDict_New( );
/* here we check if the user has (some of) the expected modules */
if( dict ) {
char *s = "import chunk, gzip, math, os, struct, string";
result = PyRun_String( s, Py_eval_input, dict, dict );
if( !result ) {
PyErr_Clear( );
/*XXX print msg about this, point to readme.html */
} else
Py_DECREF( result );
Py_DECREF( dict );
}
return;
}
/****************************************************************************