summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2008-08-27 10:46:02 +0200
committerNiels Möller <nisse@lysator.liu.se>2008-08-27 10:46:02 +0200
commit49c303e44ac66ceed7ea1b097657a48a06d86f62 (patch)
tree4b4394f2fdbccbd8ca2fdbb9d401744676d973b8 /tools
parente53a0a93728c74ec919fc6b132696d192df099e7 (diff)
downloadnettle-49c303e44ac66ceed7ea1b097657a48a06d86f62.tar.gz
(sexp_get_comment): New function.
(sexp_get_token): Use sexp_get_comment. Rev: nettle/tools/input.c:1.2
Diffstat (limited to 'tools')
-rw-r--r--tools/input.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/tools/input.c b/tools/input.c
index 5f99afb6..8dd7d0c1 100644
--- a/tools/input.c
+++ b/tools/input.c
@@ -180,7 +180,7 @@ sexp_get_quoted_char(struct sexp_input *input)
static void
sexp_get_token_string(struct sexp_input *input,
- struct nettle_buffer *string)
+ struct nettle_buffer *string)
{
assert(!input->coding);
assert(input->ctype == SEXP_NORMAL_CHAR);
@@ -334,6 +334,24 @@ sexp_get_string_length(struct sexp_input *input, enum sexp_mode mode,
sexp_get_char(input);
}
+static void
+sexp_get_comment(struct sexp_input *input, struct nettle_buffer *string)
+{
+ nettle_buffer_reset(string);
+
+ assert(input->ctype == SEXP_NORMAL_CHAR);
+ assert(input->c == ';');
+
+ do
+ {
+ sexp_push_char(input, string);
+ sexp_get_raw_char(input);
+ }
+ while (input->ctype == SEXP_NORMAL_CHAR && input->c != '\n');
+
+ input->token = SEXP_COMMENT;
+}
+
/* When called, input->c should be the first character of the current
* token.
*
@@ -409,15 +427,8 @@ sexp_get_token(struct sexp_input *input, enum sexp_mode mode,
if (mode == SEXP_CANONICAL)
die("Comment encountered in canonical mode.\n");
- do
- {
- sexp_get_raw_char(input);
- if (input->ctype != SEXP_NORMAL_CHAR)
- return;
- }
- while (input->c != '\n');
-
- break;
+ sexp_get_comment(input, string);
+ return;
default:
/* Ought to be a string */