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

kmk: Implemented the where function. Fixes #108.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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},
Note: See TracChangeset for help on using the changeset viewer.