string_merge.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. * @file string_merge.h
  3. * @brief Provide utilities for merging strings of text
  4. */
  5. /*
  6. * This program is free software: you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation, either vers* ion 3 of
  9. * the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see
  18. * <http://www.gnu.org/licenses/>.
  19. */
  20. #ifndef STRING_MERGE_H
  21. #define STRING_MERGE_H
  22. /* count the number of lines in a string */
  23. size_t count_lines (char *string, size_t length);
  24. /* fill an array of offsets with the start of all lines in a sting.
  25. * The first element will be 0 and the last element will be the length of
  26. * the array. Thi array must be (numer of lines + 1)
  27. */
  28. void index_lines (size_t array[], char* string, size_t length);
  29. /* merge two substrins */
  30. void substr_print_merge (substr loc_text, substr rem_text,
  31. print_ctxt *ctxt, doc_stream *out);
  32. /* merge two strings, printing the conflicted result to a doc_stream */
  33. void line_diff (char *loc_s, size_t loc_len, char *rem_s, size_t rem_len,
  34. print_ctxt *ctxt, doc_stream *out);
  35. typedef enum mapped_state
  36. {
  37. mapped = 0,
  38. unmapped = 1
  39. } mapped_state;
  40. /* calculate the if elements are mapped or not, and store the result
  41. * in state. states must be initialized to 0 (false)
  42. */
  43. void
  44. string_index_compareseq (char *loc_string, size_t loc_count,
  45. size_t *loc_indices, bool *loc_state,
  46. char *rem_string, size_t rem_count,
  47. size_t *rem_indices, bool *rem_state);
  48. #endif /* STRING_MERGE_H */