#include "libpspp/cast.h"
#include "libpspp/misc.h"
-
#include "gl/ftoastr.h"
#include "gl/xalloc.h"
-/* Initializes TOKEN with an arbitrary type, number 0, and a null string. */
void
-token_init (struct token *token)
+token_copy (struct token *dst, const struct token *src)
{
- token->type = 0;
- token->number = 0.0;
- token->string = ss_empty ();
+ *dst = (struct token) {
+ .type = src->type,
+ .number = src->number,
+ };
+ ss_alloc_substring (&dst->string, src->string);
}
/* Frees the string that TOKEN contains. */
token_uninit (struct token *token)
{
if (token != NULL)
- ss_dealloc (&token->string);
+ {
+ ss_dealloc (&token->string);
+ *token = (struct token) { .type = T_STOP };
+ }
}
static char *