[gq-commit] gq/src dt_int.c,1.1,1.2
Status: Beta
Brought to you by:
sur5r
|
From: <sta...@us...> - 2003-10-22 00:15:22
|
Update of /cvsroot/gqclient/gq/src
In directory sc8-pr-cvs1:/tmp/cvs-serv17392
Modified Files:
dt_int.c
Log Message:
* Make dt_int work for negative numbers
Index: dt_int.c
===================================================================
RCS file: /cvsroot/gqclient/gq/src/dt_int.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** dt_int.c 21 Oct 2003 04:46:41 -0000 1.1
--- dt_int.c 21 Oct 2003 20:53:42 -0000 1.2
***************
*** 82,95 ****
{
char *txt = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1);
! gunichar c;
if (txt) {
- GString *s = g_string_sized_new(strlen(txt));
- int nope = 0;
char *t;
! /* allow only digits, no leading zeroes */
for(t = txt, c = g_utf8_get_char(t) ;
c ;
t = g_utf8_next_char(t), c = g_utf8_get_char(t)) {
--- 82,108 ----
{
char *txt = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1);
! gunichar c = 0;
if (txt) {
char *t;
+ GString *s = g_string_sized_new(strlen(txt));
+ int nope = 0;
! /* strip leading whitespace */
for(t = txt, c = g_utf8_get_char(t) ;
+ g_unichar_isspace(c) ;
+ t = g_utf8_next_char(t), c = g_utf8_get_char(t)) {
+ }
+
+ /* one leading minus is OK */
+ if (c == g_utf8_get_char("-")) {
+ g_string_append_unichar(s, c);
+ t = g_utf8_next_char(t);
+ c = g_utf8_get_char(t);
+ }
+
+ /* allow only digits, no leading zeroes */
+ for(c = g_utf8_get_char(t) ;
c ;
t = g_utf8_next_char(t), c = g_utf8_get_char(t)) {
|