string_merge.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /**
  2. * @file string_merge.h
  3. */
  4. #ifndef STRING_MERGE_H
  5. #define STRING_MERGE_H
  6. /* count the number of lines in a string */
  7. size_t count_lines (char *string, size_t length);
  8. /* fill an array of offsets with the start of all lines in a sting.
  9. * The first element will be 0 and the last element will be the length of
  10. * the array. Thi array must be (numer of lines + 1)
  11. */
  12. void index_lines (size_t array[], char* string, size_t length);
  13. /* merge two substrins */
  14. void substr_print_merge (substr loc_text, substr rem_text,
  15. print_ctxt *ctxt, doc_stream *out);
  16. /* merge two strings, printing the conflicted result to a doc_stream */
  17. void line_diff (char *loc_s, size_t loc_len, char *rem_s, size_t rem_len,
  18. print_ctxt *ctxt, doc_stream *out);
  19. typedef enum mapped_state
  20. {
  21. mapped = 0,
  22. unmapped = 1
  23. } mapped_state;
  24. /* calculate the if elements are mapped or not, and store the result
  25. * in state. states must be initialized to 0 (false)
  26. */
  27. void
  28. string_index_compareseq (char *loc_string, size_t loc_count,
  29. size_t *loc_indices, bool *loc_state,
  30. char *rem_string, size_t rem_count,
  31. size_t *rem_indices, bool *rem_state);
  32. #endif /* STRING_MERGE_H */