diff options
| author | Geoff Voelker | 1998-04-17 05:07:15 +0000 |
|---|---|---|
| committer | Geoff Voelker | 1998-04-17 05:07:15 +0000 |
| commit | f52eb3efc422eeaf36595b4c65653db95d5a5752 (patch) | |
| tree | 8e1b3fba24e559a6d3fff12aa4505326dd270dc3 /src/w32.c | |
| parent | 9c8056fe19279f2ac8cb89bcf666d2d54456e95b (diff) | |
| download | emacs-f52eb3efc422eeaf36595b4c65653db95d5a5752.tar.gz emacs-f52eb3efc422eeaf36595b4c65653db95d5a5752.zip | |
(sys_read): Clear carriage return flag.
Report normal EOF when read fails if nothing in buffer.
Only read more if more remaining.
(check_windows_init_file): New function.
(term_ntproc): Invoke check_windows_init_file.
Diffstat (limited to 'src/w32.c')
| -rw-r--r-- | src/w32.c | 76 |
1 files changed, 68 insertions, 8 deletions
| @@ -2456,6 +2456,7 @@ sys_read (int fd, char * buffer, unsigned int count) | |||
| 2456 | *buffer++ = 0x0d; | 2456 | *buffer++ = 0x0d; |
| 2457 | count--; | 2457 | count--; |
| 2458 | nchars++; | 2458 | nchars++; |
| 2459 | fd_info[fd].flags &= ~FILE_LAST_CR; | ||
| 2459 | } | 2460 | } |
| 2460 | 2461 | ||
| 2461 | /* presence of a child_process structure means we are operating in | 2462 | /* presence of a child_process structure means we are operating in |
| @@ -2471,8 +2472,10 @@ sys_read (int fd, char * buffer, unsigned int count) | |||
| 2471 | { | 2472 | { |
| 2472 | case STATUS_READ_FAILED: | 2473 | case STATUS_READ_FAILED: |
| 2473 | case STATUS_READ_ERROR: | 2474 | case STATUS_READ_ERROR: |
| 2474 | /* report normal EOF */ | 2475 | /* report normal EOF if nothing in buffer */ |
| 2475 | return 0; | 2476 | if (nchars <= 0) |
| 2477 | fd_info[fd].flags |= FILE_AT_EOF; | ||
| 2478 | return nchars; | ||
| 2476 | 2479 | ||
| 2477 | case STATUS_READ_READY: | 2480 | case STATUS_READ_READY: |
| 2478 | case STATUS_READ_IN_PROGRESS: | 2481 | case STATUS_READ_IN_PROGRESS: |
| @@ -2501,8 +2504,9 @@ sys_read (int fd, char * buffer, unsigned int count) | |||
| 2501 | { | 2504 | { |
| 2502 | PeekNamedPipe ((HANDLE) _get_osfhandle (fd), NULL, 0, NULL, &waiting, NULL); | 2505 | PeekNamedPipe ((HANDLE) _get_osfhandle (fd), NULL, 0, NULL, &waiting, NULL); |
| 2503 | to_read = min (waiting, (DWORD) count); | 2506 | to_read = min (waiting, (DWORD) count); |
| 2504 | 2507 | ||
| 2505 | nchars += _read (fd, buffer, to_read); | 2508 | if (to_read > 0) |
| 2509 | nchars += _read (fd, buffer, to_read); | ||
| 2506 | } | 2510 | } |
| 2507 | #ifdef HAVE_SOCKETS | 2511 | #ifdef HAVE_SOCKETS |
| 2508 | else /* FILE_SOCKET */ | 2512 | else /* FILE_SOCKET */ |
| @@ -2534,10 +2538,18 @@ sys_read (int fd, char * buffer, unsigned int count) | |||
| 2534 | #endif | 2538 | #endif |
| 2535 | } | 2539 | } |
| 2536 | else | 2540 | else |
| 2537 | nchars += _read (fd, buffer, count); | 2541 | { |
| 2542 | int nread = _read (fd, buffer, count); | ||
| 2543 | if (nread >= 0) | ||
| 2544 | nchars += nread; | ||
| 2545 | else if (nchars == 0) | ||
| 2546 | nchars = nread; | ||
| 2547 | } | ||
| 2538 | 2548 | ||
| 2549 | if (nchars <= 0) | ||
| 2550 | fd_info[fd].flags |= FILE_AT_EOF; | ||
| 2539 | /* Perform text mode translation if required. */ | 2551 | /* Perform text mode translation if required. */ |
| 2540 | if ((fd_info[fd].flags & FILE_BINARY) == 0) | 2552 | else if ((fd_info[fd].flags & FILE_BINARY) == 0) |
| 2541 | { | 2553 | { |
| 2542 | nchars = crlf_to_lf (nchars, orig_buffer); | 2554 | nchars = crlf_to_lf (nchars, orig_buffer); |
| 2543 | /* If buffer contains only CR, return that. To be absolutely | 2555 | /* If buffer contains only CR, return that. To be absolutely |
| @@ -2549,8 +2561,6 @@ sys_read (int fd, char * buffer, unsigned int count) | |||
| 2549 | fd_info[fd].flags |= FILE_LAST_CR; | 2561 | fd_info[fd].flags |= FILE_LAST_CR; |
| 2550 | nchars--; | 2562 | nchars--; |
| 2551 | } | 2563 | } |
| 2552 | else | ||
| 2553 | fd_info[fd].flags &= ~FILE_LAST_CR; | ||
| 2554 | } | 2564 | } |
| 2555 | } | 2565 | } |
| 2556 | else | 2566 | else |
| @@ -2631,6 +2641,50 @@ sys_write (int fd, const void * buffer, unsigned int count) | |||
| 2631 | return nchars; | 2641 | return nchars; |
| 2632 | } | 2642 | } |
| 2633 | 2643 | ||
| 2644 | static void | ||
| 2645 | check_windows_init_file () | ||
| 2646 | { | ||
| 2647 | extern int noninteractive, inhibit_window_system; | ||
| 2648 | |||
| 2649 | /* A common indication that Emacs is not installed properly is when | ||
| 2650 | it cannot find the Windows installation file. If this file does | ||
| 2651 | not exist in the expected place, tell the user. */ | ||
| 2652 | |||
| 2653 | if (!noninteractive && !inhibit_window_system) { | ||
| 2654 | extern Lisp_Object Vwindow_system, Vload_path; | ||
| 2655 | Lisp_Object init_file; | ||
| 2656 | int fd; | ||
| 2657 | |||
| 2658 | init_file = build_string ("term/w32-win"); | ||
| 2659 | fd = openp (Vload_path, init_file, ".el:.elc", NULL, 0); | ||
| 2660 | if (fd < 0) { | ||
| 2661 | Lisp_Object load_path_print = Fprin1_to_string (Vload_path, Qnil); | ||
| 2662 | char *init_file_name = XSTRING (init_file)->data; | ||
| 2663 | char *load_path = XSTRING (load_path_print)->data; | ||
| 2664 | char *buffer = alloca (1024); | ||
| 2665 | |||
| 2666 | sprintf (buffer, | ||
| 2667 | "The Emacs Windows initialization file \"%s.el\" " | ||
| 2668 | "could not be found in your Emacs installation. " | ||
| 2669 | "Emacs checked the following directories for this file:\n" | ||
| 2670 | "\n%s\n\n" | ||
| 2671 | "When Emacs cannot find this file, it usually means that it " | ||
| 2672 | "was not installed properly, or its distribution file was " | ||
| 2673 | "not unpacked properly.\nSee the README.W32 file in the " | ||
| 2674 | "top-level Emacs directory for more information.", | ||
| 2675 | init_file_name, load_path); | ||
| 2676 | MessageBox (NULL, | ||
| 2677 | buffer, | ||
| 2678 | "Emacs Abort Dialog", | ||
| 2679 | MB_OK | MB_ICONEXCLAMATION | MB_TASKMODAL); | ||
| 2680 | close (fd); | ||
| 2681 | |||
| 2682 | /* Use the low-level Emacs abort. */ | ||
| 2683 | #undef abort | ||
| 2684 | abort (); | ||
| 2685 | } | ||
| 2686 | } | ||
| 2687 | } | ||
| 2634 | 2688 | ||
| 2635 | void | 2689 | void |
| 2636 | term_ntproc () | 2690 | term_ntproc () |
| @@ -2639,6 +2693,12 @@ term_ntproc () | |||
| 2639 | /* shutdown the socket interface if necessary */ | 2693 | /* shutdown the socket interface if necessary */ |
| 2640 | term_winsock (); | 2694 | term_winsock (); |
| 2641 | #endif | 2695 | #endif |
| 2696 | |||
| 2697 | /* Check whether we are shutting down because we cannot find the | ||
| 2698 | Windows initialization file. Do this during shutdown so that | ||
| 2699 | Emacs is initialized as possible, and so that it is out of the | ||
| 2700 | critical startup path. */ | ||
| 2701 | check_windows_init_file (); | ||
| 2642 | } | 2702 | } |
| 2643 | 2703 | ||
| 2644 | void | 2704 | void |