Diff for /freem/src/global_bltin.c between versions 1.13 and 1.15

version 1.13, 2025/04/09 14:34:30 version 1.15, 2025/04/10 01:24:38
Line 24 Line 24
  *   along with FreeM.  If not, see <https://www.gnu.org/licenses/>.   *   along with FreeM.  If not, see <https://www.gnu.org/licenses/>.
  *   *
  *   $Log$   *   $Log$
    *   Revision 1.15  2025/04/10 01:24:38  snw
    *   Remove C++ style comments
    *
    *   Revision 1.14  2025/04/09 19:52:02  snw
    *   Eliminate as many warnings as possible while building with -Wall
    *
  *   Revision 1.13  2025/04/09 14:34:30  snw   *   Revision 1.13  2025/04/09 14:34:30  snw
  *   Further work on global_bltin.c refactor   *   Further work on global_bltin.c refactor
  *   *
Line 83  static void scanpblk (char *block, long Line 89  static void scanpblk (char *block, long
 static void scandblk (char *block, long *adr, long *fnd);  static void scandblk (char *block, long *adr, long *fnd);
 static void getnewblk (int filedes, unsigned long *blknbr);  static void getnewblk (int filedes, unsigned long *blknbr);
 static short int g_collate (char *t);  static short int g_collate (char *t);
 //static short int g_numeric (char *str);  
 short g_numeric (char *str);  short g_numeric (char *str);
 void close_all_globals(void);  void close_all_globals(void);
 static void panic (void);  static void panic (void);
Line 134  static void panic (void); Line 139  static void panic (void);
 inline long gbl_path(char *key, char *buf)  inline long gbl_path(char *key, char *buf)
 {  {
     long savj;      long savj;
     long savch;                 /* saved j and ch for multiple pathes */  
   
     register long int i;      register long int i;
     register long int j;      register long int j;
     register long int k;      register long int k;
     register long int ch;      register long int ch;
     long pathscan;                      /* flag for repeated scan of pathlist setting an undef global */  
         
     /* construct full UNIX filename */      /* construct full UNIX filename */
     savj = 0;      savj = 0;
     savch = ch = EOL;  
     pathscan = TRUE;  
 nextpath:  
     k = 0;      k = 0;
     j = savj;      j = savj;
   
Line 170  nextpath: Line 170  nextpath:
         }          }
   
     }      }
   
     if (savj == 0 && ch == EOL) pathscan = FALSE;               /* one path only: inhibit search */  
           
     if (k > 0) {      if (k > 0) {
   
Line 184  nextpath: Line 182  nextpath:
   
     }      }
   
     savch = ch;  
     savj = j;      savj = j;
     i = 0;      i = 0;
     j = 0;      j = 0;
Line 238  int gbl_lock(global_handle *g, int type) Line 235  int gbl_lock(global_handle *g, int type)
   
     locking (g->fd, type, 0L);      locking (g->fd, type, 0L);
     g->locked = TRUE;      g->locked = TRUE;
   
       return TRUE;
 } /* gbl_lock() */  } /* gbl_lock() */
   
 int gbl_unlock(global_handle *g)  int gbl_unlock(global_handle *g)
Line 248  int gbl_unlock(global_handle *g) Line 247  int gbl_unlock(global_handle *g)
   
     locking (g->fd, 0, 0L);      locking (g->fd, 0, 0L);
     g->locked = FALSE;      g->locked = FALSE;
   
       return TRUE;
 } /* gbl_unlock() */  } /* gbl_unlock() */
   
 void gbl_close(global_handle *g)  void gbl_close(global_handle *g)
Line 475  global_handle *gbl_handle(char *key) Line 476  global_handle *gbl_handle(char *key)
     global_handle *g;      global_handle *g;
     char global_name[256];      char global_name[256];
     int i;      int i;
     long path_len;  
     char block[BLOCKLEN];  
     struct stat dinf;                  struct stat dinf;            
           
     i = 0;      i = 0;
