8b23145
--- xfig.3.2.5/w_util.c	2007-01-16 18:58:18.000000000 +0100
8b23145
+++ xfig.3.2.5.wip/w_util.c	2009-03-15 13:31:47.000000000 +0100
8b23145
@@ -932,21 +932,23 @@
8b23145
     DeclareArgs(4);
8b23145
     spin_struct *spins = (spin_struct*) info;
8b23145
     char	buf[200];
8b23145
-    int		val, i, pos;
8b23145
+    int		val, i, modified = 0;
8b23145
+    XawTextPosition pos;
8b23145
 
8b23145
     /* save cursor position */
8b23145
     FirstArg(XtNinsertPosition, &pos;;
8b23145
     GetValues(spins->widget);
8b23145
 
8b23145
-    buf[sizeof(buf)-1]='\0';
8b23145
-    strncpy(buf,panel_get_value(spins->widget),sizeof(buf));
8b23145
+    snprintf(buf, sizeof(buf), "%s", panel_get_value(spins->widget));
8b23145
+
8b23145
     for (i=0; i
8b23145
 	/* delete any non-digits (including leading "-" when min >= 0 */
8b23145
 	if ((spins->min >= 0.0 && buf[i] == '-') || ((buf[i] < '0' || buf[i] > '9') && buf[i] != '-') || 
8b23145
 			(i != 0 && buf[i] == '-')) {
8b23145
-	    strcpy(&buf[i],&buf[i+1]);
8b23145
+	    memmove(&buf[i], &buf[i+1], strlen(&buf[i]));
8b23145
 	    /* adjust cursor for char we just removed */
8b23145
 	    pos--;
8b23145
+	    modified = 1;
8b23145
 	} else {
8b23145
 	    i++;
8b23145
 	}
8b23145
@@ -954,15 +956,21 @@
8b23145
     if (strlen(buf) > 0 && !(strlen(buf)==1 && buf[0] == '-')) {
8b23145
 	val = atoi(buf);
8b23145
 	/* only check max.  If min is, say 3 and user wants to type 10, the 1 is too small */
8b23145
-	if (val > (int) spins->max)
8b23145
+	if (val > (int) spins->max) {
8b23145
 	    val = (int) spins->max;
8b23145
-	sprintf(buf,"%d", val);
8b23145
+	    sprintf(buf,"%d", val);
8b23145
+	    modified = 1;
8b23145
+        }
8b23145
     }
8b23145
-    panel_set_value(spins->widget, buf);
8b23145
-    /* put cursor back */
8b23145
-    if (pos < strlen(buf)) {
8b23145
-	FirstArg(XtNinsertPosition, pos+1);
8b23145
-	SetValues(spins->widget);
8b23145
+
8b23145
+    if (modified) {
8b23145
+        panel_set_value(spins->widget, buf);
8b23145
+
8b23145
+	/* put cursor back */
8b23145
+	if (pos < strlen(buf)) {
8b23145
+	    FirstArg(XtNinsertPosition, (pos+1));
8b23145
+	    SetValues(spins->widget);
8b23145
+	}
8b23145
     }
8b23145
 }
8b23145