Browse Source

Move out print_ctxt to it's own source

Andrew Young 7 years ago
parent
commit
9a53ce922f
2 changed files with 5 additions and 42 deletions
  1. 1 17
      src/print.c
  2. 4 25
      src/print.h

+ 1 - 17
src/print.c

@@ -1,28 +1,12 @@
 #include <stdlib.h>
 #include "doc_stream.h"
+#include "print_ctxt.h"
 #include "print.h"
 
 static const char *start_mark  = ">>> ";
 static const char *middle_mark = "=== ";
 static const char *end_mark    = "<<< ";
 
-print_ctxt*
-print_ctxt_create_empty (void)
-{
-  print_ctxt *ctxt = malloc (sizeof (print_ctxt));
-  print_ctxt_init (ctxt);
-  return ctxt;
-}
-
-void
-print_ctxt_init (print_ctxt *ctxt)
-{
-  ctxt->depth = 0;
-  ctxt->print_state = print_merged;
-  ctxt->structure_conflict = no_conflict;
-  ctxt->content_conflict = no_conflict;
-}
-
 void
 enter_structural_conflict (print_ctxt *ctxt, conflict_state state,
 			   char* msg, doc_stream *out)

+ 4 - 25
src/print.h

@@ -5,10 +5,11 @@
 
 #ifndef PRINT_H
 #define PRINT_H
-
-#include <stdbool.h>
 #include "doc_stream.h"
 
+struct print_ctxt;
+typedef struct print_ctxt print_ctxt;
+
 /**
  * @todo Find a way to deal with advancing the print mode with the
  * conflict markers
@@ -38,34 +39,12 @@ typedef enum conflict_state
     remote_side = 2
   } conflict_state;
 
-/**
- * @brief A context for printing doc_elt's in a tree.
- */
-typedef struct print_ctxt
-{
-  int            depth;              /*< The current depth in a document tree */
-  print_state    print_state;        /*< the current printing mode            */
-  bool           nested_conflicts;   /*< if there are netsed conflicts        */
-  conflict_state structure_conflict; /*< the current state of conflicts       */
-  conflict_state content_conflict;   /*< the current state of conflicts       */
-} print_ctxt;
-
-/**
- * @brief create and initialize a print context
- */
-print_ctxt* print_ctxt_create_empty (void);
-
-/**
- * @brief initialize a print_ctxt
- */
-void print_ctxt_init (print_ctxt *ctxt);
-
 /**
  * @brief enter a certain part of a structural conflict.
  *
  * This function enters a structural conflict.  If it is already in
  * the correct state, it will do nothing.  It will wrap up any content
- * conflicts before switching.
+ * conflicts before switching
  */
 void enter_structural_conflict (print_ctxt *ctxt, conflict_state state,
 				char* msg, doc_stream *out);