lsystem.c (6f26c71d76bb795b30684affb3b57870a7926b26) | lsystem.c (2235c7feac959bcc9ddfd6a2bc6be32102b1f84c) |
---|---|
1/* | 1/* |
2 * Copyright (C) 1984-2020 Mark Nudelman | 2 * Copyright (C) 1984-2021 Mark Nudelman |
3 * 4 * You may distribute under the terms of either the GNU General Public 5 * License or the Less License, as specified in the README file. 6 * 7 * For more information, see the README file. 8 */ 9 10 --- 81 unchanged lines hidden (view full) --- 92 */ 93 save_ifile = save_curr_ifile(); 94 (void) edit_ifile(NULL_IFILE); 95 96 /* 97 * De-initialize the terminal and take out of raw mode. 98 */ 99 deinit(); | 3 * 4 * You may distribute under the terms of either the GNU General Public 5 * License or the Less License, as specified in the README file. 6 * 7 * For more information, see the README file. 8 */ 9 10 --- 81 unchanged lines hidden (view full) --- 92 */ 93 save_ifile = save_curr_ifile(); 94 (void) edit_ifile(NULL_IFILE); 95 96 /* 97 * De-initialize the terminal and take out of raw mode. 98 */ 99 deinit(); |
100 flush(); /* Make sure the deinit chars get out */ | 100 flush(); /* Make sure the deinit chars get out */ |
101 raw_mode(0); 102#if MSDOS_COMPILER==WIN32C 103 close_getchr(); 104#endif 105 106 /* 107 * Restore signals to their defaults. 108 */ 109 init_signals(0); 110 111#if HAVE_DUP 112 /* 113 * Force standard input to be the user's terminal 114 * (the normal standard input), even if less's standard input 115 * is coming from a pipe. 116 */ 117 inp = dup(0); 118 close(0); | 101 raw_mode(0); 102#if MSDOS_COMPILER==WIN32C 103 close_getchr(); 104#endif 105 106 /* 107 * Restore signals to their defaults. 108 */ 109 init_signals(0); 110 111#if HAVE_DUP 112 /* 113 * Force standard input to be the user's terminal 114 * (the normal standard input), even if less's standard input 115 * is coming from a pipe. 116 */ 117 inp = dup(0); 118 close(0); |
119#if !MSDOS_COMPILER |
|
119#if OS2 120 /* The __open() system call translates "/dev/tty" to "con". */ | 120#if OS2 121 /* The __open() system call translates "/dev/tty" to "con". */ |
121 if (__open("/dev/tty", OPEN_READ) < 0) | 122 if (__open(tty_device(), OPEN_READ) < 0) |
122#else | 123#else |
123 if (open("/dev/tty", OPEN_READ) < 0) | 124 if (open(tty_device(), OPEN_READ) < 0) |
124#endif | 125#endif |
126#endif |
|
125 dup(inp); 126#endif 127 128 /* 129 * Pass the command to the system to be executed. 130 * If we have a SHELL environment variable, use 131 * <$SHELL -c "command"> instead of just <command>. 132 * If the command is empty, just invoke a shell. --- 31 unchanged lines hidden (view full) --- 164 * Make stdin of the child be in cooked mode. 165 */ 166 setmode(0, O_TEXT); 167 /* 168 * We don't need to catch signals of the child (it 169 * also makes trouble with some DPMI servers). 170 */ 171 __djgpp_exception_toggle(); | 127 dup(inp); 128#endif 129 130 /* 131 * Pass the command to the system to be executed. 132 * If we have a SHELL environment variable, use 133 * <$SHELL -c "command"> instead of just <command>. 134 * If the command is empty, just invoke a shell. --- 31 unchanged lines hidden (view full) --- 166 * Make stdin of the child be in cooked mode. 167 */ 168 setmode(0, O_TEXT); 169 /* 170 * We don't need to catch signals of the child (it 171 * also makes trouble with some DPMI servers). 172 */ 173 __djgpp_exception_toggle(); |
172 system(cmd); | 174 system(cmd); |
173 __djgpp_exception_toggle(); 174#else 175 system(cmd); 176#endif 177#endif 178 179#if HAVE_DUP 180 /* --- 88 unchanged lines hidden (view full) --- 269 mpos = markpos(c); 270 if (mpos == NULL_POSITION) 271 return (-1); 272 tpos = position(TOP); 273 if (tpos == NULL_POSITION) 274 tpos = ch_zero(); 275 bpos = position(BOTTOM); 276 | 175 __djgpp_exception_toggle(); 176#else 177 system(cmd); 178#endif 179#endif 180 181#if HAVE_DUP 182 /* --- 88 unchanged lines hidden (view full) --- 271 mpos = markpos(c); 272 if (mpos == NULL_POSITION) 273 return (-1); 274 tpos = position(TOP); 275 if (tpos == NULL_POSITION) 276 tpos = ch_zero(); 277 bpos = position(BOTTOM); 278 |
277 if (c == '.') 278 return (pipe_data(cmd, tpos, bpos)); 279 else if (mpos <= tpos) 280 return (pipe_data(cmd, mpos, bpos)); 281 else if (bpos == NULL_POSITION) 282 return (pipe_data(cmd, tpos, bpos)); 283 else 284 return (pipe_data(cmd, tpos, mpos)); | 279 if (c == '.') 280 return (pipe_data(cmd, tpos, bpos)); 281 else if (mpos <= tpos) 282 return (pipe_data(cmd, mpos, bpos)); 283 else if (bpos == NULL_POSITION) 284 return (pipe_data(cmd, tpos, bpos)); 285 else 286 return (pipe_data(cmd, tpos, mpos)); |
285} 286 287/* 288 * Create a pipe to the given shell command. 289 * Feed it the file contents between the positions spos and epos. 290 */ 291 public int 292pipe_data(cmd, spos, epos) --- 48 unchanged lines hidden (view full) --- 341 break; 342 if (putc(c, f) == EOF) 343 break; 344 } 345 346 /* 347 * Finish up the last line. 348 */ | 287} 288 289/* 290 * Create a pipe to the given shell command. 291 * Feed it the file contents between the positions spos and epos. 292 */ 293 public int 294pipe_data(cmd, spos, epos) --- 48 unchanged lines hidden (view full) --- 343 break; 344 if (putc(c, f) == EOF) 345 break; 346 } 347 348 /* 349 * Finish up the last line. 350 */ |
349 while (c != '\n' && c != EOI ) 350 { 351 c = ch_forw_get(); 352 if (c == EOI) 353 break; 354 if (putc(c, f) == EOF) 355 break; 356 } | 351 while (c != '\n' && c != EOI ) 352 { 353 c = ch_forw_get(); 354 if (c == EOI) 355 break; 356 if (putc(c, f) == EOF) 357 break; 358 } |
357 358 pclose(f); 359 360#ifdef SIGPIPE 361 LSIGNAL(SIGPIPE, SIG_DFL); 362#endif 363#if MSDOS_COMPILER==WIN32C 364 open_getchr(); --- 13 unchanged lines hidden --- | 359 360 pclose(f); 361 362#ifdef SIGPIPE 363 LSIGNAL(SIGPIPE, SIG_DFL); 364#endif 365#if MSDOS_COMPILER==WIN32C 366 open_getchr(); --- 13 unchanged lines hidden --- |