print_ctxt.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /**
  2. * @flie print_ctxt.c
  3. */
  4. /*
  5. * This program is free software: you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation, either vers* ion 3 of
  8. * the License, or (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see
  17. * <http://www.gnu.org/licenses/>.
  18. */
  19. #include "config.h"
  20. #include "debug.h"
  21. #include "print.h"
  22. #include "stdlib.h"
  23. #include "print_ctxt.h"
  24. /**
  25. * @brief Set all unset values in CTXT to defaults.
  26. */
  27. void print_ctxt_set_defaults (print_ctxt *ctxt);
  28. print_ctxt *
  29. print_ctxt_create_empty (void)
  30. {
  31. print_ctxt *ctxt = calloc (1, sizeof (print_ctxt));
  32. return ctxt;
  33. }
  34. void
  35. print_ctxt_init (print_ctxt *ctxt)
  36. {
  37. ctxt->depth = 0;
  38. ctxt->current_level = 0;
  39. ctxt->rmargin = 0;
  40. ctxt->tab_width = 0;
  41. ctxt->use_tabs = 0;
  42. ctxt->print_state = print_merged;
  43. ctxt->nested_conflicts = no_conflict;
  44. ctxt->structure_conflict = no_conflict;
  45. ctxt->content_conflict = no_conflict;
  46. ctxt->movement_conflict = no_conflict;
  47. ctxt->conflict_occurred = false;
  48. return;
  49. }
  50. void
  51. print_ctxt_set_defaults (print_ctxt *ctxt)
  52. {
  53. if (ctxt->rmargin == 0)
  54. {
  55. ctxt->rmargin = 77;
  56. }
  57. if (ctxt->tab_width == 0)
  58. {
  59. ctxt->tab_width = 8;
  60. }
  61. return;
  62. }