bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: quotearg.c's shell_quoting_style and MinGW


From: Eli Zaretskii
Subject: Re: quotearg.c's shell_quoting_style and MinGW
Date: Sun, 06 May 2012 23:35:58 +0300

> From: Bruno Haible <address@hidden>
> Cc: address@hidden, address@hidden, address@hidden
> Bcc: address@hidden
> 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?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]