Diff for /freem/src/routine.c between versions 1.1.1.1 and 1.7

version 1.1.1.1, 2025/01/19 02:04:04 version 1.7, 2025/04/30 14:41:03
Line 1 Line 1
 /*  /*
  *                            *   *   $Id$
  *                           * *  
  *                          *   *  
  *                     ***************  
  *                      * *       * *  
  *                       *  MUMPS  *  
  *                      * *       * *  
  *                     ***************  
  *                          *   *  
  *                           * *  
  *                            *  
  *  
  *   routine.c  
  *    Routine buffer management   *    Routine buffer management
  *   *
  *     *  
  *   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) 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.7  2025/04/30 14:41:03  snw
    *   Further debugger work
    *
    *   Revision 1.6  2025/04/13 04:22:43  snw
    *   Fix snprintf calls
    *
    *   Revision 1.5  2025/04/09 19:52:02  snw
    *   Eliminate as many warnings as possible while building with -Wall
    *
    *   Revision 1.4  2025/03/27 03:27:35  snw
    *   Install init scripts to share/freem/examples/init and fix regression in method dispatch
    *
    *   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>
Line 210  short rtn_get_superclass(char *rou, char Line 217  short rtn_get_superclass(char *rou, char
                   
         if (ch == ')') after_parens = TRUE;          if (ch == ')') after_parens = TRUE;
   
           /* ignore comments in search for superclass */
           if (ch == ';' && after_parens == TRUE) {
               found_super = FALSE;
               break;
           }
           
         if (ch == ':' && after_parens == TRUE) {          if (ch == ':' && after_parens == TRUE) {
             strcpy (buf, p);              strcpy (buf, p);
             found_super = TRUE;              found_super = TRUE;
Line 252  short rtn_get_path(char *rou, char *buf) Line 265  short rtn_get_path(char *rou, char *buf)
         stcnv_m2c (pth);          stcnv_m2c (pth);
     }      }
           
     snprintf (buf, PATHLEN, "%s/%s.m", pth, rou);      snprintf (buf, PATHLEN - 1, "%s/%s.m", pth, rou);
       
     if ((fp = fopen (buf, "r")) != NULL) {      if ((fp = fopen (buf, "r")) != NULL) {
         (void) fclose (fp);          (void) fclose (fp);
   
Line 309  m_entry *rtn_get_entries(char *rou) Line 322  m_entry *rtn_get_entries(char *rou)
     char cur_label[255];      char cur_label[255];
     int has_args = 0;      int has_args = 0;
     char *paren_pos;      char *paren_pos;
     char *curarg;  
           
     if (rtn_get_path (rou, rou_path) == FALSE) {      if (rtn_get_path (rou, rou_path) == FALSE) {
         return (m_entry *) NULL;          return (m_entry *) NULL;
Line 1135  void lineref (char **adrr) Line 1147  void lineref (char **adrr)
           
     return;      return;
 }                                       /* end of lineref() */  }                                       /* end of lineref() */
   
   #if 0
   char *routine_get_line(char *lref, char *buf)
   {
       char tmp[STRLEN];
       char a[STRLEN];
       long l1, rouoldc;
       short reload = FALSE;
       int f = 3;
       register int i;
       register int j;
       
       i = 0;
                           
       if (f > 1) {
           stcpy (tmp, lref[arg + 1]);
           i = intexpr (tmp);
       }
   
       if (a[0] == EOL) {
   
           if (i < 0) {
               return (char *) NULL;
           }
   
           /* $T(+0) returns routine name */
           if (i == 0) {
   
               if (f != 3) {
                   stcpy (a, rou_name);
               } 
               else {
                   stcpy (a, argstck[arg + 2]);
               }                                
   
               goto nxt_operator;
   
           }
   
       }
   
       if (f == 3) {
   
           reload = TRUE;  /* load routine; */
           f = mcmnd;
           mcmnd = 'd';    /* make load use standard-path */
                               
           stcpy (tmp, argstck[arg + 2]);
                               
           rouoldc = roucur - rouptr;
                               
           zload (tmp);
                               
           mcmnd = f;
                               
           if (merr () > OK) {
   
               zload (rou_name);
                                   
               if (merr () == NOPGM) {
                   ierr -= NOPGM; /* smw 15 nov 2023 TODO HUH?? */
                   *a = EOL;
   
                   goto nxt_operator;
               }
   
               return;
   
           }
   
       }
   
       j = 0;
       f = 1;
                           
       if (a[0] != EOL) {  /* 1st arg == label */
   
           for (;;) {
                           
               if (j >= (rouend - rouptr)) {
                   a[0] = EOL;
                   goto t_end;
               }
   
               l1 = j;
               f = 0;
                                   
               while (*(rouptr + (++l1)) == a[f++]);
                                   
               if (a[--f] == EOL && (*(rouptr + l1) == TAB || *(rouptr + l1) == SP || *(rouptr + l1) == '(')) break;
   
               j += (UNSIGN (*(rouptr + j)) + 2);  /* skip line */
   
           }
   
           f = 0;
   
       }
   
       if (i > 0) {
   
           while (f < i) {
   
               if ((j = j + (UNSIGN (*(rouptr + j))) + 2) >= (rouend - rouptr)) {
                   a[0] = EOL;
                   goto t_end;
               }
                                   
               f++;
   
           }
   
       }
   
       if (i < 0) {
   
           j--;
                               
           while (f != i) {
   
               while (*(rouptr + (--j)) != EOL && j >= 0);
                                   
               if (--f != i && j < 1) {
                   a[0] = EOL;
                   goto t_end;
               }
   
           }
   
           j++;
   
       }
   
       f = (-1);
       j++;
   
       while ((a[++f] = (*(rouptr + (j++)))) != EOL) {
           if (a[f] == TAB || a[f] == SP)
               break;
       }
   
       if (j >= (rouend - rouptr - 1)) {
           a[0] = EOL;
       } 
       else {
   
           a[f] = SP;
                               
           while ((*(rouptr + j)) == TAB || (*(rouptr + j)) == SP) {
               j++;
               a[++f] = SP;
           }
   
           stcpy (&a[++f], rouptr + j);
   
       }
   
   t_end:
       if (reload) {
           zload (rou_name);
           roucur = rouptr + rouoldc;
       }           /* reload routine; */
   
   
   }
   #endif

Removed from v.1.1.1.1  
changed lines
  Added in v.1.7


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