To: vim_dev@googlegroups.com Subject: Patch 8.0.1762 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1762 Problem: Terminal debug logging is a bit complicated. Solution: Make log_tr() use variable arguments (Ozaki Kiichi, closes #2730) Files: src/term.c *** ../vim-8.0.1761/src/term.c 2018-04-24 15:19:00.507068755 +0200 --- src/term.c 2018-04-24 21:36:42.993915142 +0200 *************** *** 108,117 **** /* Change this to "if 1" to debug what happens with termresponse. */ # if 0 # define DEBUG_TERMRESPONSE ! static void log_tr(char *msg); ! # define LOG_TR(msg) log_tr(msg) # else ! # define LOG_TR(msg) # endif # define STATUS_GET 1 /* send request when switching to RAW mode */ --- 108,117 ---- /* Change this to "if 1" to debug what happens with termresponse. */ # if 0 # define DEBUG_TERMRESPONSE ! static void log_tr(const char *fmt, ...); ! # define LOG_TR(msg) log_tr msg # else ! # define LOG_TR(msg) do { /**/ } while (0) # endif # define STATUS_GET 1 /* send request when switching to RAW mode */ *************** *** 1516,1530 **** init_highlight(TRUE, FALSE); # ifdef DEBUG_TERMRESPONSE { ! char buf[100]; ! int r = redraw_asap(CLEAR); ! sprintf(buf, "Received t_Co, redraw_asap(): %d", r); ! log_tr(buf); } ! # else redraw_asap(CLEAR); ! # endif } } #endif --- 1516,1528 ---- init_highlight(TRUE, FALSE); # ifdef DEBUG_TERMRESPONSE { ! int r = redraw_asap(CLEAR); ! log_tr("Received t_Co, redraw_asap(): %d", r); } ! #else redraw_asap(CLEAR); ! #endif } } #endif *************** *** 1948,1954 **** full_screen = TRUE; /* we can use termcap codes from now on */ set_term_defaults(); /* use current values as defaults */ #ifdef FEAT_TERMRESPONSE ! LOG_TR("setting crv_status to STATUS_GET"); crv_status = STATUS_GET; /* Get terminal version later */ #endif --- 1946,1952 ---- full_screen = TRUE; /* we can use termcap codes from now on */ set_term_defaults(); /* use current values as defaults */ #ifdef FEAT_TERMRESPONSE ! LOG_TR(("setting crv_status to STATUS_GET")); crv_status = STATUS_GET; /* Get terminal version later */ #endif *************** *** 3510,3516 **** && starting == 0 && *T_CRV != NUL) { ! LOG_TR("Sending CRV request"); out_str(T_CRV); crv_status = STATUS_SENT; /* check for the characters now, otherwise they might be eaten by --- 3508,3514 ---- && starting == 0 && *T_CRV != NUL) { ! LOG_TR(("Sending CRV request")); out_str(T_CRV); crv_status = STATUS_SENT; /* check for the characters now, otherwise they might be eaten by *************** *** 3541,3547 **** { char_u buf[16]; ! LOG_TR("Sending U7 request"); /* Do this in the second row. In the first row the returned sequence * may be CSI 1;2R, which is the same as . */ term_windgoto(1, 0); --- 3539,3545 ---- { char_u buf[16]; ! LOG_TR(("Sending U7 request")); /* Do this in the second row. In the first row the returned sequence * may be CSI 1;2R, which is the same as . */ term_windgoto(1, 0); *************** *** 3583,3589 **** /* Only request foreground if t_RF is set. */ if (rfg_status == STATUS_GET && *T_RFG != NUL) { ! LOG_TR("Sending FG request"); out_str(T_RFG); rfg_status = STATUS_SENT; didit = TRUE; --- 3581,3587 ---- /* Only request foreground if t_RF is set. */ if (rfg_status == STATUS_GET && *T_RFG != NUL) { ! LOG_TR(("Sending FG request")); out_str(T_RFG); rfg_status = STATUS_SENT; didit = TRUE; *************** *** 3593,3599 **** /* Only request background if t_RB is set. */ if (rbg_status == STATUS_GET && *T_RBG != NUL) { ! LOG_TR("Sending BG request"); out_str(T_RBG); rbg_status = STATUS_SENT; didit = TRUE; --- 3591,3597 ---- /* Only request background if t_RB is set. */ if (rbg_status == STATUS_GET && *T_RBG != NUL) { ! LOG_TR(("Sending BG request")); out_str(T_RBG); rbg_status = STATUS_SENT; didit = TRUE; *************** *** 3611,3621 **** # ifdef DEBUG_TERMRESPONSE static void ! log_tr(char *msg) { static FILE *fd_tr = NULL; static proftime_T start; proftime_T now; if (fd_tr == NULL) { --- 3609,3620 ---- # ifdef DEBUG_TERMRESPONSE static void ! log_tr(const char *fmt, ...) { static FILE *fd_tr = NULL; static proftime_T start; proftime_T now; + va_list ap; if (fd_tr == NULL) { *************** *** 3624,3634 **** } now = start; profile_end(&now); ! fprintf(fd_tr, "%s: %s %s\n", ! profile_msg(&now), ! must_redraw == NOT_VALID ? "NV" ! : must_redraw == CLEAR ? "CL" : " ", ! msg); } # endif #endif --- 3623,3636 ---- } now = start; profile_end(&now); ! fprintf(fd_tr, "%s: %s ", profile_msg(&now), ! must_redraw == NOT_VALID ? "NV" ! : must_redraw == CLEAR ? "CL" : " "); ! va_start(ap, fmt); ! vfprintf(fd_tr, fmt, ap); ! va_end(ap); ! fputc('\n', fd_tr); ! fflush(fd_tr); } # endif #endif *************** *** 4179,4185 **** need_gather = TRUE; /* need to fill termleader[] */ } detected_8bit = TRUE; ! LOG_TR("Switching to 8 bit"); } #endif --- 4181,4187 ---- need_gather = TRUE; /* need to fill termleader[] */ } detected_8bit = TRUE; ! LOG_TR(("Switching to 8 bit")); } #endif *************** *** 4512,4518 **** } if (i == len) { ! LOG_TR("Not enough characters for CRV"); return -1; } if (extra > 0) --- 4514,4520 ---- } if (i == len) { ! LOG_TR(("Not enough characters for CRV")); return -1; } if (extra > 0) *************** *** 4529,4535 **** { char *aw = NULL; ! LOG_TR("Received U7 status"); u7_status = STATUS_GOT; did_cursorhold = TRUE; if (col == 2) --- 4531,4537 ---- { char *aw = NULL; ! LOG_TR(("Received U7 status: %s", tp)); u7_status = STATUS_GOT; did_cursorhold = TRUE; if (col == 2) *************** *** 4545,4557 **** (char_u *)aw, 0); # ifdef DEBUG_TERMRESPONSE { ! char buf[100]; ! int r = redraw_asap(CLEAR); ! sprintf(buf, ! "set 'ambiwidth', redraw_asap(): %d", ! r); ! log_tr(buf); } # else redraw_asap(CLEAR); --- 4547,4555 ---- (char_u *)aw, 0); # ifdef DEBUG_TERMRESPONSE { ! int r = redraw_asap(CLEAR); ! log_tr("set 'ambiwidth', redraw_asap(): %d", r); } # else redraw_asap(CLEAR); *************** *** 4572,4578 **** { int version = col; ! LOG_TR("Received CRV response"); crv_status = STATUS_GOT; did_cursorhold = TRUE; --- 4570,4576 ---- { int version = col; ! LOG_TR(("Received CRV response: %s", tp)); crv_status = STATUS_GOT; did_cursorhold = TRUE; *************** *** 4598,4604 **** /* if xterm version >= 141 try to get termcap codes */ if (version >= 141) { ! LOG_TR("Enable checking for XT codes"); check_for_codes = TRUE; need_gather = TRUE; req_codes_from_term(); --- 4596,4602 ---- /* if xterm version >= 141 try to get termcap codes */ if (version >= 141) { ! LOG_TR(("Enable checking for XT codes")); check_for_codes = TRUE; need_gather = TRUE; req_codes_from_term(); *************** *** 4688,4694 **** && *T_CSH != NUL && *T_CRS != NUL) { ! LOG_TR("Sending cursor style request"); out_str(T_CRS); rcs_status = STATUS_SENT; need_flush = TRUE; --- 4686,4692 ---- && *T_CSH != NUL && *T_CRS != NUL) { ! LOG_TR(("Sending cursor style request")); out_str(T_CRS); rcs_status = STATUS_SENT; need_flush = TRUE; *************** *** 4701,4707 **** && !is_not_xterm && *T_CRC != NUL) { ! LOG_TR("Sending cursor blink mode request"); out_str(T_CRC); rbm_status = STATUS_SENT; need_flush = TRUE; --- 4699,4705 ---- && !is_not_xterm && *T_CRC != NUL) { ! LOG_TR(("Sending cursor blink mode request")); out_str(T_CRC); rbm_status = STATUS_SENT; need_flush = TRUE; *************** *** 4737,4743 **** { initial_cursor_blink = (tp[j + 4] == '1'); rbm_status = STATUS_GOT; ! LOG_TR("Received cursor blinking mode response"); key_name[0] = (int)KS_EXTRA; key_name[1] = (int)KE_IGNORE; slen = i + 1; --- 4735,4741 ---- { initial_cursor_blink = (tp[j + 4] == '1'); rbm_status = STATUS_GOT; ! LOG_TR(("Received cursor blinking mode response: %s", tp)); key_name[0] = (int)KS_EXTRA; key_name[1] = (int)KE_IGNORE; slen = i + 1; *************** *** 4779,4785 **** } if (i == len) { ! LOG_TR("not enough characters for winpos"); return -1; } } --- 4777,4783 ---- } if (i == len) { ! LOG_TR(("not enough characters for winpos")); return -1; } } *************** *** 4825,4831 **** char *newval = (3 * '6' < tp[j+7] + tp[j+12] + tp[j+17]) ? "light" : "dark"; ! LOG_TR("Received RBG response"); rbg_status = STATUS_GOT; #ifdef FEAT_TERMINAL bg_r = rval; --- 4823,4829 ---- char *newval = (3 * '6' < tp[j+7] + tp[j+12] + tp[j+17]) ? "light" : "dark"; ! LOG_TR(("Received RBG response: %s", tp)); rbg_status = STATUS_GOT; #ifdef FEAT_TERMINAL bg_r = rval; *************** *** 4845,4851 **** #ifdef FEAT_TERMINAL else { ! LOG_TR("Received RFG response"); rfg_status = STATUS_GOT; fg_r = rval; fg_g = gval; --- 4843,4849 ---- #ifdef FEAT_TERMINAL else { ! LOG_TR(("Received RFG response: %s", tp)); rfg_status = STATUS_GOT; fg_r = rval; fg_g = gval; *************** *** 4866,4872 **** } if (i == len) { ! LOG_TR("not enough characters for RB"); return -1; } } --- 4864,4870 ---- } if (i == len) { ! LOG_TR(("not enough characters for RB")); return -1; } } *************** *** 4940,4946 **** initial_cursor_shape_blink = (number & 1) ? FALSE : TRUE; rcs_status = STATUS_GOT; ! LOG_TR("Received cursor shape response"); key_name[0] = (int)KS_EXTRA; key_name[1] = (int)KE_IGNORE; --- 4938,4944 ---- initial_cursor_shape_blink = (number & 1) ? FALSE : TRUE; rcs_status = STATUS_GOT; ! LOG_TR(("Received cursor shape response: %s", tp)); key_name[0] = (int)KS_EXTRA; key_name[1] = (int)KE_IGNORE; *************** *** 4957,4963 **** { /* These codes arrive many together, each code can be * truncated at any point. */ ! LOG_TR("not enough characters for XT"); return -1; } } --- 4955,4961 ---- { /* These codes arrive many together, each code can be * truncated at any point. */ ! LOG_TR(("not enough characters for XT")); return -1; } } *************** *** 5910,5916 **** } #ifdef FEAT_TERMRESPONSE ! LOG_TR("normal character"); #endif return 0; /* no match found */ --- 5908,5914 ---- } #ifdef FEAT_TERMRESPONSE ! LOG_TR(("normal character")); #endif return 0; /* no match found */ *************** *** 6393,6407 **** * many, there can be a buffer overflow somewhere. */ while (xt_index_out < xt_index_in + 10 && key_names[xt_index_out] != NULL) { ! # ifdef DEBUG_TERMRESPONSE ! char dbuf[100]; ! sprintf(dbuf, "Requesting XT %d: %s", ! xt_index_out, key_names[xt_index_out]); ! log_tr(dbuf); ! # endif ! sprintf(buf, "\033P+q%02x%02x\033\\", ! key_names[xt_index_out][0], key_names[xt_index_out][1]); out_str_nf((char_u *)buf); ++xt_index_out; } --- 6391,6400 ---- * many, there can be a buffer overflow somewhere. */ while (xt_index_out < xt_index_in + 10 && key_names[xt_index_out] != NULL) { ! char *key_name = key_names[xt_index_out]; ! LOG_TR(("Requesting XT %d: %s", xt_index_out, key_name)); ! sprintf(buf, "\033P+q%02x%02x\033\\", key_name[0], key_name[1]); out_str_nf((char_u *)buf); ++xt_index_out; } *************** *** 6444,6457 **** break; } } - # ifdef DEBUG_TERMRESPONSE - { - char buf[100]; ! sprintf(buf, "Received XT %d: %s", xt_index_in, (char *)name); ! log_tr(buf); ! } ! # endif if (key_names[i] != NULL) { for (i = 8; (c = hexhex2nr(code + i)) >= 0; i += 2) --- 6437,6445 ---- break; } } ! LOG_TR(("Received XT %d: %s", xt_index_in, (char *)name)); ! if (key_names[i] != NULL) { for (i = 8; (c = hexhex2nr(code + i)) >= 0; i += 2) *** ../vim-8.0.1761/src/version.c 2018-04-24 20:54:01.576445033 +0200 --- src/version.c 2018-04-24 21:24:02.288389734 +0200 *************** *** 763,764 **** --- 763,766 ---- { /* Add new patch number below this line */ + /**/ + 1762, /**/ -- In war we're tough and able. Quite indefatigable Between our quests We sequin vests And impersonate Clark Gable It's a busy life in Camelot. I have to push the pram a lot. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///