2008-03-11 Corinna Vinschen <corinna@vinschen.de>
+ * environ.cc (parse_options): Use tmp_pathbuf to allocate buffer.
+ (regopt): Take tmp buffer as additional argument.
+ (environ_init): Alllcate tmpbuf earlier. Use as temporary buffer in
+ call to regopt.
+ * tls_pbuf.cc (tmp_pathbuf::c_get): Allocate one additional char.
+ (tmp_pathbuf::w_get): Allocate one additional WCHAR.
+ * winf.cc (av::unshift): Use tmp_pathbuf to allocate buffer.
+
+2008-03-11 Corinna Vinschen <corinna@vinschen.de>
+
* syscalls.cc (sync): Use MAX_PATH rather than CYG_MAX_PATH.
2008-03-10 Corinna Vinschen <corinna@vinschen.de>
if (buf == NULL)
{
- char newbuf[CYG_MAX_PATH + 7];
+ tmp_pathbuf tp;
+ char *newbuf = tp.c_get ();
newbuf[0] = '\0';
for (k = known; k->name != NULL; k++)
if (k->remember)
/* Set options from the registry. */
static bool __stdcall
-regopt (const char *name)
+regopt (const char *name, char *buf)
{
bool parsed_something = false;
- char buf[CYG_MAX_PATH];
char lname[strlen (name) + 1];
strlwr (strcpy (lname, name));
{
reg_key r (i, KEY_READ, CYGWIN_INFO_PROGRAM_OPTIONS_NAME, NULL);
- if (r.get_string (lname, buf, sizeof (buf) - 1, "") == ERROR_SUCCESS)
+ if (r.get_string (lname, buf, NT_MAX_PATH, "") == ERROR_SUCCESS)
{
parse_options (buf);
parsed_something = true;
conv_start_chars[(int) cyg_toupper (conv_envvars[i].name[0])] = 1;
}
- got_something_from_registry = regopt ("default");
+ char *tmpbuf = tp.t_get ();
+ got_something_from_registry = regopt ("default", tmpbuf);
if (myself->progname[0])
- got_something_from_registry = regopt (myself->progname) || got_something_from_registry;
+ got_something_from_registry = regopt (myself->progname, tmpbuf)
+ || got_something_from_registry;
if (!envp)
envp_passed_in = 0;
form "=X:=X:\foo\bar; these must be changed into something legal
(we could just ignore them but maybe an application will
eventually want to use them). */
- char *tmpbuf = tp.t_get ();
for (i = 0, w = rawenv; *w != L'\0'; w = wcschr (w, L'\0') + 1, i++)
{
sys_wcstombs_alloc (&newp, HEAP_NOTHEAP, w);
if (tls_pbuf.c_cnt >= TP_NUM_C_BUFS)
api_fatal ("Internal error: TP_NUM_C_BUFS too small.");
if (!tls_pbuf.c_buf[tls_pbuf.c_cnt]
- && !(tls_pbuf.c_buf[tls_pbuf.c_cnt] = (char *) malloc (NT_MAX_PATH)))
+ && !(tls_pbuf.c_buf[tls_pbuf.c_cnt] = (char *) malloc (NT_MAX_PATH + 1)))
api_fatal ("Internal error: Out of memory for new path buf.");
return tls_pbuf.c_buf[tls_pbuf.c_cnt++];
}
api_fatal ("Internal error: TP_NUM_W_BUFS too small.");
if (!tls_pbuf.w_buf[tls_pbuf.w_cnt]
&& !(tls_pbuf.w_buf[tls_pbuf.w_cnt]
- = (PWCHAR) malloc (NT_MAX_PATH * sizeof (WCHAR))))
+ = (PWCHAR) malloc ((NT_MAX_PATH + 1) * sizeof (WCHAR))))
api_fatal ("Internal error: Out of memory for new wide path buf.");
return tls_pbuf.w_buf[tls_pbuf.w_cnt++];
}