Commit 869cd834 authored by Niels Möller's avatar Niels Möller
Browse files

* examples/sexp-conv.c(sexp_put_list_start): Deleted function.

(sexp_put_list_end): Likewise.
(sexp_put_display_start): Likewise.
(sexp_put_display_end): Likewise.
(sexp_puts): Likewise.

Rev: src/nettle/examples/sexp-conv.c:1.15
parent 4b11c57a
...@@ -603,14 +603,6 @@ sexp_put_data(struct sexp_output *output, ...@@ -603,14 +603,6 @@ sexp_put_data(struct sexp_output *output,
sexp_put_char(output, data[i]); sexp_put_char(output, data[i]);
} }
static void
sexp_puts(struct sexp_output *output,
const uint8_t *s)
{
while (*s)
sexp_put_char(output, *s++);
}
static void static void
sexp_put_length(struct sexp_output *output, sexp_put_length(struct sexp_output *output,
unsigned length) unsigned length)
...@@ -667,7 +659,8 @@ sexp_put_string(struct sexp_output *output, enum sexp_mode mode, ...@@ -667,7 +659,8 @@ sexp_put_string(struct sexp_output *output, enum sexp_mode mode,
struct nettle_buffer *string) struct nettle_buffer *string)
{ {
if (!string->size) if (!string->size)
sexp_puts(output, (mode == SEXP_ADVANCED) ? "\"\"": "0:"); sexp_put_data(output, 2,
(mode == SEXP_ADVANCED) ? "\"\"": "0:");
else if (mode == SEXP_ADVANCED) else if (mode == SEXP_ADVANCED)
{ {
...@@ -738,29 +731,8 @@ sexp_put_string(struct sexp_output *output, enum sexp_mode mode, ...@@ -738,29 +731,8 @@ sexp_put_string(struct sexp_output *output, enum sexp_mode mode,
} }
} }
static void
sexp_put_list_start(struct sexp_output *output) /* Parsing and conversion functions. */
{
sexp_put_char(output, '(');
}
static void
sexp_put_list_end(struct sexp_output *output)
{
sexp_put_char(output, ')');
}
static void
sexp_put_display_start(struct sexp_output *output)
{
sexp_put_char(output, '[');
}
static void
sexp_put_display_end(struct sexp_output *output)
{
sexp_put_char(output, ']');
}
static void static void
sexp_convert_string(struct sexp_input *input, enum sexp_mode mode_in, sexp_convert_string(struct sexp_input *input, enum sexp_mode mode_in,
...@@ -774,9 +746,6 @@ sexp_convert_string(struct sexp_input *input, enum sexp_mode mode_in, ...@@ -774,9 +746,6 @@ sexp_convert_string(struct sexp_input *input, enum sexp_mode mode_in,
} }
/* Parsing and conversion functions. */
static void static void
sexp_convert_list(struct sexp_input *input, enum sexp_mode mode_in, sexp_convert_list(struct sexp_input *input, enum sexp_mode mode_in,
struct sexp_output *output, enum sexp_mode mode_out, struct sexp_output *output, enum sexp_mode mode_out,
...@@ -808,25 +777,26 @@ sexp_convert_item(struct sexp_input *input, enum sexp_mode mode_in, ...@@ -808,25 +777,26 @@ sexp_convert_item(struct sexp_input *input, enum sexp_mode mode_in,
} }
else switch(input->token) else switch(input->token)
{ {
case SEXP_LIST_START:
sexp_convert_list(input, mode_in, output, mode_out, indent);
break;
case SEXP_LIST_END: case SEXP_LIST_END:
die("Unexpected end of list.\n"); die("Unmatched end of list.\n");
case SEXP_EOF: case SEXP_EOF:
die("Unexpected end of file.\n"); die("Unexpected end of file.\n");
case SEXP_CODING_END:
die("Unexpected end of coding.\n");
case SEXP_LIST_START:
sexp_convert_list(input, mode_in, output, mode_out, indent);
break;
case SEXP_STRING: case SEXP_STRING:
sexp_put_string(output, mode_out, &input->string); sexp_put_string(output, mode_out, &input->string);
break; break;
case SEXP_DISPLAY_START: case SEXP_DISPLAY_START:
sexp_put_display_start(output); sexp_put_char(output, '[');
sexp_convert_string(input, mode_in, output, mode_out); sexp_convert_string(input, mode_in, output, mode_out);
sexp_skip_token(input, mode_in, SEXP_DISPLAY_END); sexp_skip_token(input, mode_in, SEXP_DISPLAY_END);
sexp_put_display_end(output); sexp_put_char(output, ']');
sexp_convert_string(input, mode_in, output, mode_out); sexp_convert_string(input, mode_in, output, mode_out);
break; break;
...@@ -836,14 +806,11 @@ sexp_convert_item(struct sexp_input *input, enum sexp_mode mode_in, ...@@ -836,14 +806,11 @@ sexp_convert_item(struct sexp_input *input, enum sexp_mode mode_in,
else else
{ {
sexp_get_token(input, SEXP_CANONICAL); sexp_get_token(input, SEXP_CANONICAL);
sexp_convert_item(input, SEXP_CANONICAL, output, mode_out, indent); sexp_convert_item(input, SEXP_CANONICAL, output, mode_out, indent);
sexp_skip_token(input, SEXP_CANONICAL, SEXP_CODING_END); sexp_skip_token(input, SEXP_CANONICAL, SEXP_CODING_END);
break; break;
} }
case SEXP_CODING_END:
die("Unexpected end of coding.\n");
default: default:
die("Syntax error.\n"); die("Syntax error.\n");
...@@ -857,7 +824,7 @@ sexp_convert_list(struct sexp_input *input, enum sexp_mode mode_in, ...@@ -857,7 +824,7 @@ sexp_convert_list(struct sexp_input *input, enum sexp_mode mode_in,
{ {
unsigned item; unsigned item;
sexp_put_list_start(output); sexp_put_char(output, '(');
for (item = 0;; item++) for (item = 0;; item++)
{ {
...@@ -865,7 +832,7 @@ sexp_convert_list(struct sexp_input *input, enum sexp_mode mode_in, ...@@ -865,7 +832,7 @@ sexp_convert_list(struct sexp_input *input, enum sexp_mode mode_in,
if (input->token == SEXP_LIST_END) if (input->token == SEXP_LIST_END)
{ {
sexp_put_list_end(output); sexp_put_char(output, ')');
return; return;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment