diff options
| author | Eli Zaretskii | 2012-10-12 12:20:15 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2012-10-12 12:20:15 +0200 |
| commit | 4f0800ec2ffdfee7b56062aeac263e5071cf8868 (patch) | |
| tree | e4e197cbc6c43a205bd04672d529cd317d228423 /src | |
| parent | 977c647927a5ac5916f4c737e32885f15a1a5b00 (diff) | |
| download | emacs-4f0800ec2ffdfee7b56062aeac263e5071cf8868.tar.gz emacs-4f0800ec2ffdfee7b56062aeac263e5071cf8868.zip | |
Some cleanups:
1. If fill_queue returns -1, but there were file notifications, return 0.
2. Move invariant code out of the loop in queue_notifications and
handle_file_notifications.
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32inevt.c | 42 | ||||
| -rw-r--r-- | src/w32term.c | 31 |
2 files changed, 38 insertions, 35 deletions
diff --git a/src/w32inevt.c b/src/w32inevt.c index 9b63d0c24b6..7d60c06d78d 100644 --- a/src/w32inevt.c +++ b/src/w32inevt.c | |||
| @@ -576,7 +576,7 @@ maybe_generate_resize_event (void) | |||
| 576 | 0, 0, 0); | 576 | 0, 0, 0); |
| 577 | } | 577 | } |
| 578 | 578 | ||
| 579 | static void | 579 | static int |
| 580 | handle_file_notifications (struct input_event *hold_quit) | 580 | handle_file_notifications (struct input_event *hold_quit) |
| 581 | { | 581 | { |
| 582 | BYTE *p = file_notifications; | 582 | BYTE *p = file_notifications; |
| @@ -584,26 +584,32 @@ handle_file_notifications (struct input_event *hold_quit) | |||
| 584 | const DWORD min_size | 584 | const DWORD min_size |
| 585 | = offsetof (FILE_NOTIFY_INFORMATION, FileName) + sizeof(wchar_t); | 585 | = offsetof (FILE_NOTIFY_INFORMATION, FileName) + sizeof(wchar_t); |
| 586 | struct input_event inev; | 586 | struct input_event inev; |
| 587 | int nevents = 0; | ||
| 587 | 588 | ||
| 588 | /* We cannot process notification before Emacs is fully initialized, | 589 | /* We cannot process notification before Emacs is fully initialized, |
| 589 | since we need the UTF-16LE coding-system to be set up. */ | 590 | since we need the UTF-16LE coding-system to be set up. */ |
| 590 | if (!initialized) | 591 | if (!initialized) |
| 591 | { | 592 | { |
| 592 | notification_buffer_in_use = 0; | 593 | notification_buffer_in_use = 0; |
| 593 | return; | 594 | return nevents; |
| 594 | } | 595 | } |
| 595 | 596 | ||
| 596 | enter_crit (); | 597 | enter_crit (); |
| 597 | if (notification_buffer_in_use) | 598 | if (notification_buffer_in_use) |
| 598 | { | 599 | { |
| 599 | DWORD info_size = notifications_size; | 600 | DWORD info_size = notifications_size; |
| 601 | Lisp_Object cs = intern ("utf-16le"); | ||
| 602 | Lisp_Object obj = get_watch_object (make_number (notifications_desc)); | ||
| 600 | 603 | ||
| 601 | /* notifications_size could be zero when the buffer of | 604 | /* notifications_size could be zero when the buffer of |
| 602 | notifications overflowed on the OS level, or when the | 605 | notifications overflowed on the OS level, or when the |
| 603 | directory being watched was itself deleted. Do nothing in | 606 | directory being watched was itself deleted. Do nothing in |
| 604 | that case. */ | 607 | that case. */ |
| 605 | if (info_size) | 608 | if (info_size |
| 609 | && !NILP (obj) && CONSP (obj)) | ||
| 606 | { | 610 | { |
| 611 | Lisp_Object callback = XCDR (obj); | ||
| 612 | |||
| 607 | EVENT_INIT (inev); | 613 | EVENT_INIT (inev); |
| 608 | 614 | ||
| 609 | while (info_size >= min_size) | 615 | while (info_size >= min_size) |
| @@ -614,22 +620,16 @@ handle_file_notifications (struct input_event *hold_quit) | |||
| 614 | /* Note: mule-conf is preloaded, so utf-16le must | 620 | /* Note: mule-conf is preloaded, so utf-16le must |
| 615 | already be defined at this point. */ | 621 | already be defined at this point. */ |
| 616 | Lisp_Object fname | 622 | Lisp_Object fname |
| 617 | = code_convert_string_norecord (utf_16_fn, | 623 | = code_convert_string_norecord (utf_16_fn, cs, 0); |
| 618 | intern ("utf-16le"), 0); | ||
| 619 | Lisp_Object action = lispy_file_action (fni->Action); | 624 | Lisp_Object action = lispy_file_action (fni->Action); |
| 620 | Lisp_Object obj; | ||
| 621 | 625 | ||
| 622 | obj = get_watch_object (make_number (notifications_desc)); | 626 | inev.kind = FILE_NOTIFY_EVENT; |
| 623 | if (!NILP (obj) && CONSP (obj)) | 627 | inev.code = (ptrdiff_t)notifications_desc; |
| 624 | { | 628 | inev.timestamp = GetTickCount (); |
| 625 | inev.kind = FILE_NOTIFY_EVENT; | 629 | inev.modifiers = 0; |
| 626 | inev.code = (ptrdiff_t)notifications_desc; | 630 | inev.frame_or_window = callback; |
| 627 | inev.timestamp = GetTickCount (); | 631 | inev.arg = Fcons (action, fname); |
| 628 | inev.modifiers = 0; | 632 | kbd_buffer_store_event_hold (&inev, hold_quit); |
| 629 | inev.frame_or_window = XCDR (obj); | ||
| 630 | inev.arg = Fcons (action, fname); | ||
| 631 | kbd_buffer_store_event_hold (&inev, hold_quit); | ||
| 632 | } | ||
| 633 | 633 | ||
| 634 | if (!fni->NextEntryOffset) | 634 | if (!fni->NextEntryOffset) |
| 635 | break; | 635 | break; |
| @@ -641,6 +641,7 @@ handle_file_notifications (struct input_event *hold_quit) | |||
| 641 | notification_buffer_in_use = 0; | 641 | notification_buffer_in_use = 0; |
| 642 | } | 642 | } |
| 643 | leave_crit (); | 643 | leave_crit (); |
| 644 | return nevents; | ||
| 644 | } | 645 | } |
| 645 | 646 | ||
| 646 | int | 647 | int |
| @@ -654,13 +655,16 @@ w32_console_read_socket (struct terminal *terminal, | |||
| 654 | 655 | ||
| 655 | for (;;) | 656 | for (;;) |
| 656 | { | 657 | { |
| 657 | handle_file_notifications (hold_quit); | 658 | int nfnotify = handle_file_notifications (hold_quit); |
| 659 | |||
| 658 | nev = fill_queue (0); | 660 | nev = fill_queue (0); |
| 659 | if (nev <= 0) | 661 | if (nev <= 0) |
| 660 | { | 662 | { |
| 661 | /* If nev == -1, there was some kind of error | 663 | /* If nev == -1, there was some kind of error |
| 662 | If nev == 0 then waitp must be zero and no events were available | 664 | If nev == 0 then no events were available |
| 663 | so return. */ | 665 | so return. */ |
| 666 | if (nfnotify) | ||
| 667 | nev = 0; | ||
| 664 | break; | 668 | break; |
| 665 | } | 669 | } |
| 666 | 670 | ||
diff --git a/src/w32term.c b/src/w32term.c index e1a2fbbf824..6d19d9a93ce 100644 --- a/src/w32term.c +++ b/src/w32term.c | |||
| @@ -3281,13 +3281,18 @@ queue_notifications (struct input_event *event, W32Msg *msg, struct frame *f, | |||
| 3281 | if (notification_buffer_in_use) | 3281 | if (notification_buffer_in_use) |
| 3282 | { | 3282 | { |
| 3283 | DWORD info_size = notifications_size; | 3283 | DWORD info_size = notifications_size; |
| 3284 | Lisp_Object cs = intern ("utf-16le"); | ||
| 3285 | Lisp_Object obj = get_watch_object (make_number (notifications_desc)); | ||
| 3284 | 3286 | ||
| 3285 | /* notifications_size could be zero when the buffer of | 3287 | /* notifications_size could be zero when the buffer of |
| 3286 | notifications overflowed on the OS level, or when the | 3288 | notifications overflowed on the OS level, or when the |
| 3287 | directory being watched was itself deleted. Do nothing in | 3289 | directory being watched was itself deleted. Do nothing in |
| 3288 | that case. */ | 3290 | that case. */ |
| 3289 | if (info_size) | 3291 | if (info_size |
| 3292 | && !NILP (obj) && CONSP (obj)) | ||
| 3290 | { | 3293 | { |
| 3294 | Lisp_Object callback = XCDR (obj); | ||
| 3295 | |||
| 3291 | while (info_size >= min_size) | 3296 | while (info_size >= min_size) |
| 3292 | { | 3297 | { |
| 3293 | Lisp_Object utf_16_fn | 3298 | Lisp_Object utf_16_fn |
| @@ -3296,23 +3301,17 @@ queue_notifications (struct input_event *event, W32Msg *msg, struct frame *f, | |||
| 3296 | /* Note: mule-conf is preloaded, so utf-16le must | 3301 | /* Note: mule-conf is preloaded, so utf-16le must |
| 3297 | already be defined at this point. */ | 3302 | already be defined at this point. */ |
| 3298 | Lisp_Object fname | 3303 | Lisp_Object fname |
| 3299 | = code_convert_string_norecord (utf_16_fn, | 3304 | = code_convert_string_norecord (utf_16_fn, cs, 0); |
| 3300 | intern ("utf-16le"), 0); | ||
| 3301 | Lisp_Object action = lispy_file_action (fni->Action); | 3305 | Lisp_Object action = lispy_file_action (fni->Action); |
| 3302 | Lisp_Object obj; | ||
| 3303 | 3306 | ||
| 3304 | obj = get_watch_object (make_number (notifications_desc)); | 3307 | event->kind = FILE_NOTIFY_EVENT; |
| 3305 | if (!NILP (obj) && CONSP (obj)) | 3308 | event->code = (ptrdiff_t)notifications_desc; |
| 3306 | { | 3309 | event->timestamp = msg->msg.time; |
| 3307 | event->kind = FILE_NOTIFY_EVENT; | 3310 | event->modifiers = 0; |
| 3308 | event->code = (ptrdiff_t)notifications_desc; | 3311 | event->frame_or_window = callback; |
| 3309 | event->timestamp = msg->msg.time; | 3312 | event->arg = Fcons (action, fname); |
| 3310 | event->modifiers = 0; | 3313 | kbd_buffer_store_event (event); |
| 3311 | event->frame_or_window = XCDR (obj); | 3314 | (*evcount)++; |
| 3312 | event->arg = Fcons (action, fname); | ||
| 3313 | kbd_buffer_store_event (event); | ||
| 3314 | (*evcount)++; | ||
| 3315 | } | ||
| 3316 | 3315 | ||
| 3317 | if (!fni->NextEntryOffset) | 3316 | if (!fni->NextEntryOffset) |
| 3318 | break; | 3317 | break; |