print_ctxt.c 857 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include "config.h"
  2. #include "debug.h"
  3. #include "print.h"
  4. #include "stdlib.h"
  5. #include "print_ctxt.h"
  6. /**
  7. * @brief Set all unset values in CTXT to defaults.
  8. */
  9. void print_ctxt_set_defaults (print_ctxt *ctxt);
  10. print_ctxt *
  11. print_ctxt_create_empty (void)
  12. {
  13. print_ctxt *ctxt = calloc (1, sizeof (print_ctxt));
  14. return ctxt;
  15. }
  16. void
  17. print_ctxt_init (print_ctxt *ctxt)
  18. {
  19. ctxt->depth = 0;
  20. ctxt->rmargin = 0;
  21. ctxt->tab_width = 0;
  22. ctxt->use_tabs = 0;
  23. ctxt->print_state = print_merged;
  24. ctxt->nested_conflicts = no_conflict;
  25. ctxt->structure_conflict = no_conflict;
  26. ctxt->content_conflict = no_conflict;
  27. ctxt->conflict_occurred = false;
  28. return;
  29. }
  30. void
  31. print_ctxt_set_defaults (print_ctxt *ctxt)
  32. {
  33. if (ctxt->rmargin == 0)
  34. {
  35. ctxt->rmargin = 77;
  36. }
  37. if (ctxt->tab_width == 0)
  38. {
  39. ctxt->tab_width = 8;
  40. }
  41. return;
  42. }