VirtualBox

Changeset 2532 in kBuild for trunk/src


Ignore:
Timestamp:
Aug 2, 2011 1:05:37 PM (13 years ago)
Author:
bird
Message:

kmk: Implemented the where function. Fixes #108.

Location:
trunk/src/kmk
Files:
4 edited

Legend:

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

    r2489 r2532  
    143143        -DCONFIG_WITH_STACK \
    144144        -DCONFIG_WITH_STRING_FUNCTIONS \
     145        -DCONFIG_WITH_WHERE_FUNCTION \
    145146        -DCONFIG_WITH_WHICH \
    146147        -DCONFIG_WITH_XARGS \
  • trunk/src/kmk/Makefile.kmk

    r2489 r2532  
    168168        CONFIG_WITH_STACK \
    169169        CONFIG_WITH_STRING_FUNCTIONS \
     170        CONFIG_WITH_WHERE_FUNCTION \
    170171        CONFIG_WITH_WHICH \
    171172        CONFIG_WITH_XARGS \
  • trunk/src/kmk/function.c

    r2516 r2532  
    684684}
    685685
     686#ifdef CONFIG_WITH_WHERE_FUNCTION
     687static char *
     688func_where (char *o, char **argv, const char *funcname UNUSED)
     689{
     690  struct variable *v = lookup_variable (argv[0], strlen (argv[0]));
     691  char buf[64];
     692
     693  if (v == 0)
     694    o = variable_buffer_output (o, "undefined", 9);
     695  else
     696    if (v->fileinfo.filenm)
     697      {
     698        o = variable_buffer_output (o, v->fileinfo.filenm, strlen(v->fileinfo.filenm));
     699        sprintf (buf, ":%lu", v->fileinfo.lineno);
     700        o = variable_buffer_output (o, buf, strlen(buf));
     701      }
     702    else
     703      o = variable_buffer_output (o, "no-location", 11);
     704
     705  return o;
     706}
     707#endif /* CONFIG_WITH_WHERE_FUNCTION */
     708
    686709#ifdef VMS
    687710# define IS_PATHSEP(c) ((c) == ']')
     
    52865309  { STRING_SIZE_TUPLE("sort"),          0,  1,  1,  func_sort},
    52875310  { STRING_SIZE_TUPLE("strip"),         0,  1,  1,  func_strip},
     5311#ifdef CONFIG_WITH_WHERE_FUNCTION
     5312  { STRING_SIZE_TUPLE("where"),         0,  1,  1,  func_where},
     5313#endif
    52885314  { STRING_SIZE_TUPLE("wildcard"),      0,  1,  1,  func_wildcard},
    52895315  { STRING_SIZE_TUPLE("word"),          2,  2,  1,  func_word},
  • trunk/src/kmk/variable.c

    r2489 r2532  
    12891289  && defined (CONFIG_WITH_DATE) \
    12901290  && defined (CONFIG_WITH_FILE_SIZE) \
     1291  && defined (CONFIG_WITH_WHERE_FUNCTION) \
    12911292  && defined (CONFIG_WITH_WHICH) \
    12921293  && defined (CONFIG_WITH_EVALPLUS) \
     
    13161317                          " file-size"
    13171318                          " expr if-expr select"
     1319                          " where"
    13181320                          " which"
    13191321                          " evalctx evalval evalvalctx evalcall evalcall2 eval-opt-var"
     
    13751377  strcat (buf, " expr if-expr select");
    13761378#  endif
     1379#  if defined (CONFIG_WITH_WHERE_FUNCTION)
     1380  strcat (buf, " where");
     1381#  endif
    13771382#  if defined (CONFIG_WITH_WHICH)
    13781383  strcat (buf, " which");
Note: See TracChangeset for help on using the changeset viewer.

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