Line 613  void global_bltin (short action, char *k Line 612  void global_bltin (short action, char *k
     unsigned long hdr_offset;      unsigned long hdr_offset;
           
     /* these must be static variables */      /* these must be static variables */
     static short filedes;               /* filedescr for global access */  
     static char filnam[256];            /* name of global/unix file */      static char filnam[256];            /* name of global/unix file */
   
     /* the following vars may be */      /* the following vars may be */
Line 642  void global_bltin (short action, char *k Line 640  void global_bltin (short action, char *k
   
     int iresult;      int iresult;
           
     struct stat dinf;                   /* get modification date */  
   
     long savj;  
     long savch;                 /* saved j and ch for multiple pathes */  
     register long int i;      register long int i;
     register long int j;      register long int j;
     register long int k;      register long int k;
     register long int ch;      register long int ch;
     long pathscan;                      /* flag for repeated scan of pathlist setting an undef global */  
   
       j = 0;
       
     hdr_offset = sizeof (global_header);      hdr_offset = sizeof (global_header);
           
     /* process optional limitations */      /* process optional limitations */
Line 1064  reopen: Line 1059  reopen:
     /* odd numbered actions get read access (get_sym,data,fra_order) 3 */      /* odd numbered actions get read access (get_sym,data,fra_order) 3 */
     /* even ones read/write access          (set_sym,kill_sym)   1 */      /* even ones read/write access          (set_sym,kill_sym)   1 */
   
   /* temporarily disabled    
 lock:  lock:
   */
   
     if (action == get_sym) {      if (action == get_sym) {
   
Line 1083  tfast1: Line 1080  tfast1:
             lseek (g->fd, hdr_offset + ((long) blknbr * (long) (BLOCKLEN)), SEEK_SET);              lseek (g->fd, hdr_offset + ((long) blknbr * (long) (BLOCKLEN)), SEEK_SET);
             read (g->fd, block, BLOCKLEN);              read (g->fd, block, BLOCKLEN);
   
   /* temporarily disabled
 tfast2:  tfast2:
   */
         if ((typ = block[BTYP]) == DATA) {      /* scan data block: here we test for equality only */          if ((typ = block[BTYP]) == DATA) {      /* scan data block: here we test for equality only */
   
             offset = UNSIGN (block[OFFS]) * 256 +                          offset = UNSIGN (block[OFFS]) * 256 +            
Line 1158  tfast2: Line 1155  tfast2:
             if (typ == EMPTY) {              if (typ == EMPTY) {
                                   
                 if (blknbr == ROOT) {                  if (blknbr == ROOT) {
                     //close (filedes);  
                     gbl_close (g);                      gbl_close (g);
                     goto reopen;                      goto reopen;
                 }                  }
Line 3668  static short int g_collate (char *t) Line 3664  static short int g_collate (char *t)
 /*  /*
  * test whether 'str' is canonical   * test whether 'str' is canonical
  */   */
 //static short int g_numeric (char *str)  
 short g_numeric (char *str)  short g_numeric (char *str)
 {  {
     register int ptr = 0, ch;      register int ptr = 0, ch;
Line 3758  void gbl_dump_stat(void) Line 3753  void gbl_dump_stat(void)
     access_total = 0;      access_total = 0;
     ct = 0;      ct = 0;
     for (g = global_handles_head; g != NULL; g = g->next) {      for (g = global_handles_head; g != NULL; g = g->next) {
         printf ("%-20s%-10d%-12d%-20d%-10d%s\r\n",          printf ("%-20s%-10ld%-12ld%-20ld%-10ld%s\r\n",
                 g->global_name,                  g->global_name,
                 g->use_count,                  g->use_count,
                 g->cache_misses,                  g->cache_misses,

Removed from v.1.13  
changed lines
  Added in v.1.15


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