home *** CD-ROM | disk | FTP | other *** search
- To: vim-dev@vim.org
- Subject: Patch 6.1.370
- Fcc: outbox
- From: Bram Moolenaar <Bram@moolenaar.net>
- Mime-Version: 1.0
- Content-Type: text/plain; charset=ISO-8859-1
- Content-Transfer-Encoding: 8bit
- ------------
-
- Patch 6.1.370
- Problem: #ifdef nesting is unclear.
- Solution: Insert spaces to indicate the nesting.
- Files: src/os_unix.c
-
-
- *** ../vim61.369/src/os_unix.c Sun Mar 9 14:08:43 2003
- --- src/os_unix.c Fri Mar 7 22:50:28 2003
- ***************
- *** 3027,3035 ****
- int tmode = cur_tmode;
- #ifdef USE_SYSTEM /* use system() to start the shell: simple but slow */
- int x;
- ! #ifndef __EMX__
- char_u *newcmd; /* only needed for unix */
- ! #else
- /*
- * Set the preferred shell in the EMXSHELL environment variable (but
- * only if it is different from what is already in the environment).
- --- 3036,3044 ----
- int tmode = cur_tmode;
- #ifdef USE_SYSTEM /* use system() to start the shell: simple but slow */
- int x;
- ! # ifndef __EMX__
- char_u *newcmd; /* only needed for unix */
- ! # else
- /*
- * Set the preferred shell in the EMXSHELL environment variable (but
- * only if it is different from what is already in the environment).
- ***************
- *** 3050,3063 ****
- putenv((char *)p); /* don't free the pointer! */
- }
- }
- ! #endif
-
- out_flush();
-
- if (options & SHELL_COOKED)
- settmode(TMODE_COOK); /* set to normal mode */
-
- ! #ifdef __EMX__
- if (cmd == NULL)
- x = system(""); /* this starts an interactive shell in emx */
- else
- --- 3059,3072 ----
- putenv((char *)p); /* don't free the pointer! */
- }
- }
- ! # endif
-
- out_flush();
-
- if (options & SHELL_COOKED)
- settmode(TMODE_COOK); /* set to normal mode */
-
- ! # ifdef __EMX__
- if (cmd == NULL)
- x = system(""); /* this starts an interactive shell in emx */
- else
- ***************
- *** 3069,3080 ****
- msg_outtrans(p_sh);
- msg_putchar('\n');
- }
- ! #else /* not __EMX__ */
- if (cmd == NULL)
- x = system((char *)p_sh);
- else
- {
- ! # ifdef VMS
- if (ofn = strchr((char *)cmd, '>'))
- *ofn++ = '\0';
- if (ifn = strchr((char *)cmd, '<'))
- --- 3078,3089 ----
- msg_outtrans(p_sh);
- msg_putchar('\n');
- }
- ! # else /* not __EMX__ */
- if (cmd == NULL)
- x = system((char *)p_sh);
- else
- {
- ! # ifdef VMS
- if (ofn = strchr((char *)cmd, '>'))
- *ofn++ = '\0';
- if (ifn = strchr((char *)cmd, '<'))
- ***************
- *** 3090,3096 ****
- x = vms_sys((char *)cmd, ofn, ifn);
- else
- x = system((char *)cmd);
- ! # else
- newcmd = lalloc(STRLEN(p_sh)
- + (extra_shell_arg == NULL ? 0 : STRLEN(extra_shell_arg))
- + STRLEN(p_shcf) + STRLEN(cmd) + 4, TRUE);
- --- 3099,3105 ----
- x = vms_sys((char *)cmd, ofn, ifn);
- else
- x = system((char *)cmd);
- ! # else
- newcmd = lalloc(STRLEN(p_sh)
- + (extra_shell_arg == NULL ? 0 : STRLEN(extra_shell_arg))
- + STRLEN(p_shcf) + STRLEN(cmd) + 4, TRUE);
- ***************
- *** 3124,3132 ****
-
- if (tmode == TMODE_RAW)
- settmode(TMODE_RAW); /* set to raw mode */
- ! #ifdef FEAT_TITLE
- resettitle();
- ! #endif
- return x;
-
- #else /* USE_SYSTEM */ /* don't use system(), use fork()/exec() */
- --- 3133,3141 ----
-
- if (tmode == TMODE_RAW)
- settmode(TMODE_RAW); /* set to raw mode */
- ! # ifdef FEAT_TITLE
- resettitle();
- ! # endif
- return x;
-
- #else /* USE_SYSTEM */ /* don't use system(), use fork()/exec() */
- ***************
- *** 3137,3167 ****
- char_u *newcmd = NULL;
- pid_t pid;
- pid_t wait_pid = 0;
- ! #ifdef HAVE_UNION_WAIT
- union wait status;
- ! #else
- int status = -1;
- ! #endif
- int retval = -1;
- char **argv = NULL;
- int argc;
- int i;
- char_u *p;
- int inquote;
- ! #ifdef FEAT_GUI
- int pty_master_fd = -1; /* for pty's */
- int pty_slave_fd = -1;
- char *tty_name;
- int fd_toshell[2]; /* for pipes */
- int fd_fromshell[2];
- int pipe_error = FALSE;
- ! # ifdef HAVE_SETENV
- char envbuf[50];
- ! # else
- static char envbuf_Rows[20];
- static char envbuf_Columns[20];
- # endif
- - #endif
- int did_settmode = FALSE; /* TRUE when settmode(TMODE_RAW) called */
-
- out_flush();
- --- 3146,3176 ----
- char_u *newcmd = NULL;
- pid_t pid;
- pid_t wait_pid = 0;
- ! # ifdef HAVE_UNION_WAIT
- union wait status;
- ! # else
- int status = -1;
- ! # endif
- int retval = -1;
- char **argv = NULL;
- int argc;
- int i;
- char_u *p;
- int inquote;
- ! # ifdef FEAT_GUI
- int pty_master_fd = -1; /* for pty's */
- int pty_slave_fd = -1;
- char *tty_name;
- int fd_toshell[2]; /* for pipes */
- int fd_fromshell[2];
- int pipe_error = FALSE;
- ! # ifdef HAVE_SETENV
- char envbuf[50];
- ! # else
- static char envbuf_Rows[20];
- static char envbuf_Columns[20];
- + # endif
- # endif
- int did_settmode = FALSE; /* TRUE when settmode(TMODE_RAW) called */
-
- out_flush();
- ***************
- *** 3213,3219 ****
- }
- argv[argc] = NULL;
-
- ! #ifdef FEAT_GUI
- /*
- * For the GUI: Try using a pseudo-tty to get the stdin/stdout of the
- * executed command into the Vim window. Or use a pipe.
- --- 3222,3228 ----
- }
- argv[argc] = NULL;
-
- ! # ifdef FEAT_GUI
- /*
- * For the GUI: Try using a pseudo-tty to get the stdin/stdout of the
- * executed command into the Vim window. Or use a pipe.
- ***************
- *** 3259,3274 ****
- }
-
- if (!pipe_error) /* pty or pipe opened or not used */
- ! #endif
-
- {
- ! #ifdef __BEOS__
- beos_cleanup_read_thread();
- ! #endif
- if ((pid = fork()) == -1) /* maybe we should use vfork() */
- {
- MSG_PUTS(_("\nCannot fork\n"));
- ! #ifdef FEAT_GUI
- if (gui.in_use && show_shell_mess)
- {
- if (pty_master_fd >= 0) /* close the pseudo tty */
- --- 3268,3283 ----
- }
-
- if (!pipe_error) /* pty or pipe opened or not used */
- ! # endif
-
- {
- ! # ifdef __BEOS__
- beos_cleanup_read_thread();
- ! # endif
- if ((pid = fork()) == -1) /* maybe we should use vfork() */
- {
- MSG_PUTS(_("\nCannot fork\n"));
- ! # ifdef FEAT_GUI
- if (gui.in_use && show_shell_mess)
- {
- if (pty_master_fd >= 0) /* close the pseudo tty */
- ***************
- *** 3284,3290 ****
- close(fd_fromshell[1]);
- }
- }
- ! #endif
- }
- else if (pid == 0) /* child */
- {
- --- 3293,3299 ----
- close(fd_fromshell[1]);
- }
- }
- ! # endif
- }
- else if (pid == 0) /* child */
- {
- ***************
- *** 3326,3348 ****
- close(fd);
- }
- }
- ! #ifdef FEAT_GUI
- else if (gui.in_use)
- {
-
- ! #ifdef HAVE_SETSID
- (void)setsid();
- ! #endif
- /* push stream discipline modules */
- if (options & SHELL_COOKED)
- SetupSlavePTY(pty_slave_fd);
- ! #ifdef TIOCSCTTY
- /* try to become controlling tty (probably doesn't work,
- * unless run by root) */
- ioctl(pty_slave_fd, TIOCSCTTY, (char *)NULL);
- ! #endif
- /* Simulate to have a dumb terminal (for now) */
- ! #ifdef HAVE_SETENV
- setenv("TERM", "dumb", 1);
- sprintf((char *)envbuf, "%ld", Rows);
- setenv("ROWS", (char *)envbuf, 1);
- --- 3335,3357 ----
- close(fd);
- }
- }
- ! # ifdef FEAT_GUI
- else if (gui.in_use)
- {
-
- ! # ifdef HAVE_SETSID
- (void)setsid();
- ! # endif
- /* push stream discipline modules */
- if (options & SHELL_COOKED)
- SetupSlavePTY(pty_slave_fd);
- ! # ifdef TIOCSCTTY
- /* try to become controlling tty (probably doesn't work,
- * unless run by root) */
- ioctl(pty_slave_fd, TIOCSCTTY, (char *)NULL);
- ! # endif
- /* Simulate to have a dumb terminal (for now) */
- ! # ifdef HAVE_SETENV
- setenv("TERM", "dumb", 1);
- sprintf((char *)envbuf, "%ld", Rows);
- setenv("ROWS", (char *)envbuf, 1);
- ***************
- *** 3350,3356 ****
- setenv("LINES", (char *)envbuf, 1);
- sprintf((char *)envbuf, "%ld", Columns);
- setenv("COLUMNS", (char *)envbuf, 1);
- ! #else
- /*
- * Putenv does not copy the string, it has to remain valid.
- * Use a static array to avoid loosing allocated memory.
- --- 3359,3365 ----
- setenv("LINES", (char *)envbuf, 1);
- sprintf((char *)envbuf, "%ld", Columns);
- setenv("COLUMNS", (char *)envbuf, 1);
- ! # else
- /*
- * Putenv does not copy the string, it has to remain valid.
- * Use a static array to avoid loosing allocated memory.
- ***************
- *** 3362,3368 ****
- putenv(envbuf_Rows);
- sprintf(envbuf_Columns, "COLUMNS=%ld", Columns);
- putenv(envbuf_Columns);
- ! #endif
-
- if (pty_master_fd >= 0)
- {
- --- 3371,3377 ----
- putenv(envbuf_Rows);
- sprintf(envbuf_Columns, "COLUMNS=%ld", Columns);
- putenv(envbuf_Columns);
- ! # endif
-
- if (pty_master_fd >= 0)
- {
- ***************
- *** 3397,3403 ****
- dup(1);
- }
- }
- ! #endif
- /*
- * There is no type cast for the argv, because the type may be
- * different on different machines. This may cause a warning
- --- 3406,3412 ----
- dup(1);
- }
- }
- ! # endif /* FEAT_GUI */
- /*
- * There is no type cast for the argv, because the type may be
- * different on different machines. This may cause a warning
- ***************
- *** 3415,3432 ****
- */
- catch_signals(SIG_IGN, SIG_ERR);
-
- ! #ifdef FEAT_GUI
-
- /*
- * For the GUI we redirect stdin, stdout and stderr to our window.
- */
- if (gui.in_use && show_shell_mess)
- {
- ! #define BUFLEN 100 /* length for buffer, pseudo tty limit is 128 */
- char_u buffer[BUFLEN + 1];
- ! #ifdef FEAT_MBYTE
- int buffer_off = 0; /* valid bytes in buffer[] */
- ! #endif
- char_u ta_buf[BUFLEN + 1]; /* TypeAHead */
- int ta_len = 0; /* valid bytes in ta_buf[] */
- int len;
- --- 3424,3441 ----
- */
- catch_signals(SIG_IGN, SIG_ERR);
-
- ! # ifdef FEAT_GUI
-
- /*
- * For the GUI we redirect stdin, stdout and stderr to our window.
- */
- if (gui.in_use && show_shell_mess)
- {
- ! # define BUFLEN 100 /* length for buffer, pseudo tty limit is 128 */
- char_u buffer[BUFLEN + 1];
- ! # ifdef FEAT_MBYTE
- int buffer_off = 0; /* valid bytes in buffer[] */
- ! # endif
- char_u ta_buf[BUFLEN + 1]; /* TypeAHead */
- int ta_len = 0; /* valid bytes in ta_buf[] */
- int len;
- ***************
- *** 3491,3509 ****
- */
- if (len == 1 && (pty_master_fd < 0 || cmd != NULL))
- {
- ! #ifdef SIGINT
- /*
- * Send SIGINT to the child's group or all
- * processes in our group.
- */
- if (ta_buf[ta_len] == Ctrl_C
- || ta_buf[ta_len] == intr_char)
- ! # ifdef HAVE_SETSID
- kill(-pid, SIGINT);
- ! # else
- kill(0, SIGINT);
- ! # endif
- ! #endif
- if (pty_master_fd < 0 && toshell_fd >= 0
- && ta_buf[ta_len] == Ctrl_D)
- {
- --- 3500,3518 ----
- */
- if (len == 1 && (pty_master_fd < 0 || cmd != NULL))
- {
- ! # ifdef SIGINT
- /*
- * Send SIGINT to the child's group or all
- * processes in our group.
- */
- if (ta_buf[ta_len] == Ctrl_C
- || ta_buf[ta_len] == intr_char)
- ! # ifdef HAVE_SETSID
- kill(-pid, SIGINT);
- ! # else
- kill(0, SIGINT);
- ! # endif
- ! # endif
- if (pty_master_fd < 0 && toshell_fd >= 0
- && ta_buf[ta_len] == Ctrl_D)
- {
- ***************
- *** 3531,3540 ****
- }
- else if (ta_buf[i] == '\r')
- ta_buf[i] = '\n';
- ! #ifdef FEAT_MBYTE
- if (has_mbyte)
- i += (*mb_ptr2len_check)(ta_buf + i) - 1;
- ! #endif
- }
-
- /*
- --- 3540,3549 ----
- }
- else if (ta_buf[i] == '\r')
- ta_buf[i] = '\n';
- ! # ifdef FEAT_MBYTE
- if (has_mbyte)
- i += (*mb_ptr2len_check)(ta_buf + i) - 1;
- ! # endif
- }
-
- /*
- ***************
- *** 3547,3553 ****
- {
- if (ta_buf[i] == '\n' || ta_buf[i] == '\b')
- msg_putchar(ta_buf[i]);
- ! #ifdef FEAT_MBYTE
- else if (has_mbyte)
- {
- int l = (*mb_ptr2len_check)(ta_buf + i);
- --- 3556,3562 ----
- {
- if (ta_buf[i] == '\n' || ta_buf[i] == '\b')
- msg_putchar(ta_buf[i]);
- ! # ifdef FEAT_MBYTE
- else if (has_mbyte)
- {
- int l = (*mb_ptr2len_check)(ta_buf + i);
- ***************
- *** 3555,3561 ****
- msg_outtrans_len(ta_buf + i, l);
- i += l - 1;
- }
- ! #endif
- else
- msg_outtrans_len(ta_buf + i, 1);
- }
- --- 3564,3570 ----
- msg_outtrans_len(ta_buf + i, l);
- i += l - 1;
- }
- ! # endif
- else
- msg_outtrans_len(ta_buf + i, 1);
- }
- ***************
- *** 3593,3607 ****
- while (RealWaitForChar(fromshell_fd, 10L, NULL))
- {
- len = read(fromshell_fd, (char *)buffer
- ! #ifdef FEAT_MBYTE
- + buffer_off, (size_t)(BUFLEN - buffer_off)
- ! #else
- , (size_t)BUFLEN
- ! #endif
- );
- if (len <= 0) /* end of file or error */
- goto finished;
- ! #ifdef FEAT_MBYTE
- len += buffer_off;
- buffer[len] = NUL;
- if (has_mbyte)
- --- 3602,3616 ----
- while (RealWaitForChar(fromshell_fd, 10L, NULL))
- {
- len = read(fromshell_fd, (char *)buffer
- ! # ifdef FEAT_MBYTE
- + buffer_off, (size_t)(BUFLEN - buffer_off)
- ! # else
- , (size_t)BUFLEN
- ! # endif
- );
- if (len <= 0) /* end of file or error */
- goto finished;
- ! # ifdef FEAT_MBYTE
- len += buffer_off;
- buffer[len] = NUL;
- if (has_mbyte)
- ***************
- *** 3647,3653 ****
- buffer_off = 0;
- }
- else
- ! #endif
- {
- buffer[len] = NUL;
- msg_puts(buffer);
- --- 3656,3662 ----
- buffer_off = 0;
- }
- else
- ! # endif /* FEAT_MBYTE */
- {
- buffer[len] = NUL;
- msg_puts(buffer);
- ***************
- *** 3664,3674 ****
- * Check if the child still exists, before checking for
- * typed characters (otherwise we would loose typeahead).
- */
- ! #ifdef __NeXT__
- wait_pid = wait4(pid, &status, WNOHANG, (struct rusage *) 0);
- ! #else
- wait_pid = waitpid(pid, &status, WNOHANG);
- ! #endif
- if ((wait_pid == (pid_t)-1 && errno == ECHILD)
- || (wait_pid == pid && WIFEXITED(status)))
- {
- --- 3673,3683 ----
- * Check if the child still exists, before checking for
- * typed characters (otherwise we would loose typeahead).
- */
- ! # ifdef __NeXT__
- wait_pid = wait4(pid, &status, WNOHANG, (struct rusage *) 0);
- ! # else
- wait_pid = waitpid(pid, &status, WNOHANG);
- ! # endif
- if ((wait_pid == (pid_t)-1 && errno == ECHILD)
- || (wait_pid == pid && WIFEXITED(status)))
- {
- ***************
- *** 3680,3698 ****
- finished:
- p_more = p_more_save;
-
- ! #ifndef MACOS_X_UNIX /* TODO: Is it needed for MACOS_X ? */
- /*
- * Give all typeahead that wasn't used back to ui_inchar().
- */
- if (ta_len)
- ui_inchar_undo(ta_buf, ta_len);
- ! #endif
- State = old_State;
- if (toshell_fd >= 0)
- close(toshell_fd);
- close(fromshell_fd);
- }
- ! #endif /* FEAT_GUI */
-
- /*
- * Wait until our child has exited.
- --- 3689,3707 ----
- finished:
- p_more = p_more_save;
-
- ! # ifndef MACOS_X_UNIX /* TODO: Is it needed for MACOS_X ? */
- /*
- * Give all typeahead that wasn't used back to ui_inchar().
- */
- if (ta_len)
- ui_inchar_undo(ta_buf, ta_len);
- ! # endif
- State = old_State;
- if (toshell_fd >= 0)
- close(toshell_fd);
- close(fromshell_fd);
- }
- ! # endif /* FEAT_GUI */
-
- /*
- * Wait until our child has exited.
- ***************
- *** 3705,3713 ****
- {
- wait_pid = wait(&status);
- if (wait_pid <= 0
- ! #ifdef ECHILD
- && errno == ECHILD
- ! #endif
- )
- break;
- }
- --- 3714,3722 ----
- {
- wait_pid = wait(&status);
- if (wait_pid <= 0
- ! # ifdef ECHILD
- && errno == ECHILD
- ! # endif
- )
- break;
- }
- ***************
- *** 3750,3758 ****
- if (!did_settmode)
- if (tmode == TMODE_RAW)
- settmode(TMODE_RAW); /* set to raw mode */
- ! #ifdef FEAT_TITLE
- resettitle();
- ! #endif
- vim_free(newcmd);
-
- return retval;
- --- 3759,3767 ----
- if (!did_settmode)
- if (tmode == TMODE_RAW)
- settmode(TMODE_RAW); /* set to raw mode */
- ! # ifdef FEAT_TITLE
- resettitle();
- ! # endif
- vim_free(newcmd);
-
- return retval;
- *** ../vim61.369/src/version.c Sun Mar 9 14:08:43 2003
- --- src/version.c Sun Mar 9 14:12:12 2003
- ***************
- *** 613,614 ****
- --- 613,616 ----
- { /* Add new patch number below this line */
- + /**/
- + 370,
- /**/
-
- --
- It's totally unfair to suggest - as many have - that engineers are socially
- inept. Engineers simply have different objectives when it comes to social
- interaction.
- (Scott Adams - The Dilbert principle)
-
- /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
- /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\
- \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
- \\\ Help AIDS victims, buy at Amazon -- http://ICCF.nl/click1.html ///
-