[Debootloaders-devel] r67 - trunk/rsrce
Aurélien GÉRÔME
ag-guest at costa.debian.org
Tue Jul 11 01:23:49 UTC 2006
Author: ag-guest
Date: 2006-07-11 01:23:49 +0000 (Tue, 11 Jul 2006)
New Revision: 67
Modified:
trunk/rsrce/command.c
Log:
Patch from Piotr Krysiuk to:
* allow escaping spaces (necessary for the rename command);
* add support for comments and empty lines in the input.
Modified: trunk/rsrce/command.c
===================================================================
--- trunk/rsrce/command.c 2006-07-11 01:22:31 UTC (rev 66)
+++ trunk/rsrce/command.c 2006-07-11 01:23:49 UTC (rev 67)
@@ -378,13 +378,32 @@
int cmd_exec(char *cmd)
{
+ char *dst;
char *argv[MAXARGC+1];
int argc, i;
+ if((*cmd == 0) || (*cmd == '#'))
+ return 0;
+
+ dst = cmd;
memset(argv, 0, sizeof(argv));
argc = 0;
- while((argv[argc++] = strsep(&cmd, " ")) && argc < MAXARGC+1);
-
+ argv[argc++] = dst;
+ while(argc < MAXARGC+1) {
+ if(*cmd == ' ') {
+ *dst++ = 0;
+ cmd++;
+ argv[argc++] = dst;
+ } else {
+ if(*cmd == '\\') {
+ cmd++;
+ }
+ if((*dst++ = *cmd++) == 0) {
+ break;
+ }
+ }
+ }
+
if(argv[MAXARGC]) {
fprintf(stderr, "Too many arguments\n");
return -1;
More information about the Debootloaders-devel
mailing list