23 * Use is subject to license terms.
24 */
25
26
27 /*
28 * macro.cc
29 *
30 * Handle expansion of make macros
31 */
32
33 /*
34 * Included files
35 */
36 #include <mksh/dosys.h> /* sh_command2string() */
37 #include <mksh/i18n.h> /* get_char_semantics_value() */
38 #include <mksh/macro.h>
39 #include <mksh/misc.h> /* retmem() */
40 #include <mksh/read.h> /* get_next_block_fn() */
41 #include <mksdmsi18n/mksdmsi18n.h> /* libmksdmsi18n_init() */
42
43 /*
44 * File table of contents
45 */
46 static void add_macro_to_global_list(Name macro_to_add);
47 #ifdef NSE
48 static void expand_value_with_daemon(Name name, register Property macro, register String destination, Boolean cmd);
49 #else
50 static void expand_value_with_daemon(Name, register Property macro, register String destination, Boolean cmd);
51 #endif
52
53 static void init_arch_macros(void);
54 static void init_mach_macros(void);
55 static Boolean init_arch_done = false;
56 static Boolean init_mach_done = false;
57
58
59 long env_alloc_num = 0;
60 long env_alloc_bytes = 0;
61
62 /*
847 if(left_head) {
848 retmem(left_head);
849 }
850 i = 0;
851 while (right_hand[i] != NULL) {
852 retmem(right_hand[i]);
853 i++;
854 }
855 *destination->text.p = (int) nul_char;
856 destination->text.end = destination->text.p;
857 }
858
859 static void
860 add_macro_to_global_list(Name macro_to_add)
861 {
862 Macro_list new_macro;
863 Macro_list macro_on_list;
864 char *name_on_list = (char*)NULL;
865 char *name_to_add = macro_to_add->string_mb;
866 char *value_on_list = (char*)NULL;
867 char *value_to_add = (char*)NULL;
868
869 if (macro_to_add->prop->body.macro.value != NULL) {
870 value_to_add = macro_to_add->prop->body.macro.value->string_mb;
871 } else {
872 value_to_add = "";
873 }
874
875 /*
876 * Check if this macro is already on list, if so, do nothing
877 */
878 for (macro_on_list = cond_macro_list;
879 macro_on_list != NULL;
880 macro_on_list = macro_on_list->next) {
881
882 name_on_list = macro_on_list->macro_name;
883 value_on_list = macro_on_list->value;
884
885 if (IS_EQUAL(name_on_list, name_to_add)) {
886 if (IS_EQUAL(value_on_list, value_to_add)) {
887 return;
|
23 * Use is subject to license terms.
24 */
25
26
27 /*
28 * macro.cc
29 *
30 * Handle expansion of make macros
31 */
32
33 /*
34 * Included files
35 */
36 #include <mksh/dosys.h> /* sh_command2string() */
37 #include <mksh/i18n.h> /* get_char_semantics_value() */
38 #include <mksh/macro.h>
39 #include <mksh/misc.h> /* retmem() */
40 #include <mksh/read.h> /* get_next_block_fn() */
41 #include <mksdmsi18n/mksdmsi18n.h> /* libmksdmsi18n_init() */
42
43 #include <widec.h>
44
45 /*
46 * File table of contents
47 */
48 static void add_macro_to_global_list(Name macro_to_add);
49 #ifdef NSE
50 static void expand_value_with_daemon(Name name, register Property macro, register String destination, Boolean cmd);
51 #else
52 static void expand_value_with_daemon(Name, register Property macro, register String destination, Boolean cmd);
53 #endif
54
55 static void init_arch_macros(void);
56 static void init_mach_macros(void);
57 static Boolean init_arch_done = false;
58 static Boolean init_mach_done = false;
59
60
61 long env_alloc_num = 0;
62 long env_alloc_bytes = 0;
63
64 /*
849 if(left_head) {
850 retmem(left_head);
851 }
852 i = 0;
853 while (right_hand[i] != NULL) {
854 retmem(right_hand[i]);
855 i++;
856 }
857 *destination->text.p = (int) nul_char;
858 destination->text.end = destination->text.p;
859 }
860
861 static void
862 add_macro_to_global_list(Name macro_to_add)
863 {
864 Macro_list new_macro;
865 Macro_list macro_on_list;
866 char *name_on_list = (char*)NULL;
867 char *name_to_add = macro_to_add->string_mb;
868 char *value_on_list = (char*)NULL;
869 const char *value_to_add = (char*)NULL;
870
871 if (macro_to_add->prop->body.macro.value != NULL) {
872 value_to_add = macro_to_add->prop->body.macro.value->string_mb;
873 } else {
874 value_to_add = "";
875 }
876
877 /*
878 * Check if this macro is already on list, if so, do nothing
879 */
880 for (macro_on_list = cond_macro_list;
881 macro_on_list != NULL;
882 macro_on_list = macro_on_list->next) {
883
884 name_on_list = macro_on_list->macro_name;
885 value_on_list = macro_on_list->value;
886
887 if (IS_EQUAL(name_on_list, name_to_add)) {
888 if (IS_EQUAL(value_on_list, value_to_add)) {
889 return;
|