diff options
Diffstat (limited to 'src/nvim/misc1.c')
| -rw-r--r-- | src/nvim/misc1.c | 118 |
1 files changed, 55 insertions, 63 deletions
diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c index 40db5b7cf3..faf0b0f633 100644 --- a/src/nvim/misc1.c +++ b/src/nvim/misc1.c @@ -100,8 +100,8 @@ int get_leader_len(char_u *line, char_u **flags, bool backward, bool include_spa */ found_one = FALSE; for (list = curbuf->b_p_com; *list; ) { - /* Get one option part into part_buf[]. Advance "list" to next - * one. Put "string" at start of string. */ + // Get one option part into part_buf[]. Advance "list" to next + // one. Put "string" at start of string. if (!got_com && flags != NULL) { *flags = list; // remember where flags started } @@ -113,16 +113,16 @@ int get_leader_len(char_u *line, char_u **flags, bool backward, bool include_spa } *string++ = NUL; // isolate flags from string - /* If we found a middle match previously, use that match when this - * is not a middle or end. */ + // If we found a middle match previously, use that match when this + // is not a middle or end. if (middle_match_len != 0 && vim_strchr(part_buf, COM_MIDDLE) == NULL && vim_strchr(part_buf, COM_END) == NULL) { break; } - /* When we already found a nested comment, only accept further - * nested comments. */ + // When we already found a nested comment, only accept further + // nested comments. if (got_com && vim_strchr(part_buf, COM_NEST) == NULL) { continue; } @@ -132,10 +132,10 @@ int get_leader_len(char_u *line, char_u **flags, bool backward, bool include_spa continue; } - /* Line contents and string must match. - * When string starts with white space, must have some white space - * (but the amount does not need to match, there might be a mix of - * TABs and spaces). */ + // Line contents and string must match. + // When string starts with white space, must have some white space + // (but the amount does not need to match, there might be a mix of + // TABs and spaces). if (ascii_iswhite(string[0])) { if (i == 0 || !ascii_iswhite(line[i - 1])) { continue; // missing white space @@ -145,23 +145,22 @@ int get_leader_len(char_u *line, char_u **flags, bool backward, bool include_spa } } for (j = 0; string[j] != NUL && string[j] == line[i + j]; ++j) { - ; } if (string[j] != NUL) { continue; // string doesn't match } - /* When 'b' flag used, there must be white space or an - * end-of-line after the string in the line. */ + // When 'b' flag used, there must be white space or an + // end-of-line after the string in the line. if (vim_strchr(part_buf, COM_BLANK) != NULL && !ascii_iswhite(line[i + j]) && line[i + j] != NUL) { continue; } - /* We have found a match, stop searching unless this is a middle - * comment. The middle comment can be a substring of the end - * comment in which case it's better to return the length of the - * end comment and its flags. Thus we keep searching with middle - * and end matches and use an end match if it matches better. */ + // We have found a match, stop searching unless this is a middle + // comment. The middle comment can be a substring of the end + // comment in which case it's better to return the length of the + // end comment and its flags. Thus we keep searching with middle + // and end matches and use an end match if it matches better. if (vim_strchr(part_buf, COM_MIDDLE) != NULL) { if (middle_match_len == 0) { middle_match_len = j; @@ -170,8 +169,8 @@ int get_leader_len(char_u *line, char_u **flags, bool backward, bool include_spa continue; } if (middle_match_len != 0 && j > middle_match_len) { - /* Use this match instead of the middle match, since it's a - * longer thus better match. */ + // Use this match instead of the middle match, since it's a + // longer thus better match. middle_match_len = 0; } @@ -183,8 +182,8 @@ int get_leader_len(char_u *line, char_u **flags, bool backward, bool include_spa } if (middle_match_len != 0) { - /* Use the previously found middle match after failing to find a - * match with an end. */ + // Use the previously found middle match after failing to find a + // match with an end. if (!got_com && flags != NULL) { *flags = saved_flags; } @@ -254,8 +253,8 @@ int get_last_leader_offset(char_u *line, char_u **flags) */ (void)copy_option_part(&list, part_buf, COM_MAX_LEN, ","); string = vim_strchr(part_buf, ':'); - if (string == NULL) { /* If everything is fine, this cannot actually - * happen. */ + if (string == NULL) { // If everything is fine, this cannot actually + // happen. continue; } *string++ = NUL; // Isolate flags from string. @@ -276,7 +275,7 @@ int get_last_leader_offset(char_u *line, char_u **flags) } } for (j = 0; string[j] != NUL && string[j] == line[i + j]; ++j) { - /* do nothing */; + // do nothing } if (string[j] != NUL) { continue; @@ -331,11 +330,10 @@ int get_last_leader_offset(char_u *line, char_u **flags) lower_check_bound = i; - /* Let's verify whether the comment leader found is a substring - * of other comment leaders. If it is, let's adjust the - * lower_check_bound so that we make sure that we have determined - * the comment leader correctly. - */ + // Let's verify whether the comment leader found is a substring + // of other comment leaders. If it is, let's adjust the + // lower_check_bound so that we make sure that we have determined + // the comment leader correctly. while (ascii_iswhite(*com_leader)) { ++com_leader; @@ -359,8 +357,8 @@ int get_last_leader_offset(char_u *line, char_u **flags) continue; } - /* Now we have to verify whether string ends with a substring - * beginning the com_leader. */ + // Now we have to verify whether string ends with a substring + // beginning the com_leader. for (off = (len2 > i ? i : len2); off > 0 && off + len1 > len2; ) { --off; if (!STRNCMP(string + off, com_leader, len2 - off)) { @@ -497,9 +495,9 @@ int get_keystroke(MultiQueue *events) for (;; ) { // flush output before waiting ui_flush(); - /* Leave some room for check_termcode() to insert a key code into (max - * 5 chars plus NUL). And fix_input_buffer() can triple the number of - * bytes. */ + // Leave some room for check_termcode() to insert a key code into (max + // 5 chars plus NUL). And fix_input_buffer() can triple the number of + // bytes. maxlen = (buflen - 6 - len) / 3; if (buf == NULL) { buf = xmalloc((size_t)buflen); @@ -511,8 +509,8 @@ int get_keystroke(MultiQueue *events) maxlen = (buflen - 6 - len) / 3; } - /* First time: blocking wait. Second time: wait up to 100ms for a - * terminal code to complete. */ + // First time: blocking wait. Second time: wait up to 100ms for a + // terminal code to complete. n = os_inchar(buf + len, maxlen, len == 0 ? -1L : 100L, 0, events); if (n > 0) { // Replace zero and CSI by a special key code. @@ -575,8 +573,8 @@ int get_number(int colon, int *mouse_used) *mouse_used = FALSE; } - /* When not printing messages, the user won't know what to type, return a - * zero (as if CR was hit). */ + // When not printing messages, the user won't know what to type, return a + // zero (as if CR was hit). if (msg_silent != 0) { return 0; } @@ -591,7 +589,7 @@ int get_number(int colon, int *mouse_used) ++typed; } else if (c == K_DEL || c == K_KDEL || c == K_BS || c == Ctrl_H) { if (typed > 0) { - MSG_PUTS("\b \b"); + msg_puts("\b \b"); --typed; } n /= 10; @@ -631,10 +629,10 @@ int prompt_for_number(int *mouse_used) // When using ":silent" assume that <CR> was entered. if (mouse_used != NULL) { - MSG_PUTS(_("Type number and <Enter> or click with the mouse " + msg_puts(_("Type number and <Enter> or click with the mouse " "(q or empty cancels): ")); } else { - MSG_PUTS(_("Type number and <Enter> (q or empty cancels): ")); + msg_puts(_("Type number and <Enter> (q or empty cancels): ")); } /* Set the state such that text can be selected/copied/pasted and we still @@ -674,9 +672,9 @@ void msgmore(long n) return; } - /* We don't want to overwrite another important message, but do overwrite - * a previous "more lines" or "fewer lines" message, so that "5dd" and - * then "put" reports the last action. */ + // We don't want to overwrite another important message, but do overwrite + // a previous "more lines" or "fewer lines" message, so that "5dd" and + // then "put" reports the last action. if (keep_msg != NULL && !keep_msg_more) { return; } @@ -688,25 +686,19 @@ void msgmore(long n) } if (pn > p_report) { - if (pn == 1) { - if (n > 0) { - STRLCPY(msg_buf, _("1 more line"), MSG_BUF_LEN); - } else { - STRLCPY(msg_buf, _("1 line less"), MSG_BUF_LEN); - } + if (n > 0) { + vim_snprintf(msg_buf, MSG_BUF_LEN, + NGETTEXT("%ld more line", "%ld more lines", pn), + pn); } else { - if (n > 0) { - vim_snprintf(msg_buf, MSG_BUF_LEN, - _("%" PRId64 " more lines"), (int64_t)pn); - } else { - vim_snprintf(msg_buf, MSG_BUF_LEN, - _("%" PRId64 " fewer lines"), (int64_t)pn); - } + vim_snprintf(msg_buf, MSG_BUF_LEN, + NGETTEXT("%ld line less", "%ld fewer lines", pn), + pn); } if (got_int) { xstrlcat(msg_buf, _(" (Interrupted)"), MSG_BUF_LEN); } - if (msg((char_u *)msg_buf)) { + if (msg(msg_buf)) { set_keep_msg((char_u *)msg_buf, 0); keep_msg_more = true; } @@ -928,7 +920,7 @@ int call_shell(char_u *cmd, ShellOpts opts, char_u *extra_shell_arg) } if (*p_sh == NUL) { - EMSG(_(e_shellempty)); + emsg(_(e_shellempty)); retval = -1; } else { // The external command may update a tags file, clear cached tags. @@ -966,7 +958,7 @@ char_u *get_cmd_output(char_u *cmd, char_u *infile, ShellOpts flags, size_t *ret // get a name for the temp file char_u *tempname = vim_tempname(); if (tempname == NULL) { - EMSG(_(e_notmp)); + emsg(_(e_notmp)); return NULL; } @@ -987,7 +979,7 @@ char_u *get_cmd_output(char_u *cmd, char_u *infile, ShellOpts flags, size_t *ret FILE *fd = os_fopen((char *)tempname, READBIN); if (fd == NULL) { - EMSG2(_(e_notopen), tempname); + semsg(_(e_notopen), tempname); goto done; } @@ -1000,7 +992,7 @@ char_u *get_cmd_output(char_u *cmd, char_u *infile, ShellOpts flags, size_t *ret fclose(fd); os_remove((char *)tempname); if (i != len) { - EMSG2(_(e_notread), tempname); + semsg(_(e_notread), tempname); XFREE_CLEAR(buffer); } else if (ret_len == NULL) { // Change NUL into SOH, otherwise the string is truncated. |
