From: Ben Pfaff <blp@cs.stanford.edu> Date: Sun, 11 Sep 2022 03:55:25 +0000 (-0700) Subject: macro: Coding style improvement in macro_tokens_from_string(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=36fc62cea79992b47f12f6144d89a60d1ddcbdb1;p=pspp macro: Coding style improvement in macro_tokens_from_string(). --- diff --git a/src/language/lexer/macro.c b/src/language/lexer/macro.c index 05b3041bb3..8e599f4dde 100644 --- a/src/language/lexer/macro.c +++ b/src/language/lexer/macro.c @@ -232,19 +232,17 @@ macro_tokens_from_string (struct macro_tokens *mts, const struct substring src, while (body.length > 0) { - struct macro_token mt = { - .token = { .type = T_STOP }, - .syntax = { .string = body.string }, - }; - struct token *token = &mt.token; - enum segment_type type; int seg_len = segmenter_push (&segmenter, body.string, body.length, true, &type); assert (seg_len >= 0); - struct substring segment = ss_head (body, seg_len); - enum tokenize_result result = token_from_segment (type, segment, token); + struct macro_token mt = { + .token = { .type = T_STOP }, + .syntax = ss_head (body, seg_len), + }; + enum tokenize_result result + = token_from_segment (type, mt.syntax, &mt.token); ss_advance (&body, seg_len); switch (result) @@ -253,17 +251,15 @@ macro_tokens_from_string (struct macro_tokens *mts, const struct substring src, break; case TOKENIZE_TOKEN: - mt.syntax.length = body.string - mt.syntax.string; macro_tokens_add (mts, &mt); break; case TOKENIZE_ERROR: - mt.syntax.length = body.string - mt.syntax.string; - macro_error (stack, &mt, "%s", token->string.string); + macro_error (stack, &mt, "%s", mt.token.string.string); break; } - token_uninit (token); + token_uninit (&mt.token); } }