Index: /trunk/Ohana/src/opihi/dvo/calextract.c
===================================================================
--- /trunk/Ohana/src/opihi/dvo/calextract.c	(revision 3688)
+++ /trunk/Ohana/src/opihi/dvo/calextract.c	(revision 3689)
@@ -94,4 +94,5 @@
     /* extract values, assign to vectors */
     for (i = 0; i < catalog.Naverage; i++) {
+      if (i && !(i % 10000)) { fprintf (stderr, ","); }
       m = catalog.average[i].offset;
 
@@ -125,6 +126,6 @@
       if (N == NSTAR) {
 	NSTAR += 100;
-	for (i = 0; i < NVEC; i++) {
-	  REALLOCATE (vec[i][0].elements, float, NSTAR);
+	for (j = 0; j < NVEC; j++) {
+	  REALLOCATE (vec[j][0].elements, float, NSTAR);
 	}
       }
Index: /trunk/Ohana/src/opihi/dvo/ddmags.c
===================================================================
--- /trunk/Ohana/src/opihi/dvo/ddmags.c	(revision 3688)
+++ /trunk/Ohana/src/opihi/dvo/ddmags.c	(revision 3689)
@@ -22,4 +22,7 @@
   catalog.measure = NULL;
 
+  /* find CATDIR in config system */
+  VarConfig ("CATDIR", "%s", catdir);
+
   /* load photcode information */
   if (!InitPhotcodes ()) goto escape;
@@ -30,6 +33,7 @@
   if (!GetGraphData (&graphsky, NULL, &Ngraph)) return (FALSE);
  
-  /* find CATDIR in config system */
-  VarConfig ("CATDIR", "%s", catdir);
+  /* find catalog files which overlap this region */
+  Radius = MAX (fabs(graphsky.xmax), fabs(graphsky.ymax));
+  regions = find_regions (graphsky.coords.crval1, graphsky.coords.crval2, Radius, &Nregions);
 
   /* interpret command-line options */
@@ -46,8 +50,4 @@
   if (!GetPhotcodeInfo (argv[7], &code[3], &mode[3])) return (FALSE);
   if ((mode[2] == MAG_AVE) || (mode[2] == MAG_REF)) UseAverages = TRUE;
-
-  /* find catalog files which overlap this region */
-  Radius = MAX (fabs(graphsky.xmax), fabs(graphsky.ymax));
-  regions = find_regions (graphsky.coords.crval1, graphsky.coords.crval2, Radius, &Nregions);
 
   /* init vectors to save data */
@@ -114,5 +114,4 @@
 usage:
   fprintf (stderr, "USAGE: ddmags F - F : measure.param\n");
-  return (FALSE);
 
 escape:
Index: /trunk/Ohana/src/opihi/lib.shell/variable.c
===================================================================
--- /trunk/Ohana/src/opihi/lib.shell/variable.c	(revision 3688)
+++ /trunk/Ohana/src/opihi/lib.shell/variable.c	(revision 3689)
@@ -121,5 +121,5 @@
     }
   }
-  return ((char *) NULL);
+  return (NULL);
 }
 
@@ -148,5 +148,5 @@
     }
   }
-  return ((char *) NULL);
+  return (NULL);
 }
 
@@ -168,5 +168,5 @@
   }
   free (local);
-  return ((char *) NULL);
+  return (NULL);
 }
 
Index: /trunk/Ohana/src/opihi/scripts/test.pro
===================================================================
--- /trunk/Ohana/src/opihi/scripts/test.pro	(revision 3688)
+++ /trunk/Ohana/src/opihi/scripts/test.pro	(revision 3689)
@@ -1,2 +1,39 @@
+
+macro testfit
+ create x 0 1000
+ set y = 3 + 5*x
+ set dy = 10*(rnd(x) - 0.5)
+ set yr = y + dy
+ fit x yr 1
+ echo $Cn, $Cnv
+ echo $dC
+
+ yr[100] = yr[100] + 50
+ yr[200] = yr[200] - 50
+ yr[300] = yr[300] + 100
+ yr[400] = yr[400] - 500
+ yr[500] = yr[500] + 30
+
+ fit x yr 1
+ echo $Cn, $Cnv
+ echo $dC
+
+ fit x yr 1 -clip 3 3
+ echo $Cn, $Cnv
+ echo $dC
+end
+# expected output:
+# y = 3.013781 x^0 5.000005 x^1
+#     0.063198     0.000110
+# 1, 1000
+# 2.91071543189
+# y = 2.495040 x^0 5.000303 x^1
+#     0.063198     0.000110
+# 1, 1000
+# 16.5928919554
+# y = 3.021974 x^0 4.999991 x^1
+#     0.063419     0.000110
+# 1, 995
+# 2.90820510001
 
 macro testloops
