mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-03-22 14:39:24 -05:00
split_into_argv: stop using isspace().
I checked exhaustively today and found that the only characters (even in Unicode) that Windows's default argv splitter will recognise as word separators are the space and tab characters. So I think it's a mistake to use <ctype.h> functions to identify word separators; we should use that fixed character pair, and then we know we're getting the right ones only.
This commit is contained in:
parent
a890ffb15b
commit
9adfa79767
@ -161,6 +161,11 @@
|
|||||||
#define MOD3 0
|
#define MOD3 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static inline bool is_word_sep(char c)
|
||||||
|
{
|
||||||
|
return c == ' ' || c == '\t';
|
||||||
|
}
|
||||||
|
|
||||||
void split_into_argv(char *cmdline, bool includes_program_name,
|
void split_into_argv(char *cmdline, bool includes_program_name,
|
||||||
int *argc, char ***argv, char ***argstart)
|
int *argc, char ***argv, char ***argstart)
|
||||||
{
|
{
|
||||||
@ -173,7 +178,7 @@ void split_into_argv(char *cmdline, bool includes_program_name,
|
|||||||
* First deal with the simplest of all special cases: if there
|
* First deal with the simplest of all special cases: if there
|
||||||
* aren't any arguments, return 0,NULL,NULL.
|
* aren't any arguments, return 0,NULL,NULL.
|
||||||
*/
|
*/
|
||||||
while (*cmdline && isspace((unsigned char)*cmdline)) cmdline++;
|
while (*cmdline && is_word_sep(*cmdline)) cmdline++;
|
||||||
if (!*cmdline) {
|
if (!*cmdline) {
|
||||||
if (argc) *argc = 0;
|
if (argc) *argc = 0;
|
||||||
if (argv) *argv = NULL;
|
if (argv) *argv = NULL;
|
||||||
@ -195,7 +200,7 @@ void split_into_argv(char *cmdline, bool includes_program_name,
|
|||||||
bool quote;
|
bool quote;
|
||||||
|
|
||||||
/* Skip whitespace searching for start of argument. */
|
/* Skip whitespace searching for start of argument. */
|
||||||
while (*p && isspace((unsigned char)*p)) p++;
|
while (*p && is_word_sep(*p)) p++;
|
||||||
if (!*p) break;
|
if (!*p) break;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -240,7 +245,7 @@ void split_into_argv(char *cmdline, bool includes_program_name,
|
|||||||
|
|
||||||
/* Copy data into the argument until it's finished. */
|
/* Copy data into the argument until it's finished. */
|
||||||
while (*p) {
|
while (*p) {
|
||||||
if (!quote && isspace((unsigned char)*p))
|
if (!quote && is_word_sep(*p))
|
||||||
break; /* argument is finished */
|
break; /* argument is finished */
|
||||||
|
|
||||||
if (*p == '"' || (*p == '\\' && backslash_special)) {
|
if (*p == '"' || (*p == '\\' && backslash_special)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user