IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 2792


Ignore:
Timestamp:
Dec 22, 2004, 1:23:23 PM (22 years ago)
Author:
eugene
Message:

fixing dvomath for strings

Location:
trunk/Ohana
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/doc/elixir-cvs.txt

    r2632 r2792  
    5454Ohana scripts.  I have modified sp_plot and el_plot to use 'dvo'
    5555instead.  I have also modified elixir.photreport. 
     56
     57---
     58
     59Working with Elixir / Ohana and CVS:
     60
     61The CVS repositories allows the developer to work on a copy of the
     62Ohana software, make changes to their copy of the code, test the
     63changes within their own version of the Elixir configuration system,
     64share the changes with other developers, and freeze a tested, working
     65snapshot of portions of the software.
     66
     67The Ohana software tree is divided into packages, each possibly
     68containing a single program, a group of related programs, or a C
     69library.  Within the Ohana software version control system, each of
     70these packages should be released as a single entity.  Changes may be
     71made to any of the elements which make up the package.  The new
     72changes should be tested so that the developer is confident that the
     73new version of the software may be safely introduced into the
     74production system.  At this point, the entire package is tagged with
     75an identifying name and the new release of the package may be loaded
     76into the production tree.
     77
     78In the following discussion, we illustrate the process of creating a
     79new release of a package within Elixir.
     80
     81First, check out the Ohana tree:
     82
     83set CVSROOT to username@machine:/data/elixir2/srcdir/cvs where
     84'username' is your user ID and machine is one of the CFHT linux
     85machines which mount /data/elixir2/srcdir. 
     86
     87check out your copy of the software tree:
     88
     89 cvs co ohana
     90
     91you may also check out specific releases of packages with the command:
     92 cvs co -r TAG PACKAGE  eg:
     93 cvs co -r libfits-1-0 libfits
     94
     95this version should be executed from the same directory level as the
     96cvs co ohana command; each package is placed in the directory
     97ohana/src/PACKAGE.
     98
     99The entire ohana package may be compiled from the ohana directory
     100with:
     101
     102> configure
     103> make
     104> make install
     105
     106Make edits, changes, etc to the programs in some package.  For
     107example, you might edit the .c files in the directory
     108ohana/src/gastro/src.  Occasionally publish your changes to the CVS
     109repository:
     110
     111cvs update (check for changes by other developers)
     112cvs commit [filename] (publish the changes)
     113
     114also:
     115
     116cvs add (filename)  (add a new file to the repository). 
     117
     118Once the changes have been made, make sure to compile and test your
     119copy of the program.  If you are acting as a developer, you must have
     120your version of the ohana/bin/ARCH directory in your path (before the
     121production installation path, /apps/elixir/bin).  Once the code has
     122been tested, and the package is ready for release, commit all of your
     123changes to the repository (cvs commit).  Now you may tag the new
     124release of the package.  Within the top-level directory of the
     125package, give the command:
     126
     127cvs tag -c TAG
     128
     129where TAG is the name of this release.  Within the Ohana system,
     130packages are generally tagged with names of the form PACKAGE-N-M where
     131N and M are major and minor version numbers.  For example, libfits has
     132tag names starting from libfits-1-0.  If the changes are minor, and
     133don't affect interaction with other packages, then it is only
     134necessary to change the minor version number.  If the new package
     135forces changes on other packages, it is best to change the major
     136version as well.  Major version changes should be introduced only with
     137discussion among the affected parties!   It is possible to check the
     138currenly assigned tags for a package with the command:
     139cvs status -v (filename)
     140where (filename) is some file that is part of the package.  A
     141convenient file to use is the Makefile for the package.  Assigning the
     142tag affects the repository directly (there is no need to run 'commit'
     143afterwards).  If you have outstanding changes, the -c option will
     144force CVS to complain, so you will not tag different versions of the
     145files from what you expect.
     146
     147Once the tag has been assigned, the new version of the package may be
     148introduced to the production system. This is a two step process:
     149first the new source tree is placed in the appropriate location and
     150compiled.  Then the new binaries are pushed to their final locations.
     151There are two options for installing the new package source code.
     152First, you may make a new elixir distribution.  To do this, go into
     153the ohana/etc directory, and edit the distributions.txt file.  This
     154defines the package releases which make up a complete distribution.
     155There are entries for the ohana/elixir distributions, mana
     156distributions, etc.  Make a new distribution version, update the
     157appropriate package, and save the file.  This distribution (or any
     158other older distribution) may now be constructed by executing the
     159command 'mkdist (distribution) (version)', for example:
     160mkdist elixir 1.0
     161This command extracts from the CVS repository all of the package
     162versions which are specified to be part of the given distribution
     163version.  These are placed in a single directory, along with the ohana
     164infrastructure pieces, with the directory name matching the package
     165name and version number.  This new directory may be moved or copied to
     166the official production source code location
     167(/data/elixir2/srcdir/ohana).  The entire tree may then be compiled. 
     168
     169An alternative to the above is to checkout only the new package
     170version.  To do this, go to the directory containing the production
     171code (ie, /data/elixir2/srcdir).  Perform a checkout of the specific
     172tagged release of the package of interest:
     173cvs co -r TAG PACKAGE (ie, cvs co -r libfits-1-0 libfits).  This will
     174replace the old version of the package with the new version.  Now the
     175software may be recompiled from the ohana directory.
     176
     177Once a new version of the software has been compiled, it may be pushed
     178to the production binary directory.  From the /data/elixir2/srcdir
     179directory, issue the command 'make install' (make install-test will
     180show what programs are new).
     181
  • trunk/Ohana/src/opihi/cmd.basic/run_if.c

    r2598 r2792  
    3030  /* determine value of conditional expression */
    3131  val = dvomath (1, &argv[1], &size, 0);
    32   if (val == NULL) { /* try expression as string op string */
    33     char **stack;
    34     int Nstack;
     32  if (val == NULL) return (FALSE);
     33  logic = atof (val); /* warning: round-off error is a danger */
    3534
    36     stack = isolate_elements (1, &argv[1], &Nstack);
    37     if (Nstack != 5) goto syntax;
    38     if (strcmp (stack[0], "(")) goto syntax;
    39     if (strcmp (stack[4], ")")) goto syntax;
    40     equals = -1;
    41     if (!strcmp (stack[2], "==")) equals = TRUE;
    42     if (!strcmp (stack[2], "!=")) equals = TRUE;
    43     if (equals == -1) goto syntax;
    44     logic = FALSE;
    45     if (equals && !strcmp (stack[1], stack[3])) logic = TRUE;
    46     if (!equals && strcmp (stack[1], stack[3])) logic = TRUE;
    47   } else {
    48     logic = atof (val); /* warning: round-off error is a danger */
    49   }
    5035  if (BreakOnTrue) {
    5136    if (logic) {
  • trunk/Ohana/src/opihi/include/dvomath.h

    r2598 r2792  
    5050char        **isolate_elements      PROTO((int argc, char **argv, int *nstack));
    5151StackVar     *convert_to_RPN        PROTO((int argc, char **argv, int *nstack));
    52 int           check_stack           PROTO((StackVar *stack, int Nstack));
     52int           check_stack           PROTO((StackVar *stack, int Nstack, int validsize));
    5353int           evaluate_stack        PROTO((StackVar *stack, int *Nstack));
    5454void          init_stack            PROTO((StackVar *stack));
  • trunk/Ohana/src/opihi/lib.shell/check_stack.c

    r2598 r2792  
    11# include "opihi.h"
    22
    3 int check_stack (StackVar *stack, int Nstack) {
     3int check_stack (StackVar *stack, int Nstack, int validsize) {
    44
    5   int i, Nx, Ny, Nv;
     5  int i, Nx, Ny, Nv, size;
    66  char *c, line[128];
    77
     
    1010  for (i = 0; i < Nstack; i++) {
    1111    if (stack[i].type == 'X') {
     12
    1213      /** if this is a number, put it on the list of scalers and move on **/
    1314      stack[i].Float = strtod (stack[i].name, &c);
     
    1718        continue;
    1819      }
     20
     21      /** if we demand a scalar, interpret strings as strings */
     22      if (validsize == 0) {
     23        stack[i].type  = 'W';
     24        continue;
     25      }
     26       
    1927      /** if this is a matrix, find the dimensions and check with existing values **/
    2028      if (IsBuffer (stack[i].name)) {
     
    3846        continue;
    3947      }
     48
    4049      /** if this is a vector, find the dimensions and check with existing values **/
    4150      if (IsVector (stack[i].name)) {
     
    6372  }
    6473
    65   /* we return a value which is 1 greater than the object dimension */
    66   if (Nx != -1) return (2);
    67   if (Nv != -1) return (1);
    68   return (0);
     74  /* return object dimensions */
     75  size = 0;
     76  if (Nv != -1) size = 1;
     77  if (Nx != -1) size = 2;
     78  if (validsize == -1)   return (size);
     79  if (validsize != size) return (-1);
     80  return (size);
    6981}
  • trunk/Ohana/src/opihi/lib.shell/dvomath.c

    r2598 r2792  
    2222
    2323  /* distinguish scalar, vector, matrix, check dimensions */
    24   *size = check_stack (stack, Nstack);
    25   if ((validsize != -1) && (validsize != *size)) goto error;
     24  *size = check_stack (stack, Nstack, validsize);
    2625  if (*size < 0) goto error;
    2726
  • trunk/Ohana/src/opihi/lib.shell/evaluate_stack.c

    r2598 r2792  
    2626      return (TRUE);
    2727    }
    28     fprintf (stderr, "syntax error!\n");
     28    push_error ("syntax error!");
    2929    free (tmp_stack.name);
    3030    return (FALSE);
     
    5454        return (FALSE);
    5555      }
     56
     57      /* this could be macro generated... */
     58      # define TWO_OP(A,B,FUNC) \
     59      if (!strncasecmp (&stack[i - 2].type, A, 1) && !strncasecmp (&stack[i - 1].type, B, 1)) \
     60        status = FUNC (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name);
     61
     62      TWO_OP ("M","M",MM_binary);
     63      TWO_OP ("M","V",MV_binary);
     64      TWO_OP ("M","S",MS_binary);
     65      TWO_OP ("V","M",VM_binary);
     66      TWO_OP ("V","V",VV_binary);
     67      TWO_OP ("V","S",VS_binary);
     68      TWO_OP ("S","M",SM_binary);
     69      TWO_OP ("S","V",SV_binary);
     70      TWO_OP ("S","S",SS_binary);     
     71      TWO_OP ("W","W",WW_binary);     
     72     
     73      /*
    5674      if (!strncasecmp (&stack[i - 2].type, "V", 1) && !strncasecmp (&stack[i - 1].type, "V", 1))
    5775        status = VV_binary (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name);
     
    7290      if (!strncasecmp (&stack[i - 2].type, "S", 1) && !strncasecmp (&stack[i - 1].type, "S", 1))
    7391        status = SS_binary (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name);
     92      if (!strncasecmp (&stack[i - 2].type, "X", 1) && !strncasecmp (&stack[i - 1].type, "X", 1))
     93        status = XX_binary (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name);
     94      */
     95
     96      /* string op number is not valid */
     97      if (!strncasecmp (&stack[i - 2].type, "W", 1) && strncasecmp (&stack[i - 1].type, "W", 1)) {
     98        free (tmp_stack.name);
     99        return (FALSE);
     100      }
     101      if (strncasecmp (&stack[i - 2].type, "W", 1) && !strncasecmp (&stack[i - 1].type, "W", 1)) {
     102        free (tmp_stack.name);
     103        return (FALSE);
     104      }
     105
    74106      if (!status) {
    75107        free (tmp_stack.name);
     
    102134      if (!strncasecmp (&stack[i - 1].type, "S", 1))
    103135        S_unary (&tmp_stack, &stack[i - 1], stack[i].name);
     136
     137      /* there are no valid unary string operators */
     138      if (!strncasecmp (&stack[i - 1].type, "W", 1)) {
     139        fprintf (stderr, "syntax error\n");
     140        free (tmp_stack.name);
     141        return (FALSE);
     142      }
    104143
    105144      move_stack (&stack[i-1], &tmp_stack);
  • trunk/Ohana/src/opihi/lib.shell/expand_vectors.c

    r2598 r2792  
    3737      ALLOCATE (val, char, 64);
    3838      sprintf (val, "-1");
     39      /* this choice of sentinel prevents us from using
     40         x[-1], x[-2], and is not really needed */
    3941    } else {
    4042      strncpy (tmpline, p+1, n);
    4143      tmpline[n] = 0;
    4244      val = dvomath (1, &tmpline, &size, 0);
    43       if (val == NULL) goto dumpline; /* not really a vector */
     45      if (val == NULL) goto dumpline; /* not a valid vector subscript */
    4446    }
    4547    /* find vector name */
  • trunk/Ohana/src/opihi/lib.shell/parse.c

    r2598 r2792  
    5656    if (*V1 == 0) goto error;
    5757
    58     /* command replacement.  execute the line, place answer in val. */
    5958    if (*V1 == '`') {
     59      /* command replacement.  execute the line, place answer in val. */
    6060
    6161      /* look for end of line, must be ` */
  • trunk/Ohana/src/opihi/lib.shell/stack_math.c

    r2598 r2792  
    10431043
    10441044}
     1045
     1046int WW_binary (StackVar *OUT, StackVar *V1, StackVar *V2, char *op) {
     1047
     1048  int value;
     1049 
     1050  switch (op[0]) {
     1051  case 'E':
     1052    value = strcmp (V1[0].name, V2[0].name) ? 0 : 1;
     1053    break;
     1054  case 'N':
     1055    value = strcmp (V1[0].name, V2[0].name) ? 1 : 0;
     1056    break;
     1057  default:
     1058    fprintf (stderr, "error: op %c not valid\n", op[0]);
     1059  }
     1060
     1061  strcpy (OUT[0].name, "tmp");
     1062  OUT[0].Float = value;
     1063  OUT[0].type = 'S';
     1064  OUT[0].ptr = &OUT[0].Float;
     1065  return (TRUE);
     1066
     1067}
     1068
    10451069
    10461070int S_unary (StackVar *OUT, StackVar *V1, char *op) {
Note: See TracChangeset for help on using the changeset viewer.