rem: char *save;
add: char *save=NULL;
context: insertTextInteractively(Text *tPtr, char *text, int len){    TextBlock *tb;    char *newline = NULL;    if (!tPtr->flags.editable) {        return;    }    if (len < 1 || !text)        return;    if(tPtr->flags.ignoreNewLine && *text == '\n' && len == 1)        return;    if (tPtr->flags.ownsSelection)        removeSelection(tPtr);    if (tPtr->flags.ignoreNewLine) {        int i;        for(i=0; i<len; i++) {            if (text[i] == '\n')                text[i] = ' ';        }    }    tb = tPtr->currentTextBlock;    if (!tb || tb->graphic) {        tPtr->tpos = 0;        WMAppendTextStream(tPtr, text);        layOutDocument(tPtr);        return;    }    if ((newline = strchr(text, '\n'))) {        int nlen = (int)(newline-text);        int s = tb->used - tPtr->tpos;        if (!tb->blank && nlen>0) {            char *save;            if (s > 0) {                save = wmalloc(s);                memcpy(save, &tb->text[tPtr->tpos], s);                tb->used -= (tb->used - tPtr->tpos);            }            insertTextInteractively(tPtr, text, nlen);            newline++;            WMAppendTextStream(tPtr, newline);            if (s>0) {                insertTextInteractively(tPtr, save, s);                wfree(save);            }        } else {            if (tPtr->tpos>0 && tPtr->tpos < tb->used                && !tb->graphic && tb->text) {                unsigned short savePos = tPtr->tpos;                void *ntb = WMCreateTextBlockWithText(                    tPtr, &tb->text[tPtr->tpos],                    tb->d.font, tb->color, True, tb->used - tPtr->tpos);                if(tb->sections[0].end == tPtr->tpos)                    WMAppendTextBlock(tPtr, WMCreateTextBlockWithText(tPtr,                        NULL, tb->d.font, tb->color, True, 0));                tb->used = savePos;                WMAppendTextBlock(tPtr, ntb);                tPtr->tpos = 0;            } else if (tPtr->tpos == tb->used) {                if(tPtr->flags.indentNewLine) {                    WMAppendTextBlock(tPtr, WMCreateTextBlockWithText(tPtr,                        "    ", tb->d.font, tb->color, True, 4));                    tPtr->tpos = 4;                } else {                    WMAppendTextBlock(tPtr, WMCreateTextBlockWithText(tPtr,                        NULL, tb->d.font, tb->color, True, 0));                    tPtr->tpos = 0;                }           } else if (tPtr->tpos == 0) {                if(tPtr->flags.indentNewLine) {                    WMPrependTextBlock(tPtr, WMCreateTextBlockWithText(tPtr,                        "    ", tb->d.font, tb->color, True, 4));                } else {                    WMPrependTextBlock(tPtr, WMCreateTextBlockWithText(tPtr,                        NULL, tb->d.font, tb->color, True, 0));                }                tPtr->tpos = 0;                if(tPtr->currentTextBlock->next)                    tPtr->currentTextBlock = tPtr->currentTextBlock->next;            }        }    } else {        if (tb->used + len >= tb->allocated) {            tb->allocated = reqBlockSize(tb->used+len);            tb->text = wrealloc(tb->text, tb->allocated);        }        if (tb->blank) {            memcpy(tb->text, text, len);            tb->used = len;            tPtr->tpos = len;            tb->text[tb->used] = 0;            tb->blank = False;        } else {            memmove(&(tb->text[tPtr->tpos+len]), &tb->text[tPtr->tpos],                tb->used-tPtr->tpos+1);            memmove(&tb->text[tPtr->tpos], text, len);            tb->used += len;            tPtr->tpos += len;            tb->text[tb->used] = 0;        }    }    layOutDocument(tPtr);}