mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
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:
parent
2a80846917
commit
f1a28a5528
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/* ================================================ */
|
||||
|
Loading…
Reference in New Issue
Block a user