Make any character except '/' legal in function names

darcs-hash:20061019154747-ac50b-f3ab0df1085b91ec0eadcceddb23f03d5b0247aa.gz
This commit is contained in:
axel 2006-10-20 01:47:47 +10:00
parent a5868d67f5
commit b2d4e85f17
4 changed files with 16 additions and 2 deletions

View file

@ -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" ),

View file

@ -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'_' ));

View file

@ -210,6 +210,14 @@ __sentinel wchar_t *wcsdupcat2( const wchar_t *a, ... );
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

View file

@ -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