=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/less/lsystem.c,v retrieving revision 1.1.1.2 retrieving revision 1.1.1.3 diff -c -r1.1.1.2 -r1.1.1.3 *** src/usr.bin/less/lsystem.c 2003/04/13 18:21:21 1.1.1.2 --- src/usr.bin/less/lsystem.c 2011/09/16 17:47:06 1.1.1.3 *************** *** 1,5 **** /* ! * Copyright (C) 1984-2002 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. --- 1,5 ---- /* ! * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. *************** *** 49,55 **** register char *p; #endif IFILE save_ifile; ! #if MSDOS_COMPILER char cwd[FILENAME_MAX+1]; #endif --- 49,55 ---- register char *p; #endif IFILE save_ifile; ! #if MSDOS_COMPILER && MSDOS_COMPILER!=WIN32C char cwd[FILENAME_MAX+1]; #endif *************** *** 68,73 **** --- 68,77 ---- } #if MSDOS_COMPILER + #if MSDOS_COMPILER==WIN32C + if (*cmd == '\0') + cmd = getenv("COMSPEC"); + #else /* * Working directory is global on MSDOS. * The child might change the working directory, so we *************** *** 77,82 **** --- 81,87 ---- */ getcwd(cwd, FILENAME_MAX); #endif + #endif /* * Close the current input file. *************** *** 133,141 **** char *esccmd = shell_quote(cmd); if (esccmd != NULL) { ! p = (char *) ecalloc(strlen(shell) + ! strlen(esccmd) + 5, sizeof(char)); ! sprintf(p, "%s %s %s", shell, shell_coption(), esccmd); free(esccmd); } } --- 138,146 ---- char *esccmd = shell_quote(cmd); if (esccmd != NULL) { ! int len = strlen(shell) + strlen(esccmd) + 5; ! p = (char *) ecalloc(len, sizeof(char)); ! SNPRINTF3(p, len, "%s %s %s", shell, shell_coption(), esccmd); free(esccmd); } } *************** *** 192,198 **** init(); screen_trashed = 1; ! #if MSDOS_COMPILER /* * Restore the previous directory (possibly * changed by the child program we just ran). --- 197,203 ---- init(); screen_trashed = 1; ! #if MSDOS_COMPILER && MSDOS_COMPILER!=WIN32C /* * Restore the previous directory (possibly * changed by the child program we just ran). *************** *** 367,509 **** } #endif - - #ifdef _OSK - /* - * Popen, and Pclose, for OS-9. - * - * Based on code copyright (c) 1988 by Wolfgang Ocker, Puchheim, - * Ulli Dessauer, Germering and - * Reimer Mellin, Muenchen - * (W-Germany) - * - * These functions can be copied and distributed freely for any - * non-commercial purposes. It can only be incorporated into - * commercial software with the written permission of the authors. - * - * TOP-specific code stripped out and adapted for less by M.Gregorie, 1996 - * - * address: Wolfgang Ocker - * Lochhauserstrasse 35a - * D-8039 Puchheim - * West Germany - * - * e-mail: weo@altger.UUCP, ud@altger.UUCP, ram@altger.UUCP - * pyramid!tmpmbx!recco!weo - * pyramid!tmpmbx!nitmar!ud - * pyramid!tmpmbx!ramsys!ram - * - * Martin Gregorie - * 10 Sadlers Mead - * Harlow - * Essex, CM18 6HG - * U.K. - * - * gregorie@logica.com - */ - #include - #include - extern char **environ; - extern char *getenv(); - extern int os9forkc(); - static int pids[_NFILE] = { 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 }; - /* - * p o p e n - */ - FILE *popen(name, mode) - char *name; - char *mode; - { - int fd, fd2, fdsav, pid; - static char *argv[] = {NULL, NULL, NULL }; - static char cmd[200]; - static char cmd_path[200]; - char *cp; - char *shell; - FILE *r; - if ((shell = getenv("SHELL")) == NULL) - return(NULL); - cp = name; - while (*cp == ' ') - cp++; - strcpy(cmd_path, cp); - if (cp = index(cmd_path, ' ')) - *cp++ = '\0'; - strcpy(cmd, "ex "); - strcat(cmd, cmd_path); - if (cp) - { - strcat(cmd, " "); - strcat(cmd, cp); - } - argv[0] = shell; - argv[1] = cmd; - /* - mode is "r" (stdout) or "w" (stdin) - */ - switch(mode[0]) - { - case 'w': fd = 0; - break; - case 'r': fd = 1; - break; - default: return(NULL); - } - if (fd == 1) - fflush(stdout); - fdsav = dup(fd); - close(fd); - - creat("/pipe", S_IWRITE+S_IREAD); - pid = os9exec(os9forkc, argv[0], argv, environ, 0, 0, 3); - fd2 = dup(fd); - close(fd); - dup(fdsav); - close(fdsav); - if (pid > 0) - { - pids[fd2] = pid; - r = fdopen(fd2, mode); - } - else - { - close(fd2); - r = NULL; - } - return(r); - } - - /* - * p c l o s e - */ - int pclose(fp) - FILE *fp; - { - unsigned int status; - int pid; - int fd, - i; - fd = fileno(fp); - if (pids[fd] == 0) - return(-1); - fflush(fp); - fclose(fp); - while ((pid = wait(&status)) != -1) - if (pid == pids[fd]) - break; - else - for (i = 0; i < _NFILE; i++) - if (pids[i] == pid) - { - pids[i] = 0; - break; - } - if (pid == -1) - status = -1; - pids[fd] = 0; - return(status); - } - #endif /* _OSK */ --- 372,374 ----