diff options
author | 2006-10-20 01:47:47 +1000 | |
---|---|---|
committer | 2006-10-20 01:47:47 +1000 | |
commit | b2d4e85f172fecfba0a0fcd136f6d8178ff9b90c (patch) | |
tree | 7b2c912908ebaea78389789007690c5f2de72755 | |
parent | a5868d67f5548923c4452622a24c42ff90f23188 (diff) |
Make any character except '/' legal in function names
darcs-hash:20061019154747-ac50b-f3ab0df1085b91ec0eadcceddb23f03d5b0247aa.gz
-rw-r--r-- | builtin.c | 2 | ||||
-rw-r--r-- | common.c | 6 | ||||
-rw-r--r-- | common.h | 8 | ||||
-rw-r--r-- | doc_src/function.txt | 2 |
4 files changed, 16 insertions, 2 deletions
@@ -1281,7 +1281,7 @@ static int builtin_function( wchar_t **argv ) argc-woptind ); res=1; } - else if( !(is_binding?wcsbindingname( argv[woptind] ) : !wcsvarname( argv[woptind] ) )) + else if( wcsfuncname( argv[woptind] ) ) { sb_printf( sb_err, _( L"%ls: Illegal function name '%ls'\n" ), @@ -421,6 +421,12 @@ wchar_t *wcsvarname( const wchar_t *str ) return 0; } +wchar_t *wcsfuncname( const wchar_t *str ) +{ + return wcschr( str, L'/' ); +} + + int wcsvarchr( wchar_t chr ) { return ( (iswalnum(chr)) || (chr == L'_' )); @@ -211,6 +211,14 @@ wchar_t *wcsvarname( const wchar_t *str ); /** + Test if the given string is a valid function name. + + \return null if this is a valid name, and a pointer to the first invalid character otherwise +*/ + +wchar_t *wcsfuncname( const wchar_t *str ); + +/** Test if the given string is valid in a variable name \return 1 if this is a valid name, 0 otherwise diff --git a/doc_src/function.txt b/doc_src/function.txt index 37ed23fc..75bf9e88 100644 --- a/doc_src/function.txt +++ b/doc_src/function.txt @@ -5,7 +5,7 @@ \subsection function-description Description -- \c -b or \c --key-binding specifies that the function is a key biding. Key binding functions work exactly like regular functions except that they can not be tab-completed, and may contain the '-' character. +- \c -b or \c --key-binding specifies that the function is a key biding. Key binding functions work exactly like regular functions except that they can not be tab-completed. - <code>-d DESCRIPTION</code> or \c --description=DESCRIPTION is a description of what the function does, suitable as a completion description - <code>-j PID</code> or <code> --on-job-exit PID</code> tells fish to run this function when the job with group id PID exits. Instead of PID, the string 'caller' can be specified. This is only legal when in a command substitution, and will result in the handler being triggered by the exit of the job which created this command substitution. - <code>-p PID</code> or <code> --on-process-exit PID</code> tells fish to run this function when the fish child process with process id PID exits |