--- make-3.81-orig\variable.c 2006-03-08 14:15:08.000000000 -0600 +++ make-3.81\variable.c 2006-05-30 08:56:27.172506800 -0500 @@ -861,6 +861,18 @@ char **result_0; char **result; +#ifdef WINDOWS32 + char **v_names; /* list of names as they are entered into the environment + used to keep track of envs that have been defined + */ + int rsltindx; + int rsltcnt; + + rsltindx = 0; + rsltcnt = 0; + +#endif + if (file == 0) set_list = current_variable_set_list; else @@ -938,19 +950,25 @@ } } + makelevel_key.name = MAKELEVEL_NAME; makelevel_key.length = MAKELEVEL_LENGTH; hash_delete (&table, &makelevel_key); result = result_0 = (char **) xmalloc ((table.ht_fill + 2) * sizeof (char *)); +#ifdef WINDOWS32 + v_names = (char **) xmalloc ((table.ht_fill + 2) * sizeof (char *)); +#endif + v_slot = (struct variable **) table.ht_vec; v_end = v_slot + table.ht_size; + + nextvar: for ( ; v_slot < v_end; v_slot++) if (! HASH_VACANT (*v_slot)) - { + { struct variable *v = *v_slot; - /* If V is recursively expanded and didn't come from the environment, expand its value. If it came from the environment, it should go back into the environment unchanged. */ @@ -962,8 +980,28 @@ if (strcmp(v->name, "Path") == 0 || strcmp(v->name, "PATH") == 0) convert_Path_to_windows32(value, ';'); + + /* Windows Environment variables are case preserving, to prevent two + variables with different case being defined, we lookup + the variables and see if a variable exists with the same name. + If it is found we use that name, + */ + for( rsltindx = 0; rsltindx < rsltcnt; rsltindx++ ) { + /* DO NOT INCLUDE VARIABLES THAT HAVE ALREADY BEEN DEFINED */ + if ( stricmp( v_names[rsltindx], v->name ) == 0 ) { + v_slot++; + goto nextvar; + } + } + + /* save variable for future use */ + v_names[rsltcnt] = (char *)xmalloc ( (strlen(v->name) + 1) * sizeof(char) ); + strcpy(v_names[rsltcnt], v->name); + rsltcnt++; + #endif - *result++ = concat (v->name, "=", value); + *result++ = concat ( v->name, "=", value); + free (value); } else @@ -972,10 +1010,30 @@ if (strcmp(v->name, "Path") == 0 || strcmp(v->name, "PATH") == 0) convert_Path_to_windows32(v->value, ';'); + + /* Windows Environment variables are case preserving, to prevent two + variables with different case being defined, we lookup + the variables and see if a variable exists with the same name. + If it is found we use that name, + */ + for( rsltindx = 0; rsltindx < rsltcnt; rsltindx++ ) { + /* DO NOT INCLUDE VARIABLES THAT HAVE ALREADY BEEN DEFINED */ + if ( stricmp( v_names[rsltindx], v->name ) == 0 ) { + v_slot++; + goto nextvar; + } + } + + /* save variable for future use */ + v_names[rsltcnt] = (char *)xmalloc ( (strlen(v->name) + 1) * sizeof(char) ); + strcpy(v_names[rsltcnt], v->name); + rsltcnt++; + #endif - *result++ = concat (v->name, "=", v->value); + *result++ = concat ( v->name, "=", v->value); + } - } + } *result = (char *) xmalloc (100); (void) sprintf (*result, "%s=%u", MAKELEVEL_NAME, makelevel + 1);