Diff for /freem/src/objects.c between versions 1.2 and 1.6

version 1.2, 2025/03/09 15:20:18 version 1.6, 2025/04/13 04:22:43
Line 1 Line 1
 /*  /*
  *                            *   *   $Id$
  *                           * *  
  *                          *   *  
  *                     ***************  
  *                      * *       * *  
  *                       *  MUMPS  *  
  *                      * *       * *  
  *                     ***************  
  *                          *   *  
  *                           * *  
  *                            *  
  *  
  *   objects.c  
  *    implementation of OO support   *    implementation of OO support
  *   *
  *     *  
  *   Author: Serena Willis <snw@coherent-logic.com>   *   Author: Serena Willis <snw@coherent-logic.com>
  *    Copyright (C) 1998 MUG Deutschland   *    Copyright (C) 1998 MUG Deutschland
  *    Copyright (C) 2023 Coherent Logic Development LLC   *    Copyright (C) 2023, 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.6  2025/04/13 04:22:43  snw
    *   Fix snprintf calls
    *
    *   Revision 1.5  2025/04/10 01:24:38  snw
    *   Remove C++ style comments
    *
    *   Revision 1.4  2025/04/09 19:52:02  snw
    *   Eliminate as many warnings as possible while building with -Wall
    *
    *   Revision 1.3  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 <string.h>  #include <string.h>
 #include <stdlib.h>  #include <stdlib.h>
Line 123  void obj_set_attribute(char *inst, char Line 127  void obj_set_attribute(char *inst, char
     char t_key[255];      char t_key[255];
     char t_data[255];      char t_data[255];
   
     snprintf (t_key, 254, "^$OBJECT\202%s\202%s\201", inst, attrib);      snprintf (t_key, sizeof (t_key) - 1, "^$OBJECT\202%s\202%s\201", inst, attrib);
     snprintf (t_data, 254, "%s\201", value);      snprintf (t_data, sizeof (t_data) - 1, "%s\201", value);
   
     symtab_bltin (set_sym, t_key, t_data);      symtab_bltin (set_sym, t_key, t_data);
 }  }
Line 133  short obj_get_attribute(char *inst, char Line 137  short obj_get_attribute(char *inst, char
 {  {
     char t_key[255];      char t_key[255];
   
     snprintf (t_key, 254, "^$OBJECT\202%s\202%s\201", inst, attrib);      snprintf (t_key, sizeof (t_key) - 1, "^$OBJECT\202%s\202%s\201", inst, attrib);
   
     symtab_bltin (get_sym, t_key, buf);      symtab_bltin (get_sym, t_key, buf);
   
     if (merr () == UNDEF || merr () == M6) {      if (merr () == UNDEF || merr () == M6) {
                   
         if (strcmp (attrib, "CLASS") == 0) {          if (strcmp (attrib, "CLASS") == 0) {
             // non-object variables always belong to the ^%STRING class              /* non-object variables always belong to the ^%STRING class */
             snprintf (buf, 9, "^%%STRING");              snprintf (buf, 9, "^%%STRING");
   
             merr_clear ();              merr_clear ();
Line 161  short obj_get_attribute(char *inst, char Line 165  short obj_get_attribute(char *inst, char
   
 void obj_destroy(char *inst)  void obj_destroy(char *inst)
 {  {
     char t_key[255];      char t_key[256];
   
     snprintf (t_key, 254, "^$OBJECT\202\%s\201", inst);      snprintf (t_key, sizeof (t_key) - 1, "^$OBJECT\202\%s\201", inst);
     symtab_bltin (kill_sym, t_key, " \201");      symtab_bltin (kill_sym, t_key, " \201");
 }  }
   
 void obj_create_symbols(char *objvar, char *class)  void obj_create_symbols(char *objvar, char *class)
 {  {
     char t_key[255];      char t_key[256];
     char t_data[255];      char t_data[256];
   
     snprintf (t_key, 254, "%s\201", objvar);      snprintf (t_key, sizeof (t_key) - 1, "%s\201", objvar);
     snprintf (t_data, 254, " \201");      snprintf (t_data, sizeof (t_data) - 1, " \201");
   
     symtab_bltin (set_sym, t_key, t_data);      symtab_bltin (set_sym, t_key, t_data);
   
Line 186  void obj_get_constructor(char *construct Line 190  void obj_get_constructor(char *construct
     freem_ref_t inref;      freem_ref_t inref;
     freem_ref_t outref;      freem_ref_t outref;
     register int i;      register int i;
     int argct;  
   
     argct = 0;  
           
     mref_init (&inref, MREF_RT_GLOBAL, "");      mref_init (&inref, MREF_RT_GLOBAL, "");
     internal_to_mref (&inref, class);      internal_to_mref (&inref, class);
Line 197  void obj_get_constructor(char *construct Line 198  void obj_get_constructor(char *construct
     strcpy (outref.name, inref.name);      strcpy (outref.name, inref.name);
     outref.subscript_count = inref.subscript_count + 1;      outref.subscript_count = inref.subscript_count + 1;
   
     snprintf (outref.subscripts[0], 255, ".%s", instvar);      snprintf (outref.subscripts[0], STRLEN - 1, ".%s", instvar);
   
     for (i = 0; i < inref.subscript_count; i++) {      for (i = 0; i < inref.subscript_count; i++) {
         strcpy (outref.subscripts[i + 1], inref.subscripts[i]);          strcpy (outref.subscripts[i + 1], inref.subscripts[i]);
     }      }
   
 //    mref_to_internal_prealloc (constructor, &outref);  
     mref_to_external (&outref, constructor);      mref_to_external (&outref, constructor);
     return;      return;
   

Removed from v.1.2  
changed lines
  Added in v.1.6


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