Diff for /freem/src/operator.c between versions 1.3 and 1.11

version 1.3, 2025/02/28 20:51:20 version 1.11, 2025/05/05 23:09:19
Line 1 Line 1
 /*  /*
  *                            *   *   $Id$
  *                           * *  
  *                          *   *  
  *                     ***************  
  *                      * *       * *  
  *                       *  MUMPS  *  
  *                      * *       * *  
  *                     ***************  
  *                          *   *  
  *                           * *  
  *                            *  
  *  
  *   operator.c  
  *    operators pattern-match, divide, multiply, add, power   *    operators pattern-match, divide, multiply, add, power
  *   *
  *     *  
  *   Author: Serena Willis <jpw@coherent-logic.com>   *   Author: Serena Willis <snw@coherent-logic.com>
  *    Copyright (C) 1998 MUG Deutschland   *    Copyright (C) 1998 MUG Deutschland
  *    Copyright (C) 2020 Coherent Logic Development LLC   *    Copyright (C) 2020, 2025 Coherent Logic Development LLC
  *   *
  *   *
  *   This file is part of FreeM.   *   This file is part of FreeM.
Line 35 Line 23
  *   You should have received a copy of the GNU Affero Public License   *   You should have received a copy of the GNU Affero Public License
  *   along with FreeM.  If not, see <https://www.gnu.org/licenses/>.   *   along with FreeM.  If not, see <https://www.gnu.org/licenses/>.
  *   *
    *   $Log$
    *   Revision 1.11  2025/05/05 23:09:19  snw
    *   Revert errors in E notation parsing
    *
    *   Revision 1.10  2025/05/05 23:02:39  snw
    *   More fixes around E notation
    *
    *   Revision 1.9  2025/05/05 22:52:32  snw
    *   Make E notation error message more appropriate
    *
    *   Revision 1.8  2025/05/05 19:34:46  snw
    *   Fix E notation code to disallow more than one minus sign after the E
    *
    *   Revision 1.7  2025/04/10 01:24:38  snw
    *   Remove C++ style comments
    *
    *   Revision 1.6  2025/04/09 19:52:02  snw
    *   Eliminate as many warnings as possible while building with -Wall
    *
    *   Revision 1.5  2025/03/09 19:50:47  snw
    *   Second phase of REUSE compliance and header reformat
    *
    *
    * SPDX-FileCopyrightText:  (C) 2025 Coherent Logic Development LLC
    * SPDX-License-Identifier: AGPL-3.0-or-later
  **/   **/
   
 #include "mpsdef.h"  #include "mpsdef.h"
 #include <stdlib.h>  #include <stdlib.h>
 #include <math.h>  #include <math.h>
   #include <ctype.h>
   
 int unit (char *str);  int unit (char *str);
 extern void cond_round (char *a, int digits); /* defined in expr.c */  extern void cond_round (char *a, int digits); /* defined in expr.c */
Line 801  void add (char *a, char *b)    /* string Line 815  void add (char *a, char *b)    /* string
                 mi = 1;                  mi = 1;
                 a[0] = ZERO;                  a[0] = ZERO;
             }              }
             while (a[mi] == ZERO) {              while (a[(int) mi] == ZERO) {
                 stcpy (&a[mi], &a[mi + 1]);                  stcpy (&a[(int) mi], &a[((int) mi) + 1]);
                 dpa--;                  dpa--;
             }              }
             if (dpa < 0)              if (dpa < 0)
Line 830  void add (char *a, char *b)    /* string Line 844  void add (char *a, char *b)    /* string
             }              }
             a[0] = MINUS;              a[0] = MINUS;
         }          }
         if (a[mi] == EOL) {          if (a[(int) mi] == EOL) {
             a[0] = ZERO;              a[0] = ZERO;
             a[1] = EOL;              a[1] = EOL;
         }          }
Line 1128  void mdiv (char *uu, char *v, short typ) Line 1142  void mdiv (char *uu, char *v, short typ)
   
             case '#':              case '#':
                 snprintf (uu, STRLEN - 1, "%ld\201", (((long) fp_uu) % ((long) fp_v)));                  snprintf (uu, STRLEN - 1, "%ld\201", (((long) fp_uu) % ((long) fp_v)));
                 //snprintf (uu, STRLEN - 1, "%ld\201", ((long) fp_uu < 0 ? (((long) fp_uu % (long) fp_v) + (long) fp_v) % (long) fp_v : (long) fp_uu % (long) fp_v));                  /*snprintf (uu, STRLEN - 1, "%ld\201", ((long) fp_uu < 0 ? (((long) fp_uu % (long) fp_v) + (long) fp_v) % (long) fp_v : (long) fp_uu % (long) fp_v)); */
                 break;                  break;
         }          }
                   
Line 1972  int numlit (char *str) Line 1986  int numlit (char *str)
             }              }
             continue;              continue;
         }          }
         if (expflg) {          if (expflg) {            
             if (ch == MINUS) {              if (ch == MINUS) {
                   /* TODO: revisit this; it breaks string coercion
                   if (str[i + 1] == '-') {                    
                       merr_raise (INVEXPR);
                       return (0);
                   }
                   if (!isdigit (str[i + 1])) {
                       merr_raise (INVEXPR);
                       return (0);
                   }
                   */
                 expflg = (-expflg);                  expflg = (-expflg);
                 continue;                  continue;
             }              }
             if (ch == PLUS)              if (ch == PLUS) {
                   /* TODO: revisit this; it breaks string coercion
                   if (str[i + 1] == '+') {
                       merr_raise (INVEXPR);
                       return (0);
                   }
                   if (!isdigit (str[i + 1])) {
                       merr_raise (INVEXPR);
                       return (0);
                   }
                   */
                 continue;                  continue;
               }
         }          }
         if ((result = unit (&str[i])))          if ((result = unit (&str[i])))
             ch = str[i] = EOL;              ch = str[i] = EOL;

Removed from v.1.3  
changed lines
  Added in v.1.11


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>