--- freem/src/expr.c	2025/03/22 03:39:23	1.7
+++ freem/src/expr.c	2025/03/22 04:47:18	1.8
@@ -1,5 +1,5 @@
 /*
- *   $Id: expr.c,v 1.7 2025/03/22 03:39:23 snw Exp $
+ *   $Id: expr.c,v 1.8 2025/03/22 04:47:18 snw Exp $
  *    expression parser
  *
  *  
@@ -24,6 +24,9 @@
  *   along with FreeM.  If not, see <https://www.gnu.org/licenses/>.
  *
  *   $Log: expr.c,v $
+ *   Revision 1.8  2025/03/22 04:47:18  snw
+ *   Silently truncate long names in STRING exprs when  evaluates to an obsolete MDC standard
+ *
  *   Revision 1.7  2025/03/22 03:39:23  snw
  *   Fix reverse query polyfill call-in from C side and make NAME exprs silently truncate long names in obsolete MDC dialects
  *
@@ -366,8 +369,23 @@ scan_name:
                     merr_raise (INVEXPR);
                     return;
                 }
-                
-                varnam[i++] = ch;
+
+                if ((i + 1) <= max_namlen) {
+                    varnam[i++] = ch;
+                }
+                else {
+                    if ((rtn_dialect () == D_M77) ||
+                        (rtn_dialect () == D_M84) ||
+                        (rtn_dialect () == D_M90) ||
+                        (rtn_dialect () == D_M95)) {
+                        /* silently truncate... yeah, the standard is stupid af */
+                        continue;
+                    }
+                    else {
+                        merr_raise (M56);
+                        return;
+                    }
+                }                
 
                 lastch = ch;
             }
@@ -383,7 +401,24 @@ scan_name:
         else {          /* local variable name */
 
             while (isalnum (ch = *++codptr)) {
-                varnam[i++] = ch;
+                
+                if ((i + 1) <= max_namlen) {
+                    varnam[i++] = ch;
+                }
+                else {
+                    if ((rtn_dialect () == D_M77) ||
+                        (rtn_dialect () == D_M84) ||
+                        (rtn_dialect () == D_M90) ||
+                        (rtn_dialect () == D_M95)) {
+                        /* silently truncate... yeah, the standard is stupid af */
+                        continue;
+                    }
+                    else {
+                        merr_raise (M56);
+                        return;
+                    }
+                }                
+                
             }
         
             varnam[i] = EOL;