--- freem/src/symtab_bltin.c 2025/04/10 01:24:39 1.10 +++ freem/src/symtab_bltin.c 2025/05/14 12:22:04 1.14 @@ -1,5 +1,5 @@ /* - * $Id: symtab_bltin.c,v 1.10 2025/04/10 01:24:39 snw Exp $ + * $Id: symtab_bltin.c,v 1.14 2025/05/14 12:22:04 snw Exp $ * FreeM local system table and user-defined special variable table * * @@ -24,6 +24,18 @@ * along with FreeM. If not, see . * * $Log: symtab_bltin.c,v $ + * Revision 1.14 2025/05/14 12:22:04 snw + * Further work on shared memory + * + * Revision 1.13 2025/04/19 21:52:20 snw + * Remove extraneous symbol table debugging message + * + * Revision 1.12 2025/04/14 19:56:27 snw + * Working towards FreeBSD fix + * + * Revision 1.11 2025/04/13 04:22:43 snw + * Fix snprintf calls + * * Revision 1.10 2025/04/10 01:24:39 snw * Remove C++ style comments * @@ -62,6 +74,7 @@ #include "merr.h" #include "consttbl.h" #include "shmmgr.h" +#include "log.h" /* Turn this on to get tons of lovely debugging messages about symbol-table calls */ @@ -160,13 +173,12 @@ void symtab_init (void) mbpartition = (char *) shm_alloc ((size_t) PSIZE + 2); if (mbpartition != NULL) { shm_config->hdr->use_mb_globals = TRUE; + shm_config->hdr->partition = mbpartition; } else { fprintf (stderr, "symtab_init: falling back to global-backed structured system variables\r\n"); shm_config->hdr->use_mb_globals = FALSE; } - - shm_config->hdr->partition = mbpartition; if (symtab_get_sem ()) { for (i = 0; i < 128; i++) shm_config->hdr->alphptr[i] = 0L; @@ -181,8 +193,10 @@ void symtab_init (void) fprintf (stderr, "symtab_init: could not attach to symbol table semaphore\r\n"); exit (1); } - - mbpartition = shm_config->hdr->partition; + + if (shm_config->hdr->use_mb_globals == TRUE) { + mbpartition = SOA(shm_config->hdr->partition); + } symtab_release_sem (); } @@ -210,7 +224,7 @@ short symtab_get_sem(void) sleep (1); } - fprintf (stderr, "symtab_get_sem: fail\r\n"); + logprintf (FM_LOG_ERROR, "symtab_get_sem: fail"); have_symtab_sem = FALSE; return FALSE; @@ -236,6 +250,9 @@ void symtab_shm (short action, char *key register int i; char *old_partition = partition; + global (action, key, data); + return; + if (shm_config->hdr->use_mb_globals == FALSE) { symtab_bltin (action, key, data); return; @@ -391,7 +408,7 @@ void symtab_bltin (short action, char *k stcnv_m2c (tt_with); stcnv_m2c (tt_key); - snprintf (key, 100, "%s%s\201\201", tt_with, tt_key); + sprintf (key, "%s%s\201\201", tt_with, tt_key); no_with: @@ -640,19 +657,12 @@ no_with: } while (i < PSIZE); } - else { - printf ("alphptr not found\r\n"); - } merr_raise (M6); data[0] = EOL; return; - - - - case set_sym: /* store/create variable */ @@ -1917,7 +1927,7 @@ zinvend: char esbuf[256]; - snprintf (esbuf, 255, "%d\201", estack); + snprintf (esbuf, sizeof (esbuf) - 1, "%d\201", estack); j = stcpy (newptr, esbuf);