Added accessors for the filename

This commit is contained in:
Pierre Pronchery 2008-02-27 18:20:22 +00:00
parent ccb781960c
commit fcab87e048
2 changed files with 20 additions and 0 deletions

View File

@ -33,6 +33,9 @@ void token_delete(Token * token);
/* accessors */
char const * token_get_filename(Token * token);
int token_set_filename(Token * token, char const * filename);
unsigned int token_get_col(Token * token);
void token_set_col(Token * token, unsigned int col);

View File

@ -91,6 +91,13 @@ unsigned int token_get_col(Token * token)
}
/* token_get_filename */
char const * token_get_filename(Token * token)
{
return token->filename;
}
/* token_get_line */
unsigned int token_get_line(Token * token)
{
@ -119,6 +126,16 @@ void token_set_col(Token * token, unsigned int col)
}
/* token_set_filename */
int token_set_filename(Token * token, char const * filename)
{
free(token->filename);
if((token->filename = strdup(filename)) == NULL)
return error_set_code(1, "%s", strerror(errno));
return 0;
}
/* token_set_line */
void token_set_line(Token * token, unsigned int line)
{