diff options
author | Thomas White <taw@bitwiz.org.uk> | 2016-09-13 10:33:53 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2016-09-13 10:33:53 +0200 |
commit | bfea1928198dc7afd42cca5e3e7b4028325dfdff (patch) | |
tree | fb9817acce9b947d08908ade9f018b004407260b /src/sc_parse.c | |
parent | 49bdd47afa1c174c751532dc8a5f01dd8d27914e (diff) |
Fix text deletion
Offsets are all bytes, now.
Diffstat (limited to 'src/sc_parse.c')
-rw-r--r-- | src/sc_parse.c | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/src/sc_parse.c b/src/sc_parse.c index 4329337..ed2785a 100644 --- a/src/sc_parse.c +++ b/src/sc_parse.c @@ -643,52 +643,6 @@ void scblock_delete_text(SCBlock *b, size_t o1, size_t o2) } -static void delete_from_block(SCBlock *b, int o1, int o2) -{ - if ( o1 == o2 ) return; /* nothing to delete */ - assert(o2 > o1); - char *p1 = g_utf8_offset_to_pointer(b->contents, o1); - char *p2 = g_utf8_offset_to_pointer(b->contents, o2); - memmove(p1, p2, strlen(p2)+1); -} - - -static void delete_to_end(SCBlock *b, int offs) -{ - char *p = g_utf8_offset_to_pointer(b->contents, offs); - p[0] = '\0'; -} - - -static void delete_from_start(SCBlock *b, int offs) -{ - char *p = g_utf8_offset_to_pointer(b->contents, offs); - memmove(b->contents, p, strlen(p)+1); -} - - -/* Character offsets */ -void sc_delete_text(SCBlock *b1, int o1, SCBlock *b2, int o2) -{ - if ( b1 == b2 ) { - delete_from_block(b1, o1, o2); - } else if ( b2 == b1->next ) { - delete_to_end(b1, o1); - delete_from_start(b2, o2); - } else { - delete_to_end(b1, o1); - delete_from_start(b2, o2); - b1->next = b2; - SCBlock *de = b1->next; - while ( de != b2 ) { - SCBlock *denext = de->next; - sc_block_free(de); - de = denext; - } - } -} - - /* Create a deep copy of "bl", including all its children */ SCBlock *sc_block_copy(const SCBlock *bl) { |