Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2013-07-19 21:28:34 +0400
committerChristopher Faylor <me@cgf.cx>2013-07-19 21:28:34 +0400
commit521953a83a885011c9040b635a94db5eb6b8db56 (patch)
tree1aa05b8b65b691cb4c5dccab65c4864d5e95cb54 /winsup/cygwin/winf.h
parent4b25516b5d410c38554c9595bcb674356ffee713 (diff)
* common.din: Export GetCommandLine{A,W}.
* kernel32.cc: Add includes needed for GetCommandLine functions. (ucmd): New function. (cygwin_GetCommandLineW): Ditto. (cygwin_GetCommandLineA): Ditto. * spawn.cc (child_info_spawn::worker): Rename one_line -> cmd. Use lb_wcs macro to generate a wide character version of the line buffer. Remove duplicate printing of command line. Don't access members of linebuf directly. * winf.h: Use pragma once. (linebuf): Make storage private. (linebuf::operator size_t): New operator. Return size of buf. (linebuf::operator wchar_t): New operator. (linebuf::wcs): New function. (lb_wcs): New macro. * include/cygwin/version.h: Bump API minor number to 268. * strfuncs.cc: Clarify descriptive file comment.
Diffstat (limited to 'winsup/cygwin/winf.h')
-rw-r--r--winsup/cygwin/winf.h34
1 files changed, 28 insertions, 6 deletions
diff --git a/winsup/cygwin/winf.h b/winsup/cygwin/winf.h
index 3dd63b5e0..d7488c360 100644
--- a/winsup/cygwin/winf.h
+++ b/winsup/cygwin/winf.h
@@ -6,9 +6,7 @@ This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
-#ifndef _WINF_H
-#define _WINF_H
-
+#pragma once
/* Hack for Cygwin processes. If the Windows command line length gets slightly
bigger than this value, the stack position is suddenly moved up by 64K for
no apparent reason, which results in subsequent forks failing. Since Cygwin
@@ -67,10 +65,10 @@ class av
class linebuf
{
- public:
size_t ix;
char *buf;
size_t alloced;
+ public:
linebuf () : ix (0), buf (NULL), alloced (0) {}
~linebuf () {if (buf) free (buf);}
void __reg3 add (const char *, int);
@@ -78,7 +76,31 @@ class linebuf
void prepend (const char *, int);
void __reg2 finish (bool);
bool __reg3 fromargv(av&, const char *, bool);;
- operator char *() {return buf;}
+ operator size_t () const { return ix + 1; }
+ operator const char * () const { return buf; }
+ operator wchar_t * ()
+ {
+ size_t n = ix + 1;
+ /* Note that this malloc'ed buffer is not freed by the destructor.
+ It is up to the caller to do (or not do) that. */
+ wchar_t *wbuf = (wchar_t *) malloc (sizeof (wchar_t) * n);
+ return wcs (wbuf, n);
+ }
+ wchar_t *wcs (wchar_t *wbuf, size_t n)
+ {
+ if (n == 1)
+ wbuf[0] = L'\0';
+ else
+ sys_mbstowcs (wbuf, n, buf);
+ return wbuf;
+ }
};
-#endif /*_WINF_H*/
+/* Return a temporary buffer representing the wide character version
+ of a linebuf command line. */
+#define lb_wcs(__x) \
+({ \
+ wchar_t __wbuf[(size_t) __x]; \
+ __x.wcs (__wbuf, sizeof (__wbuf) / sizeof (__wbuf[0])); \
+ __wbuf; \
+})