VirtualBox

Changeset 1439 in kBuild


Ignore:
Timestamp:
Mar 29, 2008 2:55:14 AM (17 years ago)
Author:
bird
Message:

CONFIG_WITH_EVALPLUS: evalctx, evalval, evalvalctx, evalcall and evalcall2. (all untested)

Location:
trunk/src/kmk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/Makefile.am

    r1438 r1439  
    124124        -DCONFIG_WITH_FILE_SIZE \
    125125        -DCONFIG_WITH_WHICH \
    126         -DCONFIG_WITH_EVALCTX \
     126        -DCONFIG_WITH_EVALPLUS \
    127127        -DCONFIG_WITH_MAKE_STATS \
    128128        -DCONFIG_PRETTY_COMMAND_PRINTING \
  • trunk/src/kmk/Makefile.kmk

    r1438 r1439  
    124124        CONFIG_WITH_FILE_SIZE \
    125125        CONFIG_WITH_WHICH \
    126         CONFIG_WITH_EVALCTX \
     126        CONFIG_WITH_EVALPLUS \
    127127        CONFIG_WITH_MAKE_STATS \
    128128        CONFIG_PRETTY_COMMAND_PRINTING \
  • trunk/src/kmk/function.c

    r1438 r1439  
    15131513
    15141514
    1515 #ifdef CONFIG_WITH_EVALCTX
     1515#ifdef CONFIG_WITH_EVALPLUS
    15161516/* Same as func_eval except that we push and pop the local variable
    15171517   context before evaluating the buffer. */
     
    15371537  return o;
    15381538}
    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. */
     1543static char *
     1544func_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 */
    15401572
    15411573static char *
     
    35773609  { STRING_SIZE_TUPLE("value"),         0,  1,  1,  func_value},
    35783610  { STRING_SIZE_TUPLE("eval"),          0,  1,  1,  func_eval},
    3579 #ifdef CONFIG_WITH_EVALCTX
     3611#ifdef CONFIG_WITH_EVALPLUS
    35803612  { 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},
    35813617#endif
    35823618#ifdef EXPERIMENTAL
     
    38173853  const struct function_table_entry *entry_p;
    38183854  struct variable *v;
     3855#ifdef CONFIG_WITH_EVALPLUS
     3856  char *buf;
     3857  unsigned int len;
     3858#endif
    38193859
    38203860  /* There is no way to define a variable with a space in the name, so strip
     
    38883928    }
    38893929
    3890   /* Expand the body in the context of the arguments, adding the result to
    3891      the variable buffer.  */
    3892 
    3893   v->exp_count = EXP_COUNT_MAX;
    3894 
    38953930  saved_args = max_args;
    38963931  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
    38983969  max_args = saved_args;
    38993970
    3900   v->exp_count = 0;
    3901 
    39023971  pop_variable_scope ();
    39033972
    3904   return o + strlen (o);
     3973  return o;
    39053974}
    39063975
  • trunk/src/kmk/variable.c

    r1438 r1439  
    973973#endif
    974974  register struct variable *v;
     975#ifndef KMK
    975976  char buf[200];
    976 #ifdef KMK
     977#else
     978  char buf[1024];
    977979  const char *envvar;
    978980#endif
     
    10421044  && defined (CONFIG_WITH_FILE_SIZE) \
    10431045  && defined (CONFIG_WITH_WHICH) \
    1044   && defined (CONFIG_WITH_EVALCTX) \
     1046  && defined (CONFIG_WITH_EVALPLUS) \
    10451047  && defined (CONFIG_WITH_MAKE_STATS) \
    10461048  && defined (KMK_HELPERS)
     
    10601062                          " file-size"
    10611063                          " which"
    1062                           " evalctx"
     1064                          " evalctx evalval evalvalctx evalcall evalcall2"
    10631065                          " make-stats"
    10641066                          " kb-src-tool kb-obj-base kb-obj-suff kb-src-prop kb-src-one "
     
    11061108  strcat (buf, " which");
    11071109#  endif
    1108 #  if defined (CONFIG_WITH_EVALCTX)
    1109   strcat (buf, " evalctx");
     1110#  if defined (CONFIG_WITH_EVALPLUS)
     1111  strcat (buf, " evalctx evalval evalvalctx evalcall evalcall2");
    11101112#  endif
    11111113#  if defined (CONFIG_WITH_MAKE_STATS)
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette