implementation of basic price function

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@407 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 1998-01-11 06:38:02 +00:00
parent 2a80846917
commit f1a28a5528

View File

@ -4,11 +4,34 @@
#include "price.h"
#include "single.h"
#define DECIMAL_PT '.'
/* ================================================ */
/* This callback only allows numbers with a single
* decimal point in them */
static const char *
PriceMV (const char * old, const char *change, const char *new)
{
printf (" price mv called old:%s change:%s new:%s \n", old, change, new);
return new;
if (change) {
/* if change is a decimal point, then count decimal points */
if (DECIMAL_PT == change[0]) {
int i, count=0;
for (i=0; 0 != new[i]; i++) {
if (DECIMAL_PT == new[i]) count ++;
}
if (1 >= count) return new;
return NULL;
} else {
/* accept numeric, reject non-alpha edits */
if (isdigit (change[0])) return new;
return NULL;
}
} else {
/* accept the new string if user action was delete, etc. */
return new;
}
}
/* ================================================ */