--- freem/src/operator.c 2025/04/10 01:24:38 1.7
+++ freem/src/operator.c 2025/05/05 23:02:39 1.10
@@ -1,5 +1,5 @@
/*
- * $Id: operator.c,v 1.7 2025/04/10 01:24:38 snw Exp $
+ * $Id: operator.c,v 1.10 2025/05/05 23:02:39 snw Exp $
* operators pattern-match, divide, multiply, add, power
*
*
@@ -24,6 +24,15 @@
* along with FreeM. If not, see .
*
* $Log: operator.c,v $
+ * 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
*
@@ -41,6 +50,7 @@
#include "mpsdef.h"
#include
#include
+#include
int unit (char *str);
extern void cond_round (char *a, int digits); /* defined in expr.c */
@@ -1975,11 +1985,28 @@ int numlit (char *str)
}
if (expflg) {
if (ch == MINUS) {
+ if (str[i + 1] == '-') {
+ merr_raise (INVEXPR);
+ return (0);
+ }
+ if (!isdigit (str[i + 1])) {
+ merr_raise (INVEXPR);
+ return (0);
+ }
expflg = (-expflg);
continue;
}
- if (ch == PLUS)
+ if (ch == PLUS) {
+ if (str[i + 1] == '+') {
+ merr_raise (INVEXPR);
+ return (0);
+ }
+ if (!isdigit (str[i + 1])) {
+ merr_raise (INVEXPR);
+ return (0);
+ }
continue;
+ }
}
if ((result = unit (&str[i])))
ch = str[i] = EOL;