From: Craig Berry [craig.berry@metamorgs.com] Sent: Monday, February 21, 2000 3:32 PM To: Info-VAX@Mvb.Saic.Com Subject: Re: Problem using RCS 5.7 and diffutils 2.7 "Nelson E. Ingersoll" wrote in message news:38aee76b.11160416@news.codenet.net... > Alas the system() call made in RCSUTIL/runv() apparently > also suffers this case munging behavior. I am > trying to see if I can quote the appropriate 'co' switches > in the rcsdiff.c code. So far I have not made it work right. What follows is something I was implementing for the analogous situation in diffutils, only to discover that its usage no longer matches its name and they pass the whole command string, not just arguments one at a time. This meant I would get a command passed to system() like "command ""-Arg""" which of course the CLI would not accept with the quote at the beginning. I've never looked at the RCS code, but if you take apart the command string and only pass one arg at a time, this should work. Good luck. ************* /* Place into QUOTED a quoted version of ARG suitable for `system'. Return the length of the resulting string (which is not null-terminated). If QUOTED is null, return the length without any side effects. */ #include size_t quote_system_arg (quoted, arg) char *quoted; char const *arg; { size_t len = strlen(arg); if (quoted) memcpy(quoted, arg, len); char *q; char const *a; size_t len = 2; /* start with 2 for outer quotes */ q = quoted; if (quoted) *q++ = '"'; /* add 1st outer quote */ for (a = arg; *a; *a++) { if (quoted) *q++ = *a; /* copy this character */ len++; if (*a == '"') /* if it's a quote */ len += 2; if (quoted) /* wrap 2 more around it */ { *q++ = '"'; *q++ = '"'; } } } if (quoted) *q++ = '"'; return (len); }