Diff for /freem/src/xecline.c between versions 1.19 and 1.27

version 1.19, 2025/04/30 14:41:03 version 1.27, 2025/05/19 21:29:29
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.27  2025/05/19 21:29:29  snw
    *   Add basic tab completion to direct mode
    *
    *   Revision 1.26  2025/05/19 02:03:31  snw
    *   Reverse-engineer and document argumented ZPRINT (thanks to D. Wicksell)
    *
    *   Revision 1.25  2025/05/18 18:15:38  snw
    *   Add ZEDIT command for editing routines
    *
    *   Revision 1.24  2025/05/14 12:22:04  snw
    *   Further work on shared memory
    *
    *   Revision 1.23  2025/05/06 16:10:06  snw
    *   Add extra blank before readline call on NetBSD
    *
    *   Revision 1.22  2025/05/05 14:53:17  snw
    *   Modify rpm spec to include documentation TODO
    *
    *   Revision 1.21  2025/05/01 17:02:30  snw
    *   Further debugging improvements
    *
    *   Revision 1.20  2025/04/30 17:19:16  snw
    *   Improve backtraces in debugger
    *
  *   Revision 1.19  2025/04/30 14:41:03  snw   *   Revision 1.19  2025/04/30 14:41:03  snw
  *   Further debugger work   *   Further debugger work
  *   *
Line 162  void rbuf_dump(void); Line 186  void rbuf_dump(void);
 short rbuf_slot_from_name(char *);  short rbuf_slot_from_name(char *);
 short is_standard(void);  short is_standard(void);
   
   #ifdef HAVE_LIBREADLINE
   char *m_commands[] = {
     "@",
     "!",
     "!!",
     "ablock",
     "astart",
     "astop",
     "aunblock",
     "break",
     "close",
     "do",
     "else",
     "for",
     "goto",
     "halt",
     "hang",
     "if",
     "job",
     "kill",
     "ksubscripts",
     "kvalue",
     "lock",
     "merge",
     "new",
     "open",
     "quit",
     "read",
     "set",
     "tcommit",
     "then",
     "trollback",
     "tstart",
     "use",
     "view",
     "write",
     "xecute",
     "zassert",
     "zbreak",
     "zconst",
     "zedit",
     "zgoto",
     "zhalt",
     "zinsert",
     "zjob",
     "zload",
     "zmap",
     "znew",
     "zprint",
     "zquit",
     "zremove",
     "zsave",
     "zthrow",
     "ztrap",
     "zunmap",
     "zwatch",
     "zwith",
     "zwrite",
     "ABLOCK",
     "ASTART",
     "ASTOP",
     "AUNBLOCK",
     "BREAK",
     "CLOSE",
     "DO",
     "ELSE",
     "FOR",
     "GOTO",
     "HALT",
     "HANG",
     "IF",
     "JOB",
     "KILL",
     "KSUBSCRIPTS",
     "KVALUE",
     "LOCK",
     "MERGE",
     "NEW",
     "OPEN",
     "QUIT",
     "READ",
     "SET",
     "TCOMMIT",
     "THEN",
     "TROLLBACK",
     "TSTART",
     "USE",
     "VIEW",
     "WRITE",
     "XECUTE",
     "ZASSERT",
     "ZBREAK",
     "ZCONST",
     "ZEDIT",
     "ZGOTO",
     "ZHALT",
     "ZINSERT",
     "ZJOB",
     "ZLOAD",
     "ZMAP",
     "ZNEW",
     "ZPRINT",
     "ZQUIT",
     "ZREMOVE",
     "ZSAVE",
     "ZTHROW",
     "ZTRAP",
     "ZUNMAP",
     "ZWATCH",
     "ZWITH",
     "ZWRITE",
     NULL
   };
   
   char **command_completion(const char *, int, int);
   char *command_generator(const char *, int);
   
   char **command_completion(const char *text, int start, int end)
   {
       if (start > 0) return NULL;
       rl_attempted_completion_over = 1;
       return rl_completion_matches(text, command_generator);
   }
   
   char *command_generator(const char *text, int state)
   {
       static int list_index, len;
       char *name;
   
       if (!state) {
           list_index = 0;
           len = strlen(text);
       }
   
       while ((name = m_commands[list_index++])) {
           if (strncmp(name, text, len) == 0) {
               return strdup(name);
           }
       }
   
       return NULL;
   }
   #endif
   
 /*  /*
  * xecline():   * xecline():
  *   typ (where to go on function entry):   1 = restart   *   typ (where to go on function entry):   1 = restart
Line 174  int xecline(int typ) Line 342  int xecline(int typ)
     short new_and_set = FALSE;      short new_and_set = FALSE;
     short new_object = FALSE;      short new_object = FALSE;
     short destructor_run = FALSE;      short destructor_run = FALSE;
     short debug_mode = FALSE;  
     short libcall = FALSE;      short libcall = FALSE;
     char *namold;      char *namold;
     long rouoldc;      long rouoldc;
Line 197  int xecline(int typ) Line 364  int xecline(int typ)
           
     char *reeval_codptr;      char *reeval_codptr;
     char reeval_code[512];      char reeval_code[512];
       char entryref[256];
           
     int i;      int i;
     int j;      int j;
Line 247  int xecline(int typ) Line 415  int xecline(int typ)
 next_line:          /* entry point for next command line */  next_line:          /* entry point for next command line */
   
     if (debug_mode) {      if (debug_mode) {
         debug_mode = debugger (DEBENTRY_LINE, codptr);          debug_mode = debugger (DEBENTRY_LINE, entryref);
     }      }
       
     job_set_status (pid, JSTAT_INTERPRETER);      job_set_status (pid, JSTAT_INTERPRETER);
           
     if (then_ctr > 0) {      if (then_ctr > 0) {
Line 297  next_line:          /* entry point for n Line 465  next_line:          /* entry point for n
     codptr = code;      codptr = code;
   
 next_cmnd:          /* continue line entry point */  next_cmnd:          /* continue line entry point */
       getraddress (entryref, nstx);
     if (debug_mode) {      if (debug_mode) {
         debug_mode = debugger (DEBENTRY_CMD, codptr);          debug_mode = debugger (DEBENTRY_CMD, entryref);
     }      }
   
     if (sigint_in_for) goto for_quit;      if (sigint_in_for) goto for_quit;
Line 4956  open_socket: Line 5125  open_socket:
                     if (merr () > OK) break;                      if (merr () > OK) break;
                 }                  }
                 else {                  else {
                     halt:i = 0;  halt:
                       i = 0;
                 }                  }
   
                 cleanup ();                  cleanup ();
