Mercurial > octave
comparison src/sysdep.cc @ 11586:12df7854fa7c
strip trailing whitespace from source files
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 20 Jan 2011 17:24:59 -0500 |
parents | 7d6d8c1e471f |
children | 0f70c5db58c3 |
comparison
equal
deleted
inserted
replaced
11585:1473d0cf86d2 | 11586:12df7854fa7c |
---|---|
40 #include <termios.h> | 40 #include <termios.h> |
41 #elif defined (HAVE_TERMIO_H) | 41 #elif defined (HAVE_TERMIO_H) |
42 #include <termio.h> | 42 #include <termio.h> |
43 #elif defined (HAVE_SGTTY_H) | 43 #elif defined (HAVE_SGTTY_H) |
44 #include <sgtty.h> | 44 #include <sgtty.h> |
45 #endif | 45 #endif |
46 | 46 |
47 #if defined (HAVE_CONIO_H) | 47 #if defined (HAVE_CONIO_H) |
48 #include <conio.h> | 48 #include <conio.h> |
49 #endif | 49 #endif |
50 | 50 |
169 #if defined (_MSC_VER) | 169 #if defined (_MSC_VER) |
170 static void | 170 static void |
171 MSVC_init (void) | 171 MSVC_init (void) |
172 { | 172 { |
173 w32_set_octave_home (); | 173 w32_set_octave_home (); |
174 | 174 |
175 // Init mutex to protect setjmp/longjmp and get main thread context | 175 // Init mutex to protect setjmp/longjmp and get main thread context |
176 w32_sigint_init (); | 176 w32_sigint_init (); |
177 | 177 |
178 w32_set_quiet_shutdown (); | 178 w32_set_quiet_shutdown (); |
179 } | 179 } |
187 { | 187 { |
188 #ifdef OCTAVE_USE_WINDOWS_API | 188 #ifdef OCTAVE_USE_WINDOWS_API |
189 | 189 |
190 bool retval = false; | 190 bool retval = false; |
191 | 191 |
192 // Windows native code | 192 // Windows native code |
193 // Reference: http://msdn2.microsoft.com/en-us/library/aa363788.aspx | 193 // Reference: http://msdn2.microsoft.com/en-us/library/aa363788.aspx |
194 | 194 |
195 HANDLE hfile1 = CreateFile (file1.c_str (), 0, FILE_SHARE_READ, 0, | 195 HANDLE hfile1 = CreateFile (file1.c_str (), 0, FILE_SHARE_READ, 0, |
196 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); | 196 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); |
197 | 197 |
198 if (hfile1 != INVALID_HANDLE_VALUE) | 198 if (hfile1 != INVALID_HANDLE_VALUE) |
199 { | 199 { |
200 HANDLE hfile2 = CreateFile (file2.c_str (), 0, FILE_SHARE_READ, 0, | 200 HANDLE hfile2 = CreateFile (file2.c_str (), 0, FILE_SHARE_READ, 0, |
201 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); | 201 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); |
202 | 202 |
203 if (hfile2 != INVALID_HANDLE_VALUE) | 203 if (hfile2 != INVALID_HANDLE_VALUE) |
204 { | 204 { |
205 BY_HANDLE_FILE_INFORMATION hfi1; | 205 BY_HANDLE_FILE_INFORMATION hfi1; |
206 BY_HANDLE_FILE_INFORMATION hfi2; | 206 BY_HANDLE_FILE_INFORMATION hfi2; |
207 | 207 |
208 if (GetFileInformationByHandle (hfile1, &hfi1) | 208 if (GetFileInformationByHandle (hfile1, &hfi1) |
209 && GetFileInformationByHandle (hfile2, &hfi2)) | 209 && GetFileInformationByHandle (hfile2, &hfi2)) |
210 | 210 |
211 retval = (hfi1.dwVolumeSerialNumber == hfi2.dwVolumeSerialNumber | 211 retval = (hfi1.dwVolumeSerialNumber == hfi2.dwVolumeSerialNumber |
212 && hfi1.nFileIndexHigh == hfi2.nFileIndexHigh | 212 && hfi1.nFileIndexHigh == hfi2.nFileIndexHigh |
213 && hfi1.nFileIndexLow == hfi2.nFileIndexLow); | 213 && hfi1.nFileIndexLow == hfi2.nFileIndexLow); |
214 | 214 |
215 CloseHandle (hfile2); | 215 CloseHandle (hfile2); |
253 } | 253 } |
254 | 254 |
255 // Set terminal in raw mode. From less-177. | 255 // Set terminal in raw mode. From less-177. |
256 // | 256 // |
257 // Change terminal to "raw mode", or restore to "normal" mode. | 257 // Change terminal to "raw mode", or restore to "normal" mode. |
258 // "Raw mode" means | 258 // "Raw mode" means |
259 // 1. An outstanding read will complete on receipt of a single keystroke. | 259 // 1. An outstanding read will complete on receipt of a single keystroke. |
260 // 2. Input is not echoed. | 260 // 2. Input is not echoed. |
261 // 3. On output, \n is mapped to \r\n. | 261 // 3. On output, \n is mapped to \r\n. |
262 // 4. \t is NOT expanded into spaces. | 262 // 4. \t is NOT expanded into spaces. |
263 // 5. Signal-causing characters such as ctrl-C (interrupt), | 263 // 5. Signal-causing characters such as ctrl-C (interrupt), |
264 // etc. are NOT disabled. | 264 // etc. are NOT disabled. |
265 // It doesn't matter whether an input \n is mapped to \r, or vice versa. | 265 // It doesn't matter whether an input \n is mapped to \r, or vice versa. |
311 #if defined (ONLRET) | 311 #if defined (ONLRET) |
312 s.c_oflag &= ~(ONLRET); | 312 s.c_oflag &= ~(ONLRET); |
313 #endif | 313 #endif |
314 s.c_cc[VMIN] = wait ? 1 : 0; | 314 s.c_cc[VMIN] = wait ? 1 : 0; |
315 s.c_cc[VTIME] = 0; | 315 s.c_cc[VTIME] = 0; |
316 } | 316 } |
317 else | 317 else |
318 { | 318 { |
319 // Restore saved modes. | 319 // Restore saved modes. |
320 | 320 |
321 s = save_term; | 321 s = save_term; |
353 #endif | 353 #endif |
354 #if defined (ONLRET) | 354 #if defined (ONLRET) |
355 s.c_oflag &= ~(ONLRET); | 355 s.c_oflag &= ~(ONLRET); |
356 #endif | 356 #endif |
357 s.c_cc[VMIN] = wait ? 1 : 0; | 357 s.c_cc[VMIN] = wait ? 1 : 0; |
358 } | 358 } |
359 else | 359 else |
360 { | 360 { |
361 // Restore saved modes. | 361 // Restore saved modes. |
362 | 362 |
363 s = save_term; | 363 s = save_term; |
385 | 385 |
386 // Set the modes to the way we want them. | 386 // Set the modes to the way we want them. |
387 | 387 |
388 s.sg_flags |= CBREAK; | 388 s.sg_flags |= CBREAK; |
389 s.sg_flags &= ~(ECHO); | 389 s.sg_flags &= ~(ECHO); |
390 } | 390 } |
391 else | 391 else |
392 { | 392 { |
393 // Restore saved modes. | 393 // Restore saved modes. |
394 | 394 |
395 s = save_term; | 395 s = save_term; |
455 // read can be interrupted. | 455 // read can be interrupted. |
456 | 456 |
457 octave_set_interrupt_handler (saved_interrupt_handler, false); | 457 octave_set_interrupt_handler (saved_interrupt_handler, false); |
458 | 458 |
459 int c = std::cin.get (); | 459 int c = std::cin.get (); |
460 | 460 |
461 if (std::cin.fail () || std::cin.eof ()) | 461 if (std::cin.fail () || std::cin.eof ()) |
462 std::cin.clear (); | 462 std::cin.clear (); |
463 | 463 |
464 // Restore it, enabling system call restarts (if possible). | 464 // Restore it, enabling system call restarts (if possible). |
465 octave_set_interrupt_handler (saved_interrupt_handler, true); | 465 octave_set_interrupt_handler (saved_interrupt_handler, true); |
525 | 525 |
526 int nargin = args.length (); | 526 int nargin = args.length (); |
527 | 527 |
528 if (nargin == 2 || nargin == 1) | 528 if (nargin == 2 || nargin == 1) |
529 { | 529 { |
530 std::string var = args(0).string_value (); | 530 std::string var = args(0).string_value (); |
531 | 531 |
532 if (! error_state) | 532 if (! error_state) |
533 { | 533 { |
534 std::string val = (nargin == 2 | 534 std::string val = (nargin == 2 |
535 ? args(1).string_value () : std::string ()); | 535 ? args(1).string_value () : std::string ()); |
536 | 536 |
537 if (! error_state) | 537 if (! error_state) |
538 octave_env::putenv (var, val); | 538 octave_env::putenv (var, val); |
539 else | 539 else |
540 error ("putenv: second argument should be a string"); | 540 error ("putenv: second argument should be a string"); |