Minor code cleanup, don't use expand_escape and expand_unescape any more

darcs-hash:20060206151552-ac50b-e2229d096926461f643fdcdfc79ef1ff01344a35.gz
This commit is contained in:
axel 2006-02-07 01:15:52 +10:00
parent cf3d30d4e4
commit e756f7d619
6 changed files with 13 additions and 46 deletions

View file

@ -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; i<argc; i++ )
{
free( unescaped );
unescaped = expand_unescape( argv[i], 1);
unescaped = unescape( argv[i], 1);
if( wildcard_match( current_block->param1.switch_value, unescaped ) )
{

View file

@ -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);
}

View file

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

View file

@ -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.
*/

5
kill.c
View file

@ -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<al_get_count( &list ); i++ )
{
wchar_t *next_line = expand_escape( (wchar_t *)al_get( &list, i ), 0);
wchar_t *next_line = escape( (wchar_t *)al_get( &list, i ), 0);
if( i==0 )
{
new_cut_buffer = next_line;

View file

@ -1343,7 +1343,7 @@ static void completion_insert( wchar_t *val, int is_complete )
if( quote == L'\0' )
{
replaced = expand_escape( val, 1 );
replaced = escape( val, 1 );
}
else
{
@ -1372,7 +1372,7 @@ static void completion_insert( wchar_t *val, int is_complete )
if( unescapable )
{
free( replaced );
wchar_t *tmp = expand_escape( val, 1 );
wchar_t *tmp = escape( val, 1 );
replaced = wcsdupcat( L" ", tmp );
free( tmp);
replaced[0]=quote;