mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-25 09:12:24 +00:00
Clean up the argv splitter, and in particular stop it from bombing
out ignominiously when given no arguments :-) [originally from svn r1815]
This commit is contained in:
parent
437d740fb3
commit
3983b3fc81
16
winutils.c
16
winutils.c
@ -11,6 +11,8 @@
|
|||||||
#ifdef TESTMODE
|
#ifdef TESTMODE
|
||||||
/* Definitions to allow this module to be compiled standalone for testing. */
|
/* Definitions to allow this module to be compiled standalone for testing. */
|
||||||
#define smalloc malloc
|
#define smalloc malloc
|
||||||
|
#define srealloc realloc
|
||||||
|
#define sfree free
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -130,6 +132,18 @@ void split_into_argv(char *cmdline, int *argc, char ***argv,
|
|||||||
* produce a literal quote.
|
* produce a literal quote.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* First deal with the simplest of all special cases: if there
|
||||||
|
* aren't any arguments, return 0,NULL,NULL.
|
||||||
|
*/
|
||||||
|
while (*cmdline && isspace(*cmdline)) cmdline++;
|
||||||
|
if (!*cmdline) {
|
||||||
|
if (argc) *argc = 0;
|
||||||
|
if (argv) *argv = NULL;
|
||||||
|
if (argstart) *argstart = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This will guaranteeably be big enough; we can realloc it
|
* This will guaranteeably be big enough; we can realloc it
|
||||||
* down later.
|
* down later.
|
||||||
@ -446,4 +460,4 @@ int main(int argc, char **argv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user