aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2013-08-18 15:17:10 +0200
committerThomas White <taw@bitwiz.org.uk>2013-08-18 15:17:10 +0200
commit2482923ebcecf00be8cf35fda53c2195c04fde97 (patch)
tree287c682d9f259d5fa6ee55cb7d02903dbc78a0d1
parent0894ace4ab8b8571ee0544cc7bb3e4607ae20c63 (diff)
Fix string handling bugs
-rw-r--r--src/mainwindow.c2
-rw-r--r--src/storycode.c7
2 files changed, 7 insertions, 2 deletions
diff --git a/src/mainwindow.c b/src/mainwindow.c
index 2dd3f0f..95df042 100644
--- a/src/mainwindow.c
+++ b/src/mainwindow.c
@@ -981,7 +981,7 @@ static void do_backspace(struct frame *fr, struct presentation *p)
if ( fr->pos == 0 ) return;
- olen = strlen(fr->sc);
+ olen = strlen(fr->sc) - fr->pos + 1;
tlen = 1; /* FIXME: Length of character before cursor */
memmove(fr->sc+fr->pos-tlen, fr->sc+fr->pos, olen);
diff --git a/src/storycode.c b/src/storycode.c
index b78f946..66bed60 100644
--- a/src/storycode.c
+++ b/src/storycode.c
@@ -329,7 +329,12 @@ SCBlockList *sc_find_blocks(const char *sc, const char *blockname)
} while ( i<len );
- if ( (blockname == NULL) && (j > 1) ) {
+ /* Add final block, if it exists */
+ if ( (blockname == NULL) && (j > 0) ) {
+
+ /* Leftover buffer is empty? */
+ if ( (j==1) && (tbuf[0]=='\0') ) return bl;
+
tbuf[j] = '\0';
if ( sc_block_list_add(bl, start, NULL, NULL, tbuf) )
{