From 96f5891b5d2c3acc9f1c77eb26a51f004217b220 Mon Sep 17 00:00:00 2001 From: Linas Vepstas Date: Tue, 2 Dec 1997 08:16:49 +0000 Subject: [PATCH] fix quickfill core dump git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@243 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/RegWindow.c | 59 +++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/src/RegWindow.c b/src/RegWindow.c index 1690fdb7bb..03c33f28cb 100644 --- a/src/RegWindow.c +++ b/src/RegWindow.c @@ -2767,38 +2767,39 @@ regCB( Widget mw, XtPointer cd, XtPointer cb ) regData->qf = getQuickFill( regData->qf, mvcbs->prev_text[i] ); } - /* hack alert -- text pointer not valid if non-alpha key hit */ - /* this will core dump, since ptr is NULL */ - /* this is not fixed, since the fix is not obvious to me ... */ - input = (mvcbs->verify->text->ptr)[0]; + /* ptr will be NULL if the delete key or other + * non-alphanumeric key hit */ + if (mvcbs->verify->text->ptr) { + input = (mvcbs->verify->text->ptr)[0]; - /* go to qf's child node that corresponds to the - * last character inputed by the user */ - regData->qf = getQuickFill( regData->qf, input ); - - if( (regData->qf != NULL) && (regData->qf->trans != NULL) ) - { - /* char *str = regData->qf->trans->description; */ - char str[BUFSIZE]; - strcpy( str, regData->qf->trans->description ); - DEBUG(str); + /* go to qf's child node that corresponds to the + * last character inputed by the user */ + regData->qf = getQuickFill( regData->qf, input ); - mvcbs->verify->doit = False; + if( (regData->qf != NULL) && (regData->qf->trans != NULL) ) + { + /* char *str = regData->qf->trans->description; */ + char str[BUFSIZE]; + strcpy( str, regData->qf->trans->description ); + DEBUG(str); + + mvcbs->verify->doit = False; + + XbaeMatrixSetCell( mw, row, col, str ); + XbaeMatrixRefreshCell( mw, row, col ); + XbaeMatrixSetCursorPosition( mw, regData->insert+1 ); + } + else + { + char str[BUFSIZE]; + strncpy( str, mvcbs->prev_text, regData->insert ); + /* Need to make sure the string is terminated: */ + str[regData->insert] = '\0'; - XbaeMatrixSetCell( mw, row, col, str ); - XbaeMatrixRefreshCell( mw, row, col ); - XbaeMatrixSetCursorPosition( mw, regData->insert+1 ); - } - else - { - char str[BUFSIZE]; - strncpy( str, mvcbs->prev_text, regData->insert ); - /* Need to make sure the string is terminated: */ - str[regData->insert] = '\0'; - - XbaeMatrixSetCell( mw, row, col, str ); - XbaeMatrixRefreshCell( mw, row, col ); - XbaeMatrixSetCursorPosition( mw, regData->insert ); + XbaeMatrixSetCell( mw, row, col, str ); + XbaeMatrixRefreshCell( mw, row, col ); + XbaeMatrixSetCursorPosition( mw, regData->insert ); + } } } #endif