]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
* examples/sexp-conv.c(sexp_put_list_start): Deleted function.
authorNiels Möller <nisse@lysator.liu.se>
Thu, 31 Oct 2002 18:38:57 +0000 (19:38 +0100)
committerNiels Möller <nisse@lysator.liu.se>
Thu, 31 Oct 2002 18:38:57 +0000 (19:38 +0100)
(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

examples/sexp-conv.c

index 200f115aec6a18431969cdd4af4e09c24f2f729b..a3484ee56a211f3549378244110d78ae3ef379cb 100644 (file)
@@ -581,13 +581,13 @@ sexp_put_char(struct sexp_output *output, uint8_t c)
       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);
@@ -603,14 +603,6 @@ sexp_put_data(struct sexp_output *output,
     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)
@@ -667,7 +659,8 @@ sexp_put_string(struct sexp_output *output, enum sexp_mode mode,
                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)
     {
@@ -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)
-{
-  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,
@@ -774,9 +746,6 @@ 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,
@@ -808,25 +777,26 @@ sexp_convert_item(struct sexp_input *input, enum sexp_mode mode_in,
     }
   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;
       
@@ -836,14 +806,11 @@ sexp_convert_item(struct sexp_input *input, enum sexp_mode mode_in,
       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");
@@ -857,7 +824,7 @@ sexp_convert_list(struct sexp_input *input, enum sexp_mode mode_in,
 {
   unsigned item;
 
-  sexp_put_list_start(output);
+  sexp_put_char(output, '(');
   
   for (item = 0;; item++)
     {
@@ -865,7 +832,7 @@ sexp_convert_list(struct sexp_input *input, enum sexp_mode mode_in,
 
       if (input->token == SEXP_LIST_END)
        {
-         sexp_put_list_end(output);
+         sexp_put_char(output, ')');
          return;
        }