diff options
author | Yegappan Lakshmanan <yegappan@yahoo.com> | 2023-01-14 12:32:28 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2023-01-14 12:32:28 +0000 |
commit | e8575988969579f9e1439181ae338b2ff74054a8 (patch) | |
tree | f4c8a1242cb67b073bb0e375740c764c2136af21 /src/message.c | |
parent | 378e6c03f98efc88e8c2675e05a548f9bb7889a1 (diff) |
patch 9.0.1196: code is indented more than necessaryv9.0.1196
Problem: Code is indented more than necessary.
Solution: Use an early return where it makes sense. (Yegappan Lakshmanan,
closes #11813)
Diffstat (limited to 'src/message.c')
-rw-r--r-- | src/message.c | 136 |
1 files changed, 65 insertions, 71 deletions
diff --git a/src/message.c b/src/message.c index bb3517c94e..d7b9263571 100644 --- a/src/message.c +++ b/src/message.c @@ -375,15 +375,13 @@ smsg(const char *s, ...) // give the raw message so the user at least gets a hint. return msg((char *)s); } - else - { - va_list arglist; - va_start(arglist, s); - vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist); - va_end(arglist); - return msg((char *)IObuff); - } + va_list arglist; + + va_start(arglist, s); + vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist); + va_end(arglist); + return msg((char *)IObuff); } int @@ -395,15 +393,13 @@ smsg_attr(int attr, const char *s, ...) // give the raw message so the user at least gets a hint. return msg_attr((char *)s, attr); } - else - { - va_list arglist; - va_start(arglist, s); - vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist); - va_end(arglist); - return msg_attr((char *)IObuff, attr); - } + va_list arglist; + + va_start(arglist, s); + vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist); + va_end(arglist); + return msg_attr((char *)IObuff, attr); } int @@ -415,15 +411,13 @@ smsg_attr_keep(int attr, const char *s, ...) // give the raw message so the user at least gets a hint. return msg_attr_keep((char *)s, attr, TRUE); } - else - { - va_list arglist; - va_start(arglist, s); - vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist); - va_end(arglist); - return msg_attr_keep((char *)IObuff, attr, TRUE); - } + va_list arglist; + + va_start(arglist, s); + vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist); + va_end(arglist); + return msg_attr_keep((char *)IObuff, attr, TRUE); } #endif @@ -834,16 +828,16 @@ semsg(const char *s, ...) void iemsg(char *s) { - if (!emsg_not_now()) - { - emsg_core((char_u *)s); + if (emsg_not_now()) + return; + + emsg_core((char_u *)s); #if defined(ABORT_ON_INTERNAL_ERROR) && defined(FEAT_EVAL) - set_vim_var_string(VV_ERRMSG, (char_u *)s, -1); - msg_putchar('\n'); // avoid overwriting the error message - out_flush(); - abort(); + set_vim_var_string(VV_ERRMSG, (char_u *)s, -1); + msg_putchar('\n'); // avoid overwriting the error message + out_flush(); + abort(); #endif - } } #ifndef PROTO // manual proto with __attribute__ @@ -856,29 +850,29 @@ iemsg(char *s) void siemsg(const char *s, ...) { - if (!emsg_not_now()) + if (emsg_not_now()) + return; + + if (IObuff == NULL) { - if (IObuff == NULL) - { - // Very early in initialisation and already something wrong, just - // give the raw message so the user at least gets a hint. - emsg_core((char_u *)s); - } - else - { - va_list ap; + // Very early in initialisation and already something wrong, just + // give the raw message so the user at least gets a hint. + emsg_core((char_u *)s); + } + else + { + va_list ap; - va_start(ap, s); - vim_vsnprintf((char *)IObuff, IOSIZE, s, ap); - va_end(ap); - emsg_core(IObuff); - } + va_start(ap, s); + vim_vsnprintf((char *)IObuff, IOSIZE, s, ap); + va_end(ap); + emsg_core(IObuff); + } # ifdef ABORT_ON_INTERNAL_ERROR - msg_putchar('\n'); // avoid overwriting the error message - out_flush(); - abort(); + msg_putchar('\n'); // avoid overwriting the error message + out_flush(); + abort(); # endif - } } #endif @@ -1006,28 +1000,28 @@ add_msg_hist( // allocate an entry and add the message at the end of the history p = ALLOC_ONE(struct msg_hist); - if (p != NULL) + if (p == NULL) + return; + + if (len < 0) + len = (int)STRLEN(s); + // remove leading and trailing newlines + while (len > 0 && *s == '\n') { - if (len < 0) - len = (int)STRLEN(s); - // remove leading and trailing newlines - while (len > 0 && *s == '\n') - { - ++s; - --len; - } - while (len > 0 && s[len - 1] == '\n') - --len; - p->msg = vim_strnsave(s, len); - p->next = NULL; - p->attr = attr; - if (last_msg_hist != NULL) - last_msg_hist->next = p; - last_msg_hist = p; - if (first_msg_hist == NULL) - first_msg_hist = last_msg_hist; - ++msg_hist_len; + ++s; + --len; } + while (len > 0 && s[len - 1] == '\n') + --len; + p->msg = vim_strnsave(s, len); + p->next = NULL; + p->attr = attr; + if (last_msg_hist != NULL) + last_msg_hist->next = p; + last_msg_hist = p; + if (first_msg_hist == NULL) + first_msg_hist = last_msg_hist; + ++msg_hist_len; } /* |