--- parser3/src/main/pa_exec.C 2004/07/28 13:25:41 1.64 +++ parser3/src/main/pa_exec.C 2007/04/23 10:30:31 1.69 @@ -1,13 +1,13 @@ /** @file Parser: program executing for different OS-es. - Copyright(c) 2000,2001-2004 ArtLebedev Group(http://www.artlebedev.com) + Copyright(c) 2000,2001-2005 ArtLebedev Group(http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) @todo setrlimit */ -static const char * const IDENT_EXEC_C="$Date: 2004/07/28 13:25:41 $"; +static const char * const IDENT_EXEC_C="$Date: 2007/04/23 10:30:31 $"; #include "pa_config_includes.h" @@ -27,6 +27,7 @@ static const char * const IDENT_EXEC_C=" /// this func from http://www.ccas.ru/~posp/popov/spawn.htm static DWORD CreateHiddenConsoleProcess(LPCTSTR szCmdLine, + LPCTSTR szScriptFileSpec, char *szEnv, PROCESS_INFORMATION* ppi, LPHANDLE phInWrite, @@ -72,7 +73,7 @@ static DWORD CreateHiddenConsoleProcess( // calculating script's directory char dir[MAX_STRING]; - strncpy(dir, szCmdLine, MAX_STRING-1); dir[MAX_STRING-1]=0; + strncpy(dir, szScriptFileSpec, MAX_STRING-1); dir[MAX_STRING-1]=0; lsplit(dir,' '); // trim arguments rsplit(dir,'/'); rsplit(dir,'\\'); // trim filename @@ -131,9 +132,9 @@ static const char* buildCommand(const ch buf[size]=0; if(strncmp(buf, "#!", 2)==0) { const char* begin=buf+2; - if(*begin==' ') // alx: were an old magic for some linux-es + while(*begin==' ') // alx: were an old magic for some linux-es begin++; - if(char *end=strchr(begin, '\n')) { + if(const char *end=strchr(begin, '\n')) { String string(pa_strdup(begin, end-begin)); string << " " << file_spec_cstr; result=string.cstr(); @@ -329,7 +330,7 @@ PA_exec_result pa_exec( #ifdef NO_PA_EXECS if(!forced_allow) - throw Exception("parser.runtime", + throw Exception(PARSER_RUNTIME, &file_spec, "parser execs are disabled [recompile parser without --disable-execs configure option]"); #endif @@ -338,18 +339,19 @@ PA_exec_result pa_exec( PROCESS_INFORMATION pi; HANDLE hInWrite, hOutRead, hErrRead; - const char* cmd=buildCommand(file_spec.cstr(String::L_FILE_SPEC), argv); + const char* script_spec_cstr=file_spec.cstr(String::L_FILE_SPEC); + const char* cmd=buildCommand(script_spec_cstr, argv); char* env_cstr=0; if(env) { String::Body body; Append_env_pair_info info(body); - env->for_each(append_env_pair, &info); + env->for_each(append_env_pair, &info); env_cstr=info.body.cstrm(); for(char* replacer=env_cstr; *replacer; replacer++) if(*replacer=='\1') *replacer=0; } - if(DWORD error=CreateHiddenConsoleProcess(cmd, env_cstr, &pi, &hInWrite, &hOutRead, &hErrRead)) { + if(DWORD error=CreateHiddenConsoleProcess(cmd, script_spec_cstr, env_cstr, &pi, &hInWrite, &hOutRead, &hErrRead)) { char szErrorDesc[MAX_STRING]; const char* param="the file you tried to run"; size_t error_size=FormatMessage( @@ -406,11 +408,11 @@ from http://www.apache.org/websrc/cvsweb } #endif - char* argv_cstrs[1+10+1]={file_spec_cstr, 0}; + char* argv_cstrs[1+50+1]={file_spec_cstr, 0}; const int argv_size=argv.count(); const int argv_max=sizeof(argv_cstrs)/sizeof(argv_cstrs[0])-1-1; if(argv_size>argv_max) - throw Exception("parser.runtime", + throw Exception(PARSER_RUNTIME, &file_spec, "too many arguments (%d > max %d)", argv_size, argv_max); for(int i=0; i