Line 5275  open_socket: Line 5445  open_socket:
             break;              break;
   
         /* Z-COMMANDS */          /* Z-COMMANDS */
           case ZEDIT:
               merr_raise (cmd_zedit (&ra));
               MRESCHECK(ra);
               break;
               
         case ZGO:          case ZGO:
   
             /* ZGO with arguments: same as GOTO but with BREAK on */              /* ZGO with arguments: same as GOTO but with BREAK on */
Line 5414  zgo: Line 5589  zgo:
                     merr_raise (NOPGM);                      merr_raise (NOPGM);
   
                     break;                      break;
                 }           /*error */                  }           /* error */
   
                 stcpy (varnam, rou_name);                  stcpy (varnam, rou_name);
             }              }
Line 5550  zgo: Line 5725  zgo:
                 if (*codptr == EOL || *codptr == SP) {                  if (*codptr == EOL || *codptr == SP) {
                     merr_raise (ARGLIST);                      merr_raise (ARGLIST);
                     break;                      break;
                 }           /*error */                  }           /* error */
                                   
                 dosave[0] = EOL;                  dosave[0] = EOL;
   
                 /* parse stringlit */                  /* parse strlit */
                 expr (STRING);                  expr (STRING);
                                   
                 if (merr () > OK) break;                  if (merr () > OK) break;
Line 6802  err: Line 6977  err:
         stcpy (er_buf, errmes[merr ()]);          stcpy (er_buf, errmes[merr ()]);
         stcnv_m2c (er_buf);          stcnv_m2c (er_buf);
   
   
         /*  
         if (usermode == 1 && ztrap[nstx][0] == EOL && etrap[0] == '\0') {  
             debug_mode = TRUE;  
             debugger (DEBENTRY_ERROR, codptr);  
         }  
         */  
   
                   
 #if !defined(MSDOS)  #if !defined(MSDOS)
         logprintf (FM_LOG_DEBUG, "xecline:  interpreter error %d [%s]", ierr, er_buf);          logprintf (FM_LOG_DEBUG, "xecline:  interpreter error %d [%s]", ierr, er_buf);
Line 7273  direct_mode: Line 7440  direct_mode:
                 int hist_idx;                  int hist_idx;
                 HIST_ENTRY *hist_ent;                  HIST_ENTRY *hist_ent;
   
                   rl_attempted_completion_function = command_completion;
                   
                 if (quiet_mode == FALSE) {                  if (quiet_mode == FALSE) {
                     if (tp_level == 0) {                      if (tp_level == 0) {
                         snprintf (fmrl_prompt, sizeof (fmrl_prompt) - 1, "\r\n%s.%s> ", shm_env, nsname);                          snprintf (fmrl_prompt, sizeof (fmrl_prompt) - 1, "\r\n%s.%s> ", shm_env, nsname);
Line 7284  direct_mode: Line 7453  direct_mode:
                 set_io (UNIX);                  set_io (UNIX);
   
                 job_set_status (pid, JSTAT_DIRECTMODE);                  job_set_status (pid, JSTAT_DIRECTMODE);
                   
   #if defined(__NetBSD__)
                   printf ("\r\n");
   #endif          
   
                 /* readline() does its own malloc() */                  /* readline() does its own malloc() */
                 fmrl_buf = readline (fmrl_prompt);                  fmrl_buf = readline (fmrl_prompt);
                                   
Line 7295  direct_mode: Line 7468  direct_mode:
                                           
                     goto halt;                      goto halt;
                 }                  }
   
                                   
                 if (strlen (fmrl_buf) > 0) {                  if (strlen (fmrl_buf) > 0) {
                     add_history (fmrl_buf);                      add_history (fmrl_buf);

Removed from v.1.19  
changed lines
  Added in v.1.27


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