mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 04:43:10 +00:00
Make sure tokenizer never changes input string
darcs-hash:20051210003335-ac50b-2d1b9125186b1d3f68138c2c49559d077fa5d326.gz
This commit is contained in:
parent
f05da41159
commit
33e2c81748
2 changed files with 9 additions and 2 deletions
|
@ -138,7 +138,7 @@ void tok_init( tokenizer *tok, const wchar_t *b, int flags )
|
||||||
}
|
}
|
||||||
|
|
||||||
tok->has_next = (*b != L'\0');
|
tok->has_next = (*b != L'\0');
|
||||||
tok->orig_buff = tok->buff = /*wcsdup*/(b);
|
tok->orig_buff = tok->buff = (wchar_t *)(b);
|
||||||
|
|
||||||
if( !tok->orig_buff )
|
if( !tok->orig_buff )
|
||||||
{
|
{
|
||||||
|
@ -152,7 +152,11 @@ void tok_init( tokenizer *tok, const wchar_t *b, int flags )
|
||||||
if( l != 0 )
|
if( l != 0 )
|
||||||
{
|
{
|
||||||
if( tok->orig_buff[l-1] == L'\\' )
|
if( tok->orig_buff[l-1] == L'\\' )
|
||||||
|
{
|
||||||
|
tok->free_orig = 1;
|
||||||
|
tok->orig_buff = wcsdup( tok->orig_buff );
|
||||||
tok->orig_buff[l-1] = L'\0';
|
tok->orig_buff[l-1] = L'\0';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,7 +167,8 @@ void tok_init( tokenizer *tok, const wchar_t *b, int flags )
|
||||||
void tok_destroy( tokenizer *tok )
|
void tok_destroy( tokenizer *tok )
|
||||||
{
|
{
|
||||||
free( tok->last );
|
free( tok->last );
|
||||||
// free( tok->orig_buff );
|
if( tok->free_orig )
|
||||||
|
free( tok->orig_buff );
|
||||||
}
|
}
|
||||||
|
|
||||||
int tok_last_type( tokenizer *tok )
|
int tok_last_type( tokenizer *tok )
|
||||||
|
|
|
@ -69,6 +69,8 @@ typedef struct
|
||||||
int accept_unfinished;
|
int accept_unfinished;
|
||||||
/** Whether commants should be returned*/
|
/** Whether commants should be returned*/
|
||||||
int show_comments;
|
int show_comments;
|
||||||
|
/** Flag set to true of the orig_buff points to an internal string that needs to be free()d when deallocating the tokenizer. */
|
||||||
|
int free_orig;
|
||||||
/** Type of last quote, can be either ' or ".*/
|
/** Type of last quote, can be either ' or ".*/
|
||||||
wchar_t last_quote;
|
wchar_t last_quote;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue