Changeset 1439 in kBuild
- Timestamp:
- Mar 29, 2008 2:55:14 AM (17 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/Makefile.am
r1438 r1439 124 124 -DCONFIG_WITH_FILE_SIZE \ 125 125 -DCONFIG_WITH_WHICH \ 126 -DCONFIG_WITH_EVAL CTX\126 -DCONFIG_WITH_EVALPLUS \ 127 127 -DCONFIG_WITH_MAKE_STATS \ 128 128 -DCONFIG_PRETTY_COMMAND_PRINTING \ -
trunk/src/kmk/Makefile.kmk
r1438 r1439 124 124 CONFIG_WITH_FILE_SIZE \ 125 125 CONFIG_WITH_WHICH \ 126 CONFIG_WITH_EVAL CTX\126 CONFIG_WITH_EVALPLUS \ 127 127 CONFIG_WITH_MAKE_STATS \ 128 128 CONFIG_PRETTY_COMMAND_PRINTING \ -
trunk/src/kmk/function.c
r1438 r1439 1513 1513 1514 1514 1515 #ifdef CONFIG_WITH_EVAL CTX1515 #ifdef CONFIG_WITH_EVALPLUS 1516 1516 /* Same as func_eval except that we push and pop the local variable 1517 1517 context before evaluating the buffer. */ … … 1537 1537 return o; 1538 1538 } 1539 #endif /* CONFIG_WITH_EVALCTX */ 1539 1540 /* A mix of func_eval and func_value, saves memory for the expansion. 1541 This implements both evalval and evalvalctx, the latter has its own 1542 variable context just like evalctx. */ 1543 static char * 1544 func_evalval (char *o, char **argv, const char *funcname) 1545 { 1546 /* Look up the variable. */ 1547 struct variable *v = lookup_variable (argv[0], strlen (argv[0])); 1548 if (v) 1549 { 1550 char *buf; 1551 unsigned int len; 1552 int var_ctx; 1553 1554 /* Eval the value. Pop the current variable buffer setting so that the 1555 eval'd code can use its own without conflicting. (really necessary?) */ 1556 1557 install_variable_buffer (&buf, &len); 1558 var_ctx = !strcmp(funcname, "evalvalctx"); 1559 if (var_ctx) 1560 push_new_variable_scope (); 1561 1562 eval_buffer (v->value); 1563 1564 if (var_ctx) 1565 pop_variable_scope (); 1566 restore_variable_buffer (buf, len); 1567 } 1568 1569 return o; 1570 } 1571 #endif /* CONFIG_WITH_EVALPLUS */ 1540 1572 1541 1573 static char * … … 3577 3609 { STRING_SIZE_TUPLE("value"), 0, 1, 1, func_value}, 3578 3610 { STRING_SIZE_TUPLE("eval"), 0, 1, 1, func_eval}, 3579 #ifdef CONFIG_WITH_EVAL CTX3611 #ifdef CONFIG_WITH_EVALPLUS 3580 3612 { STRING_SIZE_TUPLE("evalctx"), 0, 1, 1, func_evalctx}, 3613 { STRING_SIZE_TUPLE("evalval"), 0, 1, 0, func_evalval}, 3614 { STRING_SIZE_TUPLE("evalvalctx"), 0, 1, 0, func_evalval}, 3615 { STRING_SIZE_TUPLE("evalcall"), 1, 0, 1, func_call}, 3616 { STRING_SIZE_TUPLE("evalcall2"), 1, 0, 1, func_call}, 3581 3617 #endif 3582 3618 #ifdef EXPERIMENTAL … … 3817 3853 const struct function_table_entry *entry_p; 3818 3854 struct variable *v; 3855 #ifdef CONFIG_WITH_EVALPLUS 3856 char *buf; 3857 unsigned int len; 3858 #endif 3819 3859 3820 3860 /* There is no way to define a variable with a space in the name, so strip … … 3888 3928 } 3889 3929 3890 /* Expand the body in the context of the arguments, adding the result to3891 the variable buffer. */3892 3893 v->exp_count = EXP_COUNT_MAX;3894 3895 3930 saved_args = max_args; 3896 3931 max_args = i; 3897 o = variable_expand_string (o, body, flen+3); 3932 3933 #ifdef CONFIG_WITH_EVALPLUS 3934 if (!strcmp (funcname, "call")) 3935 { 3936 #endif 3937 /* Expand the body in the context of the arguments, adding the result to 3938 the variable buffer. */ 3939 3940 v->exp_count = EXP_COUNT_MAX; 3941 o = variable_expand_string (o, body, flen+3); 3942 v->exp_count = 0; 3943 3944 o += strlen (o); 3945 #ifdef CONFIG_WITH_EVALPLUS 3946 } 3947 else if (!strcmp (funcname, "evalcall")) 3948 { 3949 /* Evaluate the variable value directly without expanding it first. */ 3950 3951 install_variable_buffer (&buf, &len); 3952 eval_buffer (v->value); 3953 restore_variable_buffer (buf, len); 3954 } 3955 else /* evalcall2: */ 3956 { 3957 /* Expand the body first and then evaluate the output. */ 3958 3959 v->exp_count = EXP_COUNT_MAX; 3960 o = variable_expand_string (o, body, flen+3); 3961 v->exp_count = 0; 3962 3963 install_variable_buffer (&buf, &len); 3964 eval_buffer (o); 3965 restore_variable_buffer (buf, len); 3966 } 3967 #endif /* CONFIG_WITH_EVALPLUS */ 3968 3898 3969 max_args = saved_args; 3899 3970 3900 v->exp_count = 0;3901 3902 3971 pop_variable_scope (); 3903 3972 3904 return o + strlen (o);3973 return o; 3905 3974 } 3906 3975 -
trunk/src/kmk/variable.c
r1438 r1439 973 973 #endif 974 974 register struct variable *v; 975 #ifndef KMK 975 976 char buf[200]; 976 #ifdef KMK 977 #else 978 char buf[1024]; 977 979 const char *envvar; 978 980 #endif … … 1042 1044 && defined (CONFIG_WITH_FILE_SIZE) \ 1043 1045 && defined (CONFIG_WITH_WHICH) \ 1044 && defined (CONFIG_WITH_EVAL CTX) \1046 && defined (CONFIG_WITH_EVALPLUS) \ 1045 1047 && defined (CONFIG_WITH_MAKE_STATS) \ 1046 1048 && defined (KMK_HELPERS) … … 1060 1062 " file-size" 1061 1063 " which" 1062 " evalctx "1064 " evalctx evalval evalvalctx evalcall evalcall2" 1063 1065 " make-stats" 1064 1066 " kb-src-tool kb-obj-base kb-obj-suff kb-src-prop kb-src-one " … … 1106 1108 strcat (buf, " which"); 1107 1109 # endif 1108 # if defined (CONFIG_WITH_EVAL CTX)1109 strcat (buf, " evalctx ");1110 # if defined (CONFIG_WITH_EVALPLUS) 1111 strcat (buf, " evalctx evalval evalvalctx evalcall evalcall2"); 1110 1112 # endif 1111 1113 # if defined (CONFIG_WITH_MAKE_STATS)
Note:
See TracChangeset
for help on using the changeset viewer.