Re: quotearg.c's shell_quoting_style and MinGW

Eli Zaretskii <[email protected]>
Newsgroups gmane.comp.gnu.utils.bugs,gmane.comp.lib.gnulib.bugs
Message-ID <[email protected]>
> From: Bruno Haible <[email protected]>
> Cc: [email protected], [email protected], [email protected]
> Bcc: [email protected]
> Date: Sun, 06 May 2012 22:25:12 +0200
> 
> /* Identifier for the kind of interpreter of the command.  */
> enum system_command_interpreter
> {
>   /* The interpreter used by the system() and popen() functions.
>      This is equivalent to SCI_POSIX_SH on Unix platforms and
>      SCI_WINDOWS_CMD on native Windows platforms.  */
>   SCI_SYSTEM
>   /* The POSIX /bin/sh.  */
>   , SCI_POSIX_SH
> #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
>   /* The native Windows CreateProcess() function.  */
>   , SCI_WINDOWS_CREATEPROCESS
>   /* The native Windows cmd.exe interpreter.  */
>   , SCI_WINDOWS_CMD
> #endif
> };
> 
> /* Returns the number of bytes needed for the quoted string.  */
> extern size_t
>        system_quote_length (enum system_command_interpreter interpreter,
>                             const char *string);
> 
> /* Copies the quoted string to p and returns the incremented p.
>    There must be room for shell_quote_length (string) + 1 bytes at p.  */
> extern char *
>        system_quote_copy (enum system_command_interpreter interpreter,
>                           char *p, const char *string);
> 
> /* Returns the freshly allocated quoted string.  */
> extern char *
>        system_quote (enum system_command_interpreter interpreter,
>                      const char *string);
> 
> /* Returns a freshly allocated string containing all argument strings, quoted,
>    separated through spaces.  */
> extern char *
>        system_quote_argv (enum system_command_interpreter interpreter,
>                           const char * const *argv);
> 
> #ifdef __cplusplus
> }
> #endif
> 
> #endif /* _SYSTEM_QUOTE_H */
> ==============================================================================
> 
> The system_quote_argv function would be what I called create_system_command
> earlier, with the added 'interpreter' argument.
> 
> For GNU diffutils, this means just replacing specific uses of
> sh_quote with system_quote(SCI_SYSTEM, ...), right before the calls to
> popen() and system().
> 
> How does that sound?

Sounds good to me, thanks.

So on Posix hosts, this new API will probably simply call the
shell-style quoting, while on non-Posix hosts it will use separate
code, is that right?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.