Mercurial > vim
comparison src/popupwin.c @ 19637:8de319d1b82c v8.2.0375
patch 8.2.0375: Coverity warning for not using return value
Commit: https://github.com/vim/vim/commit/8210693795d6d0d51bf5b70674d4539cdde0330b
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Mar 13 14:34:38 2020 +0100
patch 8.2.0375: Coverity warning for not using return value
Problem: Coverity warning for not using return value.
Solution: Move error message to separate function.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 13 Mar 2020 14:45:04 +0100 |
parents | 804322d6c6ba |
children | c8cb1a41f64c |
comparison
equal
deleted
inserted
replaced
19636:399a2c964eb3 | 19637:8de319d1b82c |
---|---|
2490 | 2490 |
2491 redraw_all_later(NOT_VALID); | 2491 redraw_all_later(NOT_VALID); |
2492 popup_mask_refresh = TRUE; | 2492 popup_mask_refresh = TRUE; |
2493 } | 2493 } |
2494 | 2494 |
2495 static void | |
2496 error_for_popup_window(void) | |
2497 { | |
2498 emsg(_("E994: Not allowed in a popup window")); | |
2499 } | |
2500 | |
2501 int | |
2502 error_if_popup_window(int also_with_term UNUSED) | |
2503 { | |
2504 // win_execute() may set "curwin" to a popup window temporarily, but many | |
2505 // commands are disallowed then. When a terminal runs in the popup most | |
2506 // things are allowed. When a terminal is finished it can be closed. | |
2507 if (WIN_IS_POPUP(curwin) | |
2508 # ifdef FEAT_TERMINAL | |
2509 && (also_with_term || curbuf->b_term == NULL) | |
2510 && !term_is_finished(curbuf) | |
2511 # endif | |
2512 ) | |
2513 { | |
2514 error_for_popup_window(); | |
2515 return TRUE; | |
2516 } | |
2517 return FALSE; | |
2518 } | |
2519 | |
2495 /* | 2520 /* |
2496 * Close a popup window by Window-id. | 2521 * Close a popup window by Window-id. |
2497 * Does not invoke the callback. | 2522 * Does not invoke the callback. |
2498 */ | 2523 */ |
2499 void | 2524 void |
2507 for (wp = first_popupwin; wp != NULL; prev = wp, wp = wp->w_next) | 2532 for (wp = first_popupwin; wp != NULL; prev = wp, wp = wp->w_next) |
2508 if (wp->w_id == id) | 2533 if (wp->w_id == id) |
2509 { | 2534 { |
2510 if (wp == curwin) | 2535 if (wp == curwin) |
2511 { | 2536 { |
2512 ERROR_IF_ANY_POPUP_WINDOW; | 2537 error_for_popup_window(); |
2513 return; | 2538 return; |
2514 } | 2539 } |
2515 if (prev == NULL) | 2540 if (prev == NULL) |
2516 first_popupwin = wp->w_next; | 2541 first_popupwin = wp->w_next; |
2517 else | 2542 else |
2538 for (wp = *root; wp != NULL; prev = wp, wp = wp->w_next) | 2563 for (wp = *root; wp != NULL; prev = wp, wp = wp->w_next) |
2539 if (wp->w_id == id) | 2564 if (wp->w_id == id) |
2540 { | 2565 { |
2541 if (wp == curwin) | 2566 if (wp == curwin) |
2542 { | 2567 { |
2543 ERROR_IF_ANY_POPUP_WINDOW; | 2568 error_for_popup_window(); |
2544 return; | 2569 return; |
2545 } | 2570 } |
2546 if (prev == NULL) | 2571 if (prev == NULL) |
2547 *root = wp->w_next; | 2572 *root = wp->w_next; |
2548 else | 2573 else |
2884 # if defined(FEAT_TIMERS) | 2909 # if defined(FEAT_TIMERS) |
2885 dict_add_number(dict, "time", wp->w_popup_timer != NULL | 2910 dict_add_number(dict, "time", wp->w_popup_timer != NULL |
2886 ? (long)wp->w_popup_timer->tr_interval : 0L); | 2911 ? (long)wp->w_popup_timer->tr_interval : 0L); |
2887 # endif | 2912 # endif |
2888 } | 2913 } |
2889 } | |
2890 | |
2891 int | |
2892 error_if_popup_window(int also_with_term UNUSED) | |
2893 { | |
2894 // win_execute() may set "curwin" to a popup window temporarily, but many | |
2895 // commands are disallowed then. When a terminal runs in the popup most | |
2896 // things are allowed. When a terminal is finished it can be closed. | |
2897 if (WIN_IS_POPUP(curwin) | |
2898 # ifdef FEAT_TERMINAL | |
2899 && (also_with_term || curbuf->b_term == NULL) | |
2900 && !term_is_finished(curbuf) | |
2901 # endif | |
2902 ) | |
2903 { | |
2904 emsg(_("E994: Not allowed in a popup window")); | |
2905 return TRUE; | |
2906 } | |
2907 return FALSE; | |
2908 } | 2914 } |
2909 | 2915 |
2910 # if defined(FEAT_TERMINAL) || defined(PROTO) | 2916 # if defined(FEAT_TERMINAL) || defined(PROTO) |
2911 /* | 2917 /* |
2912 * Return TRUE if the current window is running a terminal in a popup window. | 2918 * Return TRUE if the current window is running a terminal in a popup window. |