diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-11-30 20:52:27 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-11-30 20:52:27 +0100 |
commit | c667da5185ce5dce914d2006d62da2be0cedb384 (patch) | |
tree | cd06b08e9fb7d701653850cd33524d3f1f5acaaf /src/charset.c | |
parent | 71136db1bfbc67c2e55f8070cdf0a241c643e45b (diff) | |
download | vim-git-c667da5185ce5dce914d2006d62da2be0cedb384.tar.gz |
patch 8.1.2368: using old C style commentsv8.1.2368
Problem: Using old C style comments.
Solution: Use // comments where appropriate.
Diffstat (limited to 'src/charset.c')
-rw-r--r-- | src/charset.c | 277 |
1 files changed, 138 insertions, 139 deletions
diff --git a/src/charset.c b/src/charset.c index 25d6d3851..7505fea2e 100644 --- a/src/charset.c +++ b/src/charset.c @@ -10,7 +10,7 @@ #include "vim.h" #if defined(HAVE_WCHAR_H) -# include <wchar.h> /* for towupper() and towlower() */ +# include <wchar.h> // for towupper() and towlower() #endif static int win_nolbr_chartabsize(win_T *wp, char_u *s, colnr_T col, int *headp); @@ -18,22 +18,22 @@ static unsigned nr2hex(unsigned c); static int chartab_initialized = FALSE; -/* b_chartab[] is an array of 32 bytes, each bit representing one of the - * characters 0-255. */ +// b_chartab[] is an array of 32 bytes, each bit representing one of the +// characters 0-255. #define SET_CHARTAB(buf, c) (buf)->b_chartab[(unsigned)(c) >> 3] |= (1 << ((c) & 0x7)) #define RESET_CHARTAB(buf, c) (buf)->b_chartab[(unsigned)(c) >> 3] &= ~(1 << ((c) & 0x7)) #define GET_CHARTAB(buf, c) ((buf)->b_chartab[(unsigned)(c) >> 3] & (1 << ((c) & 0x7))) -/* table used below, see init_chartab() for an explanation */ +// table used below, see init_chartab() for an explanation static char_u g_chartab[256]; /* * Flags for g_chartab[]. */ -#define CT_CELL_MASK 0x07 /* mask: nr of display cells (1, 2 or 4) */ -#define CT_PRINT_CHAR 0x10 /* flag: set for printable chars */ -#define CT_ID_CHAR 0x20 /* flag: set for ID chars */ -#define CT_FNAME_CHAR 0x40 /* flag: set for file name chars */ +#define CT_CELL_MASK 0x07 // mask: nr of display cells (1, 2 or 4) +#define CT_PRINT_CHAR 0x10 // flag: set for printable chars +#define CT_ID_CHAR 0x20 // flag: set for ID chars +#define CT_FNAME_CHAR 0x40 // flag: set for file name chars static int in_win_border(win_T *wp, colnr_T vcol); @@ -72,7 +72,7 @@ init_chartab(void) int buf_init_chartab( buf_T *buf, - int global) /* FALSE: only set buf->b_chartab[] */ + int global) // FALSE: only set buf->b_chartab[] { int c; int c2; @@ -102,21 +102,21 @@ buf_init_chartab( g_chartab[c++] = 1 + CT_PRINT_CHAR; while (c < 256) { - /* UTF-8: bytes 0xa0 - 0xff are printable (latin1) */ + // UTF-8: bytes 0xa0 - 0xff are printable (latin1) if (enc_utf8 && c >= 0xa0) g_chartab[c++] = CT_PRINT_CHAR + 1; - /* euc-jp characters starting with 0x8e are single width */ + // euc-jp characters starting with 0x8e are single width else if (enc_dbcs == DBCS_JPNU && c == 0x8e) g_chartab[c++] = CT_PRINT_CHAR + 1; - /* other double-byte chars can be printable AND double-width */ + // other double-byte chars can be printable AND double-width else if (enc_dbcs != 0 && MB_BYTE2LEN(c) == 2) g_chartab[c++] = CT_PRINT_CHAR + 2; else - /* the rest is unprintable by default */ + // the rest is unprintable by default g_chartab[c++] = (dy_flags & DY_UHEX) ? 4 : 2; } - /* Assume that every multi-byte char is a filename character. */ + // Assume that every multi-byte char is a filename character. for (c = 1; c < 256; ++c) if ((enc_dbcs != 0 && MB_BYTE2LEN(c) > 1) || (enc_dbcs == DBCS_JPNU && c == 0x8e) @@ -131,7 +131,7 @@ buf_init_chartab( if (enc_dbcs != 0) for (c = 0; c < 256; ++c) { - /* double-byte characters are probably word characters */ + // double-byte characters are probably word characters if (MB_BYTE2LEN(c) == 2) SET_CHARTAB(buf, c); } @@ -144,20 +144,19 @@ buf_init_chartab( SET_CHARTAB(buf, '-'); #endif - /* Walk through the 'isident', 'iskeyword', 'isfname' and 'isprint' - * options Each option is a list of characters, character numbers or - * ranges, separated by commas, e.g.: "200-210,x,#-178,-" - */ + // Walk through the 'isident', 'iskeyword', 'isfname' and 'isprint' + // options Each option is a list of characters, character numbers or + // ranges, separated by commas, e.g.: "200-210,x,#-178,-" for (i = global ? 0 : 3; i <= 3; ++i) { if (i == 0) - p = p_isi; /* first round: 'isident' */ + p = p_isi; // first round: 'isident' else if (i == 1) - p = p_isp; /* second round: 'isprint' */ + p = p_isp; // second round: 'isprint' else if (i == 2) - p = p_isf; /* third round: 'isfname' */ - else /* i == 3 */ - p = buf->b_p_isk; /* fourth round: 'iskeyword' */ + p = p_isf; // third round: 'isfname' + else // i == 3 + p = buf->b_p_isk; // fourth round: 'iskeyword' while (*p) { @@ -191,7 +190,7 @@ buf_init_chartab( || !(*p == NUL || *p == ',')) return FAIL; - if (c2 == -1) /* not a range */ + if (c2 == -1) // not a range { /* * A single '@' (not "@-@"): @@ -210,19 +209,19 @@ buf_init_chartab( } while (c <= c2) { - /* Use the MB_ functions here, because isalpha() doesn't - * work properly when 'encoding' is "latin1" and the locale is - * "C". */ + // Use the MB_ functions here, because isalpha() doesn't + // work properly when 'encoding' is "latin1" and the locale is + // "C". if (!do_isalpha || MB_ISLOWER(c) || MB_ISUPPER(c)) { - if (i == 0) /* (re)set ID flag */ + if (i == 0) // (re)set ID flag { if (tilde) g_chartab[c] &= ~CT_ID_CHAR; else g_chartab[c] |= CT_ID_CHAR; } - else if (i == 1) /* (re)set printable */ + else if (i == 1) // (re)set printable { if ((c < ' ' #ifndef EBCDIC @@ -245,14 +244,14 @@ buf_init_chartab( } } } - else if (i == 2) /* (re)set fname flag */ + else if (i == 2) // (re)set fname flag { if (tilde) g_chartab[c] &= ~CT_FNAME_CHAR; else g_chartab[c] |= CT_FNAME_CHAR; } - else /* i == 3 */ /* (re)set keyword flag */ + else // i == 3 (re)set keyword flag { if (tilde) RESET_CHARTAB(buf, c); @@ -266,7 +265,7 @@ buf_init_chartab( c = *p; p = skip_to_option_part(p); if (c == ',' && *p == NUL) - /* Trailing comma is not allowed. */ + // Trailing comma is not allowed. return FAIL; } } @@ -284,16 +283,16 @@ trans_characters( char_u *buf, int bufsize) { - int len; /* length of string needing translation */ - int room; /* room in buffer after string */ - char_u *trs; /* translated character */ - int trs_len; /* length of trs[] */ + int len; // length of string needing translation + int room; // room in buffer after string + char_u *trs; // translated character + int trs_len; // length of trs[] len = (int)STRLEN(buf); room = bufsize - len; while (*buf != 0) { - /* Assume a multi-byte character doesn't need translation. */ + // Assume a multi-byte character doesn't need translation. if (has_mbyte && (trs_len = (*mb_ptr2len)(buf)) > 1) len -= trs_len; else @@ -328,8 +327,8 @@ transstr(char_u *s) if (has_mbyte) { - /* Compute the length of the result, taking account of unprintable - * multi-byte characters. */ + // Compute the length of the result, taking account of unprintable + // multi-byte characters. len = 0; p = s; while (*p != NUL) @@ -352,7 +351,7 @@ transstr(char_u *s) if (l > 0) len += l; else - len += 4; /* illegal byte sequence */ + len += 4; // illegal byte sequence } } res = alloc(len + 1); @@ -369,7 +368,7 @@ transstr(char_u *s) { c = (*mb_ptr2char)(p); if (vim_isprintc(c)) - STRNCAT(res, p, l); /* append printable multi-byte char */ + STRNCAT(res, p, l); // append printable multi-byte char else transchar_hex(res + STRLEN(res), c); p += l; @@ -403,7 +402,7 @@ str_foldcase( #define STR_CHAR(i) (buf == NULL ? GA_CHAR(i) : buf[i]) #define STR_PTR(i) (buf == NULL ? GA_PTR(i) : buf + i) - /* Copy "str" into "buf" or allocated memory, unmodified. */ + // Copy "str" into "buf" or allocated memory, unmodified. if (buf == NULL) { ga_init2(&ga, 1, 10); @@ -414,7 +413,7 @@ str_foldcase( } else { - if (len >= buflen) /* Ugly! */ + if (len >= buflen) // Ugly! len = buflen - 1; mch_memmove(buf, str, (size_t)len); } @@ -423,7 +422,7 @@ str_foldcase( else buf[len] = NUL; - /* Make each character lower case. */ + // Make each character lower case. i = 0; while (STR_CHAR(i) != NUL) { @@ -435,15 +434,15 @@ str_foldcase( int olen = utf_ptr2len(STR_PTR(i)); int lc = utf_tolower(c); - /* Only replace the character when it is not an invalid - * sequence (ASCII character or more than one byte) and - * utf_tolower() doesn't return the original character. */ + // Only replace the character when it is not an invalid + // sequence (ASCII character or more than one byte) and + // utf_tolower() doesn't return the original character. if ((c < 0x80 || olen > 1) && c != lc) { int nlen = utf_char2len(lc); - /* If the byte length changes need to shift the following - * characters forward or backward. */ + // If the byte length changes need to shift the following + // characters forward or backward. if (olen != nlen) { if (nlen > olen) @@ -452,7 +451,7 @@ str_foldcase( ? ga_grow(&ga, nlen - olen + 1) == FAIL : len + nlen - olen >= buflen) { - /* out of memory, keep old char */ + // out of memory, keep old char lc = c; nlen = olen; } @@ -474,7 +473,7 @@ str_foldcase( (void)utf_char2bytes(lc, STR_PTR(i)); } } - /* skip to next multi-byte char */ + // skip to next multi-byte char i += (*mb_ptr2len)(STR_PTR(i)); } else @@ -508,7 +507,7 @@ transchar(int c) int i; i = 0; - if (IS_SPECIAL(c)) /* special key code, display as ~@ char */ + if (IS_SPECIAL(c)) // special key code, display as ~@ char { transchar_buf[0] = '~'; transchar_buf[1] = '@'; @@ -524,7 +523,7 @@ transchar(int c) #endif )) || (c < 256 && vim_isprintc_strict(c))) { - /* printable character */ + // printable character transchar_buf[i] = c; transchar_buf[i + 1] = NUL; } @@ -557,28 +556,28 @@ transchar_byte(int c) transchar_nonprint(char_u *buf, int c) { if (c == NL) - c = NUL; /* we use newline in place of a NUL */ + c = NUL; // we use newline in place of a NUL else if (c == CAR && get_fileformat(curbuf) == EOL_MAC) - c = NL; /* we use CR in place of NL in this case */ + c = NL; // we use CR in place of NL in this case - if (dy_flags & DY_UHEX) /* 'display' has "uhex" */ + if (dy_flags & DY_UHEX) // 'display' has "uhex" transchar_hex(buf, c); #ifdef EBCDIC - /* For EBCDIC only the characters 0-63 and 255 are not printable */ + // For EBCDIC only the characters 0-63 and 255 are not printable else if (CtrlChar(c) != 0 || c == DEL) #else - else if (c <= 0x7f) /* 0x00 - 0x1f and 0x7f */ + else if (c <= 0x7f) // 0x00 - 0x1f and 0x7f #endif { buf[0] = '^'; #ifdef EBCDIC if (c == DEL) - buf[1] = '?'; /* DEL displayed as ^? */ + buf[1] = '?'; // DEL displayed as ^? else buf[1] = CtrlChar(c); #else - buf[1] = c ^ 0x40; /* DEL displayed as ^? */ + buf[1] = c ^ 0x40; // DEL displayed as ^? #endif buf[2] = NUL; @@ -588,7 +587,7 @@ transchar_nonprint(char_u *buf, int c) transchar_hex(buf, c); } #ifndef EBCDIC - else if (c >= ' ' + 0x80 && c <= '~' + 0x80) /* 0xa0 - 0xfe */ + else if (c >= ' ' + 0x80 && c <= '~' + 0x80) // 0xa0 - 0xfe { buf[0] = '|'; buf[1] = c - 0x80; @@ -602,7 +601,7 @@ transchar_nonprint(char_u *buf, int c) buf[2] = NUL; } #endif - else /* 0x80 - 0x9f and 0xff */ + else // 0x80 - 0x9f and 0xff { /* * TODO: EBCDIC I don't know what to do with this chars, so I display @@ -610,9 +609,9 @@ transchar_nonprint(char_u *buf, int c) */ buf[0] = '~'; #ifdef EBCDIC - buf[1] = '?'; /* 0xff displayed as ~? */ + buf[1] = '?'; // 0xff displayed as ~? #else - buf[1] = (c - 0x80) ^ 0x40; /* 0xff displayed as ~? */ + buf[1] = (c - 0x80) ^ 0x40; // 0xff displayed as ~? #endif buf[2] = NUL; } @@ -676,11 +675,11 @@ char2cells(int c) return char2cells(K_SECOND(c)) + 2; if (c >= 0x80) { - /* UTF-8: above 0x80 need to check the value */ + // UTF-8: above 0x80 need to check the value if (enc_utf8) return utf_char2cells(c); - /* DBCS: double-byte means double-width, except for euc-jp with first - * byte 0x8e */ + // DBCS: double-byte means double-width, except for euc-jp with first + // byte 0x8e if (enc_dbcs != 0 && c >= 0x100) { if (enc_dbcs == DBCS_JPNU && ((unsigned)c >> 8) == 0x8e) @@ -698,10 +697,10 @@ char2cells(int c) int ptr2cells(char_u *p) { - /* For UTF-8 we need to look at more bytes if the first byte is >= 0x80. */ + // For UTF-8 we need to look at more bytes if the first byte is >= 0x80. if (enc_utf8 && *p >= 0x80) return utf_ptr2cells(p); - /* For DBCS we can tell the cell count from the first byte. */ + // For DBCS we can tell the cell count from the first byte. return (g_chartab[*p] & CT_CELL_MASK); } @@ -797,7 +796,7 @@ linetabsize(char_u *s) linetabsize_col(int startcol, char_u *s) { colnr_T col = startcol; - char_u *line = s; /* pointer to start of line, for breakindent */ + char_u *line = s; // pointer to start of line, for breakindent while (*s != NUL) col += lbr_chartabsize_adv(line, &s, col); @@ -931,7 +930,7 @@ vim_isprintc_strict(int c) */ int lbr_chartabsize( - char_u *line UNUSED, /* start of the line */ + char_u *line UNUSED, // start of the line unsigned char *s, colnr_T col) { @@ -954,7 +953,7 @@ lbr_chartabsize( */ int lbr_chartabsize_adv( - char_u *line, /* start of the line */ + char_u *line, // start of the line char_u **s, colnr_T col) { @@ -975,7 +974,7 @@ lbr_chartabsize_adv( int win_lbr_chartabsize( win_T *wp, - char_u *line UNUSED, /* start of the line */ + char_u *line UNUSED, // start of the line char_u *s, colnr_T col, int *headp UNUSED) @@ -984,7 +983,7 @@ win_lbr_chartabsize( int c; int size; colnr_T col2; - colnr_T col_adj = 0; /* col + screen size of tab */ + colnr_T col_adj = 0; // col + screen size of tab colnr_T colmax; int added; int mb_added = 0; @@ -1051,7 +1050,7 @@ win_lbr_chartabsize( break; col2 += win_chartabsize(wp, s, col2); - if (col2 >= colmax) /* doesn't fit */ + if (col2 >= colmax) // doesn't fit { size = colmax - col + col_adj; break; @@ -1061,7 +1060,7 @@ win_lbr_chartabsize( else if (has_mbyte && size == 2 && MB_BYTE2LEN(*s) > 1 && wp->w_p_wrap && in_win_border(wp, col)) { - ++size; /* Count the ">" in the last column. */ + ++size; // Count the ">" in the last column. mb_added = 1; } @@ -1159,8 +1158,8 @@ win_nolbr_chartabsize( # endif } n = ptr2cells(s); - /* Add one cell for a double-width character in the last column of the - * window, displayed with a ">". */ + // Add one cell for a double-width character in the last column of the + // window, displayed with a ">". if (n == 2 && MB_BYTE2LEN(*s) > 1 && in_win_border(wp, col)) { if (headp != NULL) @@ -1177,10 +1176,10 @@ win_nolbr_chartabsize( static int in_win_border(win_T *wp, colnr_T vcol) { - int width1; /* width of first line (after line number) */ - int width2; /* width of further lines */ + int width1; // width of first line (after line number) + int width2; // width of further lines - if (wp->w_width == 0) /* there is no border */ + if (wp->w_width == 0) // there is no border return FALSE; width1 = wp->w_width - win_col_off(wp); if ((int)vcol < width1 - 1) @@ -1210,9 +1209,9 @@ getvcol( colnr_T *end) { colnr_T vcol; - char_u *ptr; /* points to current char */ - char_u *posptr; /* points to char at pos->col */ - char_u *line; /* start of the line */ + char_u *ptr; // points to current char + char_u *posptr; // points to char at pos->col + char_u *line; // start of the line int incr; int head; #ifdef FEAT_VARTABS @@ -1224,16 +1223,16 @@ getvcol( vcol = 0; line = ptr = ml_get_buf(wp->w_buffer, pos->lnum, FALSE); if (pos->col == MAXCOL) - posptr = NULL; /* continue until the NUL */ + posptr = NULL; // continue until the NUL else { - /* Special check for an empty line, which can happen on exit, when - * ml_get_buf() always returns an empty string. */ + // Special check for an empty line, which can happen on exit, when + // ml_get_buf() always returns an empty string. if (*ptr == NUL) pos->col = 0; posptr = ptr + pos->col; if (has_mbyte) - /* always start on the first byte */ + // always start on the first byte posptr -= (*mb_head_off)(line, posptr); } @@ -1253,13 +1252,13 @@ getvcol( { head = 0; c = *ptr; - /* make sure we don't go past the end of the line */ + // make sure we don't go past the end of the line if (c == NUL) { - incr = 1; /* NUL at end of line only takes one column */ + incr = 1; // NUL at end of line only takes one column break; } - /* A tab gets expanded, depending on the current column */ + // A tab gets expanded, depending on the current column if (c == TAB) #ifdef FEAT_VARTABS incr = tabstop_padding(vcol, ts, vts); @@ -1270,16 +1269,16 @@ getvcol( { if (has_mbyte) { - /* For utf-8, if the byte is >= 0x80, need to look at - * further bytes to find the cell width. */ + // For utf-8, if the byte is >= 0x80, need to look at + // further bytes to find the cell width. if (enc_utf8 && c >= 0x80) incr = utf_ptr2cells(ptr); else incr = g_chartab[c] & CT_CELL_MASK; - /* If a double-cell char doesn't fit at the end of a line - * it wraps to the next line, it's like this char is three - * cells wide. */ + // If a double-cell char doesn't fit at the end of a line + // it wraps to the next line, it's like this char is three + // cells wide. if (incr == 2 && wp->w_p_wrap && MB_BYTE2LEN(*ptr) > 1 && in_win_border(wp, vcol)) { @@ -1291,7 +1290,7 @@ getvcol( incr = g_chartab[c] & CT_CELL_MASK; } - if (posptr != NULL && ptr >= posptr) /* character at pos->col */ + if (posptr != NULL && ptr >= posptr) // character at pos->col break; vcol += incr; @@ -1302,17 +1301,17 @@ getvcol( { for (;;) { - /* A tab gets expanded, depending on the current column */ + // A tab gets expanded, depending on the current column head = 0; incr = win_lbr_chartabsize(wp, line, ptr, vcol, &head); - /* make sure we don't go past the end of the line */ + // make sure we don't go past the end of the line if (*ptr == NUL) { - incr = 1; /* NUL at end of line only takes one column */ + incr = 1; // NUL at end of line only takes one column break; } - if (posptr != NULL && ptr >= posptr) /* character at pos->col */ + if (posptr != NULL && ptr >= posptr) // character at pos->col break; vcol += incr; @@ -1332,9 +1331,9 @@ getvcol( && !(VIsual_active && (*p_sel == 'e' || LTOREQ_POS(*pos, VIsual))) ) - *cursor = vcol + incr - 1; /* cursor at end */ + *cursor = vcol + incr - 1; // cursor at end else - *cursor = vcol + head; /* cursor at start */ + *cursor = vcol + head; // cursor at start } } @@ -1374,12 +1373,12 @@ getvvcol( if (virtual_active()) { - /* For virtual mode, only want one value */ + // For virtual mode, only want one value getvcol(wp, pos, &col, NULL, NULL); coladd = pos->coladd; endadd = 0; - /* Cannot put the cursor on part of a wide character. */ + // Cannot put the cursor on part of a wide character. ptr = ml_get_buf(wp->w_buffer, pos->lnum, FALSE); if (pos->col < (colnr_T)STRLEN(ptr)) { @@ -1388,7 +1387,7 @@ getvvcol( if (c != TAB && vim_isprintc(c)) { endadd = (colnr_T)(char2cells(c) - 1); - if (coladd > endadd) /* past end of line */ + if (coladd > endadd) // past end of line endadd = 0; else coladd = 0; @@ -1453,7 +1452,7 @@ skipwhite(char_u *q) { char_u *p = q; - while (VIM_ISWHITE(*p)) /* skip to next non-white */ + while (VIM_ISWHITE(*p)) // skip to next non-white ++p; return p; } @@ -1482,7 +1481,7 @@ skipdigits(char_u *q) { char_u *p = q; - while (VIM_ISDIGIT(*p)) /* skip to next non-digit */ + while (VIM_ISDIGIT(*p)) // skip to next non-digit ++p; return p; } @@ -1496,7 +1495,7 @@ skipbin(char_u *q) { char_u *p = q; - while (vim_isbdigit(*p)) /* skip to next non-digit */ + while (vim_isbdigit(*p)) // skip to next non-digit ++p; return p; } @@ -1509,7 +1508,7 @@ skiphex(char_u *q) { char_u *p = q; - while (vim_isxdigit(*p)) /* skip to next non-digit */ + while (vim_isxdigit(*p)) // skip to next non-digit ++p; return p; } @@ -1523,7 +1522,7 @@ skiptobin(char_u *q) { char_u *p = q; - while (*p != NUL && !vim_isbdigit(*p)) /* skip to next digit */ + while (*p != NUL && !vim_isbdigit(*p)) // skip to next digit ++p; return p; } @@ -1536,7 +1535,7 @@ skiptodigit(char_u *q) { char_u *p = q; - while (*p != NUL && !VIM_ISDIGIT(*p)) /* skip to next digit */ + while (*p != NUL && !VIM_ISDIGIT(*p)) // skip to next digit ++p; return p; } @@ -1549,7 +1548,7 @@ skiptohex(char_u *q) { char_u *p = q; - while (*p != NUL && !vim_isxdigit(*p)) /* skip to next digit */ + while (*p != NUL && !vim_isxdigit(*p)) // skip to next digit ++p; return p; } @@ -1617,7 +1616,7 @@ vim_islower(int c) if (has_mbyte) return iswlower(c); #endif - /* islower() can't handle these chars and may crash */ + // islower() can't handle these chars and may crash return FALSE; } if (enc_latin1like) @@ -1641,7 +1640,7 @@ vim_isupper(int c) if (has_mbyte) return iswupper(c); #endif - /* islower() can't handle these chars and may crash */ + // islower() can't handle these chars and may crash return FALSE; } if (enc_latin1like) @@ -1665,7 +1664,7 @@ vim_toupper(int c) if (has_mbyte) return towupper(c); #endif - /* toupper() can't handle these chars and may crash */ + // toupper() can't handle these chars and may crash return c; } if (enc_latin1like) @@ -1691,7 +1690,7 @@ vim_tolower(int c) if (has_mbyte) return towlower(c); #endif - /* tolower() can't handle these chars and may crash */ + // tolower() can't handle these chars and may crash return c; } if (enc_latin1like) @@ -1740,9 +1739,9 @@ getdigits(char_u **pp) p = *pp; retval = atol((char *)p); - if (*p == '-') /* skip negative sign */ + if (*p == '-') // skip negative sign ++p; - p = skipdigits(p); /* skip to next non-digit */ + p = skipdigits(p); // skip to next non-digit *pp = p; return retval; } @@ -1808,7 +1807,7 @@ vim_str2nr( ++ptr; } - /* Recognize hex, octal, and bin. */ + // Recognize hex, octal, and bin. if (ptr[0] == '0' && ptr[1] != '8' && ptr[1] != '9' && (maxlen == 0 || maxlen > 1)) { @@ -1816,28 +1815,28 @@ vim_str2nr( if ((what & STR2NR_HEX) && (pre == 'X' || pre == 'x') && vim_isxdigit(ptr[2]) && (maxlen == 0 || maxlen > 2)) - /* hexadecimal */ + // hexadecimal ptr += 2; else if ((what & STR2NR_BIN) && (pre == 'B' || pre == 'b') && vim_isbdigit(ptr[2]) && (maxlen == 0 || maxlen > 2)) - /* binary */ + // binary ptr += 2; else { - /* decimal or octal, default is decimal */ + // decimal or octal, default is decimal pre = 0; if (what & STR2NR_OCT) { - /* Don't interpret "0", "08" or "0129" as octal. */ + // Don't interpret "0", "08" or "0129" as octal. for (n = 1; n != maxlen && VIM_ISDIGIT(ptr[n]); ++n) { if (ptr[n] > '7') { - pre = 0; /* can't be octal */ + pre = 0; // can't be octal break; } - pre = '0'; /* assume octal */ + pre = '0'; // assume octal } } } @@ -1848,12 +1847,12 @@ vim_str2nr( if (pre == 'B' || pre == 'b' || ((what & STR2NR_BIN) && (what & STR2NR_FORCE))) { - /* bin */ + // bin if (pre != 0) - n += 2; /* skip over "0b" */ + n += 2; // skip over "0b" while ('0' <= *ptr && *ptr <= '1') { - /* avoid ubsan error for overflow */ + // avoid ubsan error for overflow if (un <= UVARNUM_MAX / 2) un = 2 * un + (uvarnumber_T)(*ptr - '0'); else @@ -1872,10 +1871,10 @@ vim_str2nr( } else if (pre == '0' || ((what & STR2NR_OCT) && (what & STR2NR_FORCE))) { - /* octal */ + // octal while ('0' <= *ptr && *ptr <= '7') { - /* avoid ubsan error for overflow */ + // avoid ubsan error for overflow if (un <= UVARNUM_MAX / 8) un = 8 * un + (uvarnumber_T)(*ptr - '0'); else @@ -1894,12 +1893,12 @@ vim_str2nr( } else if (pre != 0 || ((what & STR2NR_HEX) && (what & STR2NR_FORCE))) { - /* hex */ + // hex if (pre != 0) - n += 2; /* skip over "0x" */ + n += 2; // skip over "0x" while (vim_isxdigit(*ptr)) { - /* avoid ubsan error for overflow */ + // avoid ubsan error for overflow if (un <= UVARNUM_MAX / 16) un = 16 * un + (uvarnumber_T)hex2nr(*ptr); else @@ -1917,12 +1916,12 @@ vim_str2nr( } else { - /* decimal */ + // decimal while (VIM_ISDIGIT(*ptr)) { uvarnumber_T digit = (uvarnumber_T)(*ptr - '0'); - /* avoid ubsan error for overflow */ + // avoid ubsan error for overflow if (un < UVARNUM_MAX / 10 || (un == UVARNUM_MAX / 10 && digit <= UVARNUM_MAX % 10)) un = 10 * un + digit; @@ -1951,9 +1950,9 @@ vim_str2nr( *len = (int)(ptr - start); if (nptr != NULL) { - if (negative) /* account for leading '-' for decimal numbers */ + if (negative) // account for leading '-' for decimal numbers { - /* avoid ubsan error for overflow */ + // avoid ubsan error for overflow if (un > VARNUM_MAX) *nptr = VARNUM_MIN; else |