1 /* Internals of variables for GNU Make.
2 Copyright (C) 1988, 89, 90, 91, 92, 93, 94, 96 Free Software Foundation, Inc.
3 This file is part of GNU Make.
5 GNU Make is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
10 GNU Make is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNU Make; see the file COPYING. If not, write to
17 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
26 #include "pathstuff.h"
29 /* Hash table of all global variable definitions. */
31 #ifndef VARIABLE_BUCKETS
32 #define VARIABLE_BUCKETS 523
34 #ifndef PERFILE_VARIABLE_BUCKETS
35 #define PERFILE_VARIABLE_BUCKETS 23
37 #ifndef SMALL_SCOPE_VARIABLE_BUCKETS
38 #define SMALL_SCOPE_VARIABLE_BUCKETS 13
40 static struct variable
*variable_table
[VARIABLE_BUCKETS
];
41 static struct variable_set global_variable_set
42 = { variable_table
, VARIABLE_BUCKETS
};
43 static struct variable_set_list global_setlist
44 = { 0, &global_variable_set
};
45 struct variable_set_list
*current_variable_set_list
= &global_setlist
;
47 static struct variable
*define_variable_in_set
PARAMS ((char *name
, unsigned int length
,
48 char *value
, enum variable_origin origin
,
49 int recursive
, struct variable_set
*set
));
52 /* Implement variables. */
54 /* Define variable named NAME with value VALUE in SET. VALUE is copied.
55 LENGTH is the length of NAME, which does not need to be null-terminated.
56 ORIGIN specifies the origin of the variable (makefile, command line
58 If RECURSIVE is nonzero a flag is set in the variable saying
59 that it should be recursively re-expanded. */
61 static struct variable
*
62 define_variable_in_set (name
, length
, value
, origin
, recursive
, set
)
66 enum variable_origin origin
;
68 struct variable_set
*set
;
70 register unsigned int i
;
71 register unsigned int hashval
;
72 register struct variable
*v
;
75 for (i
= 0; i
< length
; ++i
)
76 HASH (hashval
, name
[i
]);
77 hashval
%= set
->buckets
;
79 for (v
= set
->table
[hashval
]; v
!= 0; v
= v
->next
)
81 && !strncmp (v
->name
+ 1, name
+ 1, length
- 1)
82 && v
->name
[length
] == '\0')
85 if (env_overrides
&& origin
== o_env
)
86 origin
= o_env_override
;
90 if (env_overrides
&& v
->origin
== o_env
)
91 /* V came from in the environment. Since it was defined
92 before the switches were parsed, it wasn't affected by -e. */
93 v
->origin
= o_env_override
;
95 /* A variable of this name is already defined.
96 If the old definition is from a stronger source
97 than this one, don't redefine it. */
98 if ((int) origin
>= (int) v
->origin
)
102 v
->value
= savestring (value
, strlen (value
));
104 v
->recursive
= recursive
;
109 /* Create a new variable definition and add it to the hash table. */
111 v
= (struct variable
*) xmalloc (sizeof (struct variable
));
112 v
->name
= savestring (name
, length
);
113 v
->value
= savestring (value
, strlen (value
));
115 v
->recursive
= recursive
;
117 v
->export
= v_default
;
118 v
->next
= set
->table
[hashval
];
119 set
->table
[hashval
] = v
;
123 /* Define a variable in the current variable set. */
126 define_variable (name
, length
, value
, origin
, recursive
)
130 enum variable_origin origin
;
133 return define_variable_in_set (name
, length
, value
, origin
, recursive
,
134 current_variable_set_list
->set
);
137 /* Define a variable in FILE's variable set. */
140 define_variable_for_file (name
, length
, value
, origin
, recursive
, file
)
144 enum variable_origin origin
;
148 return define_variable_in_set (name
, length
, value
, origin
, recursive
,
149 file
->variables
->set
);
152 /* Lookup a variable whose name is a string starting at NAME
153 and with LENGTH chars. NAME need not be null-terminated.
154 Returns address of the `struct variable' containing all info
155 on the variable, or nil if no such variable is defined. */
158 lookup_variable (name
, length
)
162 register struct variable_set_list
*setlist
;
164 register unsigned int i
;
165 register unsigned int rawhash
= 0;
167 for (i
= 0; i
< length
; ++i
)
168 HASH (rawhash
, name
[i
]);
170 for (setlist
= current_variable_set_list
;
171 setlist
!= 0; setlist
= setlist
->next
)
173 register struct variable_set
*set
= setlist
->set
;
174 register unsigned int hashval
= rawhash
% set
->buckets
;
175 register struct variable
*v
;
177 for (v
= set
->table
[hashval
]; v
!= 0; v
= v
->next
)
178 if (*v
->name
== *name
179 && !strncmp (v
->name
+ 1, name
+ 1, length
- 1)
180 && v
->name
[length
] == 0)
187 /* Initialize FILE's variable set list. If FILE already has a variable set
188 list, the topmost variable set is left intact, but the the rest of the
189 chain is replaced with FILE->parent's setlist. */
192 initialize_file_variables (file
)
195 register struct variable_set_list
*l
= file
->variables
;
198 l
= (struct variable_set_list
*)
199 xmalloc (sizeof (struct variable_set_list
));
200 l
->set
= (struct variable_set
*) xmalloc (sizeof (struct variable_set
));
201 l
->set
->buckets
= PERFILE_VARIABLE_BUCKETS
;
202 l
->set
->table
= (struct variable
**)
203 xmalloc (l
->set
->buckets
* sizeof (struct variable
*));
204 bzero ((char *) l
->set
->table
,
205 l
->set
->buckets
* sizeof (struct variable
*));
209 if (file
->parent
== 0)
210 l
->next
= &global_setlist
;
213 if (file
->parent
->variables
== 0)
214 initialize_file_variables (file
->parent
);
215 l
->next
= file
->parent
->variables
;
219 /* Pop the top set off the current variable set list,
220 and free all its storage. */
223 pop_variable_scope ()
225 register struct variable_set_list
*setlist
= current_variable_set_list
;
226 register struct variable_set
*set
= setlist
->set
;
227 register unsigned int i
;
229 current_variable_set_list
= setlist
->next
;
230 free ((char *) setlist
);
232 for (i
= 0; i
< set
->buckets
; ++i
)
234 register struct variable
*next
= set
->table
[i
];
237 register struct variable
*v
= next
;
244 free ((char *) set
->table
);
248 /* Create a new variable set and push it on the current setlist. */
251 push_new_variable_scope ()
253 register struct variable_set_list
*setlist
;
254 register struct variable_set
*set
;
256 set
= (struct variable_set
*) xmalloc (sizeof (struct variable_set
));
257 set
->buckets
= SMALL_SCOPE_VARIABLE_BUCKETS
;
258 set
->table
= (struct variable
**)
259 xmalloc (set
->buckets
* sizeof (struct variable
*));
260 bzero ((char *) set
->table
, set
->buckets
* sizeof (struct variable
*));
262 setlist
= (struct variable_set_list
*)
263 xmalloc (sizeof (struct variable_set_list
));
265 setlist
->next
= current_variable_set_list
;
266 current_variable_set_list
= setlist
;
269 /* Merge SET1 into SET0, freeing unused storage in SET1. */
272 merge_variable_sets (set0
, set1
)
273 struct variable_set
*set0
, *set1
;
275 register unsigned int bucket1
;
277 for (bucket1
= 0; bucket1
< set1
->buckets
; ++bucket1
)
279 register struct variable
*v1
= set1
->table
[bucket1
];
282 struct variable
*next
= v1
->next
;
283 unsigned int bucket0
;
284 register struct variable
*v0
;
286 if (set1
->buckets
>= set0
->buckets
)
292 for (n
= v1
->name
; *n
!= '\0'; ++n
)
295 bucket0
%= set0
->buckets
;
297 for (v0
= set0
->table
[bucket0
]; v0
!= 0; v0
= v0
->next
)
298 if (streq (v0
->name
, v1
->name
))
303 /* There is no variable in SET0 with the same name. */
304 v1
->next
= set0
->table
[bucket0
];
305 set0
->table
[bucket0
] = v1
;
309 /* The same variable exists in both sets.
310 SET0 takes precedence. */
320 /* Merge SETLIST1 into SETLIST0, freeing unused storage in SETLIST1. */
323 merge_variable_set_lists (setlist0
, setlist1
)
324 struct variable_set_list
**setlist0
, *setlist1
;
326 register struct variable_set_list
*list0
= *setlist0
;
327 struct variable_set_list
*last0
= 0;
329 while (setlist1
!= 0 && list0
!= 0)
331 struct variable_set_list
*next
= setlist1
;
332 setlist1
= setlist1
->next
;
334 merge_variable_sets (list0
->set
, next
->set
);
336 free ((char *) next
);
345 *setlist0
= setlist1
;
347 last0
->next
= setlist1
;
351 /* Define the automatic variables, and record the addresses
352 of their structures so we can change their values quickly. */
355 define_automatic_variables ()
358 extern char* default_shell
;
360 extern char default_shell
[];
362 register struct variable
*v
;
365 sprintf (buf
, "%u", makelevel
);
366 (void) define_variable ("MAKELEVEL", 9, buf
, o_env
, 0);
368 sprintf (buf
, "%s%s%s",
370 (remote_description
== 0 || remote_description
[0] == '\0')
372 (remote_description
== 0 || remote_description
[0] == '\0')
373 ? "" : remote_description
);
374 (void) define_variable ("MAKE_VERSION", 12, buf
, o_default
, 0);
377 /* Allow to specify a special shell just for Make,
378 and use $COMSPEC as the default $SHELL when appropriate. */
380 static char shell_str
[] = "SHELL";
381 const int shlen
= sizeof (shell_str
) - 1;
382 struct variable
*mshp
= lookup_variable ("MAKESHELL", 9);
383 struct variable
*comp
= lookup_variable ("COMSPEC", 7);
385 /* Make $MAKESHELL override $SHELL even if -e is in effect. */
387 (void) define_variable (shell_str
, shlen
,
388 mshp
->value
, o_env_override
, 0);
391 /* $COMSPEC shouldn't override $SHELL. */
392 struct variable
*shp
= lookup_variable (shell_str
, shlen
);
395 (void) define_variable (shell_str
, shlen
, comp
->value
, o_env
, 0);
400 /* This won't override any definition, but it
401 will provide one if there isn't one there. */
402 v
= define_variable ("SHELL", 5, default_shell
, o_default
, 0);
403 v
->export
= v_export
; /* Always export SHELL. */
405 /* On MSDOS we do use SHELL from environment, since
406 it isn't a standard environment variable on MSDOS,
407 so whoever sets it, does that on purpose. */
409 /* Don't let SHELL come from the environment. */
410 if (*v
->value
== '\0' || v
->origin
== o_env
|| v
->origin
== o_env_override
)
414 v
->value
= savestring (default_shell
, strlen (default_shell
));
418 /* Make sure MAKEFILES gets exported if it is set. */
419 v
= define_variable ("MAKEFILES", 9, "", o_default
, 0);
422 /* Define the magic D and F variables in terms of
423 the automatic variables they are variations of. */
425 define_variable ("@D", 2, "$(patsubst %/,%,$(dir $@))", o_automatic
, 1);
426 define_variable ("%D", 2, "$(patsubst %/,%,$(dir $%))", o_automatic
, 1);
427 define_variable ("*D", 2, "$(patsubst %/,%,$(dir $*))", o_automatic
, 1);
428 define_variable ("<D", 2, "$(patsubst %/,%,$(dir $<))", o_automatic
, 1);
429 define_variable ("?D", 2, "$(patsubst %/,%,$(dir $?))", o_automatic
, 1);
430 define_variable ("^D", 2, "$(patsubst %/,%,$(dir $^))", o_automatic
, 1);
431 define_variable ("+D", 2, "$(patsubst %/,%,$(dir $+))", o_automatic
, 1);
432 define_variable ("@F", 2, "$(notdir $@)", o_automatic
, 1);
433 define_variable ("%F", 2, "$(notdir $%)", o_automatic
, 1);
434 define_variable ("*F", 2, "$(notdir $*)", o_automatic
, 1);
435 define_variable ("<F", 2, "$(notdir $<)", o_automatic
, 1);
436 define_variable ("?F", 2, "$(notdir $?)", o_automatic
, 1);
437 define_variable ("^F", 2, "$(notdir $^)", o_automatic
, 1);
438 define_variable ("+F", 2, "$(notdir $+)", o_automatic
, 1);
441 int export_all_variables
;
443 /* Create a new environment for FILE's commands.
444 If FILE is nil, this is for the `shell' function.
445 The child's MAKELEVEL variable is incremented. */
448 target_environment (file
)
451 struct variable_set_list
*set_list
;
452 register struct variable_set_list
*s
;
453 struct variable_bucket
455 struct variable_bucket
*next
;
456 struct variable
*variable
;
458 struct variable_bucket
**table
;
459 unsigned int buckets
;
460 register unsigned int i
;
461 register unsigned nvariables
;
463 unsigned int mklev_hash
;
466 set_list
= current_variable_set_list
;
468 set_list
= file
->variables
;
470 /* Find the lowest number of buckets in any set in the list. */
472 buckets
= s
->set
->buckets
;
473 for (s
= s
->next
; s
!= 0; s
= s
->next
)
474 if (s
->set
->buckets
< buckets
)
475 buckets
= s
->set
->buckets
;
477 /* Find the hash value of the bucket `MAKELEVEL' will fall into. */
479 char *p
= "MAKELEVEL";
482 HASH (mklev_hash
, *p
++);
485 /* Temporarily allocate a table with that many buckets. */
486 table
= (struct variable_bucket
**)
487 alloca (buckets
* sizeof (struct variable_bucket
*));
488 bzero ((char *) table
, buckets
* sizeof (struct variable_bucket
*));
490 /* Run through all the variable sets in the list,
491 accumulating variables in TABLE. */
493 for (s
= set_list
; s
!= 0; s
= s
->next
)
495 register struct variable_set
*set
= s
->set
;
496 for (i
= 0; i
< set
->buckets
; ++i
)
498 register struct variable
*v
;
499 for (v
= set
->table
[i
]; v
!= 0; v
= v
->next
)
501 unsigned int j
= i
% buckets
;
502 register struct variable_bucket
*ov
;
503 register char *p
= v
->name
;
505 if (i
== mklev_hash
% set
->buckets
506 && streq (v
->name
, "MAKELEVEL"))
507 /* Don't include MAKELEVEL because it will be
508 added specially at the end. */
514 if (v
->origin
== o_default
|| v
->origin
== o_automatic
)
515 /* Only export default variables by explicit request. */
518 if (! export_all_variables
519 && v
->origin
!= o_command
520 && v
->origin
!= o_env
&& v
->origin
!= o_env_override
)
523 if (*p
!= '_' && (*p
< 'A' || *p
> 'Z')
524 && (*p
< 'a' || *p
> 'z'))
526 for (++p
; *p
!= '\0'; ++p
)
527 if (*p
!= '_' && (*p
< 'a' || *p
> 'z')
528 && (*p
< 'A' || *p
> 'Z') && (*p
< '0' || *p
> '9'))
540 if (v
->origin
== o_default
)
545 for (ov
= table
[j
]; ov
!= 0; ov
= ov
->next
)
546 if (streq (v
->name
, ov
->variable
->name
))
550 register struct variable_bucket
*entry
;
551 entry
= (struct variable_bucket
*)
552 alloca (sizeof (struct variable_bucket
));
553 entry
->next
= table
[j
];
562 result
= (char **) xmalloc ((nvariables
+ 2) * sizeof (char *));
564 for (i
= 0; i
< buckets
; ++i
)
566 register struct variable_bucket
*b
;
567 for (b
= table
[i
]; b
!= 0; b
= b
->next
)
569 register struct variable
*v
= b
->variable
;
570 /* If V is recursively expanded and didn't come from the environment,
571 expand its value. If it came from the environment, it should
572 go back into the environment unchanged. */
574 && v
->origin
!= o_env
&& v
->origin
!= o_env_override
)
576 char *value
= recursively_expand (v
);
578 if (strcmp(v
->name
, "Path") == 0 ||
579 strcmp(v
->name
, "PATH") == 0)
580 convert_Path_to_windows32(value
, ';');
582 result
[nvariables
++] = concat (v
->name
, "=", value
);
588 if (strcmp(v
->name
, "Path") == 0 ||
589 strcmp(v
->name
, "PATH") == 0)
590 convert_Path_to_windows32(v
->value
, ';');
591 result
[nvariables
++] = concat (v
->name
, "=", v
->value
);
594 result
[nvariables
++] = concat (v
->name
, "=", v
->value
);
598 result
[nvariables
] = (char *) xmalloc (100);
599 (void) sprintf (result
[nvariables
], "MAKELEVEL=%u", makelevel
+ 1);
600 result
[++nvariables
] = 0;
605 /* Try to interpret LINE (a null-terminated string) as a variable definition.
607 ORIGIN may be o_file, o_override, o_env, o_env_override,
608 or o_command specifying that the variable definition comes
609 from a makefile, an override directive, the environment with
610 or without the -e switch, or the command line.
612 A variable definition has the form "name = value" or "name := value".
613 Any whitespace around the "=" or ":=" is removed. The first form
614 defines a variable that is recursively re-evaluated. The second form
615 defines a variable whose value is variable-expanded at the time of
616 definition and then is evaluated only once at the time of expansion.
618 If a variable was defined, a pointer to its `struct variable' is returned.
619 If not, NULL is returned. */
622 try_variable_definition (filename
, lineno
, line
, origin
)
626 enum variable_origin origin
;
629 register char *p
= line
;
632 enum { bogus
, simple
, recursive
, append
} flavor
= bogus
;
633 char *name
, *expanded_name
, *value
;
639 if (c
== '\0' || c
== '#')
655 /* A colon other than := is a rule line, not a variable defn. */
657 else if (c
== '+' && *p
== '=')
665 /* This might begin a variable expansion reference. Make sure we
666 don't misrecognize chars inside the reference as =, := or +=. */
675 continue; /* Nope. */
677 /* P now points past the opening paren or brace.
678 Count parens or braces until it is matched. */
680 for (; *p
!= '\0'; ++p
)
684 else if (*p
== closeparen
&& --count
< 0)
693 beg
= next_token (line
);
694 while (end
> beg
&& isblank (end
[-1]))
698 /* Expand the name, so "$(foo)bar = baz" works. */
699 name
= (char *) alloca (end
- beg
+ 1);
700 bcopy (beg
, name
, end
- beg
);
701 name
[end
- beg
] = '\0';
702 expanded_name
= allocated_variable_expand (name
);
704 if (expanded_name
[0] == '\0')
707 fatal ("empty variable name");
709 makefile_fatal (filename
, lineno
, "empty variable name");
712 /* Calculate the variable's new value in VALUE. */
717 /* Should not be possible. */
721 /* A simple variable definition "var := value". Expand the value. */
722 value
= variable_expand (p
);
725 /* A recursive variable definition "var = value".
726 The value is used verbatim. */
730 /* An appending variable definition "var += value".
731 Extract the old value and append the new one. */
732 v
= lookup_variable (expanded_name
, strlen (expanded_name
));
735 /* There was no old value.
736 This becomes a normal recursive definition. */
742 /* Paste the old and new values together in VALUE. */
744 unsigned int oldlen
, newlen
;
747 /* The previous definition of the variable was recursive.
748 The new value comes from the unexpanded old and new values. */
751 /* The previous definition of the variable was simple.
752 The new value comes from the old value, which was expanded
753 when it was set; and from the expanded new value. */
754 p
= variable_expand (p
);
756 oldlen
= strlen (v
->value
);
758 value
= (char *) alloca (oldlen
+ 1 + newlen
+ 1);
759 bcopy (v
->value
, value
, oldlen
);
761 bcopy (p
, &value
[oldlen
+ 1], newlen
+ 1);
766 /* Many Unix Makefiles include a line saying "SHELL=/bin/sh", but
767 non-Unix systems don't conform to this default configuration (in
768 fact, most of them don't even have `/bin'). On the other hand,
769 $SHELL in the environment, if set, points to the real pathname of
771 Therefore, we generally won't let lines like "SHELL=/bin/sh" from
772 the Makefile override $SHELL from the environment. But first, we
773 look for the basename of the shell in the directory where SHELL=
774 points, and along the $PATH; if it is found in any of these places,
775 we define $SHELL to be the actual pathname of the shell. Thus, if
776 you have bash.exe installed as d:/unix/bash.exe, and d:/unix is on
777 your $PATH, then SHELL=/usr/local/bin/bash will have the effect of
778 defining SHELL to be "d:/unix/bash.exe". */
780 && strcmp (expanded_name
, "SHELL") == 0)
782 char shellpath
[PATH_MAX
];
783 extern char * __dosexec_find_on_path (const char *, char *[], char *);
785 /* See if we can find "/bin/sh.exe", "/bin/sh.com", etc. */
786 if (__dosexec_find_on_path (value
, (char **)0, shellpath
))
790 for (p
= shellpath
; *p
; p
++)
795 v
= define_variable (expanded_name
, strlen (expanded_name
),
796 shellpath
, origin
, flavor
== recursive
);
800 char *shellbase
, *bslash
;
801 struct variable
*pathv
= lookup_variable ("PATH", 4);
806 shellbase
= rindex (value
, '/');
807 bslash
= rindex (value
, '\\');
808 if (!shellbase
|| bslash
> shellbase
)
810 if (!shellbase
&& value
[1] == ':')
811 shellbase
= value
+ 1;
817 /* Search for the basename of the shell (with standard
818 executable extensions) along the $PATH. */
820 pathlen
= strlen (pathv
->value
);
821 path_string
= (char *)xmalloc (5 + pathlen
+ 2 + 1);
822 /* On MSDOS, current directory is considered as part of $PATH. */
823 sprintf (path_string
, "PATH=.;%s", pathv
? pathv
->value
: "");
824 fake_env
[0] = path_string
;
825 fake_env
[1] = (char *)0;
826 if (__dosexec_find_on_path (shellbase
, fake_env
, shellpath
))
830 for (p
= shellpath
; *p
; p
++)
835 v
= define_variable (expanded_name
, strlen (expanded_name
),
836 shellpath
, origin
, flavor
== recursive
);
839 v
= lookup_variable (expanded_name
, strlen (expanded_name
));
845 #endif /* __MSDOS__ */
847 v
= define_variable (expanded_name
, strlen (expanded_name
),
848 value
, origin
, flavor
== recursive
);
850 free (expanded_name
);
855 /* Print information for variable V, prefixing it with PREFIX. */
858 print_variable (v
, prefix
)
859 register struct variable
*v
;
870 origin
= "environment";
876 origin
= "environment under -e";
879 origin
= "command line";
882 origin
= "`override' directive";
885 origin
= "automatic";
892 printf ("# %s\n", origin
);
894 fputs (prefix
, stdout
);
896 /* Is this a `define'? */
897 if (v
->recursive
&& index (v
->value
, '\n') != 0)
898 printf ("define %s\n%s\nendef\n", v
->name
, v
->value
);
903 printf ("%s %s= ", v
->name
, v
->recursive
? "" : ":");
905 /* Check if the value is just whitespace. */
906 p
= next_token (v
->value
);
907 if (p
!= v
->value
&& *p
== '\0')
908 /* All whitespace. */
909 printf ("$(subst ,,%s)", v
->value
);
910 else if (v
->recursive
)
911 fputs (v
->value
, stdout
);
913 /* Double up dollar signs. */
914 for (p
= v
->value
; *p
!= '\0'; ++p
)
925 /* Print all the variables in SET. PREFIX is printed before
926 the actual variable definitions (everything else is comments). */
929 print_variable_set (set
, prefix
)
930 register struct variable_set
*set
;
933 register unsigned int i
, nvariables
, per_bucket
;
934 register struct variable
*v
;
936 per_bucket
= nvariables
= 0;
937 for (i
= 0; i
< set
->buckets
; ++i
)
939 register unsigned int this_bucket
= 0;
941 for (v
= set
->table
[i
]; v
!= 0; v
= v
->next
)
944 print_variable (v
, prefix
);
947 nvariables
+= this_bucket
;
948 if (this_bucket
> per_bucket
)
949 per_bucket
= this_bucket
;
953 puts ("# No variables.");
956 printf ("# %u variables in %u hash buckets.\n",
957 nvariables
, set
->buckets
);
959 printf ("# average of %.1f variables per bucket, \
960 max %u in one bucket.\n",
961 (double) nvariables
/ (double) set
->buckets
,
965 int f
= (nvariables
* 1000 + 5) / set
->buckets
;
966 printf ("# average of %d.%d variables per bucket, \
967 max %u in one bucket.\n",
976 /* Print the data base of variables. */
979 print_variable_data_base ()
981 puts ("\n# Variables\n");
983 print_variable_set (&global_variable_set
, "");
987 /* Print all the local variables of FILE. */
990 print_file_variables (file
)
993 if (file
->variables
!= 0)
994 print_variable_set (file
->variables
->set
, "# ");
999 sync_Path_environment(void)
1001 char* path
= allocated_variable_expand("$(Path)");
1002 static char* environ_path
= NULL
;
1008 * If done this before, don't leak memory unnecessarily.
1009 * Free the previous entry before allocating new one.
1015 * Create something WINDOWS32 world can grok
1017 convert_Path_to_windows32(path
, ';');
1018 environ_path
= concat("Path", "=", path
);
1019 putenv(environ_path
);