IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 14, 2011, 1:05:28 PM (15 years ago)
Author:
watersc1
Message:

Merge of trunk back into branch.

Location:
branches/czw_branch/20101203
Files:
29 edited
3 copied

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/20101203

  • branches/czw_branch/20101203/Ohana/src/opihi/cmd.astro/cgrid.c

    r29001 r30631  
    9898
    9999  if (argc != 1) {
    100     gprint (GP_ERR, "USAGE: cgrid [style]\n");
     100    gprint (GP_ERR, "USAGE: cgrid [style] [-ra-by-hour] [-labels]\n");
    101101    return (FALSE);
    102102  }
  • branches/czw_branch/20101203/Ohana/src/opihi/cmd.astro/region.c

    r30118 r30631  
    1818  FREE (name);
    1919
     20  NoClear = FALSE;
     21  if ((N = get_argument (argc, argv, "-no-clear"))) {
     22    remove_argument (N, &argc, argv);
     23    NoClear = TRUE;
     24  }
     25
    2026  if ((N = get_argument (argc, argv, "-image"))) {
    2127    remove_argument (N, &argc, argv);
    2228    KapaGetImageCoords (kapa, &graphmode.coords);
    2329    KapaGetImageRange (kapa, &graphmode.xmin, &graphmode.xmax, &graphmode.ymax, &graphmode.ymin);
     30
     31    set_variable ("XMIN", graphmode.xmin);
     32    set_variable ("XMAX", graphmode.xmax);
     33    set_variable ("YMIN", graphmode.ymin);
     34    set_variable ("YMAX", graphmode.ymax);
     35
     36    set_variable ("RMIN", Ra  + graphmode.xmin);
     37    set_variable ("RMAX", Ra  + graphmode.xmax);
     38    set_variable ("DMIN", Dec + graphmode.ymin);
     39    set_variable ("DMAX", Dec + graphmode.ymax);
     40
     41    // if (!NoClear) KapaClearSections (kapa);
     42    KapaSetLimits (kapa, &graphmode);
     43
    2444    SetGraph (&graphmode);
    2545    return (TRUE);
     
    4565    remove_argument (N, &argc, argv);
    4666    graphmode.flipnorth = FALSE;
    47   }
    48 
    49   NoClear = FALSE;
    50   if ((N = get_argument (argc, argv, "-no-clear"))) {
    51     remove_argument (N, &argc, argv);
    52     NoClear = TRUE;
    5367  }
    5468
  • branches/czw_branch/20101203/Ohana/src/opihi/cmd.data/limits.c

    r29540 r30631  
    2626
    2727  // XXX need an option to set the limits based on the current image bounds
     28  if ((N = get_argument (argc, argv, "-image"))) {
     29    remove_argument (N, &argc, argv);
     30    KapaGetImageRange (kapa, &graphmode.xmin, &graphmode.xmax, &graphmode.ymax, &graphmode.ymin);
     31
     32    set_variable ("XMIN", graphmode.xmin);
     33    set_variable ("XMAX", graphmode.xmax);
     34    set_variable ("YMIN", graphmode.ymin);
     35    set_variable ("YMAX", graphmode.ymax);
     36
     37    // if (!NoClear) KapaClearSections (kapa);
     38    SetGraph (&graphmode);
     39    KapaSetLimits (kapa, &graphmode);
     40    return (TRUE);
     41    // Set Region based on image
     42  }
    2843
    2944  if (argc == 1) {
  • branches/czw_branch/20101203/Ohana/src/opihi/cmd.data/match2d.c

    r27817 r30631  
    11# include "data.h"
     2
    23int find_matches2d (Vector *X1, Vector *Y1, Vector *X2, Vector *Y2, double Radius, Vector *index1, Vector *index2);
     4int find_matches2d_closest (Vector *X1, Vector *Y1, Vector *X2, Vector *Y2, double Radius, Vector *index);
    35
    46// match2d (X1) (Y1) (X2) (Y2) (Radius) [-index1 (index1)] [-index2 (index2)] [-nomatch1 nomatch1] [-nomatch2 nomatch2]
     
    68int match2d (int argc, char **argv) {
    79 
    8   int N;
     10  int N, CLOSEST;
    911  double Radius;
    1012  char *endptr;
     
    1214  Vector *index1, *index2;
    1315
     16  CLOSEST = FALSE;
     17  if ((N = get_argument (argc, argv, "-closest"))) {
     18    remove_argument (N, &argc, argv);
     19    CLOSEST = TRUE;
     20  }
     21
    1422  if ((N = get_argument (argc, argv, "-index1"))) {
    1523    remove_argument (N, &argc, argv);
     
    3038  if (argc != 6) {
    3139    gprint (GP_ERR, "USAGE: match2d X1 Y1 X2 Y2 Radius [-index1 (index1)] [-index2 (index2)] [-closest]\n");
    32     // gprint (GP_ERR, "USAGE: match2d X1 Y1 X2 Y2 Radius [-index1 (index1)] [-index2 (index2)] [-closest]\n");
    33     // gprint (GP_ERR, "  if -closest is provided, index1 & index2 will have the same length as X1 and X2 (respectively)\n");
    34     // gprint (GP_ERR, "    with either the index of the match or a value of -1 for non-matches\n");
    35     return (FALSE);
    36   }
     40    gprint (GP_ERR, "  if -closest is provided, index1 & index2 will have the same length as X1 and X2 (respectively)\n");
     41    gprint (GP_ERR, "    with either the index of the match or a value of -1 for non-matches\n");
     42    return (FALSE);
     43  }
     44
     45  /*
     46    we have two modes of operation: 
     47
     48    without -closest, we are finding all matched pairs within the match radius.  in this
     49    case, the two index vectors have the same length, one entry per matched pair.
     50    x1[index1],y1[index1] matches to x2[index2],y2[index2].
     51
     52    with -closest selected, we are finding the closest element of set 1 to each of set 2
     53    and vice versa.  in this case, index1 is always the same length as x1,y1, while index2
     54    is the same lengths as x2,y2.  x2[index1],y2[index1] matches x1,y1 while
     55    x1[index2],y1[index2] matches x2,y2
     56
     57   */
    3758
    3859  if ((X1vec = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) return (FALSE);   
     
    6182  }
    6283
    63   find_matches2d (X1vec, Y1vec, X2vec, Y2vec, Radius, index1, index2);
     84  if (CLOSEST) {
     85      find_matches2d_closest (X1vec, Y1vec, X2vec, Y2vec, Radius, index1);
     86      find_matches2d_closest (X2vec, Y2vec, X1vec, Y1vec, Radius, index2);
     87  } else {
     88      find_matches2d (X1vec, Y1vec, X2vec, Y2vec, Radius, index1, index2);
     89  }
    6490
    6591  return (TRUE);
     
    132158  return (TRUE);
    133159}
     160
     161// find the elements of X2,Y2 which are closest to each element of X1,Y1 (-1 if no match)
     162int find_matches2d_closest (Vector *X1, Vector *Y1, Vector *X2, Vector *Y2, double Radius, Vector *index) {
     163 
     164  off_t i, j, Jmin, Ji, I, J, *N1, *N2, NMATCH;
     165  double dX, dY, dR, Radius2, Rmin;
     166
     167  NMATCH = X1->Nelements;
     168  ResetVector (index, OPIHI_INT, NMATCH);
     169
     170  ALLOCATE (N1, off_t, X1->Nelements);
     171  ALLOCATE (N2, off_t, X2->Nelements);
     172
     173  for (i = 0; i < X1->Nelements; i++) { N1[i] = i; }
     174  for (i = 0; i < X2->Nelements; i++) { N2[i] = i; }
     175
     176  sort_coords_indexonly (X1->elements.Flt, Y1->elements.Flt, N1, X1->Nelements);
     177  sort_coords_indexonly (X2->elements.Flt, Y2->elements.Flt, N2, X2->Nelements);
     178
     179  Radius2 = Radius*Radius;
     180
     181  // find the closest entry in list 2 to the current entry in list 1:
     182  for (i = j = 0; (i < X1->Nelements) && (j < X2->Nelements);) {
     183    I = N1[i];
     184    J = N2[j];
     185
     186    dX = X1->elements.Flt[I] - X2->elements.Flt[J];
     187
     188    if (dX <= -1.02*Radius) {
     189      // no match in list 2 to this entry
     190      index->elements.Int[I] = -1;
     191      i++;
     192      continue;
     193    }
     194    if (dX >= +1.02*Radius) { j++; continue; }
     195
     196    // look for closest matches of list2() to list1(i)
     197    Jmin = -1;
     198    Rmin = Radius2;
     199    for (Ji = j; (dX > -1.02*Radius) && (Ji < X2->Nelements); Ji++) {
     200      J = N2[Ji];
     201      dX = X1->elements.Flt[I] - X2->elements.Flt[J];
     202      dY = Y1->elements.Flt[I] - Y2->elements.Flt[J];
     203      dR = dX*dX + dY*dY;
     204      if (dR > Radius2) continue;
     205      if (dR < Rmin) {
     206        Rmin = dR;
     207        Jmin  = J;
     208      }
     209    }
     210
     211    // no match in list 2 to this entry
     212    if (Jmin == -1) {
     213      index->elements.Int[I] = -1;
     214      i++;
     215      continue;
     216    }
     217    index->elements.Int[I] = Jmin;
     218    i++;
     219  }
     220  index->Nelements = NMATCH;
     221
     222  free (N1);
     223  free (N2);
     224
     225  return (TRUE);
     226}
  • branches/czw_branch/20101203/Ohana/src/opihi/cmd.data/reindex.c

    r29540 r30631  
    55int reindex (int argc, char **argv) {
    66 
    7   int  i, Npts, Nmax, valid;
     7  int  i, Npts, Nmax;
    88  Vector *ivec, *ovec, *xvec;
    99
     
    1111  Npts = 0;
    1212
    13   valid = TRUE;
    14   valid &= (argc >= 6);
    15   valid &= !strcmp(argv[2], "=");
    16   valid &= !strcmp(argv[4], "using");
    17   if (!valid) {
    18     gprint (GP_ERR, "USAGE: reindex (out) = (in) using (index)\n");
    19     gprint (GP_ERR, "  creates a new vectors (out) from (in) based on sequence in (index)\n");
    20     return (FALSE);
    21   }
     13  if (argc != 6) goto usage;
     14  if (strcmp(argv[2], "=")) goto usage;
     15  if (strcmp(argv[4], "using")) goto usage;
    2216
    2317  if ((ovec = SelectVector (argv[1], ANYVECTOR, TRUE)) == NULL) goto error;
     
    6357  DeleteVector (ovec);
    6458  return (FALSE);
     59
     60usage:
     61    gprint (GP_ERR, "USAGE: reindex (out) = (in) using (index)\n");
     62    gprint (GP_ERR, "  creates a new vectors (out) from (in) based on sequence in (index)\n");
     63    return (FALSE);
    6564}
    6665
  • branches/czw_branch/20101203/Ohana/src/opihi/cmd.data/subset.c

    r27491 r30631  
    3434
    3535  // ovec matches ivec in type
    36   ResetVector (ovec, ivec->type, MAX (tvec[0].Nelements, 1));
     36  ResetVector (ovec, ivec->type, tvec[0].Nelements);
    3737
    3838  // we have four cases: (ivec == flt or int) and (tvec == flt or int)
     
    7575
    7676  // free up unused memory
    77   ResetVector (ovec, ivec->type, MAX (Npts, 1));
     77  ResetVector (ovec, ivec->type, Npts);
    7878
    7979  DeleteVector (tvec);
  • branches/czw_branch/20101203/Ohana/src/opihi/cmd.data/vstats.c

    r21508 r30631  
    33int vstats (int argc, char **argv) {
    44 
    5   int i, N;
    6   double max, min, sum, var, dvar, mean, stdev;
    7   float IgnoreValue;
     5  int i, iter, N, Nbin, Niter;
     6  double max, min, pmin, pmax, sum, var, dvar, mean, stdev;
     7  float IgnoreValue, Nsigma;
    88  int Ignore, Quiet;
    99
    10   int *Nval, bin, Nmode, Nmed;
    11   double dx, mode, median;
     10  int *Nval, bin, Nmode, Nmed, Nused;
     11  double dx, mode, median, threshold;
    1212  Vector *vec;
     13  char *mask = NULL;
    1314
    1415  IgnoreValue = 0;
     
    2122  }
    2223
     24  Niter = 1;
     25  Nsigma = 3.0;
     26
     27  if ((N = get_argument (argc, argv, "-sigma-clip"))) {
     28    remove_argument (N, &argc, argv);
     29    Nsigma = atof(argv[N]);
     30    Niter = 3;
     31    remove_argument (N, &argc, argv);
     32  }
     33
     34  if ((N = get_argument (argc, argv, "-iter"))) {
     35    remove_argument (N, &argc, argv);
     36    Niter = atoi(argv[N]);
     37    remove_argument (N, &argc, argv);
     38  }
     39
    2340  Quiet = FALSE;
    2441  if ((N = get_argument (argc, argv, "-q"))) {
     
    3249
    3350  if (argc != 2) {
    34     gprint (GP_ERR, "USAGE: vstat (vector)\n");
     51    gprint (GP_ERR, "USAGE: vstat (vector) [-ignore value] [-q] [-quiet] [-iter Niter] [-sigma-clip Nsigma]\n");
     52    gprint (GP_ERR, "  default is 1 iteration without sigma clipping or 3 with sigma clipping\n");
    3553    return (FALSE);
    3654  }
     
    3957
    4058  /* we need two passes, one for max, min, mean, sum, one for median, stdev, etc */
     59
     60  // set a good / bad mask
     61  ALLOCATE (mask, char, vec[0].Nelements);
     62  if (vec[0].type == OPIHI_FLT) {
     63    opihi_flt *X = vec[0].elements.Flt;
     64    for (i = 0; i < vec[0].Nelements; i++, X++) {
     65      mask[i] = 1;
     66      if (!finite (*X)) continue;
     67      if (Ignore && (*X == IgnoreValue)) continue;
     68      mask[i] = 0;
     69    }     
     70  } else {
     71    opihi_int *X = vec[0].elements.Int;
     72    for (i = 0; i < vec[0].Nelements; i++, X++) {
     73      mask[i] = 1;
     74      if (!finite (*X)) continue;
     75      if (Ignore && (*X == IgnoreValue)) continue;
     76      mask[i] = 0;
     77    }     
     78  }
    4179
    4280  /* calculate max, min, mean, sum, npix */
     
    4785    opihi_flt *X = vec[0].elements.Flt;
    4886    for (i = 0; i < vec[0].Nelements; i++, X++) {
    49       if (!finite (*X)) continue;
    50       if (Ignore && (*X == IgnoreValue)) continue;
     87      if (mask[i]) continue;
    5188      max = MAX (*X, max);
    5289      min = MIN (*X, min);
     
    5794    opihi_int *X = vec[0].elements.Int;
    5895    for (i = 0; i < vec[0].Nelements; i++, X++) {
    59       if (!finite (*X)) continue;
    60       if (Ignore && (*X == IgnoreValue)) continue;
     96      if (mask[i]) continue;
    6197      max = MAX (*X, max);
    6298      min = MIN (*X, min);
     
    67103  mean = sum / N;
    68104
    69   /* calculate median and mode with resolution of (max - min) / 1000 */
    70   dx = (max - min) / 1000;
    71   if (dx == 0) {
    72     median = mode = min;
    73     stdev = 0.0;
    74     goto skip;
    75   }
    76 
    77   ALLOCATE (Nval, int, 1002);
    78   bzero (Nval, 1000*sizeof(int));
    79   var = 0;
    80   if (vec[0].type == OPIHI_FLT) {
    81     opihi_flt *X = vec[0].elements.Flt;
    82     for (i = 0; i < vec[0].Nelements; i++, X++) {
    83       if (!finite (*X)) continue;
    84       if (Ignore && (*X == IgnoreValue)) continue;
    85       bin = MAX (0, MIN (1000, (*X - min) / dx));
    86       Nval[bin] ++;
    87       dvar = (*X - mean);
    88       var += dvar*dvar;
    89     }     
    90   } else {
    91     opihi_int *X = vec[0].elements.Int;
    92     for (i = 0; i < vec[0].Nelements; i++, X++) {
    93       if (!finite (*X)) continue;
    94       if (Ignore && (*X == IgnoreValue)) continue;
    95       bin = MAX (0, MIN (1000, (*X - min) / dx));
    96       Nval[bin] ++;
    97       dvar = (*X - mean);
    98       var += dvar*dvar;
    99     }     
    100   }
    101   stdev = sqrt (var / N);
    102 
    103   Nmode = 0;
    104   mode = Nval[Nmode];
    105   median = 0;
    106   Nmed = -1;
    107   for (i = 0; i < 1001; i++) {
    108     if (Nmed == -1) {
    109       median += Nval[i];
    110       if (median >= N / 2.0) {
    111         Nmed = i;
    112         median = i * dx + min;
     105  // we do Niter passes; on each pass, we exclude entries > Nsigma from the median
     106  pmin = min;
     107  pmax = max;
     108
     109  stdev = mode = median = Nused = 0.0;
     110
     111  for (iter = 0; iter < Niter; iter ++) {
     112
     113    // reduce Nbin after the first iteration?
     114    Nbin = 1000;
     115
     116    /* calculate median and mode with resolution of (max - min) / 1000 */
     117    dx = (pmax - pmin) / Nbin;
     118    if (dx == 0) {
     119      median = mode = min;
     120      stdev = 0.0;
     121      goto skip;
     122    }
     123
     124    ALLOCATE (Nval, int, Nbin + 2);
     125    bzero (Nval, Nbin*sizeof(int));
     126    var = 0;
     127    if (vec[0].type == OPIHI_FLT) {
     128      opihi_flt *X = vec[0].elements.Flt;
     129      for (i = 0; i < vec[0].Nelements; i++, X++) {
     130        if (mask[i]) continue;
     131        bin = MAX (0, MIN (Nbin, (*X - pmin) / dx));
     132        Nval[bin] ++;
     133        dvar = (*X - mean);
     134        var += dvar*dvar;
     135      }     
     136    } else {
     137      opihi_int *X = vec[0].elements.Int;
     138      for (i = 0; i < vec[0].Nelements; i++, X++) {
     139        if (mask[i]) continue;
     140        bin = MAX (0, MIN (Nbin, (*X - pmin) / dx));
     141        Nval[bin] ++;
     142        dvar = (*X - mean);
     143        var += dvar*dvar;
     144      }     
     145    }
     146    stdev = sqrt (var / N);
     147
     148    Nmode = 0;
     149    mode = Nval[Nmode];
     150    median = 0;
     151    Nmed = -1;
     152    for (i = 0; i < Nbin + 1; i++) {
     153      if (Nmed == -1) {
     154        median += Nval[i];
     155        if (median >= N / 2.0) {
     156          Nmed = i;
     157          median = i * dx + pmin;
     158        }
    113159      }
    114     }
    115     if (mode < Nval[i]) {
    116       Nmode = i;
    117       mode = Nval[Nmode];
    118     }
    119   }
    120   mode = Nmode * dx + min;
    121   free (Nval);
     160      if (mode < Nval[i]) {
     161        Nmode = i;
     162        mode = Nval[Nmode];
     163      }
     164    }
     165    mode = Nmode * dx + pmin;
     166    free (Nval);
     167
     168    threshold = Nsigma * stdev;
     169
     170    // we are going to do another pass: mark the entries to skip
     171    pmin = max;
     172    pmax = min;
     173    if (iter < Niter - 1) {
     174      if (vec[0].type == OPIHI_FLT) {
     175        opihi_flt *X = vec[0].elements.Flt;
     176        for (i = 0; i < vec[0].Nelements; i++, X++) {
     177          if (mask[i]) continue;
     178          if (fabs(*X - median) > threshold) {
     179            mask[i] = 1;
     180          } else {
     181            pmin = MIN (*X, pmin);
     182            pmax = MAX (*X, pmax);
     183          }     
     184        }
     185      } else {
     186        opihi_int *X = vec[0].elements.Int;
     187        for (i = 0; i < vec[0].Nelements; i++, X++) {
     188          if (mask[i]) continue;
     189          if (fabs(*X - median) > threshold) {
     190            mask[i] = 1;
     191          } else {
     192            pmin = MIN (*X, pmin);
     193            pmax = MAX (*X, pmax);
     194          }
     195        }     
     196      }
     197    }
     198    // gprint (GP_ERR, "iter %d, mean: %g, stdev: %g, min: %g, max: %g, median: %g, mode: %g, Npts: %d\n",
     199    // iter, mean, stdev, min, max, median, mode, N);
     200  }
     201
     202  Nused = 0;
     203  for (i = 0; i < vec[0].Nelements; i++) {
     204    if (mask[i]) continue;
     205    Nused ++;
     206  }
    122207
    123208skip:
     209  FREE(mask);
     210
    124211  if (!Quiet) {
    125212    gprint (GP_ERR, "mean: %g, stdev: %g, min: %g, max: %g, median: %g, mode: %g, Npts: %d\n",
    126              mean, stdev, min, max, median, mode, N);
    127   }
    128 
     213            mean, stdev, min, max, median, mode, N);
     214  }
     215
     216  set_variable ("PMIN",      pmin);
     217  set_variable ("PMAX",      pmax);
    129218  set_variable ("MIN",      min);
    130219  set_variable ("MAX",      max);
     
    134223  set_variable ("TOTAL",    sum);
    135224  set_int_variable ("NPIX", N);
     225  set_int_variable ("NPTS", N);
     226  set_int_variable ("NUSED", Nused);
    136227  set_variable ("SIGMA",    stdev);
    137228  return (TRUE);
  • branches/czw_branch/20101203/Ohana/src/opihi/cmd.data/write_vectors.c

    r20936 r30631  
    140140      if (fmttype[j] == 'd') {
    141141        if (vec[j][0].type == OPIHI_FLT) {
    142           fprintf (f, fmtlist[j], (int)(vec[j][0].elements.Flt[i]));
     142          fprintf (f, fmtlist[j], (opihi_int)(vec[j][0].elements.Flt[i]));
    143143        } else {
    144           fprintf (f, fmtlist[j], (int)(vec[j][0].elements.Int[i]));
     144          fprintf (f, fmtlist[j], (opihi_int)(vec[j][0].elements.Int[i]));
    145145        }
    146146      }
    147147      if (fmttype[j] == 'f') {
    148148        if (vec[j][0].type == OPIHI_FLT) {
    149           fprintf (f, fmtlist[j], (float)(vec[j][0].elements.Flt[i]));
     149          fprintf (f, fmtlist[j], (opihi_flt)(vec[j][0].elements.Flt[i]));
    150150        } else {
    151           fprintf (f, fmtlist[j], (float)(vec[j][0].elements.Int[i]));
     151          fprintf (f, fmtlist[j], (opihi_flt)(vec[j][0].elements.Int[i]));
    152152        }
    153153      }
  • branches/czw_branch/20101203/Ohana/src/opihi/dvo/avextract.c

    r28241 r30631  
    4444
    4545  // parse skyregion options
    46   if ((selection = SetRegionSelection (&argc, argv)) == NULL) goto escape;
     46  if ((selection = SetRegionSelection (&argc, argv)) == NULL) {
     47    print_error();
     48    goto escape;
     49  }
    4750
    4851  // command-line is of the form: avextract field,field, field [where (field op value)...]
     
    6871  // construct the db Boolean math stack (frees cstack)
    6972  stack = dbRPN (Ncstack, cstack, &Nstack);
     73  if (Ncstack && !Nstack) {
     74    print_error();
     75    goto escape;
     76  }
    7077
    7178  // add the skyregion limits to the where statement (or create)
  • branches/czw_branch/20101203/Ohana/src/opihi/dvo/dbExtractImages.c

    r27587 r30631  
    241241
    242242    case IMAGE_NCAL:
    243       value.Int = image[N].Mxxxx;
     243      value.Int = image[N].nFitPhotom;
    244244      break;
    245245    case IMAGE_SKY:
    246       value.Flt = image[N].Myyyy + 0x8000;
     246      value.Flt = NAN;
    247247      break;
    248248    case IMAGE_FLAGS:
     
    299299      value.Flt = (field->ID == IMAGE_X_UR_FP) ? x : y;
    300300      break;
     301
     302    case IMAGE_X_ERR_SYS:
     303      value.Flt = image[N].dXpixSys;
     304      break;
     305    case IMAGE_Y_ERR_SYS:
     306      value.Flt = image[N].dXpixSys;
     307      break;
     308    case IMAGE_MAG_ERR_SYS:
     309      value.Flt = image[N].dMagSys;
     310      break;
     311
     312    case IMAGE_NFIT_PHOTOM:
     313      value.Int = image[N].nFitPhotom;
     314      break;
     315    case IMAGE_NFIT_ASTROM:
     316      value.Int = image[N].nFitAstrom;
     317      break;
     318    case IMAGE_NLINK_PHOTOM:
     319      value.Int = image[N].nLinkPhotom;
     320      break;
     321    case IMAGE_NLINK_ASTROM:
     322      value.Int = image[N].nLinkAstrom;
     323      break;
    301324  }
    302325  return (value);
  • branches/czw_branch/20101203/Ohana/src/opihi/dvo/dbExtractMeasures.c

    r28955 r30631  
    320320      break;
    321321    case MEAS_FWHM: /* OK */
    322       value.Flt = 0.01*(measure[0].FWx + measure[0].FWy) / 2.0;
     322      value.Flt = FromShortPixels(measure[0].FWx + measure[0].FWy) / 2.0;
    323323      break;
    324324    case MEAS_FWHM_MAJ: /* OK */
    325       value.Flt = 0.01*measure[0].FWx;
     325      value.Flt = FromShortPixels(measure[0].FWx);
    326326      break;
    327327    case MEAS_FWHM_MIN: /* OK */
    328       value.Flt = 0.01*measure[0].FWy;
     328      value.Flt = FromShortPixels(measure[0].FWy);
    329329      break;
    330330    case MEAS_THETA: /* OK */
    331       value.Flt = measure[0].theta;
     331      value.Flt = FromShortDegrees(measure[0].theta);
    332332      break;
    333333    case MEAS_MXX: /* OK */
    334       value.Flt = measure[0].Mxx;
     334      value.Flt = FromShortPixels(measure[0].Mxx);
    335335      break;
    336336    case MEAS_MXY: /* OK */
    337       value.Flt = measure[0].Mxy;
     337      value.Flt = FromShortPixels(measure[0].Mxy);
    338338      break;
    339339    case MEAS_MYY: /* OK */
    340       value.Flt = measure[0].Myy;
     340      value.Flt = FromShortPixels(measure[0].Myy);
    341341      break;
    342342    case MEAS_DOPHOT: /* OK */
     
    382382      break;
    383383    case MEAS_XCCD_ERR: /* OK */
    384       value.Flt = measure[0].dXccd / 100.0;
     384      value.Flt = FromShortPixels(measure[0].dXccd);
    385385      break;
    386386    case MEAS_YCCD_ERR: /* OK */
    387       value.Flt = measure[0].dYccd / 100.0;
     387      value.Flt = FromShortPixels(measure[0].dYccd);
     388      break;
     389    case MEAS_POS_SYS_ERR: /* OK */
     390      value.Flt = FromShortPixels(measure[0].dRsys);
    388391      break;
    389392    case MEAS_XMOSAIC: /* OK */
     
    425428      value.Flt = measure[0].psfQual;
    426429      break;
     430    case MEAS_PSF_QF_PERFECT: /* OK */
     431      value.Flt = NAN;
     432      break;
    427433    case MEAS_PSF_CHISQ: /* OK */
    428434      value.Flt = measure[0].psfChisq;
  • branches/czw_branch/20101203/Ohana/src/opihi/dvo/dbFields.c

    r28955 r30631  
    194194  if (!strcasecmp (fieldName, "XCCD:ERR"))       ESCAPE (MEAS_XCCD_ERR,       MAG_NONE, OPIHI_FLT);
    195195  if (!strcasecmp (fieldName, "YCCD:ERR"))       ESCAPE (MEAS_YCCD_ERR,       MAG_NONE, OPIHI_FLT);
     196  if (!strcasecmp (fieldName, "POS_SYS_ERR"))    ESCAPE (MEAS_POS_SYS_ERR,    MAG_NONE, OPIHI_FLT);
    196197  if (!strcasecmp (fieldName, "XMOSAIC"))        ESCAPE (MEAS_XMOSAIC,        MAG_NONE, OPIHI_FLT);
    197198  if (!strcasecmp (fieldName, "YMOSAIC"))        ESCAPE (MEAS_YMOSAIC,        MAG_NONE, OPIHI_FLT);
     
    205206  if (!strcasecmp (fieldName, "IMAGEID"))        ESCAPE (MEAS_IMAGE_ID,       MAG_NONE, OPIHI_INT);
    206207  if (!strcasecmp (fieldName, "PSF_QF"))         ESCAPE (MEAS_PSF_QF,         MAG_NONE, OPIHI_FLT);
     208  if (!strcasecmp (fieldName, "PSF_QF_PERFECT")) ESCAPE (MEAS_PSF_QF_PERFECT, MAG_NONE, OPIHI_FLT);
    207209  if (!strcasecmp (fieldName, "PSF_CHISQ"))      ESCAPE (MEAS_PSF_CHISQ,      MAG_NONE, OPIHI_FLT);
    208210  if (!strcasecmp (fieldName, "PSF_NDOF"))       ESCAPE (MEAS_PSF_NDOF,       MAG_NONE, OPIHI_INT);
     
    398400  if (!strcasecmp (fieldName, "trate"    )) ESCAPE (IMAGE_TRATE,     MAG_NONE, OPIHI_FLT);
    399401
    400   // XXX : these are mapped to ridiculous things: Myyyy + 0x8000 and Mxxxx
    401402  if (!strcasecmp (fieldName, "ncal"     )) ESCAPE (IMAGE_NCAL,      MAG_NONE, OPIHI_INT);
    402   if (!strcasecmp (fieldName, "sky"      )) ESCAPE (IMAGE_SKY,       MAG_NONE, OPIHI_FLT);
     403  if (!strcasecmp (fieldName, "sky"      )) ESCAPE (IMAGE_SKY,       MAG_NONE, OPIHI_FLT); // deprecated for now
    403404
    404405  if (!strcasecmp (fieldName, "imflags"  )) ESCAPE (IMAGE_FLAGS,     MAG_NONE, OPIHI_INT);
     
    427428  if (!strcasecmp (fieldName, "Y_UR_FP"  )) ESCAPE (IMAGE_Y_UR_FP,   MAG_NONE, OPIHI_FLT);
    428429
     430  if (!strcasecmp (fieldName, "dX_SYS"  )) ESCAPE (IMAGE_X_ERR_SYS,  MAG_NONE, OPIHI_FLT);
     431  if (!strcasecmp (fieldName, "dY_SYS"  )) ESCAPE (IMAGE_Y_ERR_SYS,  MAG_NONE, OPIHI_FLT);
     432  if (!strcasecmp (fieldName, "dM_SYS"  )) ESCAPE (IMAGE_MAG_ERR_SYS,MAG_NONE, OPIHI_FLT);
     433  if (!strcasecmp (fieldName, "NFIT_PHOTOM")) ESCAPE (IMAGE_NFIT_PHOTOM,MAG_NONE, OPIHI_INT);
     434  if (!strcasecmp (fieldName, "NFIT_ASTROM")) ESCAPE (IMAGE_NFIT_ASTROM,MAG_NONE, OPIHI_INT);
     435  if (!strcasecmp (fieldName, "NLINK_PHOTOM")) ESCAPE (IMAGE_NLINK_PHOTOM,MAG_NONE, OPIHI_INT);
     436  if (!strcasecmp (fieldName, "NLINK_ASTROM")) ESCAPE (IMAGE_NLINK_ASTROM,MAG_NONE, OPIHI_INT);
     437
    429438  // for words that don't parse, try a photcode
    430439  gprint (GP_ERR, "unknown field '%s' for image table in DVO database\n", fieldName);
  • branches/czw_branch/20101203/Ohana/src/opihi/dvo/gimages.c

    r28958 r30631  
    201201    }
    202202
    203     /*** XXX we need to re-introduce the use of applyMcal
    204     Mcal = applyMcal (&image[i], 2048.0, 2048.0);
    205     ***/
     203    // XXX Mcal = applyMcal (&image[i], 2048.0, 2048.0);
    206204
    207205  got_spot:
  • branches/czw_branch/20101203/Ohana/src/opihi/dvo/gstar.c

    r28326 r30631  
    222222            gprint (GP_LOG, "%5d ",    catalog.measure[m].photcode);
    223223            gprint (GP_LOG, "%-20s ",  GetPhotcodeNamebyCode (catalog.measure[m].photcode));
    224             gprint (GP_LOG, "%5.2f ",  0.01*catalog.measure[m].FWx);
    225             gprint (GP_LOG, "%5.2f ",  0.01*catalog.measure[m].FWy);
     224            gprint (GP_LOG, "%5.2f ",  FromShortPixels(catalog.measure[m].FWx));
     225            gprint (GP_LOG, "%5.2f ",  FromShortPixels(catalog.measure[m].FWy));
    226226
    227227            if (FULL_OUTPUT) {
     
    233233                gprint (GP_LOG, "%f ", catalog.measure[m].Xccd);
    234234                gprint (GP_LOG, "%f ", catalog.measure[m].Yccd);
    235                 gprint (GP_LOG, "%d ", catalog.measure[m].dXccd);
    236                 gprint (GP_LOG, "%d ", catalog.measure[m].dYccd);
     235                gprint (GP_LOG, "%f ", FromShortPixels(catalog.measure[m].dXccd));
     236                gprint (GP_LOG, "%f ", FromShortPixels(catalog.measure[m].dYccd));
    237237                gprint (GP_LOG, "%f ", catalog.measure[m].Sky);
    238238                gprint (GP_LOG, "%f ", catalog.measure[m].dSky);
     
    244244                gprint (GP_LOG, "%f ", catalog.measure[m].crNsigma);
    245245                gprint (GP_LOG, "%f ", catalog.measure[m].extNsigma);
    246                 gprint (GP_LOG, "%f ", (360.0/(float)0xffff)*catalog.measure[m].theta);
     246                gprint (GP_LOG, "%f ", FromShortDegrees(catalog.measure[m].theta));
    247247            }
    248248            gprint (GP_LOG, "\n");
  • branches/czw_branch/20101203/Ohana/src/opihi/dvo/images.c

    r30118 r30631  
    223223      goto got_type;
    224224    }
    225     // For 'TrianglePts' (TRI-), we are using the Mx,My, etc terms to save the coordinates
    226     // this means triangular images cannot carry photometric zero-point variations
     225    // For 'TrianglePts' (TRI-), we are absurdly overloaded values otherwise not used
    227226    if (typehash == TrianglePts) {
    228227      Npts = 3;
    229       x[0] = image[i].Mx;   y[0] = image[i].My;
    230       x[1] = image[i].Mxxx; y[1] = image[i].Mxyy;
    231       x[2] = image[i].Mxxy; y[2] = image[i].Myyy;
     228      x[0] = image[0].dXpixSys;      y[0] = image[0].dYpixSys;
     229      x[1] = image[0].dMagSys;       y[1] = image[0].nFitAstrom;
     230      x[2] = image[0].photom_map_id; y[2] = image[0].astrom_map_id;
    232231      goto got_type;
    233232    }
  • branches/czw_branch/20101203/Ohana/src/opihi/dvo/imextract.c

    r28958 r30631  
    6262  // construct the db Boolean math stack (frees cstack)
    6363  stack = dbRPN (Ncstack, cstack, &Nstack);
     64  if (Ncstack && !Nstack) {
     65    print_error();
     66    goto escape;
     67  }
    6468
    6569  // add the skyregion limits to the where statement (or create)
  • branches/czw_branch/20101203/Ohana/src/opihi/dvo/imphot.c

    r29540 r30631  
    99  char bufname[64];
    1010  float *p;
    11   double fx, fy, x, y, applyMcal();
     11  double fx, fy, x, y;
    1212  Image *image;
    1313  Buffer *buf;
     
    6363    for (y = 0; y < 200; y+=1.0) {
    6464      for (x = 0; x < 100; x+=1.0, p++) {
    65         *p = applyMcal (&image[subset[0]], (fx*x), (fy*y));
     65        // *p = applyMcal (&image[subset[0]], (fx*x), (fy*y));
     66        *p = image[subset[0]].Mcal;
    6667      }
    6768    }
     
    7071  for (j = 0; j < Nsubset; j++) {
    7172    i = subset[j];
     73    gprint (GP_ERR, "%s: %f\n", image[i].name, image[i].Mcal);
     74
     75// XXX old code when we had the option of a 2D zero point model
     76# if (0)     
    7277    switch (image[i].order) {
    7378    case 0:
     
    9095      break;
    9196    }
     97# endif
    9298  }
    9399
  • branches/czw_branch/20101203/Ohana/src/opihi/dvo/mextract.c

    r28955 r30631  
    6868  // construct the db Boolean math stack (frees cstack)
    6969  stack = dbRPN (Ncstack, cstack, &Nstack);
    70   if ((Ncstack > 0) && (Nstack < 1)) {
     70  if (Ncstack && !Nstack) {
    7171    print_error ();
    7272    goto escape;
  • branches/czw_branch/20101203/Ohana/src/opihi/dvo/mmextract.c

    r28241 r30631  
    106106  // construct the db Boolean math stack (frees cstack)
    107107  stack1 = dbRPN (Ncstack1, cstack1, &Nstack1);
    108   if ((Ncstack1 > 0) && (Nstack1 < 1)) {
     108  if (Ncstack1 && !Nstack1) {
    109109    print_error ();
    110110    goto escape;
     
    113113  // construct the db Boolean math stack (frees cstack)
    114114  stack2 = dbRPN (Ncstack2, cstack2, &Nstack2);
    115   if ((Ncstack2 > 0) && (Nstack2 < 1)) {
     115  if (Ncstack2 && !Nstack2) {
    116116    print_error ();
    117117    goto escape;
  • branches/czw_branch/20101203/Ohana/src/opihi/dvo/photometry.c

    r28955 r30631  
    778778  } else {
    779779   
    780     if (0.01 * measure[0].FWx < 3.0) return (FALSE);
    781     if (0.01 * measure[0].FWx > 10.0) return (FALSE);
     780    if (FromShortPixels(measure[0].FWx < 3.0)) return (FALSE);
     781    if (FromShortPixels(measure[0].FWx > 10.0)) return (FALSE);
    782782
    783783    return (TRUE);
     
    810810    Nm = 0;
    811811    for (i = 0; i < average[0].Nmeasure; i++) {
    812       fwhm = measure[i].FWx / 100.0;
     812      fwhm = FromShortPixels(measure[i].FWx);
    813813      switch (FWHMsign) {
    814814        case 0:
     
    11661166      break;
    11671167    case MEAS_FWHM: /* OK */
    1168       value = 0.01*measure[0].FWx;
     1168      value = FromShortPixels(measure[0].FWx);
    11691169      break;
    11701170    case MEAS_DB_FLAGS: /* ? */
  • branches/czw_branch/20101203/Ohana/src/opihi/dvo/skycat.c

    r20936 r30631  
    3636
    3737  if (argc != 1) {
    38     gprint (GP_ERR, "USAGE: skycat [-all]\n");
     38    gprint (GP_ERR, "USAGE: skycat [-all] [-depth depth] [-v]\n");
    3939    return (FALSE);
    4040  }
     
    116116
    117117  r = ohana_normalize_angle (r);
     118  while (r < Rmin) { r += 360.0; }
     119  while (r > Rmax) { r -= 360.0; }
    118120
    119121  if (*leftside == -1) {
  • branches/czw_branch/20101203/Ohana/src/opihi/include/dvoshell.h

    r28958 r30631  
    107107      MEAS_XCCD_ERR,
    108108      MEAS_YCCD_ERR,
     109      MEAS_POS_SYS_ERR,
    109110      MEAS_XMOSAIC,
    110111      MEAS_YMOSAIC,
     
    116117      MEAS_IMAGE_ID,
    117118      MEAS_PSF_QF,
     119      MEAS_PSF_QF_PERFECT,
    118120      MEAS_PSF_CHISQ,
    119121      MEAS_PSF_NDOF,
     
    218220      IMAGE_Y_UL_FP,
    219221      IMAGE_Y_UR_FP,
     222      IMAGE_X_ERR_SYS,
     223      IMAGE_Y_ERR_SYS,
     224      IMAGE_MAG_ERR_SYS,
     225      IMAGE_NFIT_PHOTOM,
     226      IMAGE_NFIT_ASTROM,
     227      IMAGE_NLINK_PHOTOM,
     228      IMAGE_NLINK_ASTROM
    220229};
    221230
  • branches/czw_branch/20101203/Ohana/src/opihi/include/shell.h

    r27790 r30631  
    7676char         *expand_vars               PROTO((char *line));
    7777char         *expand_vectors            PROTO((char *line));
    78 char         *parse                     PROTO((char *line));
     78char         *parse                     PROTO((int *status, char *line));
    7979char        **parse_commands            PROTO((char *, int *));
    8080void          welcome                   PROTO((void));
  • branches/czw_branch/20101203/Ohana/src/opihi/lib.shell/VectorOps.c

    r20936 r30631  
    178178  vec[0].Nelements = Nelements;
    179179  if (type == OPIHI_FLT) {
    180     REALLOCATE (vec[0].elements.Flt, opihi_flt, Nelements);
     180    REALLOCATE (vec[0].elements.Flt, opihi_flt, MAX(1, Nelements));
    181181    vec[0].type = OPIHI_FLT;
    182182  } else {
    183     REALLOCATE (vec[0].elements.Int, opihi_int, Nelements);
     183    REALLOCATE (vec[0].elements.Int, opihi_int, MAX(1, Nelements));
    184184    vec[0].type = OPIHI_INT;
    185185  }
  • branches/czw_branch/20101203/Ohana/src/opihi/lib.shell/command.c

    r27790 r30631  
    1010  Command *cmd;
    1111
    12   // rawline = NULL;
    13   rawline = strcreate (line);
     12  // the input line is never NULL
     13  if (!line) { fprintf (stderr, "programming error\n"); abort(); }
     14
     15  rawline = strcreate (line);  // used for error messages which should echo the unparsed line
    1416
    1517  /* force a space between ! and first word: !ls becomes ! ls */
     
    2224  /* expand anything of the form $fred or $fred$sam, etc */
    2325  line = expand_vars (line);     /* line is freed here, new one allocated */
     26  if (!line) goto escape;
     27
    2428  /* expand anything of the form fred[N] */
    2529  line = expand_vectors (line);  /* line is freed here, new one allocated */
     30  if (!line) goto escape;
    2631
    2732  // print the line with the variables and vectors expanded, but before evaluating
     
    2934  if (VERBOSE_SHELL == OPIHI_VERBOSE_ON) gprint (GP_ERR, "opihi: %s\n", line);
    3035
    31   /* solve math expresions, assign variable, if needed */
    32   line = parse (line);        /* line is freed here, new one allocated */
    33   /* any entry in line of the form {foo} returns value or tmp vector / buffer */
     36  /* solve math expresions, assign variable, if needed.  any entry in line of the form {foo}
     37   * returns value or tmp vector / buffer */
     38  line = parse (&status, line);        /* line is freed here, new one allocated */
     39  if (!status) goto escape;
    3440
    3541  /* we may have reallocated line, return new pointer */
     
    3945  if (argc == 0) {
    4046      FREE (rawline);
     47      set_int_variable ("STATUS", TRUE);
    4148      return (TRUE);  /* empty command or assignment */
    4249  }
     
    7481  FREE (rawline);
    7582  return (status);
     83
     84 escape:
     85  set_int_variable ("STATUS", FALSE);
     86
     87  # if (DEBUG)
     88  gprint (GP_ERR, "command: %s, status: %d\n", line, FALSE);
     89  # endif
     90
     91  FREE (rawline);
     92
     93  if (VERBOSE_SHELL != OPIHI_VERBOSE_OFF) gprint (GP_ERR, "error on line: %s\n", rawline);
     94
     95  // return the current value of line, in case it was modified
     96  *outline = line;
     97  return FALSE;
    7698}
    7799
  • branches/czw_branch/20101203/Ohana/src/opihi/lib.shell/expand_vars.c

    r15878 r30631  
    6464    /* variable assignment (skip these variables) */
    6565    if ((L == line) && (V1 != NULL)) {
    66       if ((*V1 == '=') || !strcmp (V1, "++") || !strcmp (V1, "--")) {
     66      int isAssignment;
     67
     68      isAssignment = FALSE;
     69      isAssignment |= (V1[0] == '=');
     70      isAssignment |= (V1[0] == '+') && (V1[1] == '=');
     71      isAssignment |= (V1[0] == '-') && (V1[1] == '=');
     72      isAssignment |= (V1[0] == '+') && (V1[1] == '+');
     73      isAssignment |= (V1[0] == '-') && (V1[1] == '-');
     74
     75      if (isAssignment) {
    6776        *N = *L;
    6877        free (V0);
  • branches/czw_branch/20101203/Ohana/src/opihi/lib.shell/parse.c

    r27491 r30631  
    11# include "opihi.h"
    22
    3 char *parse (char *line) {
     3char *parse (int *status, char *line) {
    44
    55  double fval;
    66  float *fptr;
    77  char *newline, *N, *L, *val, *B, *V, *V0, *V1, *c1, *c2, *p;
    8   int Nx, Ny, Nbytes, status, size, NLINE, isBuffer, inRange;
     8  int Nx, Ny, Nbytes, filestatus, size, NLINE, isBuffer, inRange;
    99  FILE *f;
    1010  Vector *vec;
    1111  Buffer *buf;
     12
     13  *status = TRUE;
    1214
    1315  Ny = 0;
     
    4951    }
    5052
     53    if (!strncmp (V1, "+=", 2)) {
     54        V1 ++;
     55        if (*V1 == 0) goto error;
     56        V1 ++;
     57        if (*V1 == 0) goto error;
     58
     59        val = get_variable (V0);
     60        if (val == NULL) {
     61            fval = 0.0;
     62        } else {
     63            fval = atof (val);
     64        }
     65
     66        /* dvomath returns a new string, or NULL, with the result of the expression */
     67        val = dvomath (1, &V1, &size, 0);
     68        if (val == NULL) goto error;
     69        fval += atof(val);
     70        // save the result
     71        set_variable (V0, fval);
     72        goto escape;
     73    }
     74
     75    if (!strncmp (V1, "-=", 2)) {
     76        V1 ++;
     77        if (*V1 == 0) goto error;
     78        V1 ++;
     79        if (*V1 == 0) goto error;
     80
     81        val = get_variable (V0);
     82        if (val == NULL) {
     83            fval = 0.0;
     84        } else {
     85            fval = atof (val);
     86        }
     87
     88        /* dvomath returns a new string, or NULL, with the result of the expression */
     89        val = dvomath (1, &V1, &size, 0);
     90        if (val == NULL) goto error;
     91        fval -= atof(val);
     92        // save the result
     93        set_variable (V0, fval);
     94        goto escape;
     95    }
     96
    5197    /* not an assignement, syntax error */
    5298    if (*V1 != '=') goto error;
     
    73119      Nbytes = fread (val, 1, 1023, f);
    74120      val[Nbytes] = 0;
    75       status = pclose (f);
     121      filestatus = pclose (f);
    76122      free (B);
    77123
    78       if (status) gprint (GP_ERR, "warning: exit status of command %d\n", status);
     124      if (filestatus) gprint (GP_ERR, "warning: exit status of command %d\n", filestatus);
    79125
    80126      /* convert all but last return to ' '.  drop last return */
     
    88134        }
    89135      }
     136      // save the resulting value
     137      set_str_variable (V0, val);
     138      goto escape;  /* frees temp variables */
     139    }
     140
     141    /* simple variable assignment */
     142    /* dvomath returns a new string, or NULL, with the result of the expression */
     143    val = dvomath (1, &V1, &size, 0);
     144    if (val == NULL) {
     145      while (OHANA_WHITESPACE (*V1)) V1++;
     146      val = strcreate (V1);
    90147    }
    91 
    92     /* simple variable assignment */
    93     if (*V1 != '`') {
    94       /* dvomath returns a new string, or NULL, with the result of the expression */
    95       val = dvomath (1, &V1, &size, 0);
    96       if (val == NULL) {
    97         while (OHANA_WHITESPACE (*V1)) V1++;
    98         val = strcreate (V1);
    99       }
    100     }
    101     /* both dvomath and command replacement create (char *) val */
     148    // save the result
    102149    set_str_variable (V0, val);
    103150    goto escape;  /* frees temp variables */
     
    172219      if (!inRange) {
    173220        gprint (GP_ERR, "no element %d,%d\n", Nx, Ny);
    174         goto escape;
     221        goto error;
    175222      }
    176223      if (Nx < 0) Nx += buf[0].header.Naxis[0];
     
    188235      if (!inRange) {
    189236        gprint (GP_ERR, "no element %d\n", Nx);
    190         goto escape;
     237        goto error;
    191238      }
    192239      if (Nx < 0) Nx += vec[0].Nelements;
     
    197244      }
    198245    }
    199 
    200246    goto escape;
    201247  }
     
    226272    if (c1 == NULL) {
    227273      gprint (GP_ERR, "no close brackets!\n");
    228       goto escape;
     274      goto error;
    229275    }
    230276    c2 = strchr (L, '{');
    231277    if ((c2 != NULL) && (c2 < c1)) {
    232278      gprint (GP_ERR, "can't nest brackets!\n");
    233       goto escape;
     279      goto error;
    234280    }
    235281    *c1 = 0;
     
    240286    if (val == NULL) {
    241287      print_error ();
    242       goto escape;
     288      goto error;
    243289    }
    244290
     
    257303 
    258304  REALLOCATE (newline, char, strlen (newline) + 1);
     305  *status = TRUE;
    259306  return (newline);
    260307
    261308error:
    262309  gprint (GP_ERR, "syntax error\n");
    263 
    264 escape:
     310  // assignment or increment operation: free line and return NULL
    265311  if (line != (char *) NULL) free (line);
    266312  if (val != (char *) NULL) free (val);
    267313  if (V0 != (char *) NULL) free (V0);
     314  *status = FALSE;
     315  return NULL;
     316
     317escape:
     318  // assignment or increment operation: free line and return NULL
     319  if (line != (char *) NULL) free (line);
     320  if (val != (char *) NULL) free (val);
     321  if (V0 != (char *) NULL) free (V0);
     322  *status = TRUE;
    268323  return (NULL);
    269324}
  • branches/czw_branch/20101203/Ohana/src/opihi/lib.shell/stack_math.c

    r27435 r30631  
    972972        *out = OP;                                              \
    973973      }                                                         \
    974       clear_stack (V1);                                         \
    975       return (TRUE);                                            \
     974      goto escape;                                              \
    976975    }                                                           \
    977976    if ((V1->vector->type == OPIHI_INT) && (FTYPE == 'S')) {    \
     
    982981        *out = OP;                                              \
    983982      }                                                         \
    984       clear_stack (V1);                                         \
    985       return (TRUE);                                            \
     983      goto escape;                                              \
    986984    }                                                           \
    987985    if ((V1->vector->type == OPIHI_INT) && (FTYPE == 's')) {    \
     
    992990        *out = OP;                                              \
    993991      }                                                         \
    994       clear_stack (V1);                                         \
    995       return (TRUE);                                            \
     992      goto escape;                                              \
    996993    } }                                                 
    997994
     
    10351032# undef V_FUNC
    10361033
     1034escape:
     1035
    10371036  if (V1[0].type == 'v') {
    10381037    free (V1[0].vector[0].elements.Ptr);
Note: See TracChangeset for help on using the changeset viewer.