Index: /trunk/Ohana/src/kapa2/src/DrawFrame.c
===================================================================
--- /trunk/Ohana/src/kapa2/src/DrawFrame.c	(revision 18425)
+++ /trunk/Ohana/src/kapa2/src/DrawFrame.c	(revision 18426)
@@ -23,4 +23,7 @@
     lweight = MAX (0, MIN (10, graph[0].axis[i].lweight));
     XSetLineAttributes (graphic->display, graphic->gc, lweight, LineSolid, CapNotLast, JoinMiter);
+    
+    graph[0].axis[i].color = MAX (0, MIN (15, graph[0].axis[i].color));
+
     XSetForeground (graphic->display, graphic->gc, graphic->color[graph[0].axis[i].color]);
     DrawRotTextInit (graphic->display, graphic->window, graphic->gc, graphic->color[graph[0].axis[i].color], graphic->back);
Index: /trunk/Ohana/src/kapa2/src/LoadFrame.c
===================================================================
--- /trunk/Ohana/src/kapa2/src/LoadFrame.c	(revision 18425)
+++ /trunk/Ohana/src/kapa2/src/LoadFrame.c	(revision 18426)
@@ -26,4 +26,5 @@
   
   KiiScanMessage (sock, "%lf %d", &lweight, &color);
+  color = MAX (0, MIN (15, color));
 
   KiiScanMessage (sock, "%s %s %s", Axis, Labels, Ticks);
Index: /trunk/Ohana/src/opihi/cmd.basic/substr.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/substr.c	(revision 18425)
+++ /trunk/Ohana/src/opihi/cmd.basic/substr.c	(revision 18426)
@@ -13,4 +13,14 @@
   N1 = atof (argv[2]);
   N2 = atof (argv[3]);
+
+  // add a range check here
+  if ((N1 < 0) || (N1 >=  strlen(argv[1]))) {
+      gprint (GP_ERR, "ERROR: N1 out of range\n");
+      return (FALSE);
+  }
+  if ((N2 < 0) || (N2 >=  strlen(argv[1])) || (N2 < N1)) {
+      gprint (GP_ERR, "ERROR: N2 out of range\n");
+      return (FALSE);
+  }
 
   len = strlen (argv[1]);
Index: /trunk/Ohana/src/opihi/dvo/gstar.c
===================================================================
--- /trunk/Ohana/src/opihi/dvo/gstar.c	(revision 18425)
+++ /trunk/Ohana/src/opihi/dvo/gstar.c	(revision 18426)
@@ -204,6 +204,8 @@
 	    gprint (GP_LOG, "%2d ",    catalog.measure[m].dophot);
 	    gprint (GP_LOG, "%3x ",    catalog.measure[m].dbFlags);
-	    gprint (GP_LOG, "%3d ",    catalog.measure[m].photcode);
+	    gprint (GP_LOG, "%5d ",    catalog.measure[m].photcode);
 	    gprint (GP_LOG, "%-20s  ", GetPhotcodeNamebyCode (catalog.measure[m].photcode));
+	    gprint (GP_LOG, "%5.2f ",  0.01*catalog.measure[m].FWx);
+	    gprint (GP_LOG, "%5.2f ",  0.01*catalog.measure[m].FWy);
 
 	    if (FULL_OUTPUT) {
Index: /trunk/Ohana/src/opihi/lib.shell/gprint.c
===================================================================
--- /trunk/Ohana/src/opihi/lib.shell/gprint.c	(revision 18425)
+++ /trunk/Ohana/src/opihi/lib.shell/gprint.c	(revision 18426)
@@ -134,5 +134,5 @@
   }
 
-  // check the special cases 
+  // check the special cases (do not close old file in these cases)
   if (stream[0].file == stdout) {
     stream[0].file = file;
@@ -243,9 +243,9 @@
   // we allow the user to set stdout to ERR and stderr to LOG if they want
   if (!strcmp (stream[0].name, "stdout")) {
-    stream[0].file = stdout;
+    gprintCloseFile (stream, stdout);
     return;
   }
   if (!strcmp (stream[0].name, "stderr")) {
-    stream[0].file = stderr;
+    gprintCloseFile (stream, stderr);
     return;
   }
@@ -254,8 +254,10 @@
   file = fopen (stream[0].name, "a");
   if (file == NULL) {
+    // XXX this is a problem: we are leaving open the old file
     fprintf (stderr, "cannot open file %s\n", stream[0].name);
     free (stream[0].name);
-    stream[0].file = (dest == GP_LOG) ? stdout : stderr;
+    file = (dest == GP_LOG) ? stdout : stderr;
     stream[0].name = (dest == GP_LOG) ? strcreate ("stdout") : strcreate("stderr");
+    gprintCloseFile (stream, file);
     return;
   }
