IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 16, 2007, 2:27:00 PM (18 years ago)
Author:
eugene
Message:

fixed cases of hard-wired line length; some api cleanup in stack_math

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/lib.shell/isolate_elements.c

    r10073 r15878  
    88
    99/* local private static variables */
    10 int Nchar, Nout, NOUT;
    11 char **out;
     10int NCHAR, Nchar, Nout, NOUT;
     11char **myOutput;
    1212
    1313char **isolate_elements (int Nin, char **in, int *nout) {
     
    1717  NOUT = Nin;
    1818  Nchar = Nout = 0;
    19   ALLOCATE (out, char *, NOUT);
    20   ALLOCATE (out[Nout], char, NCHARS);
     19  NCHAR = 256;
     20  ALLOCATE (myOutput, char *, NOUT);
     21  ALLOCATE (myOutput[Nout], char, NCHAR);
    2122
    2223  for (i = 0; i < Nin; i++) {
     
    3536        /* check previous entry on line */
    3637        if (Nchar) {
    37           OpStat = IsAnOp (out[Nout]);
    38           if (out[Nout][0] == ')') OpStat = FALSE;
     38          OpStat = IsAnOp (myOutput[Nout]);
     39          if (myOutput[Nout][0] == ')') OpStat = FALSE;
    3940        } else {
    40           OpStat = IsAnOp (out[Nout-1]);
    41           if (out[Nout-1][0] == ')') OpStat = FALSE;
     41          OpStat = IsAnOp (myOutput[Nout-1]);
     42          if (myOutput[Nout-1][0] == ')') OpStat = FALSE;
    4243        }
    4344        /* if - follows an operator, must be negator */
     
    6768        /* check previous entry on line */
    6869        if (Nchar) {
    69           OpStat = IsAnOp (out[Nout]);
    70           if (out[Nout][0] == ')') OpStat = FALSE;
     70          OpStat = IsAnOp (myOutput[Nout]);
     71          if (myOutput[Nout][0] == ')') OpStat = FALSE;
    7172        } else {
    72           OpStat = IsAnOp (out[Nout-1]);
    73           if (out[Nout-1][0] == ')') OpStat = FALSE;
     73          OpStat = IsAnOp (myOutput[Nout-1]);
     74          if (myOutput[Nout-1][0] == ')') OpStat = FALSE;
    7475        }
    7576        /* if + follows an operator, must be posator */
     
    9192        if (posate) continue;
    9293        EndOfString ();
    93         /* copy operator to out[Nout] */
     94        /* copy operator to myOutput[Nout] */
    9495        InsertValue (in[i][j]);
    9596        if (negate) InsertValue ('-');
     
    131132
    132133  /* one extra entry is allocated, free here */
    133   free (out[Nout]);
     134  free (myOutput[Nout]);
    134135  *nout = Nout;
    135   return (out);
     136  return (myOutput);
    136137
    137138}
    138139
    139140void InsertValue (char c) {
    140   out[Nout][Nchar] = c;
     141  myOutput[Nout][Nchar] = c;
    141142  Nchar ++;
    142   out[Nout][Nchar] = 0;
     143  if (Nchar >= NCHAR - 2) {
     144    NCHAR += 256;
     145    REALLOCATE (myOutput[Nout], char, NCHAR);
     146  }
     147  myOutput[Nout][Nchar] = 0;
    143148}
    144149
    145150void EndOfString () {
    146151  if (Nchar > 0) {
    147     out[Nout][Nchar] = 0;
     152    myOutput[Nout][Nchar] = 0;
    148153    Nout ++;
    149154    Nchar = 0;
     
    151156    if (Nout >= NOUT - 1) {
    152157      NOUT += 10;
    153       REALLOCATE (out, char *, NOUT);
     158      REALLOCATE (myOutput, char *, NOUT);
    154159    }
    155     ALLOCATE (out[Nout], char, NCHARS);
     160    NCHAR = 256;
     161    ALLOCATE (myOutput[Nout], char, NCHAR);
    156162  }
    157163}
Note: See TracChangeset for help on using the changeset viewer.