From e756f7d619a7458768d59cd9bd1c97c6a1c7788a Mon Sep 17 00:00:00 2001 From: axel Date: Tue, 7 Feb 2006 01:15:52 +1000 Subject: [PATCH] Minor code cleanup, don't use expand_escape and expand_unescape any more darcs-hash:20060206151552-ac50b-e2229d096926461f643fdcdfc79ef1ff01344a35.gz --- builtin.c | 3 +-- complete.c | 8 ++++---- expand.c | 14 ++++---------- expand.h | 25 ------------------------- kill.c | 5 ++--- reader.c | 4 ++-- 6 files changed, 13 insertions(+), 46 deletions(-) diff --git a/builtin.c b/builtin.c index ba87f6635..a54be9e4c 100644 --- a/builtin.c +++ b/builtin.c @@ -47,7 +47,6 @@ #include "parser.h" #include "reader.h" #include "env.h" -#include "expand.h" #include "common.h" #include "wgetopt.h" #include "sanity.h" @@ -2937,7 +2936,7 @@ static int builtin_case( wchar_t **argv ) for( i=1; iparam1.switch_value, unescaped ) ) { diff --git a/complete.c b/complete.c index b50729fd7..4c2d0680c 100644 --- a/complete.c +++ b/complete.c @@ -846,7 +846,7 @@ static const wchar_t *complete_get_desc_suffix( const wchar_t *suff_orig ) } } - wchar_t *tmp = expand_escape( suff, 0 ); + wchar_t *tmp = escape( suff, 0 ); free(suff); suff = tmp; @@ -1088,7 +1088,7 @@ static void complete_cmd_desc( const wchar_t *cmd, array_list_t *comp ) return; } - esc = expand_escape( cmd_start, 1 ); + esc = escape( cmd_start, 1 ); lookup_cmd = wcsdupcat( L"__fish_describe_command ", esc ); free(esc); @@ -1524,7 +1524,7 @@ void complete_load( wchar_t *cmd, { if( !tm || (*tm != buf.st_mtime ) ) { - wchar_t *esc = expand_escape( (wchar_t *)path.buff, 1 ); + wchar_t *esc = escape( (wchar_t *)path.buff, 1 ); wchar_t *src_cmd = wcsdupcat( L". ", esc ); if( !tm ) @@ -2134,7 +2134,7 @@ static void append_switch( string_buffer_t *out, if( !argument || argument==L"" ) return; - esc = expand_escape( argument, 1 ); + esc = escape( argument, 1 ); sb_printf( out, L" --%ls %ls", opt, esc ); free(esc); } diff --git a/expand.c b/expand.c index de1869cea..5b71fe80e 100644 --- a/expand.c +++ b/expand.c @@ -181,12 +181,6 @@ void expand_variable_array( const wchar_t *val, array_list_t *out ) } } -wchar_t *expand_escape( const wchar_t *in, - int escape_all ) -{ - return escape( in, escape_all ); -} - /** Test if the specified string does not contain character which can @@ -243,7 +237,7 @@ wchar_t *expand_escape_variable( const wchar_t *in ) } else { - wchar_t *val = expand_escape( el, 1 ); + wchar_t *val = escape( el, 1 ); sb_append( &buff, val ); free( val ); } @@ -269,7 +263,7 @@ wchar_t *expand_escape_variable( const wchar_t *in ) } else { - wchar_t *val = expand_escape( el, 1 ); + wchar_t *val = escape( el, 1 ); sb_append( &buff, val ); free( val ); } @@ -1217,7 +1211,7 @@ static int expand_subshell( wchar_t *in, array_list_t *out ) { wchar_t *sub_item, *sub_item2; sub_item = (wchar_t *)al_get( &sub_res, i ); - sub_item2 = expand_escape( sub_item, 1 ); + sub_item2 = escape( sub_item, 1 ); free(sub_item); int item_len = wcslen( sub_item2 ); @@ -1251,7 +1245,7 @@ static int expand_subshell( wchar_t *in, array_list_t *out ) } -wchar_t *expand_unescape( const wchar_t * in, int escape_special ) +static wchar_t *expand_unescape( const wchar_t * in, int escape_special ) { wchar_t *res = unescape( in, escape_special ); if( !res ) diff --git a/expand.h b/expand.h index 6065dc30c..61331875b 100644 --- a/expand.h +++ b/expand.h @@ -143,31 +143,6 @@ int expand_string( wchar_t *in, array_list_t *out, int flag ); */ wchar_t *expand_one( wchar_t *in, int flag ); -/** - Expand backslashed escapes and substitute them with their unescaped - counterparts. Also optionally change the wildcards, the tilde - character and a few more into constants which are defined in a - private use area of Unicode. This assumes wchar_t is a unicode - character. character set. - - The result must be free()d. The original string is not modified. If - an invalid sequence is specified, 0 is returned. - -*/ -wchar_t *expand_unescape( const wchar_t * in, int escape_special ); - -/** - Replace special characters with escape sequences. Newline is - replaced with \n, etc. - - The result must be free()d. The original string is not modified. - - \param in The string to be escaped - \param escape_all Whether all characters wich hold special meaning in fish (Pipe, semicolon, etc,) should be escaped, or only unprintable characters - \return The escaped string -*/ -wchar_t *expand_escape( const wchar_t *in, int escape_all ); - /** Convert the variable value to a human readable form, i.e. escape things, handle arrays, etc. Suitable for pretty-printing. */ diff --git a/kill.c b/kill.c index 1ee62d132..f3c07e195 100644 --- a/kill.c +++ b/kill.c @@ -25,7 +25,6 @@ #include "sanity.h" #include "common.h" #include "env.h" -#include "expand.h" #include "exec.h" #include "parser.h" @@ -95,7 +94,7 @@ void kill_add( wchar_t *str ) wchar_t *disp; if( (disp = env_get( L"DISPLAY" )) ) { - wchar_t *escaped_str = expand_escape( str, 1 ); + wchar_t *escaped_str = escape( str, 1 ); wchar_t *cmd = wcsdupcat2(L"echo ", escaped_str, L"|xsel -b",0); exec_subshell( cmd, 0 ); free( cut_buffer ); @@ -137,7 +136,7 @@ static void kill_check_x_buffer() for( i=0; i