~ubuntu-branches/ubuntu/karmic/libsdl1.2/karmic

« back to all changes in this revision

Viewing changes to src/main/win32/SDL_win32_main.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Kowalik
  • Date: 2008-01-05 14:10:45 UTC
  • mto: (2.1.3 lenny)
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20080105141045-mjdg2rp09mamme4a
Tags: upstream-1.2.13
ImportĀ upstreamĀ versionĀ 1.2.13

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
#define isspace(a) (((CHAR)a == ' ') || ((CHAR)a == '\t'))
54
54
#endif /* _WIN32_WCE < 300 */
55
55
 
 
56
static void UnEscapeQuotes( char *arg )
 
57
{
 
58
        char *last = NULL;
 
59
 
 
60
        while( *arg ) {
 
61
                if( *arg == '"' && *last == '\\' ) {
 
62
                        char *c_curr = arg;
 
63
                        char *c_last = last;
 
64
 
 
65
                        while( *c_curr ) {
 
66
                                *c_last = *c_curr;
 
67
                                c_last = c_curr;
 
68
                                c_curr++;
 
69
                        }
 
70
                        *c_last = '\0';
 
71
                }
 
72
                last = arg;
 
73
                arg++;
 
74
        }
 
75
}
 
76
 
56
77
/* Parse a command line buffer into arguments */
57
78
static int ParseCommandLine(char *cmdline, char **argv)
58
79
{
59
80
        char *bufp;
60
 
        int argc;
 
81
        char *lastp = NULL;
 
82
        int argc, last_argc;
61
83
 
62
 
        argc = 0;
 
84
        argc = last_argc = 0;
63
85
        for ( bufp = cmdline; *bufp; ) {
64
86
                /* Skip leading whitespace */
65
87
                while ( isspace(*bufp) ) {
75
97
                                ++argc;
76
98
                        }
77
99
                        /* Skip over word */
78
 
                        while ( *bufp && (*bufp != '"') ) {
 
100
                        while ( *bufp && ( *bufp != '"' || *lastp == '\\' ) ) {
 
101
                                lastp = bufp;
79
102
                                ++bufp;
80
103
                        }
81
104
                } else {
96
119
                        }
97
120
                        ++bufp;
98
121
                }
 
122
 
 
123
                /* Strip out \ from \" sequences */
 
124
                if( argv && last_argc != argc ) {
 
125
                        UnEscapeQuotes( argv[last_argc] );      
 
126
                }
 
127
                last_argc = argc;       
99
128
        }
100
129
        if ( argv ) {
101
130
                argv[argc] = NULL;