This is the mail archive of the cygwin-patches mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 1/3] Move the core environment parsing of environ_init into a new win32env_to_cygenv function.


On Jan  5 18:39, Erik M. Bray wrote:
> @@ -805,32 +796,8 @@ environ_init (char **envp, int envc)
>  	}
>        debug_printf ("GetEnvironmentStrings returned %p", rawenv);
>  
> -      /* Current directory information is recorded as variables of the
> -	 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).  */
> -      for (i = 0, w = rawenv; *w != L'\0'; w = wcschr (w, L'\0') + 1, i++)
> -	{
> -	  sys_wcstombs_alloc_no_path (&newp, HEAP_NOTHEAP, w);
> -	  if (i >= envc)
> -	    envp = (char **) realloc (envp, (4 + (envc += 100)) * sizeof (char *));
> -	  envp[i] = newp;
> -	  if (*newp == '=')
> -	    *newp = '!';
> -	  char *eq = strchrnul (newp, '=');
> -	  ucenv (newp, eq);	/* uppercase env vars which need it */
> -	  if (*newp == 'T' && strncmp (newp, "TERM=", 5) == 0)
> -	    sawTERM = 1;
> -	  else if (*newp == 'C' && strncmp (newp, "CYGWIN=", 7) == 0)
> -	    parse_options (newp + 7);
> -	  if (*eq)
> -	    posify_maybe (envp + i, *++eq ? eq : --eq, tmpbuf);
> -	  debug_printf ("%p: %s", envp[i], envp[i]);
> -	}
> +	  lastenviron = envp = win32env_to_cygenv(rawenv, true);
                                                ^^^
                                                space missing

>  
> -      if (!sawTERM)
> -	envp[i++] = strdup (cygterm);
> -      envp[i] = NULL;
>        FreeEnvironmentStringsW (rawenv);
>  
>      out:
> @@ -852,6 +819,53 @@ environ_init (char **envp, int envc)
>    __endtry
>  }
>  
> +
> +char **
      ^^^
      Header claims __stdcall, missing here.  But in fact it
      might be prudent to make this a __reg2 function instead.

> +win32env_to_cygenv(PWCHAR rawenv, bool posify)
                    ^^^
                    space missing

> +{

>  /* Function called by qsort to sort environment strings.  */
>  static int
>  env_sort (const void *a, const void *b)
> diff --git a/winsup/cygwin/environ.h b/winsup/cygwin/environ.h
> index 46beb2d..7bd87da 100644
> --- a/winsup/cygwin/environ.h
> +++ b/winsup/cygwin/environ.h
> @@ -45,4 +45,6 @@ extern "C" char __stdcall **cur_environ ();
>  char ** __reg3 build_env (const char * const *envp, PWCHAR &envblock,
>  			  int &envc, bool need_envblock, HANDLE new_token);
>  
> +char __stdcall ** win32env_to_cygenv (PWCHAR rawenv, bool posify);
        ^^^^^      ^^^
        __reg2?    no space here


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

Attachment: signature.asc
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]