Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13205/src
Modified Files: Tag: devel_0_38 s_entry.c Log Message: tokenizing the command line string is sensitive to whitespace - use preparsed __argc and __argv instead
Index: s_entry.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/s_entry.c,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -C2 -d -r1.2 -r1.2.4.1 *** s_entry.c 6 Sep 2004 20:20:35 -0000 1.2 --- s_entry.c 10 Nov 2004 10:52:15 -0000 1.2.4.1 *************** *** 2,7 **** that externs can link back to functions defined in pd. */
- #include <stdio.h> - int sys_main(int argc, char **argv);
--- 2,5 ---- *************** *** 9,46 **** #include <windows.h> #include <stdio.h> ! #include <malloc.h> ! ! #define MAXARGS 1024 ! #define MAXARGLEN 1024 ! ! /* jsarlo { */ ! int tokenizeCommandLineString(char *clString, char **tokens) ! { ! int i, charCount = 0; ! int tokCount= 0; ! int quoteOpen = 0; ! ! for (i = 0; i < (int)strlen(clString); i++) ! { ! if (clString[i] == '"') ! { ! quoteOpen = !quoteOpen; ! } ! else if (clString[i] == ' ' && !quoteOpen) ! { ! tokens[tokCount][charCount] = 0; ! tokCount++; ! charCount = 0; ! } ! else ! { ! tokens[tokCount][charCount] = clString[i]; ! charCount++; ! } ! } ! tokens[tokCount][charCount] = 0; ! tokCount++; ! return tokCount; ! }
int WINAPI WinMain(HINSTANCE hInstance, --- 7,11 ---- #include <windows.h> #include <stdio.h> ! #include <stdlib.h>
int WINAPI WinMain(HINSTANCE hInstance, *************** *** 49,68 **** int nCmdShow) { ! int i, argc; ! char *argv[MAXARGS]; ! ! __try { ! for (i = 0; i < MAXARGS; i++) ! { ! argv[i] = (char *)malloc(MAXARGLEN * sizeof(char)); ! } ! GetModuleFileName(NULL, argv[0], MAXARGLEN); ! argc = tokenizeCommandLineString(lpCmdLine, argv + 1) + 1; ! sys_main(argc, argv); ! for (i = 0; i < MAXARGS; i++) ! { ! free(argv[i]); ! } } __finally --- 14,20 ---- int nCmdShow) { ! __try { ! sys_main(__argc,__argv); /* use preparsed arguments */ } __finally *************** *** 72,77 **** }
- /* } jsarlo */ - #else /* not MSW */ int main(int argc, char **argv) --- 24,27 ---- *************** *** 81,83 **** #endif
- --- 31,32 ----