From b4476c72363f5485c51e6acdbd246221f3981875 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se>
Date: Sun, 12 Jan 2003 16:07:10 +0100
Subject: [PATCH] * tools/sexp-conv.c (struct sexp_parser): Renamed struct (was
 struct sexp_parse_state). Added input pointer. Updated users to not pass
 around both parser and input. (sexp_check_token): handle token == 0.
 (sexp_parse): Simplified a little by calling sexp_check_token
 unconditionally.

* tools/sexp-conv.c (sexp_convert_string): Deleted function.
(sexp_skip_token): Likewise.

* tools/sexp-conv.c (enum sexp_token): New constant SEXP_DISPLAY.
Start constants from 1, to keep 0 free for special uses.
(struct sexp_parse_state): New struct for keeping track of parser
state.
(sexp_parse_init): New function.
(sexp_check_token): New function, replacing sexp_skip_token.
(sexp_parse): New function.
(sexp_convert_item): Simplified by using sexp_parse.
(sexp_convert_list): Use sexp_parse.
(main): Likewise.

Rev: src/nettle/tools/sexp-conv.c:1.10
---
 tools/sexp-conv.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/tools/sexp-conv.c b/tools/sexp-conv.c
index f2f027de..8241a597 100644
--- a/tools/sexp-conv.c
+++ b/tools/sexp-conv.c
@@ -603,8 +603,7 @@ sexp_check_token(struct sexp_parser *parser,
   sexp_get_token(parser->input,
 		 parser->transport ? SEXP_CANONICAL : parser->mode);
 
-  /* FIXME: Handle token == 0 meaning any. */ 
-  if (parser->input->token != token)
+  if (token && parser->input->token != token)
     die("Syntax error.\n");
 }
 
@@ -620,12 +619,10 @@ sexp_parse(struct sexp_parser *parser)
 {
   for (;;)
     {
-      if (!parser->expected)
-	sexp_get_token(parser->input,
-		       parser->transport ? SEXP_CANONICAL : parser->mode);
-      else
+      sexp_check_token(parser, parser->expected);
+
+      if (parser->expected)
 	{
-	  sexp_check_token(parser, parser->expected);
 	  parser->expected = 0;
 	  
 	  if (parser->input->token == SEXP_STRING)
-- 
GitLab