home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Mint / Editors / mjovesrc.zoo / jovepost.let < prev    next >
Text File  |  1991-10-18  |  2KB  |  84 lines

  1. I am posting this for my brother Doug, who can't get to Usenet.
  2.  
  3.  
  4. Recently, I have been working on a port of the JOVE editor, V. 4.14.6.
  5. I am using the MiNT libs and attempting to add all the features
  6. from the BSD version.  This includes the use of ptys for
  7. interactive processes, such as M-X shell.  So far, all of the
  8. editing features work, as do the non-interactive process control
  9. routines, including M-X shell-command and M-X compile-it.
  10.  
  11. However, the interactive commands I have tested so far, M-X shell and
  12. M-X i-shell-command, don't work.  M-X shell starts the shell, opens
  13. the *shell* buffer and then ksh sticks its prompt into the buffer.
  14. After this, nothing happens.  I can type text into the buffer, but it
  15. never gets to the shell.  The shell sits there waiting, trying to
  16. read Q:/jovep0, but not getting any response.  You'd think that this
  17. would be an easy one.  Except that the suspect code was my hack.
  18.  
  19. You see, the MiNT libs lack an ffs().  In the following code fragment,
  20. you can see what I did to fix this:
  21.  
  22. #ifdef MiNT
  23. int
  24. ffs(int i)
  25. {
  26.     int j;
  27. #define NUMBITS  (sizeof(int) * 8)
  28.  
  29.     for (j = 1; j <= NUMBITS; j++)
  30.         if (i & ~(0xffffffff >> j))                /* 32-bit libs */
  31.             return (NUMBITS - --j);
  32. }
  33. #endif
  34.  
  35. int
  36. jgetchar()
  37. {
  38.     long        reads;
  39.     register int    tmp,
  40.             nfds;
  41.     int        c;
  42.  
  43.     if (nchars <= 0) {
  44.         /* Get a character from the keyboard, first checking for
  45.            any input from a process.  Handle that first, and then
  46.            deal with the terminal input. */
  47.         do {
  48.             do {
  49.                 reads = global_fd;
  50.                 nfds = select(32, &reads, (long *)NULL, (long *)NULL, (struct timeval *)NULL);
  51.             } while (nfds < 0 && errno == EINTR);
  52.  
  53.             if (nfds == -1)
  54.                 complain("\rerror in select %ld: %s", global_fd, strerror(errno));
  55.             else {
  56.                 if (reads & 01) {
  57.                     nchars = read(0, (UnivPtr) smbuf, sizeof(smbuf));
  58.                     reads &= ~01;
  59.                     nfds -= 1;
  60.                 }
  61.                 while (nfds--) {
  62. /* here's where ffs() gets called  */    tmp = ffs(reads) - 1;
  63.                     read_proc(tmp);
  64.                     reads &= ~(1L << tmp);
  65.                 }
  66.             }
  67.         } while (nchars <= 0);
  68.  
  69.         if (nchars <= 0)
  70.             finish(SIGHUP);
  71.  
  72.         bp = smbuf;
  73.         InputPending = (nchars > 1);
  74.     }
  75.  
  76.     if (((c = *bp) & 0200) && MetaKey) {
  77.         *bp = (c & CHARMASK);
  78.         return '\033';
  79.     }
  80.     nchars -= 1;
  81.     return *bp++ & 0377;
  82. }
  83.  
  84.