+2015-10-22 Corinna Vinschen <corinna@vinschen.de>
+
+ * strfuncs.cc (sys_cp_wcstombs): Always return number of multibytes
+ without trailing NUL as the documentation implies. Throughout Cygwin,
+ fix usage to align to this pattern.
+ * fhandler_process.cc (format_process_winexename): Drop trailing NUL
+ and LF from output.
+
2015-10-21 Corinna Vinschen <corinna@vinschen.de>
* thread.cc (pthread_getattr_np): Fix memory leak, remove usage of
if (!__argc)
{
PWCHAR wline = GetCommandLineW ();
- size_t size = sys_wcstombs (NULL, 0, wline);
+ size_t size = sys_wcstombs (NULL, 0, wline) + 1;
char *line = (char *) alloca (size);
sys_wcstombs (line, size, wline);
int totlen = GetEnvironmentVariableW (name0, valbuf, 32768);
if (totlen > 0)
{
- totlen = sys_wcstombs (NULL, 0, valbuf);
+ totlen = sys_wcstombs (NULL, 0, valbuf) + 1;
if (x == HEAP_1_STR)
totlen += namelen;
else
_pinfo *p = (_pinfo *) data;
size_t len = sys_wcstombs (NULL, 0, p->progname);
destbuf = (char *) crealloc_abort (destbuf, len + 1);
- sys_wcstombs (destbuf, len, p->progname);
- destbuf[len] = '\n';
- return len + 1;
+ /* With trailing \0 for backward compat reasons. */
+ sys_wcstombs (destbuf, len + 1, p->progname);
+ return len;
}
struct heap_info
while (nwc)
{
- siz = sys_wcstombs (dst, len, src, nwc);
+ siz = sys_wcstombs (dst, len, src, nwc) + 1;
sum += siz;
if (dst)
{
else
buf->st_size = sys_wcstombs (NULL, 0,
(wchar_t *) tmpbuf,
- dwSize / sizeof (wchar_t));
+ dwSize / sizeof (wchar_t))
+ + 1;
if (tmpbuf)
free (tmpbuf);
}
}
if (type == REG_SZ || type == REG_EXPAND_SZ || type == REG_LINK)
bufalloc = sys_wcstombs (NULL, 0, (wchar_t *) tmpbuf,
- size / sizeof (wchar_t));
+ size / sizeof (wchar_t)) + 1;
else if (type == REG_MULTI_SZ)
bufalloc = multi_wcstombs (NULL, 0, (wchar_t *) tmpbuf,
size / sizeof (wchar_t));
&ifp->ifa_frndlyname;
iff->ifrf_len = sys_wcstombs (iff->ifrf_friendlyname,
IFRF_FRIENDLYNAMESIZ,
- pap->FriendlyName);
+ pap->FriendlyName) + 1;
}
static void
{
char *tmpbuf = tp.c_get ();
if (sys_wcstombs (tmpbuf, NT_MAX_PATH, (PWCHAR) (cp + 2))
- > SYMLINK_MAX + 1)
+ > SYMLINK_MAX)
return 0;
res = posixify (tmpbuf);
}
srcbuf += 2;
char *tmpbuf = tp.c_get ();
if (sys_wcstombs (tmpbuf, NT_MAX_PATH, (PWCHAR) srcbuf)
- > SYMLINK_MAX + 1)
+ > SYMLINK_MAX)
debug_printf ("symlink string too long");
else
res = posixify (tmpbuf);
PWCHAR spath = (PWCHAR)
(pffei->EaName + pffei->EaNameLength + 1);
res = sys_wcstombs (contents, SYMLINK_MAX + 1,
- spath, pffei->EaValueLength) - 1;
+ spath, pffei->EaValueLength);
pflags |= PATH_SYMLINK;
}
return res;
}
if (n + bytes <= len)
{
- n += bytes;
if (dst)
{
for (int i = 0; i < bytes; ++i)
}
if (*pwcs++ == 0x00)
break;
+ n += bytes;
}
else
break;
if (GetEnvironmentVariableW (L"USERNAME", user_name, user_name_len)
|| GetEnvironmentVariableW (L"USER", user_name, user_name_len))
{
- char mb_user_name[user_name_len = sys_wcstombs (NULL, 0, user_name)];
+ char mb_user_name[user_name_len = sys_wcstombs (NULL, 0, user_name) + 1];
sys_wcstombs (mb_user_name, user_name_len, user_name);
set_name (mb_user_name);
}