X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Flexer%2Ftoken.c;h=69fd48fb62d48e3a193435dee7763155c71cec1e;hb=dde9b7b4e92fd1221de01e429343ea72ae444e33;hp=718f3d07f3d480a1580d59714ee8348e63a38e5e;hpb=74709d3f6d7c102bb3226f7f132c8be78ce8e8c2;p=pspp diff --git a/src/language/lexer/token.c b/src/language/lexer/token.c index 718f3d07f3..69fd48fb62 100644 --- a/src/language/lexer/token.c +++ b/src/language/lexer/token.c @@ -27,17 +27,17 @@ #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. */ @@ -45,7 +45,10 @@ void token_uninit (struct token *token) { if (token != NULL) - ss_dealloc (&token->string); + { + ss_dealloc (&token->string); + *token = (struct token) { .type = T_STOP }; + } } static char *