X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fw32spawn.h;h=6c748d06270869f2eb3c5ca759b7422783f138b4;hb=3a59228aa9e83e507b62eb5281817accccee72ba;hp=693b119702bfbdc39090481b8f456faa3174cc49;hpb=d8ccc13ba3ba05654f9be09bba5492cc8da30c3b;p=gnulib.git diff --git a/lib/w32spawn.h b/lib/w32spawn.h index 693b11970..6c748d062 100644 --- a/lib/w32spawn.h +++ b/lib/w32spawn.h @@ -1,5 +1,5 @@ /* Auxiliary functions for the creation of subprocesses. Native Woe32 API. - Copyright (C) 2001, 2003, 2004-2009 Free Software Foundation, Inc. + Copyright (C) 2001, 2003-2010 Free Software Foundation, Inc. Written by Bruno Haible , 2003. This program is free software: you can redistribute it and/or modify @@ -79,13 +79,13 @@ undup_safer_noinherit (int tempfd, int origfd) { if (dup2 (tempfd, origfd) < 0) error (EXIT_FAILURE, errno, _("cannot restore fd %d: dup2 failed"), - origfd); + origfd); close (tempfd); } else { /* origfd was closed or open to no handle at all. Set it to a closed - state. This is (nearly) equivalent to the original state. */ + state. This is (nearly) equivalent to the original state. */ close (origfd); } } @@ -143,68 +143,68 @@ prepare_spawn (char **argv) const char *string = argv[i]; if (string[0] == '\0') - new_argv[i] = xstrdup ("\"\""); + new_argv[i] = xstrdup ("\"\""); else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) - { - bool quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); - size_t length; - unsigned int backslashes; - const char *s; - char *quoted_string; - char *p; - - length = 0; - backslashes = 0; - if (quote_around) - length++; - for (s = string; *s != '\0'; s++) - { - char c = *s; - if (c == '"') - length += backslashes + 1; - length++; - if (c == '\\') - backslashes++; - else - backslashes = 0; - } - if (quote_around) - length += backslashes + 1; - - quoted_string = (char *) xmalloc (length + 1); - - p = quoted_string; - backslashes = 0; - if (quote_around) - *p++ = '"'; - for (s = string; *s != '\0'; s++) - { - char c = *s; - if (c == '"') - { - unsigned int j; - for (j = backslashes + 1; j > 0; j--) - *p++ = '\\'; - } - *p++ = c; - if (c == '\\') - backslashes++; - else - backslashes = 0; - } - if (quote_around) - { - unsigned int j; - for (j = backslashes; j > 0; j--) - *p++ = '\\'; - *p++ = '"'; - } - *p = '\0'; - - new_argv[i] = quoted_string; - } + { + bool quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); + size_t length; + unsigned int backslashes; + const char *s; + char *quoted_string; + char *p; + + length = 0; + backslashes = 0; + if (quote_around) + length++; + for (s = string; *s != '\0'; s++) + { + char c = *s; + if (c == '"') + length += backslashes + 1; + length++; + if (c == '\\') + backslashes++; + else + backslashes = 0; + } + if (quote_around) + length += backslashes + 1; + + quoted_string = (char *) xmalloc (length + 1); + + p = quoted_string; + backslashes = 0; + if (quote_around) + *p++ = '"'; + for (s = string; *s != '\0'; s++) + { + char c = *s; + if (c == '"') + { + unsigned int j; + for (j = backslashes + 1; j > 0; j--) + *p++ = '\\'; + } + *p++ = c; + if (c == '\\') + backslashes++; + else + backslashes = 0; + } + if (quote_around) + { + unsigned int j; + for (j = backslashes; j > 0; j--) + *p++ = '\\'; + *p++ = '"'; + } + *p = '\0'; + + new_argv[i] = quoted_string; + } else - new_argv[i] = (char *) string; + new_argv[i] = (char *) string; } new_argv[argc] = NULL;