assert(done <= sizeof(encoded));
for (i = 0; i<done; i++)
- {
- if (output->pos > LINE_WIDTH
- && output->pos > (output->coding_indent + 10))
- sexp_put_newline(output, output->coding_indent);
-
- sexp_put_raw_char(output, encoded[i]);
- }
+ {
+ if (output->pos > LINE_WIDTH
+ && output->pos > (output->coding_indent + 10))
+ sexp_put_newline(output, output->coding_indent);
+
+ sexp_put_raw_char(output, encoded[i]);
+ }
}
else
sexp_put_raw_char(output, c);
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
sexp_put_length(struct sexp_output *output,
unsigned length)
struct nettle_buffer *string)
{
if (!string->size)
- sexp_puts(output, (mode == SEXP_ADVANCED) ? "\"\"": "0:");
+ sexp_put_data(output, 2,
+ (mode == SEXP_ADVANCED) ? "\"\"": "0:");
else if (mode == SEXP_ADVANCED)
{
}
}
-static void
-sexp_put_list_start(struct sexp_output *output)
-{
- 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, ']');
-}
+\f
+/* Parsing and conversion functions. */
static void
sexp_convert_string(struct sexp_input *input, enum sexp_mode mode_in,
}
-\f
-/* Parsing and conversion functions. */
-
static void
sexp_convert_list(struct sexp_input *input, enum sexp_mode mode_in,
struct sexp_output *output, enum sexp_mode mode_out,
}
else switch(input->token)
{
- case SEXP_LIST_START:
- sexp_convert_list(input, mode_in, output, mode_out, indent);
- break;
-
case SEXP_LIST_END:
- die("Unexpected end of list.\n");
-
+ die("Unmatched end of list.\n");
case SEXP_EOF:
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:
sexp_put_string(output, mode_out, &input->string);
break;
case SEXP_DISPLAY_START:
- sexp_put_display_start(output);
+ sexp_put_char(output, '[');
sexp_convert_string(input, mode_in, output, mode_out);
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);
break;
else
{
sexp_get_token(input, SEXP_CANONICAL);
-
sexp_convert_item(input, SEXP_CANONICAL, output, mode_out, indent);
sexp_skip_token(input, SEXP_CANONICAL, SEXP_CODING_END);
break;
}
- case SEXP_CODING_END:
- die("Unexpected end of coding.\n");
default:
die("Syntax error.\n");
{
unsigned item;
- sexp_put_list_start(output);
+ sexp_put_char(output, '(');
for (item = 0;; item++)
{
if (input->token == SEXP_LIST_END)
{
- sexp_put_list_end(output);
+ sexp_put_char(output, ')');
return;
}