fix quickfill core dump

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@243 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 1997-12-02 08:16:49 +00:00
parent 3b37a3cc38
commit 96f5891b5d

View File

@ -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