IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 41388


Ignore:
Timestamp:
Jul 7, 2020, 9:33:22 AM (6 years ago)
Author:
eugene
Message:

correctly handle if,else where logic is not 0 or 1; catch repeated else-blocks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/cmd.basic/run_if.c

    r31667 r41388  
    55
    66  int ThisList, depth, done, status, InlineCommand;
    7   int i, length, logic;
     7  int i, length, logic, foundElse;
    88  char *input, *val, *line;
    99  int nloop, size;
     
    6060  ThisList = current_list_depth();
    6161
     62  foundElse = FALSE;
    6263  done = FALSE;
    6364  while (!done) {
     
    9192    /* check for an "else", invert logic */
    9293    if ((depth == 0) && !strncasecmp (input, "ELSE", 4)) {
    93       logic ^= TRUE;
     94      logic = !logic;
    9495      free (input);
     96
     97      if (foundElse) {
     98        gprint (GP_ERR, "multiple 'ELSE' statements in if-block with 'END'\n");
     99        return FALSE;
     100      }
     101      foundElse = TRUE;
    95102      continue;
    96103    }
Note: See TracChangeset for help on using the changeset viewer.