diff options
author | Boris Kolpackov <boris@kolpackov.net> | 2004-10-21 17:42:24 +0000 |
---|---|---|
committer | Boris Kolpackov <boris@kolpackov.net> | 2004-10-21 17:42:24 +0000 |
commit | 547abfa13e2037c0461e3965911f5322737f2bda (patch) | |
tree | ce001b95fcc334baab9cb14c530ae3f0a115d2d1 /function.c | |
parent | 71fd6bfa1ce41da2dcc9ae0d28f037129d9c481a (diff) | |
download | gunmake-547abfa13e2037c0461e3965911f5322737f2bda.tar.gz |
New $(lastword ) built-in function: implementation, documentation and tests.
Diffstat (limited to 'function.c')
-rw-r--r-- | function.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -667,6 +667,22 @@ func_firstword (char *o, char **argv, const char *funcname UNUSED) return o; } +static char * +func_lastword (char *o, char **argv, const char *funcname UNUSED) +{ + unsigned int i; + char *words = argv[0]; /* Use a temp variable for find_next_token */ + char *p = 0; + char *t; + + while ((t = find_next_token (&words, &i))) + p = t; + + if (p != 0) + o = variable_buffer_output (o, p, i); + + return o; +} static char * func_words (char *o, char **argv, const char *funcname UNUSED) @@ -1754,6 +1770,7 @@ static struct function_table_entry function_table_init[] = { STRING_SIZE_TUPLE("findstring"), 2, 2, 1, func_findstring}, { STRING_SIZE_TUPLE("firstword"), 0, 1, 1, func_firstword}, { STRING_SIZE_TUPLE("join"), 2, 2, 1, func_join}, + { STRING_SIZE_TUPLE("lastword"), 0, 1, 1, func_lastword}, { STRING_SIZE_TUPLE("patsubst"), 3, 3, 1, func_patsubst}, { STRING_SIZE_TUPLE("shell"), 0, 1, 1, func_shell}, { STRING_SIZE_TUPLE("sort"), 0, 1, 1, func_sort}, |