From: Robert Pengelly Date: Thu, 18 Sep 2025 10:51:16 +0000 (+0100) Subject: Update PATH X-Git-Url: https://git.candlhat.org/?a=commitdiff_plain;h=8a982091ae1ce46f9f32d7cef56d6a5678e18f20;p=xmake.git Update PATH --- diff --git a/variable.c b/variable.c index 9460e98..a1fb77f 100644 --- a/variable.c +++ b/variable.c @@ -1,12 +1,20 @@ /****************************************************************************** * @file variable.c *****************************************************************************/ +#if defined (__GNUC__) +# ifndef _POSIX_C_SOURCE +# define _POSIX_C_SOURCE 200112L /* for setenv() */ +# endif +#endif + #include #include #include #if defined (unix) || defined (__unix) || defined (__unix__) || defined (__APPLE__) -# define __USE_POSIX +# ifndef __USE_POSIX +# define __USE_POSIX +# endif #elif defined (_WIN32) # define strcasecmp _stricmp #endif @@ -794,7 +802,7 @@ char *variable_expand_line (const char *filename, unsigned long line_no, char *l } else { - if (state->env_override) { + if (state->env_override || strcmp (content, "PATH") == 0) { if ((alloc_replacement = getenv (content))) { @@ -1081,6 +1089,32 @@ void parse_var_line (const char *filename, unsigned long line_no, char *line, en } + if (strcmp (var_name, "PATH") == 0) { + +#if defined (_WIN32) + + char *temp = xmalloc (strlen (new_value) + 6); + int i; + + sprintf (temp, "PATH=%s", new_value); + + for (i = 5; temp[i] != '\0'; i++) { + + if (temp[i] == ':' && temp[i + 1] != '\\') { + temp[i] = ';'; + } + + } + + _putenv (temp); + free (temp); + +#else + setenv ("PATH", new_value, 1); +#endif + + } + if ((var = variable_change (var_name, new_value, origin))) { var->flavor = flavor; }