Merge pull request #4768 from justinmk/char_u

msg_puts_printf: remove char_u
This commit is contained in:
Justin M. Keyes 2016-05-17 02:36:22 -04:00
commit c9b1ad3a57

View File

@ -1508,51 +1508,44 @@ void msg_puts_attr(char_u *s, int attr)
msg_puts_attr_len(s, -1, attr); msg_puts_attr_len(s, -1, attr);
} }
/* /// Like msg_puts_attr(), but with a maximum length "maxlen" (in bytes).
* Like msg_puts_attr(), but with a maximum length "maxlen" (in bytes). /// When "maxlen" is -1 there is no maximum length.
* When "maxlen" is -1 there is no maximum length. /// When "maxlen" is >= 0 the message is not put in the history.
* When "maxlen" is >= 0 the message is not put in the history.
*/
static void msg_puts_attr_len(char_u *str, int maxlen, int attr) static void msg_puts_attr_len(char_u *str, int maxlen, int attr)
{ {
/* // If redirection is on, also write to the redirection file.
* If redirection is on, also write to the redirection file.
*/
redir_write(str, maxlen); redir_write(str, maxlen);
/* // Don't print anything when using ":silent cmd".
* Don't print anything when using ":silent cmd". if (msg_silent != 0) {
*/
if (msg_silent != 0)
return; return;
}
/* if MSG_HIST flag set, add message to history */ // if MSG_HIST flag set, add message to history
if ((attr & MSG_HIST) && maxlen < 0) { if ((attr & MSG_HIST) && maxlen < 0) {
add_msg_hist(str, -1, attr); add_msg_hist(str, -1, attr);
attr &= ~MSG_HIST; attr &= ~MSG_HIST;
} }
/* // When writing something to the screen after it has scrolled, requires a
* When writing something to the screen after it has scrolled, requires a // wait-return prompt later. Needed when scrolling, resetting
* wait-return prompt later. Needed when scrolling, resetting // need_wait_return after some prompt, and then outputting something
* need_wait_return after some prompt, and then outputting something // without scrolling
* without scrolling if (msg_scrolled != 0 && !msg_scrolled_ign) {
*/ need_wait_return = true;
if (msg_scrolled != 0 && !msg_scrolled_ign) }
need_wait_return = TRUE; msg_didany = true; // remember that something was outputted
msg_didany = TRUE; /* remember that something was outputted */
/* // If there is no valid screen, use fprintf so we can see error messages.
* If there is no valid screen, use fprintf so we can see error messages. // If termcap is not active, we may be writing in an alternate console
* If termcap is not active, we may be writing in an alternate console // window, cursor positioning may not work correctly (window size may be
* window, cursor positioning may not work correctly (window size may be // different, e.g. for Win32 console) or we just don't know where the
* different, e.g. for Win32 console) or we just don't know where the // cursor is.
* cursor is. if (msg_use_printf()) {
*/ msg_puts_printf((char *)str, maxlen);
if (msg_use_printf()) } else {
msg_puts_printf(str, maxlen); msg_puts_display(str, maxlen, attr, false);
else }
msg_puts_display(str, maxlen, attr, FALSE);
} }
/* /*
@ -1926,46 +1919,46 @@ int msg_use_printf(void)
return !embedded_mode && !ui_active(); return !embedded_mode && !ui_active();
} }
/* /// Print a message when there is no valid screen.
* Print a message when there is no valid screen. static void msg_puts_printf(char *str, int maxlen)
*/
static void msg_puts_printf(char_u *str, int maxlen)
{ {
char_u *s = str; char *s = str;
char_u buf[4]; char buf[4];
char_u *p; char *p;
while (*s != NUL && (maxlen < 0 || (int)(s - str) < maxlen)) { while (*s != NUL && (maxlen < 0 || (int)(s - str) < maxlen)) {
if (!(silent_mode && p_verbose == 0)) { if (!(silent_mode && p_verbose == 0)) {
/* NL --> CR NL translation (for Unix, not for "--version") */ // NL --> CR NL translation (for Unix, not for "--version")
/* NL --> CR translation (for Mac) */
p = &buf[0]; p = &buf[0];
if (*s == '\n' && !info_message) if (*s == '\n' && !info_message) {
*p++ = '\r'; *p++ = '\r';
}
*p++ = *s; *p++ = *s;
*p = '\0'; *p = '\0';
if (info_message) /* informative message, not an error */ if (info_message) {
mch_msg((char *)buf); mch_msg(buf);
else
mch_errmsg((char *)buf);
}
/* primitive way to compute the current column */
if (cmdmsg_rl) {
if (*s == '\r' || *s == '\n')
msg_col = Columns - 1;
else
--msg_col;
} else { } else {
if (*s == '\r' || *s == '\n') mch_errmsg(buf);
msg_col = 0;
else
++msg_col;
} }
++s;
} }
msg_didout = TRUE; /* assume that line is not empty */
// primitive way to compute the current column
if (cmdmsg_rl) {
if (*s == '\r' || *s == '\n') {
msg_col = Columns - 1;
} else {
msg_col--;
}
} else {
if (*s == '\r' || *s == '\n') {
msg_col = 0;
} else {
msg_col++;
}
}
s++;
}
msg_didout = true; // assume that line is not empty
} }
/* /*