IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 8, 2023, 12:17:35 PM (3 years ago)
Author:
eugene
Message:

merge from eam_branches/ipp-20220316. fixes for more pendantic gcc; add opihi memory stats; string vector improvements; use named macros for fixed string lengths

Location:
trunk/Ohana
Files:
2 deleted
37 edited
4 copied

Legend:

Unmodified
Added
Removed
  • trunk/Ohana

  • trunk/Ohana/src/opihi/Makefile.Common

    r13615 r42389  
    4242        @if [ ! -d $(LIB) ]; then mkdir -p $(LIB); fi
    4343        rm -f $@
    44         gcc -shared -Wl,-soname,$*.so -o $@ $^ -lc
     44#       gcc -shared -Wl,-soname,$*.so -o $@ $^ -lc
     45        gcc -shared -Wl,-soname,$*.so -o $@ $^ -lc -Wl,--allow-multiple-definition
    4546
    4647$(DESTLIB)/%.so: $(LIB)/%.$(ARCH).so
  • trunk/Ohana/src/opihi/cmd.basic/list.c

    r42081 r42389  
    111111      set_str_variable (line, argv[i+3]);
    112112    }
    113     snprintf (line, MAX_LINE_LENGTH, "%s:n", argv[1]);
     113    snprintf_nowarn (line, MAX_LINE_LENGTH, "%s:n", argv[1]);
    114114    set_int_variable (line, i);
    115115
     
    133133    int isFound;
    134134
    135     snprintf (line, MAX_LINE_LENGTH, "%s:n", argv[1]);
     135    snprintf_nowarn (line, MAX_LINE_LENGTH, "%s:n", argv[1]);
    136136    int nList = get_int_variable (line, &isFound);
    137137    if (!isFound) {
     
    145145
    146146    for (i = start; i < nList; i++) {
    147       snprintf (line, MAX_LINE_LENGTH, "%s:%d", argv[1], i);
     147      snprintf_nowarn (line, MAX_LINE_LENGTH, "%s:%d", argv[1], i);
    148148      char *word = get_variable (line);
    149149      if (!word) break;
    150150      if (i > 0) {
    151         snprintf (output, MAX_LINE_LENGTH, "%s %s", tmpline, word);
     151        snprintf_nowarn (output, MAX_LINE_LENGTH, "%s %s", tmpline, word);
    152152      } else {
    153         snprintf (output, MAX_LINE_LENGTH, "%s", word);
     153        snprintf_nowarn (output, MAX_LINE_LENGTH, "%s", word);
    154154      }
    155155      strcpy (tmpline, output);
     
    179179   
    180180    // old list must exist, or give an error
    181     snprintf (line, MAX_LINE_LENGTH, "%s:n", argv[3]);
     181    snprintf_nowarn (line, MAX_LINE_LENGTH, "%s:n", argv[3]);
    182182    N = get_int_variable (line, &found);
    183183    if (!found) {
     
    188188     
    189189
    190     snprintf (line, MAX_LINE_LENGTH, "%s:n", argv[1]);
     190    snprintf_nowarn (line, MAX_LINE_LENGTH, "%s:n", argv[1]);
    191191    set_int_variable (line, N);
    192192    for (i = 0; i < N; i++) {
    193       snprintf (line, MAX_LINE_LENGTH, "%s:%d", argv[3], i);
     193      snprintf_nowarn (line, MAX_LINE_LENGTH, "%s:%d", argv[3], i);
    194194      value = get_variable (line);
    195       // snprintf (line, MAX_LINE_LENGTH, "%s:%d", argv[1], i);
     195      // snprintf_nowarn (line, MAX_LINE_LENGTH, "%s:%d", argv[1], i);
    196196      set_list_varname (line, argv[1], i, EXCEL_STYLE);
    197197      set_str_variable (line, value);
     
    207207    }
    208208   
    209     snprintf (line, MAX_LINE_LENGTH, "%s:n", argv[1]);
     209    snprintf_nowarn (line, MAX_LINE_LENGTH, "%s:n", argv[1]);
    210210    N = get_int_variable (line, &found);
    211211    for (i = 0; i < argc - 3; i++) {
    212       // snprintf (line, MAX_LINE_LENGTH, "%s:%d", argv[1], N + i);
     212      // snprintf_nowarn (line, MAX_LINE_LENGTH, "%s:%d", argv[1], N + i);
    213213      set_list_varname (line, argv[1], N + i, EXCEL_STYLE);
    214214      set_str_variable (line, argv[i+3]);
    215215    }
    216     snprintf (line, MAX_LINE_LENGTH, "%s:n", argv[1]);
     216    snprintf_nowarn (line, MAX_LINE_LENGTH, "%s:n", argv[1]);
    217217    set_int_variable (line, N + i);
    218218
     
    231231    char line2[MAX_LINE_LENGTH];
    232232
    233     snprintf (line, MAX_LINE_LENGTH, "%s:n", argv[1]); // line = LIST:n
     233    snprintf_nowarn (line, MAX_LINE_LENGTH, "%s:n", argv[1]); // line = LIST:n
    234234    N = get_int_variable (line, &found);
    235235
    236236    // loop over all list elements:
    237237    for (i = 0; i < N; i++) {
    238       // snprintf (line, MAX_LINE_LENGTH, "%s:%d", argv[1], i);
     238      // snprintf_nowarn (line, MAX_LINE_LENGTH, "%s:%d", argv[1], i);
    239239      set_list_varname (line, argv[1], i, EXCEL_STYLE); // line = LIST:i
    240240      value = get_variable (line);
     
    245245        free (value);
    246246        for (j = i + 1; j < N; j++) {
    247           // snprintf (line, MAX_LINE_LENGTH, "%s:%d", argv[1], j);
     247          // snprintf_nowarn (line, MAX_LINE_LENGTH, "%s:%d", argv[1], j);
    248248          set_list_varname (line2, argv[1], j, EXCEL_STYLE); // line2 = LIST:j
    249249          next_value = get_variable (line2);
     
    252252        }
    253253        DeleteNamedScalar (line); // line = LIST:(N-1)
    254         snprintf (line, MAX_LINE_LENGTH, "%s:n", argv[1]); // line = LIST:n (new value of n)
     254        snprintf_nowarn (line, MAX_LINE_LENGTH, "%s:n", argv[1]); // line = LIST:n (new value of n)
    255255        set_int_variable (line, N - 1);
    256256        return (TRUE);
     
    309309      depth --;
    310310      if (depth < 0) { /* we hit the last "END", loop is done */
    311         snprintf (line, MAX_LINE_LENGTH, "%s:n", argv[1]);
     311        snprintf_nowarn (line, MAX_LINE_LENGTH, "%s:n", argv[1]);
    312312        set_int_variable (line, i);
    313313        free (input);
     
    317317
    318318    if (*input) {
    319       // snprintf (line, MAX_LINE_LENGTH, "%s:%d", argv[1], i);
     319      // snprintf_nowarn (line, MAX_LINE_LENGTH, "%s:%d", argv[1], i);
    320320      set_list_varname (line, argv[1], i, EXCEL_STYLE);
    321321      set_str_variable (line, input);
     
    381381  free (val);
    382382   
    383   snprintf (line, MAX_LINE_LENGTH, "%s:n", listname);
     383  snprintf_nowarn (line, MAX_LINE_LENGTH, "%s:n", listname);
    384384  set_int_variable (line, i);
    385385  return (TRUE);
     
    399399  // otherwise save all glob matches
    400400  if (globList.gl_pathc == 0) {
    401     snprintf (line, MAX_LINE_LENGTH, "%s:n", listname);
     401    snprintf_nowarn (line, MAX_LINE_LENGTH, "%s:n", listname);
    402402    set_int_variable (line, 0);
    403403    return TRUE;
     
    409409    set_str_variable (line, globList.gl_pathv[i]);
    410410  }
    411   snprintf (line, MAX_LINE_LENGTH, "%s:n", listname);
     411  snprintf_nowarn (line, MAX_LINE_LENGTH, "%s:n", listname);
    412412  set_int_variable (line, Nfile);
    413413  return (TRUE);
     
    430430    Nline ++;
    431431  }
    432   snprintf (varname, MAX_LINE_LENGTH, "%s:n", listname);
     432  snprintf_nowarn (varname, MAX_LINE_LENGTH, "%s:n", listname);
    433433  set_int_variable (varname, Nline);
    434434  return TRUE;
     
    463463    FREE (new);
    464464  }
    465   snprintf (line, MAX_LINE_LENGTH, "%s:n", argv[1]);
     465  snprintf_nowarn (line, MAX_LINE_LENGTH, "%s:n", argv[1]);
    466466  set_int_variable (line, nWords);
    467467
  • trunk/Ohana/src/opihi/cmd.basic/memory.c

    r41341 r42389  
    2727  if (!strcasecmp (argv[1], "checkfree")) {
    2828    ohana_memcheck (1);
     29    return (TRUE);
     30  }
     31  if (!strcasecmp (argv[1], "stats")) {
     32    OhanaMemstats memstats = ohana_memstats (0);
     33    set_variable ("memory:Ntotal", memstats.Ntotal);
     34    set_variable ("memory:Nbytes", memstats.Nbytes);
     35    set_variable ("memory:Ngood",  memstats.Ngood);
     36    set_variable ("memory:Nbad",   memstats.Nbad);
    2937    return (TRUE);
    3038  }
  • trunk/Ohana/src/opihi/cmd.basic/run_while.c

    r31667 r42389  
    7272  // test the logic once before running the loop
    7373  logic_line = strcreate (argv[1]);
    74   logic_line = expand_vars (logic_line);
     74  logic_line = expand_vars (logic_line); // recalculates scalar elements
     75  logic_line = expand_vectors (logic_line); // recalculates vector/matrix elements (e.g., vec[])
    7576  val = dvomath (1, &logic_line, &size, 0);
    7677  free (logic_line);
     
    9091
    9192    logic_line = strcreate (argv[1]);
    92     logic_line = expand_vars (logic_line);
     93    logic_line = expand_vars (logic_line); // recalculates scalar elements
     94    logic_line = expand_vectors (logic_line); // recalculates vector/matrix elements (e.g., vec[])
    9395    val = dvomath (1, &logic_line, &size, 0);
    9496    free (logic_line);
  • trunk/Ohana/src/opihi/cmd.data/Makefile

    r42128 r42389  
    140140$(SRC)/radial.$(ARCH).o \
    141141$(SRC)/rd.$(ARCH).o             \
     142$(SRC)/rdjpg.$(ARCH).o          \
    142143$(SRC)/rdseg.$(ARCH).o          \
    143144$(SRC)/read_vectors.$(ARCH).o   \
     
    154155$(SRC)/set.$(ARCH).o            \
    155156$(SRC)/shift.$(ARCH).o          \
     157$(SRC)/opihi_size.$(ARCH).o        \
    156158$(SRC)/sort.$(ARCH).o           \
    157159$(SRC)/spline.$(ARCH).o         \
  • trunk/Ohana/src/opihi/cmd.data/cursor.c

    r39457 r42389  
    4242    KiiCursorRead (kapa, &X, &Y, &Z, &R, &D, key);
    4343
    44     sprintf (string, "X%s", key);
    45     set_variable (string, X);
    46     sprintf (string, "Y%s", key);
    47     set_variable (string, Y);
    48     sprintf (string, "Z%s", key);
    49     set_variable (string, Z);
    50     sprintf (string, "R%s", key);
    51     set_variable (string, R);
    52     sprintf (string, "D%s", key);
    53     set_variable (string, D);
     44    snprintf_nowarn (string, 20, "X%s", key);    set_variable (string, X);
     45    snprintf_nowarn (string, 20, "Y%s", key);    set_variable (string, Y);
     46    snprintf_nowarn (string, 20, "Z%s", key);    set_variable (string, Z);
     47    snprintf_nowarn (string, 20, "R%s", key);    set_variable (string, R);
     48    snprintf_nowarn (string, 20, "D%s", key);    set_variable (string, D);
    5449
    5550    set_str_variable ("KEY", key);
  • trunk/Ohana/src/opihi/cmd.data/init.c

    r42128 r42389  
    126126int queue2book       PROTO((int, char **));
    127127int rd               PROTO((int, char **));
     128int rdjpg            PROTO((int, char **));
    128129int rdseg            PROTO((int, char **));
    129130int read_vectors     PROTO((int, char **));
     
    160161int tvgrid           PROTO((int, char **));
    161162int opihi_type       PROTO((int, char **));
     163int opihi_size       PROTO((int, char **));
    162164int uniq             PROTO((int, char **));
    163165int uniqpair         PROTO((int, char **));
     
    336338  {1, "ipptool2book", queue2book,       "convert queue with ipptool output to book"},
    337339  {1, "rd",           rd,               "load fits image"},
     340  {1, "rdjpg",        rdjpg,            "load jpeg image"},
    338341  {1, "rdseg",        rdseg,            "read a segment of an image from a file"},
    339342  {1, "read",         read_vectors,     "read vectors from datafile"},
     
    350353  {1, "set",          set,              "image and vector math"},
    351354  {1, "shift",        shift,            "shift data in an image"},
     355  {1, "size",         opihi_size,       "get vector/matrix dimension/size information"},
    352356  {1, "sort",         sort_vectors,     "sort list of vectors"},
    353357  {1, "spline",       spline_command,   "shift data in an image"},
  • trunk/Ohana/src/opihi/cmd.data/limits.c

    r40291 r42389  
    6161    APPLY = TRUE;
    6262  }
     63
    6364  char *name = NULL;
    6465  if ((N = get_argument (argc, argv, "-n"))) {
     
    6768    remove_argument (N, &argc, argv);
    6869  }
    69 
    7070  if (!GetGraph (&graphmode, &kapa, name)) return (FALSE);
    7171  FREE (name);
     72
     73  // this is not super intuitive
     74  if ((N = get_argument (argc, argv, "-boxsize"))) {
     75    remove_argument (N, &argc, argv);
     76    float dx, dy;
     77    // ask kapa for the size of the graph region in pixels
     78    KapaGetLimits (kapa, &dx, &dy);
     79    set_variable ("KAPA_XPIX", fabs(dx));
     80    set_variable ("KAPA_YPIX", fabs(dy));
     81  }
    7282
    7383  // XXX need an option to set the limits based on the current image bounds
     
    169179  return (TRUE);
    170180}
     181
     182/* -minX value : the minimum X axis value will be no higher than this value
     183   -maxX value : the maximum X axis value will be no lower than this value
     184   -delX value : the range of the X axis will be at least this value
     185
     186   These can be used to prevent the range from collapsing. 
     187   These are only used if the -a option is supplied, otherwise the supplied or auto-calculated
     188   ranges are used (this seems like an poor choice)
     189
     190*/
     191
     192
     193   
  • trunk/Ohana/src/opihi/cmd.data/read_vectors.c

    r42082 r42389  
    385385      if (!lineStatus && VERBOSE) {
    386386        char temp[32];
    387         strncpy (temp, c0, 32);
    388         temp[31] = 0;
     387        strncpy_nowarn (temp, c0, 31);
    389388        gprint (GP_ERR, "skip line %s\n\n", temp);
    390389      }
  • trunk/Ohana/src/opihi/cmd.data/reindex.c

    r42082 r42389  
    7272    }
    7373  }
     74  if (ivec->type == OPIHI_STR) {
     75    opihi_int *vx = xvec[0].elements.Int;
     76    for (Npts = i = 0; i < xvec[0].Nelements; i++, vx++) {
     77      if (Npts >= NPTS) {
     78        NPTS += 2000;
     79        REALLOCATE (ovec[0].elements.Str, char *, NPTS);
     80      }
     81      if (*vx < 0) {
     82        if (KEEP_UNMATCH) {
     83          ovec[0].elements.Str[Npts] = strcreate(""); // XXX use a different or a specified value?
     84          Npts++;
     85        }
     86        continue;
     87      }
     88      if (*vx > Nmax) ESCAPE("unexpected value in index: "OPIHI_INT_FMT" (%d)\n", *vx, i);
     89      ovec[0].elements.Str[Npts] = strcreate(ivec->elements.Str[*vx]);
     90      Npts++;
     91    }
     92  }
    7493
    7594  // free up unused memory
  • trunk/Ohana/src/opihi/cmd.data/subset.c

    r42311 r42389  
    4444  ResetVector (ovec, ivec->type, tvec[0].Nelements);
    4545
    46   // we have four cases: (ivec == flt or int) and (tvec == flt or int)
     46  // we have size cases: (ivec == flt, int, str) and (tvec == flt or int)
    4747  if ((ivec->type == OPIHI_FLT) && (tvec->type == OPIHI_FLT)) {
    4848    opihi_flt *vi = ivec[0].elements.Flt;
     
    8181    }
    8282  }
     83  // XXX if ivec is an existing vector, this step will
     84  // leak (existing elements need to be freed if they
     85  // have been allocated).
    8386  if ((ivec->type == OPIHI_STR) && (tvec->type == OPIHI_FLT)) {
    8487    opihi_flt *vt = tvec[0].elements.Flt;
    8588    for (Npts = i = 0; i < tvec[0].Nelements; i++, vt++) {
    8689      if (!*vt) continue;
    87       ovec[0].elements.Str[Npts] = strcreate (ivec[0].elements.Str[i]);
     90      ovec[0].elements.Str[Npts] = strcreate(ivec[0].elements.Str[i]);
    8891      Npts++;
    8992    }
     
    9396    for (Npts = i = 0; i < tvec[0].Nelements; i++, vt++) {
    9497      if (!*vt) continue;
    95       ovec[0].elements.Str[Npts] = strcreate (ivec[0].elements.Str[i]);
     98      ovec[0].elements.Str[Npts] = strcreate(ivec[0].elements.Str[i]);
    9699      Npts++;
    97100    }
  • trunk/Ohana/src/opihi/cmd.data/svd.c

    r29540 r42389  
    5858
    5959  // try C.R. Bond's version -- requires matrices in the form A[row][col] not A[row*Ncol + col]
    60   if (1) {
     60  if (0) {
    6161      int j;
    6262      double **a, **u, **v, *q;
  • trunk/Ohana/src/opihi/cmd.data/test/histogram.sh

    r20936 r42389  
    3535 local i
    3636
    37  list word -x "ps -p $PID -o rss"
    38  $startmem = $word:1
     37 create xhis 0 10 0.1
     38 $i = 1
     39
     40 memory stats
     41 $startmem = $memory:Ntotal
    3942
    4043 for i 0 1000
     
    4245 end
    4346 
    44  list word -x "ps -p $PID -o rss"
    45  $endmem = $word:1
     47 memory stats
     48 $endmem = $memory:Ntotal
    4649
    4750 $PASS = 1
  • trunk/Ohana/src/opihi/cmd.data/test/join.sh

    r36084 r42389  
    2121
    2222 join ID1 ID2
    23 
    24 mana: for i 0 index1[]
    25 >> echo index1[$i] index2[$i]
    26 >> end
    27 0 2
    28 2 1
    29 4 0
    30 5 3
    31 mana: join ID1 ID2 -outer
    32 mana: vectors
    33     N       name      size
    34     0        ID1          6 (INT)
    35     1       val1          6 (FLT)
    36     2        ID2          4 (INT)
    37     3        val          4 (FLT)
    38     4     index1          6 (INT)
    39     5     index2          4 (INT)
    40 mana: for i 0 index1[]
    41 >> echo index1[$i]
    42 >> end
    43 2
    44 -1
    45 1
    46 -1
    47 0
    48 3
    49 mana: echo ID1[2]
    50 3
    51 mana: echo ID1[0] ID2[2]
    52 1 1
    53 mana: for i 0 index1[]
    54 >> if (index1[$i] == -1) continue
    55 >> $N = index1[$i]
    56 >> echo $i index1[$i] ID1[$i] ID2[$N]
    57 >> end
    58 0 2 1 1
    59 2 1 3 3
    60 4 0 5 5
    61 5 3 6 6
    62 mana: for i 0 index2[]
    63 >> if (index2[$i] == -1) continue
    64 >> $N = index2[$i]
    65 >> echo $i index2[$i] ID2[$i] ID1[$N]
    66 >> end
    67 0 4 5 5
    68 1 2 3 3
    69 2 0 1 1
    70 3 5 6 6
    71 mana:
    72 
    73  # if ((xvec[1024] != 17) || (yvec[1024] != 100))
    74  #  $PASS = 0
    75  #  echo "Value mismatch: xvec[1024] yvec[1024] (should be 17,100)"
    76  # end
    77  #
    78  # imhist -q buff xvec yvec -region 40 0 25 10 -range 0 10
    79  #
    80  # if ((xvec[1024] != 10) || (yvec[1024] != 100))
    81  #  $PASS = 0
    82  #  echo "Value mismatch: xvec[1024] yvec[1024] (should be 10,100)"
    83  # end
    8423
    8524end
  • trunk/Ohana/src/opihi/cmd.data/threshold.c

    r42277 r42389  
    33int QUIET = FALSE;
    44
    5 void _threshold_set_values (double value, int Nbin, double level) {
     5void _threshold_set_values (double value, int Nbin, double level, int thresherr) {
    66
    77  set_variable ("threshval", value);
    88  set_int_variable ("threshbin", Nbin);
    99  set_variable ("threshold", level);
     10  set_int_variable ("thresherr", thresherr);
    1011
    1112  if (!QUIET) gprint (GP_LOG, "theshold %f (bin %d is %f)\n", level, Nbin, value);
     
    117118    if (vecy[0].elements.Flt[BinMin] > value) {
    118119      if (SATURATE) {
    119         _threshold_set_values (vecy[0].elements.Flt[BinMin], BinMin, vecx[0].elements.Flt[BinMin]);
     120        _threshold_set_values (vecy[0].elements.Flt[BinMin], BinMin, vecx[0].elements.Flt[BinMin], 1);
    120121        return TRUE;
    121122      } else {
    122123        gprint (GP_ERR, "ERROR: all values above threshold\n");
    123         _threshold_set_values (NAN, -1, NAN);
     124        _threshold_set_values (NAN, -1, NAN, 1);
    124125        return FALSE;
    125126      }
     
    127128    if (vecy[0].elements.Flt[BinMax] < value) {
    128129      if (SATURATE) {
    129         _threshold_set_values (vecy[0].elements.Flt[BinMax], BinMax, vecx[0].elements.Flt[BinMax]);
     130        _threshold_set_values (vecy[0].elements.Flt[BinMax], BinMax, vecx[0].elements.Flt[BinMax], 1);
    130131        return TRUE;
    131132      } else {
    132133        gprint (GP_ERR, "ERROR: all values below threshold\n");
    133         _threshold_set_values (NAN, -1, NAN);
     134        _threshold_set_values (NAN, -1, NAN, 1);
    134135        return FALSE;
    135136      }
     
    156157    if (vecy[0].elements.Flt[BinMin] < value) {
    157158      if (SATURATE) {
    158         _threshold_set_values (vecy[0].elements.Flt[BinMin], BinMin, vecx[0].elements.Flt[BinMin]);
     159        _threshold_set_values (vecy[0].elements.Flt[BinMin], BinMin, vecx[0].elements.Flt[BinMin], 1);
    159160        return TRUE;
    160161      } else {
    161162        gprint (GP_ERR, "ERROR: all values below threshold\n");
    162         _threshold_set_values (NAN, -1, NAN);
     163        _threshold_set_values (NAN, -1, NAN, 1);
    163164        return FALSE;
    164165      }
     
    166167    if (vecy[0].elements.Flt[BinMax] > value) {
    167168      if (SATURATE) {
    168         _threshold_set_values (vecy[0].elements.Flt[BinMax], BinMax, vecx[0].elements.Flt[BinMax]);
     169        _threshold_set_values (vecy[0].elements.Flt[BinMax], BinMax, vecx[0].elements.Flt[BinMax], 1);
    169170        return TRUE;
    170171      } else {
    171172        gprint (GP_ERR, "ERROR: all values above threshold\n");
    172         _threshold_set_values (NAN, -1, NAN);
     173        _threshold_set_values (NAN, -1, NAN, 1);
    173174        return FALSE;
    174175      }
     
    219220  }
    220221
    221   _threshold_set_values (y1, Nhi, Xvalue);
     222  _threshold_set_values (y1, Nhi, Xvalue, 0);
    222223  return (TRUE);
    223224}
  • trunk/Ohana/src/opihi/cmd.data/tvcolors.c

    r41341 r42389  
    4141    gprint (GP_ERR, "   f: 0 - 1 defines the scale value for the transition\n");
    4242    gprint (GP_ERR, "   R,G,B: 0 - 1 define the value of the color at the transition point\n");
     43
     44    gprint (GP_ERR, "   There are 5 colormap file format options:\n");
     45    gprint (GP_ERR, "   * file:filename : index Red Green Blue\n");
     46    gprint (GP_ERR, "   * lgcy:filename : index Red Blue Green\n");
     47    gprint (GP_ERR, "   * csvf:filename : index,Red,Green,Blue\n");
     48    gprint (GP_ERR, "   * cetf:filename : fRed,fGreen,fBlue \n");
     49    gprint (GP_ERR, "   * cetr:filename : fRed,fGreen,fBlue \n\n");
     50    gprint (GP_ERR, "   The index value goes from 0.0 to 1.0 and sets transitions (must be monotonic).\n");
     51    gprint (GP_ERR, "   In the CET cases, the index is implicit, with 256 entries expected.\n");
     52    gprint (GP_ERR, "   For cetr: the index is reversed.\n");
     53
    4354    return (FALSE);
    4455  }
  • trunk/Ohana/src/opihi/cmd.data/wd.c

    r41674 r42389  
    115115      Ns = strlen (simple);
    116116      No = 80 - Ns;
    117       strncpy (temp_header.buffer, simple, Ns);
     117      strncpy_nowarn (temp_header.buffer, simple, Ns);
    118118      memset (&temp_header.buffer[Ns], ' ', No);
    119119    }
     
    275275  return (f);
    276276}
    277 
    278 
    279 ///    /* fix up header */
    280 ///    {
    281 ///      static char simple[] = "XTENSION= 'IMAGE  '            / Image extension";
    282 ///      int Ns, No;
    283 ///      Ns = strlen (simple);
    284 ///      No = 80 - Ns;
    285 ///      strncpy (temp_header.buffer, simple, Ns);
    286 ///      memset (&temp_header.buffer[Ns], ' ', No);
    287 ///    }
    288 ///
    289 ///    /* position to end of file to write new extend */
    290 ///    fseeko (f, 0LL, SEEK_END);
    291 ///    nbytes = fwrite (temp_header.buffer, 1, temp_header.datasize, f);
    292 ///    fclose (f);
    293 ///    if (nbytes != temp_header.datasize) {
    294 ///      gprint (GP_ERR, "failed to write file\n");
    295 ///      status = FALSE;
    296 ///      goto done1;
    297 ///    }
    298 ///
    299 ///  }
  • trunk/Ohana/src/opihi/cmd.data/write_vectors.c

    r42127 r42389  
    214214    /* identify type (%NNNNd %NNNNf) */
    215215    for (p2 = p1 + 1; (*p2 == '.') || (*p2 == '-') || (*p2 == '+') || (*p2 == ' ') || isdigit(*p2); p2++);
    216     strncpy (fmtlist[j], p0, p2 - p0 + 1);
     216    strncpy_nowarn (fmtlist[j], p0, p2 - p0 + 1);
    217217    switch (*p2) {
    218218      case 'e':
  • trunk/Ohana/src/opihi/dvo/aregion.c

    r27435 r42389  
    4949  fread (buffer, 1, 48*NDecLines[NBigDec], f);
    5050  for (i = 0; !done && (i < NDecLines[NBigDec]); i++) {
    51     strncpy (temp, &buffer[i*48], 48);
    52     temp[49] = 0;
     51    strncpy_nowarn (temp, &buffer[i*48], 48);
    5352    hstgsc_hms_to_deg (&RA0, &RA1, &DEC0, &DEC1, &temp[7]);
    5453    if (RA1 < RA0) RA1 += 360.0;
  • trunk/Ohana/src/opihi/dvo/coordmosaic.c

    r39233 r42389  
    311311     
    312312      memset (segment, 0, 16); memcpy  (segment, &SEGMENT[i*Nsegment], 4);
    313       snprintf (name, 16, "%s_L_CX%dY%d", segment, XORDER[i], YORDER[i]);
     313      snprintf_nowarn (name, 16, "%s_L_CX%dY%d", segment, XORDER[i], YORDER[i]);
    314314      double xvalue = get_double_variable (name, &found);
    315315      xmask = !found;
    316316     
    317317      memset (segment, 0, 16); memcpy  (segment, &SEGMENT[i*Nsegment], 4);
    318       snprintf (name, 16, "%s_M_CX%dY%d", segment, XORDER[i], YORDER[i]);
     318      snprintf_nowarn (name, 16, "%s_M_CX%dY%d", segment, XORDER[i], YORDER[i]);
    319319      double yvalue = get_double_variable (name, &found);
    320320      ymask = !found;
     
    437437
    438438        int found, xmask, ymask;
    439         snprintf (name, 16, "L_X%dY%d", ix, iy);
     439        snprintf_nowarn (name, 16, "L_X%dY%d", ix, iy);
    440440        double xvalue = get_double_variable (name, &found);
    441441        xmask = !found;
    442442
    443         snprintf (name, 16, "M_X%dY%d", ix, iy);
     443        snprintf_nowarn (name, 16, "M_X%dY%d", ix, iy);
    444444        double yvalue = get_double_variable (name, &found);
    445445        ymask = !found;
  • trunk/Ohana/src/opihi/dvo/elixir.c

    r27611 r42389  
    44int ReadMsg (char *fifo, char **message);
    55
     6# define MY_MAX_PATH 256
     7
    68int elixir (int argc, char **argv) {
    79 
    8   char message[256], cmd[256], ElixirBase[256];
    9   char fifo[256], fifodir[256], msgfile[256];
     10  char message[MY_MAX_PATH], cmd[MY_MAX_PATH], ElixirBase[MY_MAX_PATH];
     11  char fifo[MY_MAX_PATH], fifodir[MY_MAX_PATH], msgfile[MY_MAX_PATH];
    1012  char *answer;
    1113  int N;
     
    3840    return (FALSE);
    3941  }
    40   sprintf (fifo, "%s.msg", ElixirBase);
     42  snprintf_nowarn (fifo, MY_MAX_PATH, "%s.msg", ElixirBase);
    4143  if (!VarConfig ("FIFOS", "%s", fifodir)) {
    4244    gprint (GP_ERR, "FIFOS not in config, using local /tmp\n");
    4345    strcpy (fifodir, "/tmp");
    4446  }
    45   sprintf (fifo, "%s.msg", ElixirBase);
     47  snprintf_nowarn (fifo, MY_MAX_PATH, "%s.msg", ElixirBase);
    4648
    47   sprintf (msgfile, "%s/EMsg.XXXXXX", fifodir);
     49  snprintf_nowarn (msgfile, MY_MAX_PATH, "%s/EMsg.XXXXXX", fifodir);
    4850  if (mkstemp (msgfile) == -1) {
    4951    gprint (GP_ERR, "can't create fifo\n");
    5052    return (FALSE);
    5153  }
    52   sprintf (message, "%s %s", cmd, msgfile);
     54  snprintf_nowarn (message, MY_MAX_PATH, "%s %s", cmd, msgfile);
    5355  unlink (msgfile);
    5456
  • trunk/Ohana/src/opihi/dvo/find_regions.c

    r27435 r42389  
    100100    fread (buffer, 48*NDecLines[NBigDec + j], 1, f);
    101101    for (i = 0; (i < NDecLines[NBigDec + j]); i++) {
    102       strncpy (temp, &buffer[i*48], 48);
    103       temp[49] = 0;
     102      strncpy_nowarn (temp, &buffer[i*48], 48);
    104103      hstgsc_hms_to_deg (&RA0, &RA1, &DEC0, &DEC1, &temp[7]);
    105104      if (RA1 < RA0) RA1 += 360.0;
  • trunk/Ohana/src/opihi/include/dvomath.h

    r42083 r42389  
    125125int           M_unary               PROTO((StackVar *OUT, StackVar *V1, char *op));
    126126int           W_unary               PROTO((StackVar *OUT, StackVar *V1, char *op));
     127int           L_unary               PROTO((StackVar *OUT, StackVar *V1, char *op));
    127128
    128129/* variable handling */
  • trunk/Ohana/src/opihi/include/pcontrol.h

    r36623 r42389  
    341341
    342342void pcontrol_exit (int n);
     343void QuitCheckSystemThread (void);
    343344
    344345// Job   *FindJobByID (IDtype JobID, int *StackID);
  • trunk/Ohana/src/opihi/lib.data/svdcmp.c

    r34088 r42389  
    2323  l = nm = 0;
    2424  ALLOCATE (rv1, float, Nx);
     25
    2526  for (i = 0; i < Nx; i++) {
    2627    l = i + 1;
     
    2930    if (i < Ny) {
    3031      for (k = i; k < Ny; k++) scale += fabs(a[k*Nx + i]);
    31       if (scale) {
     32      if (scale > 0.0) {
    3233        for (k = i; k < Ny; k++) {
    3334          a[k*Nx + i] /= scale;
     
    3536        }
    3637        f = a[i*Nx + i];
    37         g  = -FSIGN(sqrt(s), f);
     38        g = sqrt(s);
     39        if (f > 0.0) { g = -g; }
    3840        h = f*g - s;
    3941        a[i*Nx + i] = f-g;
    4042        if (i != Nx - 1) {
    4143          for (j = l; j < Nx; j++) {
    42             for (s = 0.0, k = i; k < Ny; k++) s += a[k*Nx + i]*a[k*Nx + j];
     44            s = 0.0;
     45            for (k = i; k < Ny; k++) { s += a[k*Nx + i]*a[k*Nx + j]; }
    4346            f = s/h;
    44             for (k = i; k < Ny; k++) a[k*Nx + j] += f*a[k*Nx + i];
     47            for (k = i; k < Ny; k++) { a[k*Nx + j] += f*a[k*Nx + i]; }
    4548          }
    4649        }
    47         for (k = i; k < Ny; k++) a[k*Nx + i] *= scale;
     50        for (k = i; k < Ny; k++) { a[k*Nx + i] *= scale; }
    4851      }
    4952    }
     
    5154    g = s = scale = 0.0;
    5255    if ((i < Ny) && (i != (Nx - 1))) {
    53       for (k = l; k < Nx; k++) scale += fabs(a[i*Nx + k]);
    54       if (scale) {
     56      for (k = l; k < Nx; k++) { scale += fabs(a[i*Nx + k]); }
     57      if (scale > 0.0) {
    5558        for (k = l; k < Nx; k++) {
    5659          a[i*Nx + k] /= scale;
     
    5861        }
    5962        f = a[i*Nx + l];
    60         g = -FSIGN(sqrt(s), f);
     63        g = sqrt(s);
     64        if (f > 0.0) { g = -g; }
    6165        h = f*g - s;
    6266        a[i*Nx + l] = f-g;
    63         for (k = l; k < Nx; k++) rv1[k] = a[i*Nx + k]/h;
     67        for (k = l; k < Nx; k++) { rv1[k] = a[i*Nx + k]/h; }
    6468        if (i != Ny - 1) {
    6569          for (j = l; j < Ny; j++) {
    66             for (s = 0.0, k = l; k < Nx; k++) s += a[j*Nx + k]*a[i*Nx + k];
    67             for (k = l; k < Nx; k++) a[j*Nx + k] += s*rv1[k];
     70            s = 0.0;
     71            for (k = l; k < Nx; k++) { s += a[j*Nx + k]*a[i*Nx + k];}
     72            for (k = l; k < Nx; k++) { a[j*Nx + k] += s*rv1[k]; }
    6873          }
    6974        }
    70         for (k = l; k < Nx; k++) a[i*Nx + k] *= scale;
     75        for (k = l; k < Nx; k++) { a[i*Nx + k] *= scale; }
    7176      }
    7277    }
     
    7681  for (i = Nx - 1; i >= 0; i--) {
    7782    if (i < Nx - 1) {
    78       if (g) {
     83      if (g != 0.0) {
    7984        /* isn't l == n to start?? */
    8085        for (j = l; j < Nx; j++) v[j*Nx + i] = (a[i*Nx + j]/a[i*Nx + l])/g;
    8186        for (j = l; j < Nx; j++) {
    82           for (s = 0.0, k = l; k < Nx; k++) s += a[i*Nx + k]*v[k*Nx + j];
     87          s = 0.0;
     88          for (k = l; k < Nx; k++) s += a[i*Nx + k]*v[k*Nx + j];
    8389          for (k = l; k < Nx; k++) v[k*Nx + j] += s*v[k*Nx + i];
    8490        }
    8591      }
    86       for (j = l; j < Nx; j++) v[i*Nx + j] = v[j*Nx + i] = 0.0;
     92      for (j = l; j < Nx; j++) { v[i*Nx + j] = v[j*Nx + i] = 0.0; }
    8793    }
    8894    v[i*Nx + i] = 1.0;
     
    9399    l = i + 1;
    94100    g = w[i];
    95     if (i < Nx - 1)
    96       for (j = l; j < Nx; j++) a[i*Nx + j] = 0.0;
    97     if (g) {
     101    if (i < Nx - 1) { for (j = l; j < Nx; j++) {a[i*Nx + j] = 0.0; }}
     102    if (g != 0.0) {
    98103      g = 1.0/g;
    99104      if (i != Nx - 1) {
    100105        for (j = l; j < Nx; j++) {
    101           for (s = 0.0, k = l; k < Ny; k++) s += a[k*Nx + i]*a[k*Nx + j];
     106          s = 0.0;
     107          for (k = l; k < Ny; k++) { s += a[k*Nx + i]*a[k*Nx + j];}
    102108          f = (s/a[i*Nx + i])*g;
    103           for (k = i; k < Ny; k++) a[k*Nx + j] += f*a[k*Nx + i];
    104         }
    105       }
    106       for (j = i; j < Ny; j++) a[j*Nx + i] *= g;
     109          for (k = i; k < Ny; k++) { a[k*Nx + j] += f*a[k*Nx + i]; }
     110        }
     111      }
     112      for (j = i; j < Ny; j++) { a[j*Nx + i] *= g; }
    107113    } else {
    108       for (j = i; j < Ny; j++) a[j*Nx + i] = 0.0;
    109     }
    110     ++a[i*Nx + i];
     114      for (j = i; j < Ny; j++) { a[j*Nx + i] = 0.0; }
     115    }
     116    a[i*Nx + i] ++;
    111117  }
    112118
     
    126132        c = 0.0;
    127133        s = 1.0;
    128         for (i = l; i < k; i++) {
     134        for (i = l; i <= k; i++) {
    129135          f = s*rv1[i];
    130136          if (fabs(f)+anorm != anorm) {
     
    160166      f = ((y-z)*(y+z) + (g-h)*(g+h))/(2.0*h*y);
    161167      g = hypot (f, 1.0);
    162       f = ((x-z)*(x+z) + h*((y/(f+FSIGN(g, f)))-h))/x;
     168     
     169      float tmp = g;
     170      if (f < 0.0) { tmp = - tmp; }
     171
     172      f = ((x-z)*(x+z) + h*((y/(f+tmp))-h))/x;
     173
    163174      c = s = 1.0;
    164       for (j = l; j < nm; j++) {
     175      for (j = l; j <= nm; j++) {
    165176        i = j+1;
    166177        g = rv1[i];
     
    184195        z = hypot(f, h);
    185196        w[j] = z;
    186         if (z) {
     197        if (z != 0.0) {
    187198          z = 1.0/z;
    188199          c = f*z;
  • trunk/Ohana/src/opihi/lib.data/svdcmp_bond_new.c

    r29540 r42389  
    6363                        g = 0.0;
    6464                else {
    65                         f = u[i][i+1];
     65                    f = u[i][i+1]; // XXXX this line will overrun the memory of u[][i+1] : i+1
    6666                        g = (f < 0) ? sqrt(s) : -sqrt(s);
    6767                        h = f * g - s;
  • trunk/Ohana/src/opihi/lib.shell/VectorIO.c

    r42126 r42389  
    261261  memset (endptr, ' ', FT_LINE_LENGTH);
    262262
    263   strncpy (endptr, newline, 80);
     263  strncpy_nowarn (endptr, newline, 80);
    264264  endptr += FT_LINE_LENGTH;
    265265
  • trunk/Ohana/src/opihi/lib.shell/evaluate_stack.c

    r42080 r42389  
    6767    if (stack[0].type == ST_VECTOR) {
    6868      /* need to make a copy so we set output value? */
    69       V_unary (&tmp_stack, &stack[0], "=");
     69      if (stack->vector->type == OPIHI_STR) {
     70        L_unary (&tmp_stack, &stack[0], "=");
     71      } else {
     72        V_unary (&tmp_stack, &stack[0], "=");
     73      }
    7074      move_stack (&stack[0], &tmp_stack);
    7175      return (TRUE);
  • trunk/Ohana/src/opihi/lib.shell/expand_vectors.c

    r42080 r42389  
    2828  ALLOCATE (newline, char, NLINE);
    2929
     30  // special case: don't expand vectors in while () statement
     31  char *V0 = thiscomm (line);
     32  if (V0 && !strncmp ("while", V0, strlen(V0))) {
     33      strcpy (newline, line);
     34      free (line);
     35      return (newline);
     36  }
     37  free (V0);
     38
    3039  /* look for form fred[stuff] */
    31   /* skip first word (command) */
    32   L = nextword (line);
     40  if (*line == '(') {
     41    // if line is "(stuff)" then do not skip first word
     42      L = line;
     43  } else {
     44    /* skip first word (command) */
     45    L = nextword (line);
     46  }
    3347  if (L == NULL) {
    3448    free (newline);
     
    3751
    3852  n = L - line;
    39   strncpy (newline, line, n);
     53  strncpy_nowarn (newline, line, n);
    4054  N = newline + n;
    4155  J = 0;
     
    242256
    243257    n = (int) (w - L);
    244     strncpy (N, L, n);
     258    strncpy_nowarn (N, L, n);
    245259    N += n;
    246260    n = strlen (strValue);
    247     strncpy (N, strValue, n);
     261    strncpy_nowarn (N, strValue, n);
    248262    N += n;
    249263    L = q + 1;
     
    260274
    261275  n = strlen (L);
    262   strncpy (N, L, n);
    263   N[n] = 0;
     276  strncpy_nowarn (N, L, n);
    264277  free (line);
    265278  return (newline);
  • trunk/Ohana/src/opihi/lib.shell/stack_math.c

    r42311 r42389  
    17141714  char line[512]; // this is only used to report an error
    17151715  snprintf (line, 512, "error: op %s not defined as unary vector op!", op);
     1716  push_error (line);
     1717  return (FALSE);
     1718
     1719escape:
     1720
     1721  if (V1[0].type == ST_VECTOR_TMP) {
     1722    free (V1[0].vector[0].elements.Ptr);
     1723    free (V1[0].vector);
     1724    V1[0].vector = NULL;
     1725  } 
     1726
     1727  clear_stack (V1);
     1728  return (TRUE);
     1729
     1730}
     1731
     1732// vector string operations
     1733int L_unary (StackVar *OUT, StackVar *V1, char *op) {
     1734
     1735  int Nx = V1[0].vector[0].Nelements;
     1736
     1737  OUT[0].vector = InitVector ();
     1738  OUT[0].type = ST_VECTOR_TMP; /*** <<--- says this is a temporary matrix ***/
     1739
     1740  ResetVector (OUT[0].vector, OPIHI_STR, V1[0].vector[0].Nelements);
     1741  char **Iv =  V1[0].vector[0].elements.Str;
     1742  char **Ov = OUT[0].vector[0].elements.Str;
     1743  if (!strcmp (op, "=")) {
     1744    for (int i = 0; i < Nx; i++) {                     
     1745      Ov[i] = strcreate (Iv[i]);
     1746    }                                                                   
     1747    goto escape;                                                       
     1748  }
     1749
     1750  // free the temp vector if needed
     1751  if (V1[0].type == ST_VECTOR_TMP) {
     1752    // XXX this probably does not free the strings
     1753    free (V1[0].vector[0].elements.Ptr);
     1754    free (V1[0].vector);
     1755    V1[0].vector = NULL;
     1756  } 
     1757
     1758  clear_stack (V1);
     1759
     1760  char line[512]; // this is only used to report an error
     1761  snprintf (line, 512, "error: op %s not defined as unary string vector op!", op);
    17161762  push_error (line);
    17171763  return (FALSE);
  • trunk/Ohana/src/opihi/pantasks/controller_status.c

    r37807 r42389  
    2626  }
    2727
    28   snprintf (command, 1024, "status");
     28  snprintf_nowarn (command, 1024, "status");
    2929  for (i = 1; i < argc; i++) {
    30     snprintf (tmpline, 1024, "%s %s", command, argv[i]);
     30    snprintf_nowarn (tmpline, 1024, "%s %s", command, argv[i]);
    3131    strcpy (command, tmpline);
    3232  }
  • trunk/Ohana/src/opihi/pantasks/pantasks_server.c.in

    r41483 r42389  
    138138  ConfigFree ();
    139139
     140  // XXX this function is currently called by the thread running ListenClients, but
     141  // it should be called by the main above.  have this function trigger the
     142  // thread shutdown
     143
    140144  QuitJobsAndTasksThread(); pthread_join (JobsAndTasksThread, NULL);
    141145  QuitControllerThread();   pthread_join (controllerThread, NULL);
  • trunk/Ohana/src/opihi/pcontrol/CheckSystem.c

    r39457 r42389  
    44static struct timeval lastlive = {0, 0};
    55static RunLevels RunLevel = PCONTROL_RUN_NONE;
     6
     7static int CheckSystemThreadRuns = TRUE;
     8
     9void QuitCheckSystemThread (void) {
     10  CheckSystemThreadRuns = FALSE; 
     11}
     12
    613
    714RunLevels SetRunLevel (RunLevels level) {
     
    6774  gprintInit ();
    6875
    69   while (1) {
     76  while (CheckSystemThreadRuns) {
    7077    // stop here if the user-thread requests (no objects in flight)
    7178    TestCheckPoint ();
  • trunk/Ohana/src/opihi/pcontrol/pcontrol.c.in

    r39457 r42389  
    99# define opihi_rcfile ".pcontrolrc"
    1010
     11# ifdef THREADED 
     12  static pthread_t clientsThread;
     13# endif
     14
    1115/* program-dependent initialization */
    1216void program_init (int *argc, char **argv) {
     
    1418  OHANA_UNUSED_PARAM(argv);
    1519 
    16 # ifdef THREADED 
    17   pthread_t clientsThread;
    18 # endif
    19 
    2020  auto_break = TRUE;
    2121
     
    8383  SetRunLevel (PCONTROL_RUN_HOSTS);
    8484  DownHosts ();
     85
     86  QuitCheckSystemThread(); pthread_join (clientsThread, NULL);
     87
    8588  ConfigFree ();
    86 
    8789  FreeBasic ();
    8890  FreePcontrol ();
  • trunk/Ohana/src/opihi/pcontrol/test/linesize.sh

    r18114 r42389  
    2727
    2828  for i 1 10
    29     job echo $inline7
     29    job echo $inline6
    3030  end
    3131
     
    3434  for i 1 10
    3535    stdout $i -var outline
    36     strlen "$inline7" Nin
     36    strlen "$inline6" Nin
    3737    strlen "$outline" Nout
    3838
  • trunk/Ohana/src/opihi/test/tests.sh

    r41470 r42389  
    5353  for Tj 0 $testscripts:n
    5454    if ($VERBOSE > 1)
    55       echo " running $testscripts:$Tj"
     55      echo " ----- running $testscripts:$Tj -----"
    5656    end
    5757    runtests $testscripts:$Tj     
Note: See TracChangeset for help on using the changeset viewer.