--- freem/src/xecline.c 2025/03/01 04:45:51 1.3 +++ freem/src/xecline.c 2025/04/10 01:24:39 1.13 @@ -1,23 +1,11 @@ /* - * * - * * * - * * * - * *************** - * * * * * - * * MUMPS * - * * * * * - * *************** - * * * - * * * - * * - * - * xecline.c + * $Id: xecline.c,v 1.13 2025/04/10 01:24:39 snw Exp $ * freem interpreter proper * * - * Author: Serena Willis + * Author: Serena Willis * Copyright (C) 1998 MUG Deutschland - * Copyright (C) 2020 Coherent Logic Development LLC + * Copyright (C) 2020, 2025 Coherent Logic Development LLC * * * This file is part of FreeM. @@ -35,6 +23,37 @@ * You should have received a copy of the GNU Affero Public License * along with FreeM. If not, see . * + * $Log: xecline.c,v $ + * Revision 1.13 2025/04/10 01:24:39 snw + * Remove C++ style comments + * + * Revision 1.12 2025/04/09 19:52:02 snw + * Eliminate as many warnings as possible while building with -Wall + * + * Revision 1.11 2025/04/02 03:02:42 snw + * Stop requiring users to pass -e to fmadm when -u or -g are passed + * + * Revision 1.10 2025/03/27 03:27:35 snw + * Install init scripts to share/freem/examples/init and fix regression in method dispatch + * + * Revision 1.9 2025/03/24 04:13:12 snw + * Replace action macro dat with fra_dat to avoid symbol conflict on OS/2 + * + * Revision 1.8 2025/03/24 04:05:36 snw + * Replace crlf with frm_crlf to avoid symbol conflict with readline on OS/2 + * + * Revision 1.7 2025/03/22 22:52:24 snw + * Add STRLEN_GBL macro to manage global string length + * + * Revision 1.6 2025/03/22 21:44:32 snw + * Make the startup messages fewer and add environment name to direct-mode prompt + * + * Revision 1.5 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 @@ -891,8 +910,7 @@ set0: if (isalpha (vn[0]) && *(codptr + 1) == ':') { char sc_string[255]; - register int sci; - + codptr += 2; expr (NAME); @@ -928,8 +946,7 @@ set0: if (*++codptr != '=') { -/* SET A++ or SET A-- equivalent to SET A+=1 SET A-=1 currently disabled */ -//#ifdef NEVER + /* unary ++/-- */ if ((ch == '+' || ch == '-') && ch == *codptr) { codptr++; setop = ch; @@ -938,7 +955,6 @@ set0: goto set2; } -//#endif /* NEVER */ merr_raise (ASSIGNER); break; @@ -1024,7 +1040,9 @@ set2: if (new_and_set == TRUE) new_and_set = FALSE; if (new_object == TRUE) new_object = FALSE; +/* set1: +*/ if (*codptr != ',') break; if (*++codptr == '@') goto again; @@ -1076,8 +1094,8 @@ set: goto err; } - expr (STRING); - + expr (STRING); + if (merr () > OK) goto err; stcpy (tmp2, argptr); @@ -1588,7 +1606,7 @@ set10: } if (stcat (tmp2, &tmp3[arg4]) == 0) { - merr_raise (M56); //JPW + merr_raise (M56); /* snw */ goto err; } @@ -2367,7 +2385,6 @@ s_end: #ifdef DEBUG_NEWSTACK printf ("EXTRINSIC\r\n"); #endif - //printf (" extr_types[%d] = '%d'\r\n", nstx, extr_types[nstx]); if (*codptr == EOL || *codptr == SP) { #ifdef DEBUG_NEWSTACK @@ -3753,7 +3770,7 @@ off3: break; case KILL: - + /* argumentless: KILL all local variables */ if (((ch = *codptr) == SP) || ch == EOL) { symtab (kill_all, "", ""); @@ -3787,8 +3804,10 @@ off3: if (destructor_ct) { for (cd = 0; cd < destructor_ct; cd++) { - strcat (destc, destructors[cd]); - strcat (destc, ","); + if (strlen (destructors[cd]) > 0) { + strcat (destc, destructors[cd]); + strcat (destc, ","); + } } destructor_ct = 0; @@ -3936,7 +3955,7 @@ off3: stcpy (objvar, vn); - symtab (dat, objvar, datres); + symtab (fra_dat, objvar, datres); dat_res = atoi (datres); if (dat_res > 0) { @@ -3990,8 +4009,9 @@ off3: goto set2; } +/* post_new: - +*/ ch = nstx; while (nestc[ch] == FOR) ch--; /* FOR does not define a NEW level */ @@ -4320,7 +4340,7 @@ use0: /* entry point for proces break; case 2: - crlf[io] = tvexpr (argptr); + frm_crlf[io] = tvexpr (argptr); break; case 3: @@ -4422,7 +4442,7 @@ use_socket: /* need to evaluate the following 6 lines carefully - smw 2023-10-15 */ if (k != HOME) { - crlf[k] = FALSE; + frm_crlf[k] = FALSE; fm_nodelay[k] = FALSE; xpos[k] = 0; ypos[k] = 0; @@ -5080,15 +5100,11 @@ open_socket: #endif if (nestc[nstx] == BREAK) { -// printf ("nestc[nstx] was BREAK\r\n"); if (repQUIT) continue; merr_raise (OK - CTRLB); goto zgo; /*cont. single step */ } -// else { -// printf ("nestc[nstx] was _not_ BREAK\r\n"); -// } if (nestc[nstx] == FOR) { @@ -5538,7 +5554,7 @@ zgo: for (; beg < end; beg += UNSIGN (*beg) + 2) { - if (crlf[io]) { + if (frm_crlf[io]) { write_m ("\012\201"); } else { @@ -5554,7 +5570,7 @@ zgo: rouins = beg; } - if (crlf[io]) { + if (frm_crlf[io]) { write_m ("\012\201"); } else { @@ -5664,9 +5680,6 @@ zgo: } case ZWRITE: - - -zwrite: { short k; char w_tmp[512]; @@ -5790,7 +5803,6 @@ zwritep: expr (NAME); - //if (varnam[0] == '^') merr_raise (GLOBER); if (merr () > OK) goto err; codptr++; @@ -5823,16 +5835,16 @@ zwritep: } if (varnam[0] != '^') { - symtab (dat, varnam, tmp2); + symtab (fra_dat, varnam, tmp2); zwmode = 'L'; } else { if (varnam[1] == '$') { - ssvn (dat, varnam, tmp2); + ssvn (fra_dat, varnam, tmp2); zwmode = '$'; } else { - global (dat, varnam, tmp2); + global (fra_dat, varnam, tmp2); zwmode = '^'; } } @@ -5943,21 +5955,21 @@ zwritep: switch (zwmode) { case 'L': - symtab (dat, tmp, tmp3); + symtab (fra_dat, tmp, tmp3); symtab (get_sym, tmp, &w_tmp[1]); break; case '$': - ssvn (dat, tmp, tmp3); + ssvn (fra_dat, tmp, tmp3); ssvn (get_sym, tmp, &w_tmp[1]); break; case '^': - global (dat, tmp, tmp3); + global (fra_dat, tmp, tmp3); global (get_sym, tmp, &w_tmp[1]); break; @@ -6032,62 +6044,7 @@ zwritep: break; - case ZALLOCATE: - - /* argumentless is not permitted */ - if (*codptr == SP || *codptr == EOL) { - merr_raise (ARGLIST); - break; - } - - expr (NAME); - - if (merr () > OK) goto err; - - tmp[0] = SP; - stcpy (&tmp[1], varnam); - stcat (tmp, "\001\201"); - - frm_timeout = (-1L); /* no timeout */ - - if (*++codptr == ':') { - codptr++; - - expr (STRING); - - frm_timeout = intexpr (argptr); - - if (merr () > OK) goto err; - if (frm_timeout < 0L) frm_timeout = 0L; - } - - lock (tmp, frm_timeout, ZALLOCATE); - break; - - - case ZDEALLOCATE: - - tmp[0] = SP; - - if (*codptr == SP || *codptr == EOL) { - tmp[1] = EOL; - } - else { - expr (NAME); - - if (merr () > OK) goto err; - - stcpy (&tmp[1], varnam); - - codptr++; - } - - lock (tmp, -1L, ZDEALLOCATE); /* -1: no timeout */ - break; - - /* user defined Z-COMMAND */ - - + /* user defined Z-COMMAND */ case PRIVATE: private: /* for in-MUMPS defined commands */ @@ -6626,15 +6583,15 @@ evthandler: /* for event hand /* run the next iteration of GTK's event loop */ - //TODO: replace with libXt event loop - //gtk_main_iteration_do (TRUE); + /* TODO: replace with libXt event loop */ + /* gtk_main_iteration_do (TRUE); */ /* dequeue any events */ evt_count = mwapi_dequeue_events (syn_handlers); if (evt_count) { /* write them out */ - //printf ("event handlers = '%s'\r\n", syn_handlers); + /* printf ("event handlers = '%s'\r\n", syn_handlers); */ syn_event_entry_nstx = nstx; @@ -7079,7 +7036,7 @@ restart: DSW &= ~BIT0; /* enable ECHO */ - // print here + /* print here */ { char *t_rtn; char *t_nsn = (char *) malloc (STRLEN * sizeof (char)); @@ -7210,10 +7167,10 @@ direct_mode: if (quiet_mode == FALSE) { if (tp_level == 0) { - snprintf (fmrl_prompt, 255, "\r\n%s> ", nsname); + snprintf (fmrl_prompt, 255, "\r\n%s.%s> ", shm_env, nsname); } else { - snprintf (fmrl_prompt, 255, "\r\nTL%d:%s> ", tp_level, nsname); + snprintf (fmrl_prompt, 255, "\r\nTL%d:%s.%s> ", tp_level, shm_env, nsname); } } set_io (UNIX); @@ -7417,17 +7374,12 @@ direct_mode: #endif if (merr () > OK) goto err; - - - // printf ("zbflag = %d\r\n", zbflag); if (code[0] == EOL && zbflag && nestc[nstx] == BREAK) { - //printf ("cont single step\r\n"); debug_mode = TRUE; merr_raise (OK - CTRLB); - //printf ("ierr now '%d'\r\n", ierr); goto zgo; } /* single step */ } @@ -7493,7 +7445,7 @@ void rbuf_dump(void) for (i = 0; i < NO_OF_RBUF; i++) { - sprintf (flgs, ""); + flgs[0] = '\0'; if (ages[i] == 0) { sprintf (rnam, "---------");