Annotation of freem/src/symtab_dispatch.c, revision 1.6

1.1       snw         1: /*
1.6     ! snw         2:  *   $Id: symtab_dispatch.c,v 1.5 2025/04/13 04:22:43 snw Exp $
1.1       snw         3:  *    symbol table dispatch module
                      4:  *
                      5:  *  
1.2       snw         6:  *   Author: Serena Willis <snw@coherent-logic.com>
1.1       snw         7:  *    Copyright (C) 1998 MUG Deutschland
1.3       snw         8:  *    Copyright (C) 2020, 2025 Coherent Logic Development LLC
1.1       snw         9:  *
                     10:  *
                     11:  *   This file is part of FreeM.
                     12:  *
                     13:  *   FreeM is free software: you can redistribute it and/or modify
                     14:  *   it under the terms of the GNU Affero Public License as published by
                     15:  *   the Free Software Foundation, either version 3 of the License, or
                     16:  *   (at your option) any later version.
                     17:  *
                     18:  *   FreeM is distributed in the hope that it will be useful,
                     19:  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
                     20:  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     21:  *   GNU Affero Public License for more details.
                     22:  *
                     23:  *   You should have received a copy of the GNU Affero Public License
                     24:  *   along with FreeM.  If not, see <https://www.gnu.org/licenses/>.
                     25:  *
1.4       snw        26:  *   $Log: symtab_dispatch.c,v $
1.6     ! snw        27:  *   Revision 1.5  2025/04/13 04:22:43  snw
        !            28:  *   Fix snprintf calls
        !            29:  *
1.5       snw        30:  *   Revision 1.4  2025/03/27 03:27:35  snw
                     31:  *   Install init scripts to share/freem/examples/init and fix regression in method dispatch
                     32:  *
1.4       snw        33:  *   Revision 1.3  2025/03/09 19:50:47  snw
                     34:  *   Second phase of REUSE compliance and header reformat
                     35:  *
1.3       snw        36:  *
                     37:  * SPDX-FileCopyrightText:  (C) 2025 Coherent Logic Development LLC
                     38:  * SPDX-License-Identifier: AGPL-3.0-or-later
1.1       snw        39:  **/
                     40: 
                     41: #include <string.h>
                     42: #include <ctype.h>
                     43: #include "mpsdef.h"
                     44: #include "mref.h"
                     45: #include "objects.h"
                     46: 
                     47: void symtab (short action, char *key, char *data)
                     48: {
                     49:     register int i;
                     50:     register int j;
                     51:     char ch;
                     52: 
                     53:     short res;
                     54:     char obj_class[255];
                     55:     char t_rou[255];
                     56:     char t_cls[255];
                     57:     
                     58:     freem_ref_t rv;
                     59:     freem_ref_t *r = &rv;
                     60: 
                     61:     mref_init (r, MREF_RT_LOCAL, "");
                     62:     internal_to_mref (r, key);
                     63: 
1.6     ! snw        64:     /*
1.1       snw        65:     res = obj_is_object (r->name);    
                     66: 
                     67:     if (res == TRUE) {
                     68:         res = obj_get_attribute (r->name, "CLASS", obj_class);
                     69:         stcpy (t_rou, rou_name);
                     70:         stcnv_m2c (t_rou);
                     71:         strcpy (t_cls, &(obj_class[1]));
                     72:         
                     73:         if ((strcmp (t_rou, t_cls) != 0) && (obj_is_field_private (key) == TRUE)) {
                     74:             merr_raise (OBJFLDACCV);
                     75:             return;
                     76:         }        
                     77: 
                     78:         if (r->subscript_count == 0 && action == kill_sym) {
                     79:             
1.5       snw        80:             if (destructor_ct < 10) {                
                     81:                 snprintf (destructors[destructor_ct++], OBJ_DSTRSIZE - 1, "DESTROY^%%SYSOOP(\"%s\",.%s)", t_cls, r->name);
1.1       snw        82:             }
                     83:             
                     84:             obj_destroy (key);
                     85:             
                     86:         }
                     87:         
1.6     ! snw        88:     }
        !            89:     */
1.1       snw        90:     
                     91:     if (action != fra_order && action != fra_query) {
                     92:         for (i = 0; i < r->subscript_count; i++) {
                     93:             
                     94:             if (strlen (r->subscripts[i]) < 1) {
                     95:                 merr_raise (SBSCR);
                     96:                 return;
                     97:             }
                     98:             
                     99:         }
                    100:     }
                    101: 
                    102:     if (rtn_dialect () == D_M77) {
                    103: 
                    104:         for (i = 0; i < r->subscript_count; i++) {
                    105:             for (j = 0; j < strlen (r->subscripts[i]); j++) {
                    106: 
                    107:                 ch = r->subscripts[i][j];
                    108: 
                    109:                 if (!isdigit (ch)) {
                    110:                     merr_raise (NOSTAND);
                    111:                     return;
                    112:                 }
                    113:                 
                    114:             }
                    115:         }
                    116: 
                    117:     }
                    118: 
                    119:     symtab_bltin (action, key, data);
                    120:     
                    121: }

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