From c8c3f1d496bfb24fdb712356fb61ab1dfadcca91 Mon Sep 17 00:00:00 2001
From: deuce <>
Date: Fri, 23 May 2003 20:47:18 +0000
Subject: [PATCH] Added K_DECIMAL mode flag for floating-point numbers.

---
 src/uifc/uifc.h   |  1 +
 src/uifc/uifc32.c | 10 ++++++++++
 2 files changed, 11 insertions(+)

diff --git a/src/uifc/uifc.h b/src/uifc/uifc.h
index eee68c93e7..3193fe5366 100644
--- a/src/uifc/uifc.h
+++ b/src/uifc/uifc.h
@@ -197,6 +197,7 @@
 #define K_ALPHA 	(1L<<10)	/* Only allow alphabetic characters 		*/
 #define K_SCANNING	(1L<<11)	/* UPC Scanner is active... return on '%'	*/
 #define K_TABEXIT	(1L<<12)	/* Return on TAB					    	*/
+#define K_DECIMAL	(1L<<13)	/* Allow floating point numbers only		*/
 
 #define HELPBUF_SIZE 4000
 
diff --git a/src/uifc/uifc32.c b/src/uifc/uifc32.c
index b1514833dc..1a74bf7f79 100644
--- a/src/uifc/uifc32.c
+++ b/src/uifc/uifc32.c
@@ -1247,6 +1247,7 @@ int ugetstr(int left, int top, char *outstr, int max, long mode, int *lastkey)
 	uchar   str[256],ins=0,buf[256],y;
 	int		ch;
 	int     i,j,k,f=0;	/* i=offset, j=length */
+	BOOL	gotdecimal=FALSE;
 
 	gotoxy(left,top);
 	cursor=_NORMALCURSOR;
@@ -1358,6 +1359,8 @@ int ugetstr(int left, int top, char *outstr, int max, long mode, int *lastkey)
 							gotoxy(wherex()-((j-i)+2),y);
 							i--;
 							j--;
+							if(str[i]=='.')
+								gotdecimal=FALSE;
 							for(k=i;k<j;k++)
 								str[k]=str[k+1]; 
 						}
@@ -1413,6 +1416,13 @@ int ugetstr(int left, int top, char *outstr, int max, long mode, int *lastkey)
 			}
 			if(mode&K_NUMBER && !isdigit(ch))
 				continue;
+			if(mode&K_DECIMAL && !isdigit(ch)) {
+				if(ch!='.')
+					continue;
+				if(gotdecimal)
+					continue;
+				gotdecimal=TRUE;
+			}
 			if(mode&K_ALPHA && !isalpha(ch))
 				continue;
 			if((ch>=SP || (ch==1 && mode&K_MSG)) && i<max && (!ins || j<max) && isprint(ch))
-- 
GitLab