summaryrefslogtreecommitdiff
path: root/src/fileio.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fileio.c')
-rw-r--r--src/fileio.c1065
1 files changed, 530 insertions, 535 deletions
diff --git a/src/fileio.c b/src/fileio.c
index c15c7bd28..6600b5920 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -14,10 +14,10 @@
#include "vim.h"
#if defined(__TANDEM) || defined(__MINT__)
-# include <limits.h> /* for SSIZE_MAX */
+# include <limits.h> // for SSIZE_MAX
#endif
-/* Is there any system that doesn't have access()? */
+// Is there any system that doesn't have access()?
#define USE_MCH_ACCESS
static char_u *next_fenc(char_u **pp, int *alloced);
@@ -43,8 +43,8 @@ filemess(
if (msg_silent != 0)
return;
- msg_add_fname(buf, name); /* put file name in IObuff with quotes */
- /* If it's extremely long, truncate it. */
+ msg_add_fname(buf, name); // put file name in IObuff with quotes
+ // If it's extremely long, truncate it.
if (STRLEN(IObuff) > IOSIZE - 80)
IObuff[IOSIZE - 80] = NUL;
STRCAT(IObuff, s);
@@ -56,14 +56,14 @@ filemess(
msg_scroll_save = msg_scroll;
if (shortmess(SHM_OVERALL) && !exiting && p_verbose == 0)
msg_scroll = FALSE;
- if (!msg_scroll) /* wait a bit when overwriting an error msg */
+ if (!msg_scroll) // wait a bit when overwriting an error msg
check_for_delay(FALSE);
msg_start();
if (prev_msg_col != 0 && msg_col == 0)
msg_putchar('\r'); // overwrite any previous message.
msg_scroll = msg_scroll_save;
msg_scrolled_ign = TRUE;
- /* may truncate the message to avoid a hit-return prompt */
+ // may truncate the message to avoid a hit-return prompt
msg_outtrans_attr(msg_may_trunc(FALSE, IObuff), attr);
msg_clr_eos();
out_flush();
@@ -102,7 +102,7 @@ readfile(
linenr_T from,
linenr_T lines_to_skip,
linenr_T lines_to_read,
- exarg_T *eap, /* can be NULL! */
+ exarg_T *eap, // can be NULL!
int flags)
{
int fd = 0;
@@ -114,15 +114,15 @@ readfile(
int read_fifo = (flags & READ_FIFO);
int set_options = newfile || read_buffer
|| (eap != NULL && eap->read_edit);
- linenr_T read_buf_lnum = 1; /* next line to read from curbuf */
- colnr_T read_buf_col = 0; /* next char to read from this line */
+ linenr_T read_buf_lnum = 1; // next line to read from curbuf
+ colnr_T read_buf_col = 0; // next char to read from this line
char_u c;
linenr_T lnum = from;
- char_u *ptr = NULL; /* pointer into read buffer */
- char_u *buffer = NULL; /* read buffer */
- char_u *new_buffer = NULL; /* init to shut up gcc */
- char_u *line_start = NULL; /* init to shut up gcc */
- int wasempty; /* buffer was empty before reading */
+ char_u *ptr = NULL; // pointer into read buffer
+ char_u *buffer = NULL; // read buffer
+ char_u *new_buffer = NULL; // init to shut up gcc
+ char_u *line_start = NULL; // init to shut up gcc
+ int wasempty; // buffer was empty before reading
colnr_T len;
long size = 0;
char_u *p;
@@ -136,58 +136,58 @@ readfile(
context_sha256_T sha_ctx;
int read_undo_file = FALSE;
#endif
- int split = 0; /* number of split lines */
-#define UNKNOWN 0x0fffffff /* file size is unknown */
+ int split = 0; // number of split lines
+#define UNKNOWN 0x0fffffff // file size is unknown
linenr_T linecnt;
- int error = FALSE; /* errors encountered */
- int ff_error = EOL_UNKNOWN; /* file format with errors */
- long linerest = 0; /* remaining chars in line */
+ int error = FALSE; // errors encountered
+ int ff_error = EOL_UNKNOWN; // file format with errors
+ long linerest = 0; // remaining chars in line
#ifdef UNIX
int perm = 0;
- int swap_mode = -1; /* protection bits for swap file */
+ int swap_mode = -1; // protection bits for swap file
#else
int perm;
#endif
- int fileformat = 0; /* end-of-line format */
+ int fileformat = 0; // end-of-line format
int keep_fileformat = FALSE;
stat_T st;
int file_readonly;
linenr_T skip_count = 0;
linenr_T read_count = 0;
int msg_save = msg_scroll;
- linenr_T read_no_eol_lnum = 0; /* non-zero lnum when last line of
- * last read was missing the eol */
+ linenr_T read_no_eol_lnum = 0; // non-zero lnum when last line of
+ // last read was missing the eol
int try_mac;
int try_dos;
int try_unix;
int file_rewind = FALSE;
int can_retry;
- linenr_T conv_error = 0; /* line nr with conversion error */
- linenr_T illegal_byte = 0; /* line nr with illegal byte */
- int keep_dest_enc = FALSE; /* don't retry when char doesn't fit
- in destination encoding */
+ linenr_T conv_error = 0; // line nr with conversion error
+ linenr_T illegal_byte = 0; // line nr with illegal byte
+ int keep_dest_enc = FALSE; // don't retry when char doesn't fit
+ // in destination encoding
int bad_char_behavior = BAD_REPLACE;
- /* BAD_KEEP, BAD_DROP or character to
- * replace with */
- char_u *tmpname = NULL; /* name of 'charconvert' output file */
+ // BAD_KEEP, BAD_DROP or character to
+ // replace with
+ char_u *tmpname = NULL; // name of 'charconvert' output file
int fio_flags = 0;
- char_u *fenc; /* fileencoding to use */
- int fenc_alloced; /* fenc_next is in allocated memory */
- char_u *fenc_next = NULL; /* next item in 'fencs' or NULL */
+ char_u *fenc; // fileencoding to use
+ int fenc_alloced; // fenc_next is in allocated memory
+ char_u *fenc_next = NULL; // next item in 'fencs' or NULL
int advance_fenc = FALSE;
long real_size = 0;
#ifdef USE_ICONV
- iconv_t iconv_fd = (iconv_t)-1; /* descriptor for iconv() or -1 */
+ iconv_t iconv_fd = (iconv_t)-1; // descriptor for iconv() or -1
# ifdef FEAT_EVAL
- int did_iconv = FALSE; /* TRUE when iconv() failed and trying
- 'charconvert' next */
+ int did_iconv = FALSE; // TRUE when iconv() failed and trying
+ // 'charconvert' next
# endif
#endif
- int converted = FALSE; /* TRUE if conversion done */
- int notconverted = FALSE; /* TRUE if conversion wanted but it
- wasn't possible */
+ int converted = FALSE; // TRUE if conversion done
+ int notconverted = FALSE; // TRUE if conversion wanted but it
+ // wasn't possible
char_u conv_rest[CONV_RESTLEN];
- int conv_restlen = 0; /* nr of bytes in conv_rest[] */
+ int conv_restlen = 0; // nr of bytes in conv_rest[]
pos_T orig_start;
buf_T *old_curbuf;
char_u *old_b_ffname;
@@ -195,9 +195,9 @@ readfile(
int using_b_ffname;
int using_b_fname;
- au_did_filetype = FALSE; /* reset before triggering any autocommands */
+ au_did_filetype = FALSE; // reset before triggering any autocommands
- curbuf->b_no_eol_lnum = 0; /* in case it was set by the previous read */
+ curbuf->b_no_eol_lnum = 0; // in case it was set by the previous read
/*
* If there is no file name yet, use the one for the read file.
@@ -215,10 +215,10 @@ readfile(
return FAIL;
}
- /* Remember the initial values of curbuf, curbuf->b_ffname and
- * curbuf->b_fname to detect whether they are altered as a result of
- * executing nasty autocommands. Also check if "fname" and "sfname"
- * point to one of these values. */
+ // Remember the initial values of curbuf, curbuf->b_ffname and
+ // curbuf->b_fname to detect whether they are altered as a result of
+ // executing nasty autocommands. Also check if "fname" and "sfname"
+ // point to one of these values.
old_curbuf = curbuf;
old_b_ffname = curbuf->b_ffname;
old_b_fname = curbuf->b_fname;
@@ -226,11 +226,11 @@ readfile(
|| (sfname == curbuf->b_ffname);
using_b_fname = (fname == curbuf->b_fname) || (sfname == curbuf->b_fname);
- /* After reading a file the cursor line changes but we don't want to
- * display the line. */
+ // After reading a file the cursor line changes but we don't want to
+ // display the line.
ex_no_reprint = TRUE;
- /* don't display the file info for another buffer now */
+ // don't display the file info for another buffer now
need_fileinfo = FALSE;
/*
@@ -253,7 +253,7 @@ readfile(
{
orig_start = curbuf->b_op_start;
- /* Set '[ mark to the line above where the lines go (line 1 if zero). */
+ // Set '[ mark to the line above where the lines go (line 1 if zero).
curbuf->b_op_start.lnum = ((from == 0) ? 1 : from);
curbuf->b_op_start.col = 0;
@@ -279,9 +279,9 @@ readfile(
}
if ((shortmess(SHM_OVER) || curbuf->b_help) && p_verbose == 0)
- msg_scroll = FALSE; /* overwrite previous file message */
+ msg_scroll = FALSE; // overwrite previous file message
else
- msg_scroll = TRUE; /* don't overwrite previous file message */
+ msg_scroll = TRUE; // don't overwrite previous file message
/*
* If the name ends in a path separator, we can't open it. Check here,
@@ -309,12 +309,12 @@ readfile(
* check for it before the mch_open().
*/
perm = mch_getperm(fname);
- if (perm >= 0 && !S_ISREG(perm) /* not a regular file ... */
- && !S_ISFIFO(perm) /* ... or fifo */
- && !S_ISSOCK(perm) /* ... or socket */
+ if (perm >= 0 && !S_ISREG(perm) // not a regular file ...
+ && !S_ISFIFO(perm) // ... or fifo
+ && !S_ISSOCK(perm) // ... or socket
# ifdef OPEN_CHR_FILES
&& !(S_ISCHR(perm) && is_dev_fd_file(fname))
- /* ... or a character special file named /dev/fd/<n> */
+ // ... or a character special file named /dev/fd/<n>
# endif
)
{
@@ -347,7 +347,7 @@ readfile(
#endif
}
- /* Set default or forced 'fileformat' and 'binary'. */
+ // Set default or forced 'fileformat' and 'binary'.
set_file_options(set_options, eap);
/*
@@ -362,7 +362,7 @@ readfile(
if (newfile && !read_stdin && !read_buffer && !read_fifo)
{
- /* Remember time of file. */
+ // Remember time of file.
if (mch_stat((char *)fname, &st) >= 0)
{
buf_store_time(curbuf, &st, fname);
@@ -382,9 +382,8 @@ readfile(
swap_mode = (st.st_mode & 0644) | 0600;
#endif
#ifdef FEAT_CW_EDITOR
- /* Get the FSSpec on MacOS
- * TODO: Update it properly when the buffer name changes
- */
+ // Get the FSSpec on MacOS
+ // TODO: Update it properly when the buffer name changes
(void)GetFSSpecFromPath(curbuf->b_ffname, &curbuf->b_FSSpec);
#endif
#ifdef VMS
@@ -401,8 +400,8 @@ readfile(
curbuf->b_orig_mode = 0;
}
- /* Reset the "new file" flag. It will be set again below when the
- * file doesn't exist. */
+ // Reset the "new file" flag. It will be set again below when the
+ // file doesn't exist.
curbuf->b_flags &= ~(BF_NEW | BF_NEW_W);
}
@@ -414,7 +413,7 @@ readfile(
if (read_stdin)
{
#if defined(MSWIN)
- /* Force binary I/O on stdin to avoid CR-LF -> LF conversion. */
+ // Force binary I/O on stdin to avoid CR-LF -> LF conversion.
setmode(0, O_BINARY);
#endif
}
@@ -434,13 +433,13 @@ readfile(
|| (fd = mch_open((char *)fname, O_RDWR | O_EXTRA, 0)) < 0)
{
file_readonly = TRUE;
- /* try to open ro */
+ // try to open ro
fd = mch_open((char *)fname, O_RDONLY | O_EXTRA, 0);
}
#endif
}
- if (fd < 0) /* cannot open at all */
+ if (fd < 0) // cannot open at all
{
#ifndef UNIX
int isdir_f;
@@ -451,11 +450,11 @@ readfile(
* On Amiga we can't open a directory, check here.
*/
isdir_f = (mch_isdir(fname));
- perm = mch_getperm(fname); /* check if the file exists */
+ perm = mch_getperm(fname); // check if the file exists
if (isdir_f)
{
filemess(curbuf, sfname, (char_u *)_("is a directory"), 0);
- curbuf->b_p_ro = TRUE; /* must use "w!" now */
+ curbuf->b_p_ro = TRUE; // must use "w!" now
}
else
#endif
@@ -473,15 +472,15 @@ readfile(
*/
curbuf->b_flags |= BF_NEW;
- /* Create a swap file now, so that other Vims are warned
- * that we are editing this file. Don't do this for a
- * "nofile" or "nowrite" buffer type. */
+ // Create a swap file now, so that other Vims are warned
+ // that we are editing this file. Don't do this for a
+ // "nofile" or "nowrite" buffer type.
#ifdef FEAT_QUICKFIX
if (!bt_dontwrite(curbuf))
#endif
{
check_need_swap(newfile);
- /* SwapExists autocommand may mess things up */
+ // SwapExists autocommand may mess things up
if (curbuf != old_curbuf
|| (using_b_ffname
&& (old_b_ffname != curbuf->b_ffname))
@@ -498,23 +497,23 @@ readfile(
filemess(curbuf, sfname,
(char_u *)_("[New DIRECTORY]"), 0);
#ifdef FEAT_VIMINFO
- /* Even though this is a new file, it might have been
- * edited before and deleted. Get the old marks. */
+ // Even though this is a new file, it might have been
+ // edited before and deleted. Get the old marks.
check_marks_read();
#endif
- /* Set forced 'fileencoding'. */
+ // Set forced 'fileencoding'.
if (eap != NULL)
set_forced_fenc(eap);
apply_autocmds_exarg(EVENT_BUFNEWFILE, sfname, sfname,
FALSE, curbuf, eap);
- /* remember the current fileformat */
+ // remember the current fileformat
save_file_ff(curbuf);
#if defined(FEAT_EVAL)
- if (aborting()) /* autocmds may abort script processing */
+ if (aborting()) // autocmds may abort script processing
return FAIL;
#endif
- return OK; /* a new file is not an error */
+ return OK; // a new file is not an error
}
else
{
@@ -526,7 +525,7 @@ readfile(
(errno == EOVERFLOW) ? _("[File too big]") :
# endif
_("[Permission Denied]")), 0);
- curbuf->b_p_ro = TRUE; /* must use "w!" now */
+ curbuf->b_p_ro = TRUE; // must use "w!" now
}
}
@@ -542,8 +541,8 @@ readfile(
if (set_options)
{
- /* Don't change 'eol' if reading from buffer as it will already be
- * correctly set when reading stdin. */
+ // Don't change 'eol' if reading from buffer as it will already be
+ // correctly set when reading stdin.
if (!read_buffer)
{
curbuf->b_p_eol = TRUE;
@@ -553,9 +552,9 @@ readfile(
curbuf->b_start_bomb = FALSE;
}
- /* Create a swap file now, so that other Vims are warned that we are
- * editing this file.
- * Don't do this for a "nofile" or "nowrite" buffer type. */
+ // Create a swap file now, so that other Vims are warned that we are
+ // editing this file.
+ // Don't do this for a "nofile" or "nowrite" buffer type.
#ifdef FEAT_QUICKFIX
if (!bt_dontwrite(curbuf))
#endif
@@ -571,7 +570,7 @@ readfile(
return FAIL;
}
#ifdef UNIX
- /* Set swap file protection bits after creating it. */
+ // Set swap file protection bits after creating it.
if (swap_mode > 0 && curbuf->b_ml.ml_mfp != NULL
&& curbuf->b_ml.ml_mfp->mf_fname != NULL)
{
@@ -611,7 +610,7 @@ readfile(
return FAIL;
}
- ++no_wait_return; /* don't wait for return yet */
+ ++no_wait_return; // don't wait for return yet
/*
* Set '[ mark to the line above where the lines go (line 1 if zero).
@@ -634,7 +633,7 @@ readfile(
* the file before reading it.
*/
if (!read_stdin)
- close(fd); /* ignore errors */
+ close(fd); // ignore errors
/*
* The output from the autocommands should not overwrite anything and
@@ -654,7 +653,7 @@ readfile(
else
apply_autocmds_exarg(EVENT_FILEREADPRE, sfname, sfname,
FALSE, NULL, eap);
- /* autocommands may have changed it */
+ // autocommands may have changed it
try_mac = (vim_strchr(p_ffs, 'm') != NULL);
try_dos = (vim_strchr(p_ffs, 'd') != NULL);
try_unix = (vim_strchr(p_ffs, 'x') != NULL);
@@ -664,11 +663,11 @@ readfile(
msg_scroll = m;
#ifdef FEAT_EVAL
- if (aborting()) /* autocmds may abort script processing */
+ if (aborting()) // autocmds may abort script processing
{
--no_wait_return;
msg_scroll = msg_save;
- curbuf->b_p_ro = TRUE; /* must use "w!" now */
+ curbuf->b_p_ro = TRUE; // must use "w!" now
return FAIL;
}
#endif
@@ -690,12 +689,12 @@ readfile(
emsg(_("E200: *ReadPre autocommands made the file unreadable"));
else
emsg(_("E201: *ReadPre autocommands must not change current buffer"));
- curbuf->b_p_ro = TRUE; /* must use "w!" now */
+ curbuf->b_p_ro = TRUE; // must use "w!" now
return FAIL;
}
}
- /* Autocommands may add lines to the file, need to check if it is empty */
+ // Autocommands may add lines to the file, need to check if it is empty
wasempty = (curbuf->b_ml.ml_flags & ML_EMPTY);
if (!recoverymode && !filtering && !(flags & READ_DUMMY))
@@ -717,7 +716,7 @@ readfile(
mch_msg(_("Vim: Reading from stdin...\n"));
#endif
#ifdef FEAT_GUI
- /* Also write a message in the GUI window, if there is one. */
+ // Also write a message in the GUI window, if there is one.
if (gui.in_use && !gui.dying && !gui.starting)
{
p = (char_u *)_("Reading from stdin...");
@@ -730,7 +729,7 @@ readfile(
filemess(curbuf, sfname, (char_u *)"", 0);
}
- msg_scroll = FALSE; /* overwrite the file message */
+ msg_scroll = FALSE; // overwrite the file message
/*
* Set linecnt now, before the "retry" caused by a wrong guess for
@@ -738,7 +737,7 @@ readfile(
*/
linecnt = curbuf->b_ml.ml_line_count;
- /* "++bad=" argument. */
+ // "++bad=" argument.
if (eap != NULL && eap->bad_char != 0)
{
bad_char_behavior = eap->bad_char;
@@ -759,7 +758,7 @@ readfile(
}
else if (curbuf->b_p_bin)
{
- fenc = (char_u *)""; /* binary: don't convert */
+ fenc = (char_u *)""; // binary: don't convert
fenc_alloced = FALSE;
}
else if (curbuf->b_help)
@@ -767,12 +766,12 @@ readfile(
char_u firstline[80];
int fc;
- /* Help files are either utf-8 or latin1. Try utf-8 first, if this
- * fails it must be latin1.
- * Always do this when 'encoding' is "utf-8". Otherwise only do
- * this when needed to avoid [converted] remarks all the time.
- * It is needed when the first line contains non-ASCII characters.
- * That is only in *.??x files. */
+ // Help files are either utf-8 or latin1. Try utf-8 first, if this
+ // fails it must be latin1.
+ // Always do this when 'encoding' is "utf-8". Otherwise only do
+ // this when needed to avoid [converted] remarks all the time.
+ // It is needed when the first line contains non-ASCII characters.
+ // That is only in *.??x files.
fenc = (char_u *)"latin1";
c = enc_utf8;
if (!c && !read_stdin)
@@ -780,8 +779,8 @@ readfile(
fc = fname[STRLEN(fname) - 1];
if (TOLOWER_ASC(fc) == 'x')
{
- /* Read the first line (and a bit more). Immediately rewind to
- * the start of the file. If the read() fails "len" is -1. */
+ // Read the first line (and a bit more). Immediately rewind to
+ // the start of the file. If the read() fails "len" is -1.
len = read_eintr(fd, firstline, 80);
vim_lseek(fd, (off_T)0L, SEEK_SET);
for (p = firstline; p < firstline + len; ++p)
@@ -798,9 +797,9 @@ readfile(
fenc_next = fenc;
fenc = (char_u *)"utf-8";
- /* When the file is utf-8 but a character doesn't fit in
- * 'encoding' don't retry. In help text editing utf-8 bytes
- * doesn't make sense. */
+ // When the file is utf-8 but a character doesn't fit in
+ // 'encoding' don't retry. In help text editing utf-8 bytes
+ // doesn't make sense.
if (!enc_utf8)
keep_dest_enc = TRUE;
}
@@ -808,12 +807,12 @@ readfile(
}
else if (*p_fencs == NUL)
{
- fenc = curbuf->b_p_fenc; /* use format from buffer */
+ fenc = curbuf->b_p_fenc; // use format from buffer
fenc_alloced = FALSE;
}
else
{
- fenc_next = p_fencs; /* try items in 'fileencodings' */
+ fenc_next = p_fencs; // try items in 'fileencodings'
fenc = next_fenc(&fenc_next, &fenc_alloced);
}
@@ -847,11 +846,11 @@ retry:
}
else if (read_stdin || vim_lseek(fd, (off_T)0L, SEEK_SET) != 0)
{
- /* Can't rewind the file, give up. */
+ // Can't rewind the file, give up.
error = TRUE;
goto failed;
}
- /* Delete the previously read lines. */
+ // Delete the previously read lines.
while (lnum > from)
ml_delete(lnum--, FALSE);
file_rewind = FALSE;
@@ -877,17 +876,17 @@ retry:
try_unix = try_dos = try_mac = FALSE;
}
else if (curbuf->b_p_bin)
- fileformat = EOL_UNIX; /* binary: use Unix format */
+ fileformat = EOL_UNIX; // binary: use Unix format
else if (*p_ffs == NUL)
- fileformat = get_fileformat(curbuf);/* use format from buffer */
+ fileformat = get_fileformat(curbuf);// use format from buffer
else
- fileformat = EOL_UNKNOWN; /* detect from file */
+ fileformat = EOL_UNKNOWN; // detect from file
}
#ifdef USE_ICONV
if (iconv_fd != (iconv_t)-1)
{
- /* aborted conversion with iconv(), close the descriptor */
+ // aborted conversion with iconv(), close the descriptor
iconv_close(iconv_fd);
iconv_fd = (iconv_t)-1;
}
@@ -902,8 +901,8 @@ retry:
if (eap != NULL && eap->force_enc != 0)
{
- /* Conversion given with "++cc=" wasn't possible, read
- * without conversion. */
+ // Conversion given with "++cc=" wasn't possible, read
+ // without conversion.
notconverted = TRUE;
conv_error = 0;
if (fenc_alloced)
@@ -927,7 +926,7 @@ retry:
}
if (tmpname != NULL)
{
- mch_remove(tmpname); /* delete converted file */
+ mch_remove(tmpname); // delete converted file
VIM_CLEAR(tmpname);
}
}
@@ -941,8 +940,8 @@ retry:
if (converted)
{
- /* "ucs-bom" means we need to check the first bytes of the file
- * for a BOM. */
+ // "ucs-bom" means we need to check the first bytes of the file
+ // for a BOM.
if (STRCMP(fenc, ENC_UCSBOM) == 0)
fio_flags = FIO_UCSBOM;
@@ -968,7 +967,7 @@ retry:
#endif
#ifdef MACOS_CONVERT
- /* Conversion from Apple MacRoman to latin1 or UTF-8 */
+ // Conversion from Apple MacRoman to latin1 or UTF-8
if (fio_flags == 0)
fio_flags = get_mac_fio_flags(fenc);
#endif
@@ -1001,18 +1000,18 @@ retry:
# ifdef USE_ICONV
did_iconv = FALSE;
# endif
- /* Skip conversion when it's already done (retry for wrong
- * "fileformat"). */
+ // Skip conversion when it's already done (retry for wrong
+ // "fileformat").
if (tmpname == NULL)
{
tmpname = readfile_charconvert(fname, fenc, &fd);
if (tmpname == NULL)
{
- /* Conversion failed. Try another one. */
+ // Conversion failed. Try another one.
advance_fenc = TRUE;
if (fd < 0)
{
- /* Re-opening the original file failed! */
+ // Re-opening the original file failed!
emsg(_("E202: Conversion made file unreadable!"));
error = TRUE;
goto failed;
@@ -1030,17 +1029,17 @@ retry:
#endif
)
{
- /* Conversion wanted but we can't.
- * Try the next conversion in 'fileencodings' */
+ // Conversion wanted but we can't.
+ // Try the next conversion in 'fileencodings'
advance_fenc = TRUE;
goto retry;
}
}
}
- /* Set "can_retry" when it's possible to rewind the file and try with
- * another "fenc" value. It's FALSE when no other "fenc" to try, reading
- * stdin or fixed at a specific encoding. */
+ // Set "can_retry" when it's possible to rewind the file and try with
+ // another "fenc" value. It's FALSE when no other "fenc" to try, reading
+ // stdin or fixed at a specific encoding.
can_retry = (*fenc != NUL && !read_stdin && !read_fifo && !keep_dest_enc);
if (!skip_read)
@@ -1064,8 +1063,8 @@ retry:
#ifdef FEAT_CRYPT
if (curbuf->b_cryptstate != NULL)
{
- /* Need to free the state, but keep the key, don't want to ask for
- * it again. */
+ // Need to free the state, but keep the key, don't want to ask for
+ // it again.
crypt_free_state(curbuf->b_cryptstate);
curbuf->b_cryptstate = NULL;
}
@@ -1083,23 +1082,22 @@ retry:
if (!skip_read)
{
#if defined(SSIZE_MAX) && (SSIZE_MAX < 0x10000L)
- size = SSIZE_MAX; /* use max I/O size, 52K */
+ size = SSIZE_MAX; // use max I/O size, 52K
#else
- /* Use buffer >= 64K. Add linerest to double the size if the
- * line gets very long, to avoid a lot of copying. But don't
- * read more than 1 Mbyte at a time, so we can be interrupted.
- */
+ // Use buffer >= 64K. Add linerest to double the size if the
+ // line gets very long, to avoid a lot of copying. But don't
+ // read more than 1 Mbyte at a time, so we can be interrupted.
size = 0x10000L + linerest;
if (size > 0x100000L)
size = 0x100000L;
#endif
}
- /* Protect against the argument of lalloc() going negative. */
+ // Protect against the argument of lalloc() going negative.
if (size < 0 || size + linerest + 1 < 0 || linerest >= MAXCOL)
{
++split;
- *ptr = NL; /* split line by inserting a NL */
+ *ptr = NL; // split line by inserting a NL
size = 1;
}
else
@@ -1118,23 +1116,23 @@ retry:
error = TRUE;
break;
}
- if (linerest) /* copy characters from the previous buffer */
+ if (linerest) // copy characters from the previous buffer
mch_memmove(new_buffer, ptr - linerest, (size_t)linerest);
vim_free(buffer);
buffer = new_buffer;
ptr = buffer + linerest;
line_start = buffer;
- /* May need room to translate into.
- * For iconv() we don't really know the required space, use a
- * factor ICONV_MULT.
- * latin1 to utf-8: 1 byte becomes up to 2 bytes
- * utf-16 to utf-8: 2 bytes become up to 3 bytes, 4 bytes
- * become up to 4 bytes, size must be multiple of 2
- * ucs-2 to utf-8: 2 bytes become up to 3 bytes, size must be
- * multiple of 2
- * ucs-4 to utf-8: 4 bytes become up to 6 bytes, size must be
- * multiple of 4 */
+ // May need room to translate into.
+ // For iconv() we don't really know the required space, use a
+ // factor ICONV_MULT.
+ // latin1 to utf-8: 1 byte becomes up to 2 bytes
+ // utf-16 to utf-8: 2 bytes become up to 3 bytes, 4 bytes
+ // become up to 4 bytes, size must be multiple of 2
+ // ucs-2 to utf-8: 2 bytes become up to 3 bytes, size must be
+ // multiple of 2
+ // ucs-4 to utf-8: 4 bytes become up to 6 bytes, size must be
+ // multiple of 4
real_size = (int)size;
#ifdef USE_ICONV
if (iconv_fd != (iconv_t)-1)
@@ -1148,19 +1146,19 @@ retry:
else if (fio_flags & FIO_UCS4)
size = (size * 2 / 3) & ~3;
else if (fio_flags == FIO_UCSBOM)
- size = size / ICONV_MULT; /* worst case */
+ size = size / ICONV_MULT; // worst case
#ifdef MSWIN
else if (fio_flags & FIO_CODEPAGE)
- size = size / ICONV_MULT; /* also worst case */
+ size = size / ICONV_MULT; // also worst case
#endif
#ifdef MACOS_CONVERT
else if (fio_flags & FIO_MACROMAN)
- size = size / ICONV_MULT; /* also worst case */
+ size = size / ICONV_MULT; // also worst case
#endif
if (conv_restlen > 0)
{
- /* Insert unconverted bytes from previous line. */
+ // Insert unconverted bytes from previous line.
mch_memmove(ptr, conv_rest, conv_restlen);
ptr += conv_restlen;
size -= conv_restlen;
@@ -1186,9 +1184,9 @@ retry:
n = (int)STRLEN(p);
if ((int)tlen + n + 1 > size)
{
- /* Filled up to "size", append partial line.
- * Change NL to NUL to reverse the effect done
- * below. */
+ // Filled up to "size", append partial line.
+ // Change NL to NUL to reverse the effect done
+ // below.
n = (int)(size - tlen);
for (ni = 0; ni < n; ++ni)
{
@@ -1202,8 +1200,8 @@ retry:
}
else
{
- /* Append whole line and new-line. Change NL
- * to NUL to reverse the effect done below. */
+ // Append whole line and new-line. Change NL
+ // to NUL to reverse the effect done below.
for (ni = 0; ni < n; ++ni)
{
if (p[ni] == NL)
@@ -1215,8 +1213,8 @@ retry:
read_buf_col = 0;
if (++read_buf_lnum > from)
{
- /* When the last line didn't have an
- * end-of-line don't add it now either. */
+ // When the last line didn't have an
+ // end-of-line don't add it now either.
if (!curbuf->b_p_eol)
--tlen;
size = tlen;
@@ -1264,22 +1262,22 @@ retry:
decrypted_size = crypt_decode_alloc(
curbuf->b_cryptstate, ptr, size, &newptr);
- /* If the crypt layer is buffering, not producing
- * anything yet, need to read more. */
+ // If the crypt layer is buffering, not producing
+ // anything yet, need to read more.
if (decrypted_size == 0)
continue;
if (linerest == 0)
{
- /* Simple case: reuse returned buffer (may be
- * NULL, checked later). */
+ // Simple case: reuse returned buffer (may be
+ // NULL, checked later).
new_buffer = newptr;
}
else
{
long_u new_size;
- /* Need new buffer to add bytes carried over. */
+ // Need new buffer to add bytes carried over.
new_size = (long_u)(decrypted_size + linerest + 1);
new_buffer = lalloc(new_size, FALSE);
if (new_buffer == NULL)
@@ -1311,7 +1309,7 @@ retry:
if (size <= 0)
{
- if (size < 0) /* read error */
+ if (size < 0) // read error
error = TRUE;
else if (conv_restlen > 0)
{
@@ -1320,7 +1318,7 @@ retry:
* not be converted. Truncated file?
*/
- /* When we did a conversion report an error. */
+ // When we did a conversion report an error.
if (fio_flags != 0
#ifdef USE_ICONV
|| iconv_fd != (iconv_t)-1
@@ -1333,7 +1331,7 @@ retry:
conv_error = curbuf->b_ml.ml_line_count
- linecnt + 1;
}
- /* Remember the first linenr with an illegal byte */
+ // Remember the first linenr with an illegal byte
else if (illegal_byte == 0)
illegal_byte = curbuf->b_ml.ml_line_count
- linecnt + 1;
@@ -1344,10 +1342,10 @@ retry:
}
else
{
- /* Replace the trailing bytes with the replacement
- * character if we were converting; if we weren't,
- * leave the UTF8 checking code to do it, as it
- * works slightly differently. */
+ // Replace the trailing bytes with the replacement
+ // character if we were converting; if we weren't,
+ // leave the UTF8 checking code to do it, as it
+ // works slightly differently.
if (bad_char_behavior != BAD_KEEP && (fio_flags != 0
#ifdef USE_ICONV
|| iconv_fd != (iconv_t)-1
@@ -1360,7 +1358,7 @@ retry:
--conv_restlen;
}
}
- fio_flags = 0; /* don't convert this */
+ fio_flags = 0; // don't convert this
#ifdef USE_ICONV
if (iconv_fd != (iconv_t)-1)
{
@@ -1395,7 +1393,7 @@ retry:
char_u *ccname;
int blen;
- /* no BOM detection in a short file or in binary mode */
+ // no BOM detection in a short file or in binary mode
if (size < 2 || curbuf->b_p_bin)
ccname = NULL;
else
@@ -1403,7 +1401,7 @@ retry:
fio_flags == FIO_UCSBOM ? FIO_ALL : get_fio_flags(fenc));
if (ccname != NULL)
{
- /* Remove BOM from the text */
+ // Remove BOM from the text
filesize += blen;
size -= blen;
mch_memmove(ptr, ptr + blen, (size_t)size);
@@ -1418,24 +1416,24 @@ retry:
{
if (ccname == NULL)
{
- /* No BOM detected: retry with next encoding. */
+ // No BOM detected: retry with next encoding.
advance_fenc = TRUE;
}
else
{
- /* BOM detected: set "fenc" and jump back */
+ // BOM detected: set "fenc" and jump back
if (fenc_alloced)
vim_free(fenc);
fenc = ccname;
fenc_alloced = FALSE;
}
- /* retry reading without getting new bytes or rewinding */
+ // retry reading without getting new bytes or rewinding
skip_read = TRUE;
goto retry;
}
}
- /* Include not converted bytes. */
+ // Include not converted bytes.
ptr -= conv_restlen;
size += conv_restlen;
conv_restlen = 0;
@@ -1480,7 +1478,7 @@ retry:
conv_error = readfile_linenr(linecnt,
ptr, (char_u *)top);
- /* Deal with a bad byte and continue with the next. */
+ // Deal with a bad byte and continue with the next.
++fromp;
--from_size;
if (bad_char_behavior == BAD_KEEP)
@@ -1497,13 +1495,13 @@ retry:
if (from_size > 0)
{
- /* Some remaining characters, keep them for the next
- * round. */
+ // Some remaining characters, keep them for the next
+ // round.
mch_memmove(conv_rest, (char_u *)fromp, from_size);
conv_restlen = (int)from_size;
}
- /* move the linerest to before the converted characters */
+ // move the linerest to before the converted characters
line_start = ptr - linerest;
mch_memmove(line_start, buffer, (size_t)linerest);
size = (long)((char_u *)top - ptr);
@@ -1533,7 +1531,7 @@ retry:
* character at a time to get it right.
*/
- /* Replacement string for WideCharToMultiByte(). */
+ // Replacement string for WideCharToMultiByte().
if (bad_char_behavior > 0)
replstr[0] = bad_char_behavior;
else
@@ -1556,22 +1554,22 @@ retry:
{
found_bad = FALSE;
-# ifdef CP_UTF8 /* VC 4.1 doesn't define CP_UTF8 */
+# ifdef CP_UTF8 // VC 4.1 doesn't define CP_UTF8
if (codepage == CP_UTF8)
{
- /* Handle CP_UTF8 input ourselves to be able to handle
- * trailing bytes properly.
- * Get one UTF-8 character from src. */
+ // Handle CP_UTF8 input ourselves to be able to handle
+ // trailing bytes properly.
+ // Get one UTF-8 character from src.
bytelen = (int)utf_ptr2len_len(src, size);
if (bytelen > size)
{
- /* Only got some bytes of a character. Normally
- * it's put in "conv_rest", but if it's too long
- * deal with it as if they were illegal bytes. */
+ // Only got some bytes of a character. Normally
+ // it's put in "conv_rest", but if it's too long
+ // deal with it as if they were illegal bytes.
if (bytelen <= CONV_RESTLEN)
break;
- /* weird overlong byte sequence */
+ // weird overlong byte sequence
bytelen = size;
found_bad = TRUE;
}
@@ -1588,8 +1586,8 @@ retry:
else
# endif
{
- /* We don't know how long the byte sequence is, try
- * from one to three bytes. */
+ // We don't know how long the byte sequence is, try
+ // from one to three bytes.
for (bytelen = 1; bytelen <= size && bytelen <= 3;
++bytelen)
{
@@ -1602,9 +1600,9 @@ retry:
}
if (ucs2len == 0)
{
- /* If we have only one byte then it's probably an
- * incomplete byte sequence. Otherwise discard
- * one byte as a bad character. */
+ // If we have only one byte then it's probably an
+ // incomplete byte sequence. Otherwise discard
+ // one byte as a bad character.
if (size == 1)
break;
found_bad = TRUE;
@@ -1616,10 +1614,10 @@ retry:
{
int i;
- /* Convert "ucs2buf[ucs2len]" to 'enc' in "dst". */
+ // Convert "ucs2buf[ucs2len]" to 'enc' in "dst".
if (enc_utf8)
{
- /* From UCS-2 to UTF-8. Cannot fail. */
+ // From UCS-2 to UTF-8. Cannot fail.
for (i = 0; i < ucs2len; ++i)
dst += utf_char2bytes(ucs2buf[i], dst);
}
@@ -1628,9 +1626,9 @@ retry:
BOOL bad = FALSE;
int dstlen;
- /* From UCS-2 to "enc_codepage". If the
- * conversion uses the default character "?",
- * the data doesn't fit in this encoding. */
+ // From UCS-2 to "enc_codepage". If the
+ // conversion uses the default character "?",
+ // the data doesn't fit in this encoding.
dstlen = WideCharToMultiByte(enc_codepage, 0,
(LPCWSTR)ucs2buf, ucs2len,
(LPSTR)dst, (int)(src - dst),
@@ -1644,7 +1642,7 @@ retry:
if (found_bad)
{
- /* Deal with bytes we can't convert. */
+ // Deal with bytes we can't convert.
if (can_retry)
goto rewind_retry;
if (conv_error == 0)
@@ -1667,12 +1665,12 @@ retry:
if (size > 0)
{
- /* An incomplete byte sequence remaining. */
+ // An incomplete byte sequence remaining.
mch_memmove(conv_rest, src, size);
conv_restlen = size;
}
- /* The new size is equal to how much "dst" was advanced. */
+ // The new size is equal to how much "dst" was advanced.
size = (long)(dst - ptr);
}
else
@@ -1709,7 +1707,7 @@ retry:
p = ptr + size;
if (fio_flags == FIO_UTF8)
{
- /* Check for a trailing incomplete UTF-8 sequence */
+ // Check for a trailing incomplete UTF-8 sequence
tail = ptr + size - 1;
while (tail > ptr && (*tail & 0xc0) == 0x80)
--tail;
@@ -1721,13 +1719,13 @@ retry:
}
else if (fio_flags & (FIO_UCS2 | FIO_UTF16))
{
- /* Check for a trailing byte */
+ // Check for a trailing byte
p = ptr + (size & ~1);
if (size & 1)
tail = p;
if ((fio_flags & FIO_UTF16) && p > ptr)
{
- /* Check for a trailing leading word */
+ // Check for a trailing leading word
if (fio_flags & FIO_ENDIAN_L)
{
u8c = (*--p << 8);
@@ -1744,16 +1742,16 @@ retry:
p += 2;
}
}
- else /* FIO_UCS4 */
+ else // FIO_UCS4
{
- /* Check for trailing 1, 2 or 3 bytes */
+ // Check for trailing 1, 2 or 3 bytes
p = ptr + (size & ~3);
if (size & 3)
tail = p;
}
- /* If there is a trailing incomplete sequence move it to
- * conv_rest[]. */
+ // If there is a trailing incomplete sequence move it to
+ // conv_rest[].
if (tail != NULL)
{
conv_restlen = (int)((ptr + size) - tail);
@@ -1785,7 +1783,7 @@ retry:
if (p == ptr)
{
- /* Missing leading word. */
+ // Missing leading word.
if (can_retry)
goto rewind_retry;
if (conv_error == 0)
@@ -1797,8 +1795,8 @@ retry:
u8c = bad_char_behavior;
}
- /* found second word of double-word, get the first
- * word and compute the resulting character */
+ // found second word of double-word, get the first
+ // word and compute the resulting character
if (fio_flags & FIO_ENDIAN_L)
{
u16c = (*--p << 8);
@@ -1812,7 +1810,7 @@ retry:
u8c = 0x10000 + ((u16c & 0x3ff) << 10)
+ (u8c & 0x3ff);
- /* Check if the word is indeed a leading word. */
+ // Check if the word is indeed a leading word.
if (u16c < 0xd800 || u16c > 0xdbff)
{
if (can_retry)
@@ -1836,7 +1834,7 @@ retry:
u8c += (unsigned)*--p << 8;
u8c += *--p;
}
- else /* big endian */
+ else // big endian
{
u8c = *--p;
u8c += (unsigned)*--p << 8;
@@ -1844,7 +1842,7 @@ retry:
u8c += (unsigned)*--p << 24;
}
}
- else /* UTF-8 */
+ else // UTF-8
{
if (*--p < 0x80)
u8c = *p;
@@ -1855,9 +1853,9 @@ retry:
u8c = utf_ptr2char(p);
if (len == 0)
{
- /* Not a valid UTF-8 character, retry with
- * another fenc when possible, otherwise just
- * report the error. */
+ // Not a valid UTF-8 character, retry with
+ // another fenc when possible, otherwise just
+ // report the error.
if (can_retry)
goto rewind_retry;
if (conv_error == 0)
@@ -1870,19 +1868,19 @@ retry:
}
}
}
- if (enc_utf8) /* produce UTF-8 */
+ if (enc_utf8) // produce UTF-8
{
dest -= utf_char2len(u8c);
(void)utf_char2bytes(u8c, dest);
}
- else /* produce Latin1 */
+ else // produce Latin1
{
--dest;
if (u8c >= 0x100)
{
- /* character doesn't fit in latin1, retry with
- * another fenc when possible, otherwise just
- * report the error. */
+ // character doesn't fit in latin1, retry with
+ // another fenc when possible, otherwise just
+ // report the error.
if (can_retry)
goto rewind_retry;
if (conv_error == 0)
@@ -1901,7 +1899,7 @@ retry:
}
}
- /* move the linerest to before the converted characters */
+ // move the linerest to before the converted characters
line_start = dest - linerest;
mch_memmove(line_start, buffer, (size_t)linerest);
size = (long)((ptr + real_size) - dest);
@@ -1911,7 +1909,7 @@ retry:
{
int incomplete_tail = FALSE;
- /* Reading UTF-8: Check if the bytes are valid UTF-8. */
+ // Reading UTF-8: Check if the bytes are valid UTF-8.
for (p = ptr; ; ++p)
{
int todo = (int)((ptr + size) - p);
@@ -1921,22 +1919,22 @@ retry:
break;
if (*p >= 0x80)
{
- /* A length of 1 means it's an illegal byte. Accept
- * an incomplete character at the end though, the next
- * read() will get the next bytes, we'll check it
- * then. */
+ // A length of 1 means it's an illegal byte. Accept
+ // an incomplete character at the end though, the next
+ // read() will get the next bytes, we'll check it
+ // then.
l = utf_ptr2len_len(p, todo);
if (l > todo && !incomplete_tail)
{
- /* Avoid retrying with a different encoding when
- * a truncated file is more likely, or attempting
- * to read the rest of an incomplete sequence when
- * we have already done so. */
+ // Avoid retrying with a different encoding when
+ // a truncated file is more likely, or attempting
+ // to read the rest of an incomplete sequence when
+ // we have already done so.
if (p > ptr || filesize > 0)
incomplete_tail = TRUE;
- /* Incomplete byte sequence, move it to conv_rest[]
- * and try to read the rest of it, unless we've
- * already done so. */
+ // Incomplete byte sequence, move it to conv_rest[]
+ // and try to read the rest of it, unless we've
+ // already done so.
if (p > ptr)
{
conv_restlen = todo;
@@ -1947,21 +1945,21 @@ retry:
}
if (l == 1 || l > todo)
{
- /* Illegal byte. If we can try another encoding
- * do that, unless at EOF where a truncated
- * file is more likely than a conversion error. */
+ // Illegal byte. If we can try another encoding
+ // do that, unless at EOF where a truncated
+ // file is more likely than a conversion error.
if (can_retry && !incomplete_tail)
break;
#ifdef USE_ICONV
- /* When we did a conversion report an error. */
+ // When we did a conversion report an error.
if (iconv_fd != (iconv_t)-1 && conv_error == 0)
conv_error = readfile_linenr(linecnt, ptr, p);
#endif
- /* Remember the first linenr with an illegal byte */
+ // Remember the first linenr with an illegal byte
if (conv_error == 0 && illegal_byte == 0)
illegal_byte = readfile_linenr(linecnt, ptr, p);
- /* Drop, keep or replace the bad byte. */
+ // Drop, keep or replace the bad byte.
if (bad_char_behavior == BAD_DROP)
{
mch_memmove(p, p + 1, todo - 1);
@@ -1977,23 +1975,23 @@ retry:
}
if (p < ptr + size && !incomplete_tail)
{
- /* Detected a UTF-8 error. */
+ // Detected a UTF-8 error.
rewind_retry:
- /* Retry reading with another conversion. */
+ // Retry reading with another conversion.
#if defined(FEAT_EVAL) && defined(USE_ICONV)
if (*p_ccv != NUL && iconv_fd != (iconv_t)-1)
- /* iconv() failed, try 'charconvert' */
+ // iconv() failed, try 'charconvert'
did_iconv = TRUE;
else
#endif
- /* use next item from 'fileencodings' */
+ // use next item from 'fileencodings'
advance_fenc = TRUE;
file_rewind = TRUE;
goto retry;
}
}
- /* count the number of characters (after conversion!) */
+ // count the number of characters (after conversion!)
filesize += size;
/*
@@ -2001,10 +1999,10 @@ rewind_retry:
*/
if (fileformat == EOL_UNKNOWN)
{
- /* First try finding a NL, for Dos and Unix */
+ // First try finding a NL, for Dos and Unix
if (try_dos || try_unix)
{
- /* Reset the carriage return counter. */
+ // Reset the carriage return counter.
if (try_mac)
try_mac = 1;
@@ -2023,10 +2021,10 @@ rewind_retry:
try_mac++;
}
- /* Don't give in to EOL_UNIX if EOL_MAC is more likely */
+ // Don't give in to EOL_UNIX if EOL_MAC is more likely
if (fileformat == EOL_UNIX && try_mac)
{
- /* Need to reset the counters when retrying fenc. */
+ // Need to reset the counters when retrying fenc.
try_mac = 1;
try_unix = 1;
for (; p >= ptr && *p != CAR; p--)
@@ -2045,20 +2043,20 @@ rewind_retry:
}
}
else if (fileformat == EOL_UNKNOWN && try_mac == 1)
- /* Looking for CR but found no end-of-line markers at
- * all: use the default format. */
+ // Looking for CR but found no end-of-line markers at
+ // all: use the default format.
fileformat = default_fileformat();
}
- /* No NL found: may use Mac format */
+ // No NL found: may use Mac format
if (fileformat == EOL_UNKNOWN && try_mac)
fileformat = EOL_MAC;
- /* Still nothing found? Use first format in 'ffs' */
+ // Still nothing found? Use first format in 'ffs'
if (fileformat == EOL_UNKNOWN)
fileformat = default_fileformat();
- /* if editing a new file: may set p_tx and p_ff */
+ // if editing a new file: may set p_tx and p_ff
if (set_options)
set_fileformat(fileformat, OPT_LOCAL);
}
@@ -2073,18 +2071,18 @@ rewind_retry:
--ptr;
while (++ptr, --size >= 0)
{
- /* catch most common case first */
+ // catch most common case first
if ((c = *ptr) != NUL && c != CAR && c != NL)
continue;
if (c == NUL)
- *ptr = NL; /* NULs are replaced by newlines! */
+ *ptr = NL; // NULs are replaced by newlines!
else if (c == NL)
- *ptr = CAR; /* NLs are replaced by CRs! */
+ *ptr = CAR; // NLs are replaced by CRs!
else
{
if (skip_count == 0)
{
- *ptr = NUL; /* end of line */
+ *ptr = NUL; // end of line
len = (colnr_T) (ptr - line_start + 1);
if (ml_append(lnum, line_start, len, newfile) == FAIL)
{
@@ -2098,8 +2096,8 @@ rewind_retry:
++lnum;
if (--read_count == 0)
{
- error = TRUE; /* break loop */
- line_start = ptr; /* nothing left to write */
+ error = TRUE; // break loop
+ line_start = ptr; // nothing left to write
break;
}
}
@@ -2114,21 +2112,21 @@ rewind_retry:
--ptr;
while (++ptr, --size >= 0)
{
- if ((c = *ptr) != NUL && c != NL) /* catch most common case */
+ if ((c = *ptr) != NUL && c != NL) // catch most common case
continue;
if (c == NUL)
- *ptr = NL; /* NULs are replaced by newlines! */
+ *ptr = NL; // NULs are replaced by newlines!
else
{
if (skip_count == 0)
{
- *ptr = NUL; /* end of line */
+ *ptr = NUL; // end of line
len = (colnr_T)(ptr - line_start + 1);
if (fileformat == EOL_DOS)
{
if (ptr > line_start && ptr[-1] == CAR)
{
- /* remove CR before NL */
+ // remove CR before NL
ptr[-1] = NUL;
--len;
}
@@ -2168,8 +2166,8 @@ rewind_retry:
++lnum;
if (--read_count == 0)
{
- error = TRUE; /* break loop */
- line_start = ptr; /* nothing left to write */
+ error = TRUE; // break loop
+ line_start = ptr; // nothing left to write
break;
}
}
@@ -2184,7 +2182,7 @@ rewind_retry:
}
failed:
- /* not an error, max. number of lines reached */
+ // not an error, max. number of lines reached
if (error && read_count == 0)
error = FALSE;
@@ -2201,7 +2199,7 @@ failed:
&& *line_start == Ctrl_Z
&& ptr == line_start + 1))
{
- /* remember for when writing */
+ // remember for when writing
if (set_options)
curbuf->b_p_eol = FALSE;
*ptr = NUL;
@@ -2219,7 +2217,7 @@ failed:
}
if (set_options)
- save_file_ff(curbuf); /* remember the current file format */
+ save_file_ff(curbuf); // remember the current file format
#ifdef FEAT_CRYPT
if (curbuf->b_cryptstate != NULL)
@@ -2229,12 +2227,12 @@ failed:
}
if (cryptkey != NULL && cryptkey != curbuf->b_p_key)
crypt_free_key(cryptkey);
- /* Don't set cryptkey to NULL, it's used below as a flag that
- * encryption was used. */
+ // Don't set cryptkey to NULL, it's used below as a flag that
+ // encryption was used.
#endif
- /* If editing a new file: set 'fenc' for the current buffer.
- * Also for ":read ++edit file". */
+ // If editing a new file: set 'fenc' for the current buffer.
+ // Also for ":read ++edit file".
if (set_options)
set_string_option_direct((char_u *)"fenc", -1, fenc,
OPT_FREE|OPT_LOCAL, 0);
@@ -2246,7 +2244,7 @@ failed:
#endif
if (!read_buffer && !read_stdin)
- close(fd); /* errors are ignored */
+ close(fd); // errors are ignored
#ifdef HAVE_FD_CLOEXEC
else
{
@@ -2260,7 +2258,7 @@ failed:
#ifdef HAVE_DUP
if (read_stdin)
{
- /* Use stderr for stdin, makes shell commands work. */
+ // Use stderr for stdin, makes shell commands work.
close(0);
vim_ignored = dup(2);
}
@@ -2268,17 +2266,17 @@ failed:
if (tmpname != NULL)
{
- mch_remove(tmpname); /* delete converted file */
+ mch_remove(tmpname); // delete converted file
vim_free(tmpname);
}
- --no_wait_return; /* may wait for return now */
+ --no_wait_return; // may wait for return now
/*
* In recovery mode everything but autocommands is skipped.
*/
if (!recoverymode)
{
- /* need to delete the last line, which comes from the empty buffer */
+ // need to delete the last line, which comes from the empty buffer
if (newfile && wasempty && !(curbuf->b_ml.ml_flags & ML_EMPTY))
{
#ifdef FEAT_NETBEANS_INTG
@@ -2297,17 +2295,17 @@ failed:
{
redraw_curbuf_later(NOT_VALID);
#ifdef FEAT_DIFF
- /* After reading the text into the buffer the diff info needs to
- * be updated. */
+ // After reading the text into the buffer the diff info needs to
+ // be updated.
diff_invalidate(curbuf);
#endif
#ifdef FEAT_FOLDING
- /* All folds in the window are invalid now. Mark them for update
- * before triggering autocommands. */
+ // All folds in the window are invalid now. Mark them for update
+ // before triggering autocommands.
foldUpdateAll(curwin);
#endif
}
- else if (linecnt) /* appended at least one line */
+ else if (linecnt) // appended at least one line
appended_lines_mark(from, linecnt);
#ifndef ALWAYS_USE_GUI
@@ -2318,7 +2316,7 @@ failed:
*/
if (read_stdin)
{
- settmode(TMODE_RAW); /* set to raw mode */
+ settmode(TMODE_RAW); // set to raw mode
starttermcap();
screenclear();
}
@@ -2330,33 +2328,33 @@ failed:
{
filemess(curbuf, sfname, (char_u *)_(e_interr), 0);
if (newfile)
- curbuf->b_p_ro = TRUE; /* must use "w!" now */
+ curbuf->b_p_ro = TRUE; // must use "w!" now
}
msg_scroll = msg_save;
#ifdef FEAT_VIMINFO
check_marks_read();
#endif
- return OK; /* an interrupt isn't really an error */
+ return OK; // an interrupt isn't really an error
}
if (!filtering && !(flags & READ_DUMMY))
{
- msg_add_fname(curbuf, sfname); /* fname in IObuff with quotes */
+ msg_add_fname(curbuf, sfname); // fname in IObuff with quotes
c = FALSE;
#ifdef UNIX
- if (S_ISFIFO(perm)) /* fifo */
+ if (S_ISFIFO(perm)) // fifo
{
STRCAT(IObuff, _("[fifo]"));
c = TRUE;
}
- if (S_ISSOCK(perm)) /* or socket */
+ if (S_ISSOCK(perm)) // or socket
{
STRCAT(IObuff, _("[socket]"));
c = TRUE;
}
# ifdef OPEN_CHR_FILES
- if (S_ISCHR(perm)) /* or character special */
+ if (S_ISCHR(perm)) // or character special
{
STRCAT(IObuff, _("[character special]"));
c = TRUE;
@@ -2430,8 +2428,8 @@ failed:
VIM_CLEAR(keep_msg);
msg_scrolled_ign = TRUE;
#ifdef ALWAYS_USE_GUI
- /* Don't show the message when reading stdin, it would end up in a
- * message box (which might be shown when exiting!) */
+ // Don't show the message when reading stdin, it would end up in a
+ // message box (which might be shown when exiting!)
if (read_stdin || read_buffer)
p = msg_may_trunc(FALSE, IObuff);
else
@@ -2443,23 +2441,23 @@ failed:
}
if (read_stdin || read_buffer || restart_edit != 0
|| (msg_scrolled != 0 && !need_wait_return))
- /* Need to repeat the message after redrawing when:
- * - When reading from stdin (the screen will be cleared next).
- * - When restart_edit is set (otherwise there will be a delay
- * before redrawing).
- * - When the screen was scrolled but there is no wait-return
- * prompt. */
+ // Need to repeat the message after redrawing when:
+ // - When reading from stdin (the screen will be cleared next).
+ // - When restart_edit is set (otherwise there will be a delay
+ // before redrawing).
+ // - When the screen was scrolled but there is no wait-return
+ // prompt.
set_keep_msg(p, 0);
msg_scrolled_ign = FALSE;
}
- /* with errors writing the file requires ":w!" */
+ // with errors writing the file requires ":w!"
if (newfile && (error
|| conv_error != 0
|| (illegal_byte > 0 && bad_char_behavior != BAD_KEEP)))
curbuf->b_p_ro = TRUE;
- u_clearline(); /* cannot use "U" command after adding lines */
+ u_clearline(); // cannot use "U" command after adding lines
/*
* In Ex mode: cursor at last new line.
@@ -2470,7 +2468,7 @@ failed:
else
curwin->w_cursor.lnum = from + 1;
check_cursor_lnum();
- beginline(BL_WHITE | BL_FIX); /* on first non-blank */
+ beginline(BL_WHITE | BL_FIX); // on first non-blank
if (!cmdmod.lockmarks)
{
@@ -2514,8 +2512,8 @@ failed:
*/
curbuf->b_no_eol_lnum = read_no_eol_lnum;
- /* When reloading a buffer put the cursor at the first line that is
- * different. */
+ // When reloading a buffer put the cursor at the first line that is
+ // different.
if (flags & READ_KEEP_UNDO)
u_find_first_changed();
@@ -2537,8 +2535,8 @@ failed:
int m = msg_scroll;
int n = msg_scrolled;
- /* Save the fileformat now, otherwise the buffer will be considered
- * modified if the format/encoding was automatically detected. */
+ // Save the fileformat now, otherwise the buffer will be considered
+ // modified if the format/encoding was automatically detected.
if (set_options)
save_file_ff(curbuf);
@@ -2569,7 +2567,7 @@ failed:
if (msg_scrolled == n)
msg_scroll = m;
# ifdef FEAT_EVAL
- if (aborting()) /* autocmds may abort script processing */
+ if (aborting()) // autocmds may abort script processing
return FAIL;
# endif
}
@@ -2604,9 +2602,9 @@ is_dev_fd_file(char_u *fname)
*/
static linenr_T
readfile_linenr(
- linenr_T linecnt, /* line count before reading more bytes */
- char_u *p, /* start of more bytes read */
- char_u *endp) /* end of more bytes read */
+ linenr_T linecnt, // line count before reading more bytes
+ char_u *p, // start of more bytes read
+ char_u *endp) // end of more bytes read
{
char_u *s;
linenr_T lnum;
@@ -2647,7 +2645,7 @@ prep_exarg(exarg_T *eap, buf_T *buf)
void
set_file_options(int set_options, exarg_T *eap)
{
- /* set default 'fileformat' */
+ // set default 'fileformat'
if (set_options)
{
if (eap != NULL && eap->force_ff != 0)
@@ -2656,7 +2654,7 @@ set_file_options(int set_options, exarg_T *eap)
set_fileformat(default_fileformat(), OPT_LOCAL);
}
- /* set or reset 'binary' */
+ // set or reset 'binary'
if (eap != NULL && eap->force_bin != 0)
{
int oldval = curbuf->b_p_bin;
@@ -2742,9 +2740,9 @@ next_fenc(char_u **pp, int *alloced)
*/
static char_u *
readfile_charconvert(
- char_u *fname, /* name of input file */
- char_u *fenc, /* converted from */
- int *fdp) /* in/out: file descriptor of file */
+ char_u *fname, // name of input file
+ char_u *fenc, // converted from
+ int *fdp) // in/out: file descriptor of file
{
char_u *tmpname;
char *errmsg = NULL;
@@ -2754,7 +2752,7 @@ readfile_charconvert(
errmsg = _("Can't find temp file for conversion");
else
{
- close(*fdp); /* close the input file, ignore errors */
+ close(*fdp); // close the input file, ignore errors
*fdp = -1;
if (eval_charconvert(fenc, enc_utf8 ? (char_u *)"utf-8" : p_enc,
fname, tmpname) == FAIL)
@@ -2766,17 +2764,17 @@ readfile_charconvert(
if (errmsg != NULL)
{
- /* Don't use emsg(), it breaks mappings, the retry with
- * another type of conversion might still work. */
+ // Don't use emsg(), it breaks mappings, the retry with
+ // another type of conversion might still work.
msg(errmsg);
if (tmpname != NULL)
{
- mch_remove(tmpname); /* delete converted file */
+ mch_remove(tmpname); // delete converted file
VIM_CLEAR(tmpname);
}
}
- /* If the input file is closed, open it (caller should check for error). */
+ // If the input file is closed, open it (caller should check for error).
if (*fdp < 0)
*fdp = mch_open((char *)fname, O_RDONLY | O_EXTRA, 0);
@@ -2793,24 +2791,24 @@ readfile_charconvert(
*/
static char_u *
check_for_cryptkey(
- char_u *cryptkey, /* previous encryption key or NULL */
- char_u *ptr, /* pointer to read bytes */
- long *sizep, /* length of read bytes */
- off_T *filesizep, /* nr of bytes used from file */
- int newfile, /* editing a new buffer */
- char_u *fname, /* file name to display */
- int *did_ask) /* flag: whether already asked for key */
+ char_u *cryptkey, // previous encryption key or NULL
+ char_u *ptr, // pointer to read bytes
+ long *sizep, // length of read bytes
+ off_T *filesizep, // nr of bytes used from file
+ int newfile, // editing a new buffer
+ char_u *fname, // file name to display
+ int *did_ask) // flag: whether already asked for key
{
int method = crypt_method_nr_from_magic((char *)ptr, *sizep);
int b_p_ro = curbuf->b_p_ro;
if (method >= 0)
{
- /* Mark the buffer as read-only until the decryption has taken place.
- * Avoids accidentally overwriting the file with garbage. */
+ // Mark the buffer as read-only until the decryption has taken place.
+ // Avoids accidentally overwriting the file with garbage.
curbuf->b_p_ro = TRUE;
- /* Set the cryptmethod local to the buffer. */
+ // Set the cryptmethod local to the buffer.
crypt_set_cm_option(curbuf, method);
if (cryptkey == NULL && !*did_ask)
{
@@ -2818,17 +2816,17 @@ check_for_cryptkey(
cryptkey = curbuf->b_p_key;
else
{
- /* When newfile is TRUE, store the typed key in the 'key'
- * option and don't free it. bf needs hash of the key saved.
- * Don't ask for the key again when first time Enter was hit.
- * Happens when retrying to detect encoding. */
+ // When newfile is TRUE, store the typed key in the 'key'
+ // option and don't free it. bf needs hash of the key saved.
+ // Don't ask for the key again when first time Enter was hit.
+ // Happens when retrying to detect encoding.
smsg(_(need_key_msg), fname);
msg_scroll = TRUE;
crypt_check_method(method);
cryptkey = crypt_get_key(newfile, FALSE);
*did_ask = TRUE;
- /* check if empty key entered */
+ // check if empty key entered
if (cryptkey != NULL && *cryptkey == NUL)
{
if (cryptkey != curbuf->b_p_key)
@@ -2846,30 +2844,30 @@ check_for_cryptkey(
method, cryptkey, ptr);
crypt_set_cm_option(curbuf, method);
- /* Remove cryptmethod specific header from the text. */
+ // Remove cryptmethod specific header from the text.
header_len = crypt_get_header_len(method);
if (*sizep <= header_len)
- /* invalid header, buffer can't be encrypted */
+ // invalid header, buffer can't be encrypted
return NULL;
*filesizep += header_len;
*sizep -= header_len;
mch_memmove(ptr, ptr + header_len, (size_t)*sizep);
- /* Restore the read-only flag. */
+ // Restore the read-only flag.
curbuf->b_p_ro = b_p_ro;
}
}
- /* When starting to edit a new file which does not have encryption, clear
- * the 'key' option, except when starting up (called with -x argument) */
+ // When starting to edit a new file which does not have encryption, clear
+ // the 'key' option, except when starting up (called with -x argument)
else if (newfile && *curbuf->b_p_key != NUL && !starting)
set_option_value((char_u *)"key", 0L, (char_u *)"", OPT_LOCAL);
return cryptkey;
}
-#endif /* FEAT_CRYPT */
+#endif // FEAT_CRYPT
#if defined(VMS) && !defined(MIN)
-/* Older DECC compiler for VAX doesn't define MIN() */
+// Older DECC compiler for VAX doesn't define MIN()
# define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
@@ -2878,8 +2876,8 @@ check_for_cryptkey(
*/
int
check_file_readonly(
- char_u *fname, /* full path to file */
- int perm UNUSED) /* known permissions on file */
+ char_u *fname, // full path to file
+ int perm UNUSED) // known permissions on file
{
#ifndef USE_MCH_ACCESS
int fd = 0;
@@ -2926,17 +2924,17 @@ set_rw_fname(char_u *fname, char_u *sfname)
{
buf_T *buf = curbuf;
- /* It's like the unnamed buffer is deleted.... */
+ // It's like the unnamed buffer is deleted....
if (curbuf->b_p_bl)
apply_autocmds(EVENT_BUFDELETE, NULL, NULL, FALSE, curbuf);
apply_autocmds(EVENT_BUFWIPEOUT, NULL, NULL, FALSE, curbuf);
#ifdef FEAT_EVAL
- if (aborting()) /* autocmds may abort script processing */
+ if (aborting()) // autocmds may abort script processing
return FAIL;
#endif
if (curbuf != buf)
{
- /* We are in another buffer now, don't do the renaming. */
+ // We are in another buffer now, don't do the renaming.
emsg(_(e_auchangedbuf));
return FAIL;
}
@@ -2944,16 +2942,16 @@ set_rw_fname(char_u *fname, char_u *sfname)
if (setfname(curbuf, fname, sfname, FALSE) == OK)
curbuf->b_flags |= BF_NOTEDITED;
- /* ....and a new named one is created */
+ // ....and a new named one is created
apply_autocmds(EVENT_BUFNEW, NULL, NULL, FALSE, curbuf);
if (curbuf->b_p_bl)
apply_autocmds(EVENT_BUFADD, NULL, NULL, FALSE, curbuf);
#ifdef FEAT_EVAL
- if (aborting()) /* autocmds may abort script processing */
+ if (aborting()) // autocmds may abort script processing
return FAIL;
#endif
- /* Do filetype detection now if 'filetype' is empty. */
+ // Do filetype detection now if 'filetype' is empty.
if (*curbuf->b_p_ft == NUL)
{
if (au_has_group((char_u *)"filetypedetect"))
@@ -3047,9 +3045,9 @@ msg_add_eol(void)
time_differs(long t1, long t2)
{
#if defined(__linux__) || defined(MSWIN)
- /* On a FAT filesystem, esp. under Linux, there are only 5 bits to store
- * the seconds. Since the roundoff is done when flushing the inode, the
- * time may change unexpectedly by one second!!! */
+ // On a FAT filesystem, esp. under Linux, there are only 5 bits to store
+ // the seconds. Since the roundoff is done when flushing the inode, the
+ // time may change unexpectedly by one second!!!
return (t1 - t2 > 1 || t2 - t1 > 1);
#else
return (t1 != t2);
@@ -3074,21 +3072,21 @@ need_conversion(char_u *fenc)
}
else
{
- /* Ignore difference between "ansi" and "latin1", "ucs-4" and
- * "ucs-4be", etc. */
+ // Ignore difference between "ansi" and "latin1", "ucs-4" and
+ // "ucs-4be", etc.
enc_flags = get_fio_flags(p_enc);
fenc_flags = get_fio_flags(fenc);
same_encoding = (enc_flags != 0 && fenc_flags == enc_flags);
}
if (same_encoding)
{
- /* Specified encoding matches with 'encoding'. This requires
- * conversion when 'encoding' is Unicode but not UTF-8. */
+ // Specified encoding matches with 'encoding'. This requires
+ // conversion when 'encoding' is Unicode but not UTF-8.
return enc_unicode != 0;
}
- /* Encodings differ. However, conversion is not needed when 'enc' is any
- * Unicode encoding and the file is UTF-8. */
+ // Encodings differ. However, conversion is not needed when 'enc' is any
+ // Unicode encoding and the file is UTF-8.
return !(enc_utf8 && fenc_flags == FIO_UTF8);
}
@@ -3130,7 +3128,7 @@ get_fio_flags(char_u *ptr)
}
if (prop & ENC_LATIN1)
return FIO_LATIN1;
- /* must be ENC_DBCS, requires iconv() */
+ // must be ENC_DBCS, requires iconv()
return 0;
}
@@ -3145,14 +3143,14 @@ get_win_fio_flags(char_u *ptr)
{
int cp;
- /* Cannot do this when 'encoding' is not utf-8 and not a codepage. */
+ // Cannot do this when 'encoding' is not utf-8 and not a codepage.
if (!enc_utf8 && enc_codepage <= 0)
return 0;
cp = encname2codepage(ptr);
if (cp == 0)
{
-# ifdef CP_UTF8 /* VC 4.1 doesn't define CP_UTF8 */
+# ifdef CP_UTF8 // VC 4.1 doesn't define CP_UTF8
if (STRCMP(ptr, "utf-8") == 0)
cp = CP_UTF8;
else
@@ -3197,7 +3195,7 @@ check_for_bom(
if (p[0] == 0xef && p[1] == 0xbb && size >= 3 && p[2] == 0xbf
&& (flags == FIO_ALL || flags == FIO_UTF8 || flags == 0))
{
- name = "utf-8"; /* EF BB BF */
+ name = "utf-8"; // EF BB BF
len = 3;
}
else if (p[0] == 0xff && p[1] == 0xfe)
@@ -3205,28 +3203,28 @@ check_for_bom(
if (size >= 4 && p[2] == 0 && p[3] == 0
&& (flags == FIO_ALL || flags == (FIO_UCS4 | FIO_ENDIAN_L)))
{
- name = "ucs-4le"; /* FF FE 00 00 */
+ name = "ucs-4le"; // FF FE 00 00
len = 4;
}
else if (flags == (FIO_UCS2 | FIO_ENDIAN_L))
- name = "ucs-2le"; /* FF FE */
+ name = "ucs-2le"; // FF FE
else if (flags == FIO_ALL || flags == (FIO_UTF16 | FIO_ENDIAN_L))
- /* utf-16le is preferred, it also works for ucs-2le text */
- name = "utf-16le"; /* FF FE */
+ // utf-16le is preferred, it also works for ucs-2le text
+ name = "utf-16le"; // FF FE
}
else if (p[0] == 0xfe && p[1] == 0xff
&& (flags == FIO_ALL || flags == FIO_UCS2 || flags == FIO_UTF16))
{
- /* Default to utf-16, it works also for ucs-2 text. */
+ // Default to utf-16, it works also for ucs-2 text.
if (flags == FIO_UCS2)
- name = "ucs-2"; /* FE FF */
+ name = "ucs-2"; // FE FF
else
- name = "utf-16"; /* FE FF */
+ name = "utf-16"; // FE FF
}
else if (size >= 4 && p[0] == 0 && p[1] == 0 && p[2] == 0xfe
&& p[3] == 0xff && (flags == FIO_ALL || flags == FIO_UCS4))
{
- name = "ucs-4"; /* 00 00 FE FF */
+ name = "ucs-4"; // 00 00 FE FF
len = 4;
}
@@ -3287,7 +3285,7 @@ shorten_fname(char_u *full_path, char_u *dir_name)
{
if (vim_ispathsep(*p))
++p;
-#ifndef VMS /* the path separator is always part of the path */
+#ifndef VMS // the path separator is always part of the path
else
p = NULL;
#endif
@@ -3360,8 +3358,8 @@ shorten_fnames(int force)
{
shorten_buf_fname(buf, dirname, force);
- /* Always make the swap file name a full path, a "nofile" buffer may
- * also have a swap file. */
+ // Always make the swap file name a full path, a "nofile" buffer may
+ // also have a swap file.
mf_fullname(buf->b_ml.ml_mfp);
}
status_redraw_all();
@@ -3392,9 +3390,9 @@ shorten_filenames(char_u **fnames, int count)
{
if ((p = shorten_fname(fnames[i], dirname)) != NULL)
{
- /* shorten_fname() returns pointer in given "fnames[i]". If free
- * "fnames[i]" first, "p" becomes invalid. So we need to copy
- * "p" first then free fnames[i]. */
+ // shorten_fname() returns pointer in given "fnames[i]". If free
+ // "fnames[i]" first, "p" becomes invalid. So we need to copy
+ // "p" first then free fnames[i].
p = vim_strsave(p);
vim_free(fnames[i]);
fnames[i] = p;
@@ -3418,7 +3416,7 @@ shorten_filenames(char_u **fnames, int count)
modname(
char_u *fname,
char_u *ext,
- int prepend_dot) /* may prepend a '.' to file name */
+ int prepend_dot) // may prepend a '.' to file name
{
return buf_modname((curbuf->b_p_sn || curbuf->b_shortname),
fname, ext, prepend_dot);
@@ -3426,10 +3424,10 @@ modname(
char_u *
buf_modname(
- int shortname, /* use 8.3 file name */
+ int shortname, // use 8.3 file name
char_u *fname,
char_u *ext,
- int prepend_dot) /* may prepend a '.' to file name */
+ int prepend_dot) // may prepend a '.' to file name
{
char_u *retval;
char_u *s;
@@ -3459,7 +3457,7 @@ buf_modname(
retval[fnamelen++] = PATHSEP;
retval[fnamelen] = NUL;
}
- prepend_dot = FALSE; /* nothing to prepend a dot to */
+ prepend_dot = FALSE; // nothing to prepend a dot to
}
else
{
@@ -3469,7 +3467,7 @@ buf_modname(
return NULL;
STRCPY(retval, fname);
#ifdef VMS
- vms_remove_version(retval); /* we do not need versions here */
+ vms_remove_version(retval); // we do not need versions here
#endif
}
@@ -3482,7 +3480,7 @@ buf_modname(
for (ptr = retval + fnamelen; ptr > retval; MB_PTR_BACK(retval, ptr))
{
if (*ext == '.' && shortname)
- if (*ptr == '.') /* replace '.' by '_' */
+ if (*ptr == '.') // replace '.' by '_'
*ptr = '_';
if (vim_ispathsep(*ptr))
{
@@ -3491,7 +3489,7 @@ buf_modname(
}
}
- /* the file name has at most BASENAMELEN characters. */
+ // the file name has at most BASENAMELEN characters.
if (STRLEN(ptr) > (unsigned)BASENAMELEN)
ptr[BASENAMELEN] = '\0';
@@ -3569,7 +3567,7 @@ buf_modname(
*/
if (fname != NULL && STRCMP(fname, retval) == 0)
{
- /* we search for a character that can be replaced by '_' */
+ // we search for a character that can be replaced by '_'
while (--s >= ptr)
{
if (*s != '_')
@@ -3578,7 +3576,7 @@ buf_modname(
break;
}
}
- if (s < ptr) /* fname was "________.<ext>", how tricky! */
+ if (s < ptr) // fname was "________.<ext>", how tricky!
*ptr = 'v';
}
return retval;
@@ -3600,9 +3598,9 @@ vim_fgets(char_u *buf, int size, FILE *fp)
eof = fgets((char *)buf, size, fp);
if (buf[size - 2] != NUL && buf[size - 2] != '\n')
{
- buf[size - 1] = NUL; /* Truncate the line */
+ buf[size - 1] = NUL; // Truncate the line
- /* Now throw away the rest of the line: */
+ // Now throw away the rest of the line:
do
{
tbuf[FGETS_SIZE - 2] = NUL;
@@ -3631,7 +3629,7 @@ vim_rename(char_u *from, char_u *to)
stat_T st;
long perm;
#ifdef HAVE_ACL
- vim_acl_T acl; /* ACL from original file */
+ vim_acl_T acl; // ACL from original file
#endif
int use_tmp_file = FALSE;
@@ -3658,9 +3656,9 @@ vim_rename(char_u *from, char_u *to)
{
stat_T st_to;
- /* It's possible for the source and destination to be the same file.
- * This happens when "from" and "to" differ in case and are on a FAT32
- * filesystem. In that case go through a temp file name. */
+ // It's possible for the source and destination to be the same file.
+ // This happens when "from" and "to" differ in case and are on a FAT32
+ // filesystem. In that case go through a temp file name.
if (mch_stat((char *)to, &st_to) >= 0
&& st.st_dev == st_to.st_dev
&& st.st_ino == st_to.st_ino)
@@ -3671,9 +3669,9 @@ vim_rename(char_u *from, char_u *to)
{
BY_HANDLE_FILE_INFORMATION info1, info2;
- /* It's possible for the source and destination to be the same file.
- * In that case go through a temp file name. This makes rename("foo",
- * "./foo") a no-op (in a complicated way). */
+ // It's possible for the source and destination to be the same file.
+ // In that case go through a temp file name. This makes rename("foo",
+ // "./foo") a no-op (in a complicated way).
if (win32_fileinfo(from, &info1) == FILEINFO_OK
&& win32_fileinfo(to, &info2) == FILEINFO_OK
&& info1.dwVolumeSerialNumber == info2.dwVolumeSerialNumber
@@ -3703,13 +3701,13 @@ vim_rename(char_u *from, char_u *to)
{
if (mch_rename(tempname, (char *)to) == 0)
return 0;
- /* Strange, the second step failed. Try moving the
- * file back and return failure. */
+ // Strange, the second step failed. Try moving the
+ // file back and return failure.
mch_rename(tempname, (char *)from);
return -1;
}
- /* If it fails for one temp name it will most likely fail
- * for any temp name, give up. */
+ // If it fails for one temp name it will most likely fail
+ // for any temp name, give up.
return -1;
}
}
@@ -3755,7 +3753,7 @@ vim_rename(char_u *from, char_u *to)
*/
perm = mch_getperm(from);
#ifdef HAVE_ACL
- /* For systems that support ACL: get the ACL from the original file. */
+ // For systems that support ACL: get the ACL from the original file.
acl = mch_get_acl(from);
#endif
fd_in = mch_open((char *)from, O_RDONLY|O_EXTRA, 0);
@@ -3767,7 +3765,7 @@ vim_rename(char_u *from, char_u *to)
return -1;
}
- /* Create the new file with same permissions as the original. */
+ // Create the new file with same permissions as the original.
fd_out = mch_open((char *)to,
O_CREAT|O_EXCL|O_WRONLY|O_EXTRA|O_NOFOLLOW, (int)perm);
if (fd_out == -1)
@@ -3806,7 +3804,7 @@ vim_rename(char_u *from, char_u *to)
errmsg = _("E210: Error reading \"%s\"");
to = from;
}
-#ifndef UNIX /* for Unix mch_open() already set the permission */
+#ifndef UNIX // for Unix mch_open() already set the permission
mch_setperm(to, perm);
#endif
#ifdef HAVE_ACL
@@ -3837,20 +3835,20 @@ static int already_warned = FALSE;
*/
int
check_timestamps(
- int focus) /* called for GUI focus event */
+ int focus) // called for GUI focus event
{
buf_T *buf;
int didit = 0;
int n;
- /* Don't check timestamps while system() or another low-level function may
- * cause us to lose and gain focus. */
+ // Don't check timestamps while system() or another low-level function may
+ // cause us to lose and gain focus.
if (no_check_timestamps > 0)
return FALSE;
- /* Avoid doing a check twice. The OK/Reload dialog can cause a focus
- * event and we would keep on checking if the file is steadily growing.
- * Do check again after typing something. */
+ // Avoid doing a check twice. The OK/Reload dialog can cause a focus
+ // event and we would keep on checking if the file is steadily growing.
+ // Do check again after typing something.
if (focus && did_check_timestamps)
{
need_check_timestamps = TRUE;
@@ -3859,7 +3857,7 @@ check_timestamps(
if (!stuff_empty() || global_busy || !typebuf_typed()
|| autocmd_busy || curbuf_lock > 0 || allbuf_lock > 0)
- need_check_timestamps = TRUE; /* check later */
+ need_check_timestamps = TRUE; // check later
else
{
++no_wait_return;
@@ -3867,7 +3865,7 @@ check_timestamps(
already_warned = FALSE;
FOR_ALL_BUFFERS(buf)
{
- /* Only check buffers in a window. */
+ // Only check buffers in a window.
if (buf->b_nwindows > 0)
{
bufref_T bufref;
@@ -3878,8 +3876,8 @@ check_timestamps(
didit = n;
if (n > 0 && !bufref_valid(&bufref))
{
- /* Autocommands have removed the buffer, start at the
- * first one again. */
+ // Autocommands have removed the buffer, start at the
+ // first one again.
buf = firstbuf;
continue;
}
@@ -3889,7 +3887,7 @@ check_timestamps(
need_check_timestamps = FALSE;
if (need_wait_return && didit == 2)
{
- /* make sure msg isn't overwritten */
+ // make sure msg isn't overwritten
msg_puts("\n");
out_flush();
}
@@ -3910,7 +3908,7 @@ move_lines(buf_T *frombuf, buf_T *tobuf)
linenr_T lnum;
char_u *p;
- /* Copy the lines in "frombuf" to "tobuf". */
+ // Copy the lines in "frombuf" to "tobuf".
curbuf = tobuf;
for (lnum = 1; lnum <= frombuf->b_ml.ml_line_count; ++lnum)
{
@@ -3924,15 +3922,15 @@ move_lines(buf_T *frombuf, buf_T *tobuf)
vim_free(p);
}
- /* Delete all the lines in "frombuf". */
+ // Delete all the lines in "frombuf".
if (retval != FAIL)
{
curbuf = frombuf;
for (lnum = curbuf->b_ml.ml_line_count; lnum > 0; --lnum)
if (ml_delete(lnum, FALSE) == FAIL)
{
- /* Oops! We could try putting back the saved lines, but that
- * might fail again... */
+ // Oops! We could try putting back the saved lines, but that
+ // might fail again...
retval = FAIL;
break;
}
@@ -3952,7 +3950,7 @@ move_lines(buf_T *frombuf, buf_T *tobuf)
int
buf_check_timestamp(
buf_T *buf,
- int focus UNUSED) /* called for GUI focus event */
+ int focus UNUSED) // called for GUI focus event
{
stat_T st;
int stat_res;
@@ -3981,9 +3979,9 @@ buf_check_timestamp(
set_bufref(&bufref, buf);
- /* If there is no file name, the buffer is not loaded, 'buftype' is
- * set, we are in the middle of a save or being called recursively: ignore
- * this buffer. */
+ // If there is no file name, the buffer is not loaded, 'buftype' is
+ // set, we are in the middle of a save or being called recursively: ignore
+ // this buffer.
if (buf->b_ffname == NULL
|| buf->b_ml.ml_mfp == NULL
|| !bt_normal(buf)
@@ -4026,8 +4024,8 @@ buf_check_timestamp(
else
buf_store_time(buf, &st, buf->b_ffname);
- /* Don't do anything for a directory. Might contain the file
- * explorer. */
+ // Don't do anything for a directory. Might contain the file
+ // explorer.
if (mch_isdir(buf->b_fname))
;
@@ -4116,8 +4114,8 @@ buf_check_timestamp(
mesg2 = _("See \":help W16\" for more info.");
}
else
- /* Only timestamp changed, store it to avoid a warning
- * in check_mtime() later. */
+ // Only timestamp changed, store it to avoid a warning
+ // in check_mtime() later.
buf->b_mtime_read = buf->b_mtime;
}
}
@@ -4145,8 +4143,8 @@ buf_check_timestamp(
tbuf = alloc(STRLEN(path) + STRLEN(mesg) + STRLEN(mesg2) + 2);
sprintf(tbuf, mesg, path);
#ifdef FEAT_EVAL
- /* Set warningmsg here, before the unimportant and output-specific
- * mesg2 has been appended. */
+ // Set warningmsg here, before the unimportant and output-specific
+ // mesg2 has been appended.
set_vim_var_string(VV_WARNINGMSG, (char_u *)tbuf, -1);
#endif
#if defined(FEAT_CON_DIALOG) || defined(FEAT_GUI_DIALOG)
@@ -4190,10 +4188,10 @@ buf_check_timestamp(
#ifdef FEAT_GUI
if (!focus)
#endif
- /* give the user some time to think about it */
+ // give the user some time to think about it
ui_delay(1004L, TRUE);
- /* don't redraw and erase the message */
+ // don't redraw and erase the message
redraw_cmdline = FALSE;
}
}
@@ -4207,7 +4205,7 @@ buf_check_timestamp(
if (reload)
{
- /* Reload the buffer. */
+ // Reload the buffer.
buf_reload(buf, orig_mode);
#ifdef FEAT_PERSISTENT_UNDO
if (buf->b_p_udf && buf->b_ffname != NULL)
@@ -4215,7 +4213,7 @@ buf_check_timestamp(
char_u hash[UNDO_HASH_SIZE];
buf_T *save_curbuf = curbuf;
- /* Any existing undo file is unusable, write it now. */
+ // Any existing undo file is unusable, write it now.
curbuf = buf;
u_compute_hash(hash);
u_write_undo(NULL, FALSE, buf, hash);
@@ -4224,13 +4222,13 @@ buf_check_timestamp(
#endif
}
- /* Trigger FileChangedShell when the file was changed in any way. */
+ // Trigger FileChangedShell when the file was changed in any way.
if (bufref_valid(&bufref) && retval != 0)
(void)apply_autocmds(EVENT_FILECHANGEDSHELLPOST,
buf->b_fname, buf->b_fname, FALSE, buf);
#ifdef FEAT_GUI
- /* restore this in case an autocommand has set it; it would break
- * 'mousefocus' */
+ // restore this in case an autocommand has set it; it would break
+ // 'mousefocus'
need_mouse_correct = save_mouse_correct;
#endif
@@ -4256,12 +4254,12 @@ buf_reload(buf_T *buf, int orig_mode)
aco_save_T aco;
int flags = READ_NEW;
- /* set curwin/curbuf for "buf" and save some things */
+ // set curwin/curbuf for "buf" and save some things
aucmd_prepbuf(&aco, buf);
- /* We only want to read the text from the file, not reset the syntax
- * highlighting, clear marks, diff status, etc. Force the fileformat
- * and encoding to be the same. */
+ // We only want to read the text from the file, not reset the syntax
+ // highlighting, clear marks, diff status, etc. Force the fileformat
+ // and encoding to be the same.
if (prep_exarg(&ea, buf) == OK)
{
old_cursor = curwin->w_cursor;
@@ -4269,8 +4267,8 @@ buf_reload(buf_T *buf, int orig_mode)
if (p_ur < 0 || curbuf->b_ml.ml_line_count <= p_ur)
{
- /* Save all the text, so that the reload can be undone.
- * Sync first so that this is a separate undo-able action. */
+ // Save all the text, so that the reload can be undone.
+ // Sync first so that this is a separate undo-able action.
u_sync(FALSE);
saved = u_savecommon(0, curbuf->b_ml.ml_line_count + 1, 0, TRUE);
flags |= READ_KEEP_UNDO;
@@ -4287,12 +4285,12 @@ buf_reload(buf_T *buf, int orig_mode)
savebuf = NULL;
else
{
- /* Allocate a buffer without putting it in the buffer list. */
+ // Allocate a buffer without putting it in the buffer list.
savebuf = buflist_new(NULL, NULL, (linenr_T)1, BLN_DUMMY);
set_bufref(&bufref, savebuf);
if (savebuf != NULL && buf == curbuf)
{
- /* Open the memline. */
+ // Open the memline.
curbuf = savebuf;
curwin->w_buffer = savebuf;
saved = ml_open(curbuf);
@@ -4310,8 +4308,8 @@ buf_reload(buf_T *buf, int orig_mode)
if (saved == OK)
{
- curbuf->b_flags |= BF_CHECK_RO; /* check for RO again */
- keep_filetype = TRUE; /* don't detect 'filetype' */
+ curbuf->b_flags |= BF_CHECK_RO; // check for RO again
+ keep_filetype = TRUE; // don't detect 'filetype'
if (readfile(buf->b_ffname, buf->b_fname, (linenr_T)0,
(linenr_T)0,
(linenr_T)MAXLNUM, &ea, flags) != OK)
@@ -4322,17 +4320,17 @@ buf_reload(buf_T *buf, int orig_mode)
semsg(_("E321: Could not reload \"%s\""), buf->b_fname);
if (savebuf != NULL && bufref_valid(&bufref) && buf == curbuf)
{
- /* Put the text back from the save buffer. First
- * delete any lines that readfile() added. */
+ // Put the text back from the save buffer. First
+ // delete any lines that readfile() added.
while (!BUFEMPTY())
if (ml_delete(buf->b_ml.ml_line_count, FALSE) == FAIL)
break;
(void)move_lines(savebuf, buf);
}
}
- else if (buf == curbuf) /* "buf" still valid */
+ else if (buf == curbuf) // "buf" still valid
{
- /* Mark the buffer as unmodified and free undo info. */
+ // Mark the buffer as unmodified and free undo info.
unchanged(buf, TRUE, TRUE);
if ((flags & READ_KEEP_UNDO) == 0)
{
@@ -4341,7 +4339,7 @@ buf_reload(buf_T *buf, int orig_mode)
}
else
{
- /* Mark all undo states as changed. */
+ // Mark all undo states as changed.
u_unchanged(curbuf);
}
}
@@ -4352,12 +4350,12 @@ buf_reload(buf_T *buf, int orig_mode)
wipe_buffer(savebuf, FALSE);
#ifdef FEAT_DIFF
- /* Invalidate diff info if necessary. */
+ // Invalidate diff info if necessary.
diff_invalidate(curbuf);
#endif
- /* Restore the topline and cursor position and check it (lines may
- * have been removed). */
+ // Restore the topline and cursor position and check it (lines may
+ // have been removed).
if (old_topline > curbuf->b_ml.ml_line_count)
curwin->w_topline = curbuf->b_ml.ml_line_count;
else
@@ -4371,26 +4369,26 @@ buf_reload(buf_T *buf, int orig_mode)
win_T *wp;
tabpage_T *tp;
- /* Update folds unless they are defined manually. */
+ // Update folds unless they are defined manually.
FOR_ALL_TAB_WINDOWS(tp, wp)
if (wp->w_buffer == curwin->w_buffer
&& !foldmethodIsManual(wp))
foldUpdateAll(wp);
}
#endif
- /* If the mode didn't change and 'readonly' was set, keep the old
- * value; the user probably used the ":view" command. But don't
- * reset it, might have had a read error. */
+ // If the mode didn't change and 'readonly' was set, keep the old
+ // value; the user probably used the ":view" command. But don't
+ // reset it, might have had a read error.
if (orig_mode == curbuf->b_orig_mode)
curbuf->b_p_ro |= old_ro;
- /* Modelines must override settings done by autocommands. */
+ // Modelines must override settings done by autocommands.
do_modelines(0);
}
- /* restore curwin/curbuf and a few other things */
+ // restore curwin/curbuf and a few other things
aucmd_restbuf(&aco);
- /* Careful: autocommands may have made "buf" invalid! */
+ // Careful: autocommands may have made "buf" invalid!
}
void
@@ -4412,7 +4410,7 @@ buf_store_time(buf_T *buf, stat_T *st, char_u *fname UNUSED)
void
write_lnum_adjust(linenr_T offset)
{
- if (curbuf->b_no_eol_lnum != 0) /* only if there is a missing eol */
+ if (curbuf->b_no_eol_lnum != 0) // only if there is a missing eol
curbuf->b_no_eol_lnum += offset;
}
@@ -4611,7 +4609,7 @@ delete_recursive(char_u *name)
#endif
#if defined(TEMPDIRNAMES) || defined(PROTO)
-static long temp_count = 0; /* Temp filename counter. */
+static long temp_count = 0; // Temp filename counter.
/*
* Delete the temp directory and all files it contains.
@@ -4621,7 +4619,7 @@ vim_deltempdir(void)
{
if (vim_tempdir != NULL)
{
- /* remove the trailing path separator */
+ // remove the trailing path separator
gettail(vim_tempdir)[-1] = NUL;
delete_recursive(vim_tempdir);
VIM_CLEAR(vim_tempdir);
@@ -4661,11 +4659,11 @@ vim_settempdir(char_u *tempdir)
*/
char_u *
vim_tempname(
- int extra_char UNUSED, /* char to use in the name instead of '?' */
+ int extra_char UNUSED, // char to use in the name instead of '?'
int keep UNUSED)
{
#ifdef USE_TMPNAM
- char_u itmp[L_tmpnam]; /* use tmpnam() */
+ char_u itmp[L_tmpnam]; // use tmpnam()
#elif defined(MSWIN)
WCHAR itmp[TEMPNAMELEN];
#else
@@ -4699,22 +4697,22 @@ vim_tempname(
long off;
# endif
- /* Expand $TMP, leave room for "/v1100000/999999999".
- * Skip the directory check if the expansion fails. */
+ // Expand $TMP, leave room for "/v1100000/999999999".
+ // Skip the directory check if the expansion fails.
expand_env((char_u *)tempdirs[i], itmp, TEMPNAMELEN - 20);
if (itmp[0] != '$' && mch_isdir(itmp))
{
- /* directory exists */
+ // directory exists
add_pathsep(itmp);
# ifdef HAVE_MKDTEMP
{
# if defined(UNIX) || defined(VMS)
- /* Make sure the umask doesn't remove the executable bit.
- * "repl" has been reported to use "177". */
+ // Make sure the umask doesn't remove the executable bit.
+ // "repl" has been reported to use "177".
mode_t umask_save = umask(077);
# endif
- /* Leave room for filename */
+ // Leave room for filename
STRCAT(itmp, "vXXXXXX");
if (mkdtemp((char *)itmp) != NULL)
vim_settempdir(itmp);
@@ -4723,15 +4721,15 @@ vim_tempname(
# endif
}
# else
- /* Get an arbitrary number of up to 6 digits. When it's
- * unlikely that it already exists it will be faster,
- * otherwise it doesn't matter. The use of mkdir() avoids any
- * security problems because of the predictable number. */
+ // Get an arbitrary number of up to 6 digits. When it's
+ // unlikely that it already exists it will be faster,
+ // otherwise it doesn't matter. The use of mkdir() avoids any
+ // security problems because of the predictable number.
nr = (mch_get_pid() + (long)time(NULL)) % 1000000L;
itmplen = STRLEN(itmp);
- /* Try up to 10000 different values until we find a name that
- * doesn't exist. */
+ // Try up to 10000 different values until we find a name that
+ // doesn't exist.
for (off = 0; off < 10000L; ++off)
{
int r;
@@ -4741,15 +4739,15 @@ vim_tempname(
sprintf((char *)itmp + itmplen, "v%ld", nr + off);
# ifndef EEXIST
- /* If mkdir() does not set errno to EEXIST, check for
- * existing file here. There is a race condition then,
- * although it's fail-safe. */
+ // If mkdir() does not set errno to EEXIST, check for
+ // existing file here. There is a race condition then,
+ // although it's fail-safe.
if (mch_stat((char *)itmp, &st) >= 0)
continue;
# endif
# if defined(UNIX) || defined(VMS)
- /* Make sure the umask doesn't remove the executable bit.
- * "repl" has been reported to use "177". */
+ // Make sure the umask doesn't remove the executable bit.
+ // "repl" has been reported to use "177".
umask_save = umask(077);
# endif
r = vim_mkdir(itmp, 0700);
@@ -4762,14 +4760,14 @@ vim_tempname(
break;
}
# ifdef EEXIST
- /* If the mkdir() didn't fail because the file/dir exists,
- * we probably can't create any dir here, try another
- * place. */
+ // If the mkdir() didn't fail because the file/dir exists,
+ // we probably can't create any dir here, try another
+ // place.
if (errno != EEXIST)
# endif
break;
}
-# endif /* HAVE_MKDTEMP */
+# endif // HAVE_MKDTEMP
if (vim_tempdir != NULL)
break;
}
@@ -4778,15 +4776,15 @@ vim_tempname(
if (vim_tempdir != NULL)
{
- /* There is no need to check if the file exists, because we own the
- * directory and nobody else creates a file in it. */
+ // There is no need to check if the file exists, because we own the
+ // directory and nobody else creates a file in it.
sprintf((char *)itmp, "%s%ld", vim_tempdir, temp_count++);
return vim_strsave(itmp);
}
return NULL;
-#else /* TEMPDIRNAMES */
+#else // TEMPDIRNAMES
# ifdef MSWIN
WCHAR wszTempFile[_MAX_PATH + 1];
@@ -4801,7 +4799,7 @@ vim_tempname(
wszTempFile[1] = NUL;
}
wcscpy(buf4, L"VIM");
- buf4[2] = extra_char; /* make it "VIa", "VIb", etc. */
+ buf4[2] = extra_char; // make it "VIa", "VIb", etc.
if (GetTempFileNameW(wszTempFile, buf4, 0, itmp) == 0)
return NULL;
if (!keep)
@@ -4823,7 +4821,7 @@ vim_tempname(
# ifdef USE_TMPNAM
char_u *p;
- /* tmpnam() will make its own name */
+ // tmpnam() will make its own name
p = tmpnam((char *)itmp);
if (p == NULL || *p == NUL)
return NULL;
@@ -4831,15 +4829,14 @@ vim_tempname(
char_u *p;
# ifdef VMS_TEMPNAM
- /* mktemp() is not working on VMS. It seems to be
- * a do-nothing function. Therefore we use tempnam().
- */
+ // mktemp() is not working on VMS. It seems to be
+ // a do-nothing function. Therefore we use tempnam().
sprintf((char *)itmp, "VIM%c", extra_char);
p = (char_u *)tempnam("tmp:", (char *)itmp);
if (p != NULL)
{
- /* VMS will use '.LIS' if we don't explicitly specify an extension,
- * and VIM will then be unable to find the file later */
+ // VMS will use '.LIS' if we don't explicitly specify an extension,
+ // and VIM will then be unable to find the file later
STRCPY(itmp, p);
STRCAT(itmp, ".txt");
free(p);
@@ -4857,7 +4854,7 @@ vim_tempname(
return vim_strsave(itmp);
# endif // MSWIN
-#endif /* TEMPDIRNAMES */
+#endif // TEMPDIRNAMES
}
#if defined(BACKSLASH_IN_FILENAME) || defined(PROTO)
@@ -4873,7 +4870,7 @@ forward_slash(char_u *fname)
if (path_with_url(fname))
return;
for (p = fname; *p != NUL; ++p)
- /* The Big5 encoding can have '\' in the trail byte. */
+ // The Big5 encoding can have '\' in the trail byte.
if (enc_dbcs != 0 && (*mb_ptr2len)(p) > 1)
++p;
else if (*p == '\\')
@@ -4890,17 +4887,17 @@ forward_slash(char_u *fname)
*/
int
match_file_pat(
- char_u *pattern, /* pattern to match with */
- regprog_T **prog, /* pre-compiled regprog or NULL */
- char_u *fname, /* full path of file name */
- char_u *sfname, /* short file name or NULL */
- char_u *tail, /* tail of path */
- int allow_dirs) /* allow matching with dir */
+ char_u *pattern, // pattern to match with
+ regprog_T **prog, // pre-compiled regprog or NULL
+ char_u *fname, // full path of file name
+ char_u *sfname, // short file name or NULL
+ char_u *tail, // tail of path
+ int allow_dirs) // allow matching with dir
{
regmatch_T regmatch;
int result = FALSE;
- regmatch.rm_ic = p_fic; /* ignore case if 'fileignorecase' is set */
+ regmatch.rm_ic = p_fic; // ignore case if 'fileignorecase' is set
if (prog != NULL)
regmatch.regprog = *prog;
else
@@ -4945,7 +4942,7 @@ match_file_list(char_u *list, char_u *sfname, char_u *ffname)
tail = gettail(sfname);
- /* try all patterns in 'wildignore' */
+ // try all patterns in 'wildignore'
p = list;
while (*p)
{
@@ -4975,11 +4972,11 @@ match_file_list(char_u *list, char_u *sfname, char_u *ffname)
char_u *
file_pat_to_reg_pat(
char_u *pat,
- char_u *pat_end, /* first char after pattern or NULL */
- char *allow_dirs, /* Result passed back out in here */
- int no_bslash UNUSED) /* Don't use a backward slash as pathsep */
+ char_u *pat_end, // first char after pattern or NULL
+ char *allow_dirs, // Result passed back out in here
+ int no_bslash UNUSED) // Don't use a backward slash as pathsep
{
- int size = 2; /* '^' at start, '$' at end */
+ int size = 2; // '^' at start, '$' at end
char_u *endp;
char_u *reg_pat;
char_u *p;
@@ -5002,12 +4999,12 @@ file_pat_to_reg_pat(
case '{':
case '}':
case '~':
- size += 2; /* extra backslash */
+ size += 2; // extra backslash
break;
#ifdef BACKSLASH_IN_FILENAME
case '\\':
case '/':
- size += 4; /* could become "[\/]" */
+ size += 4; // could become "[\/]"
break;
#endif
default:
@@ -5045,7 +5042,7 @@ file_pat_to_reg_pat(
case '*':
reg_pat[i++] = '.';
reg_pat[i++] = '*';
- while (p[1] == '*') /* "**" matches like "*" */
+ while (p[1] == '*') // "**" matches like "*"
++p;
break;
case '.':
@@ -5062,12 +5059,11 @@ file_pat_to_reg_pat(
#ifdef BACKSLASH_IN_FILENAME
if (!no_bslash)
{
- /* translate:
- * "\x" to "\\x" e.g., "dir\file"
- * "\*" to "\\.*" e.g., "dir\*.c"
- * "\?" to "\\." e.g., "dir\??.c"
- * "\+" to "\+" e.g., "fileX\+.c"
- */
+ // translate:
+ // "\x" to "\\x" e.g., "dir\file"
+ // "\*" to "\\.*" e.g., "dir\*.c"
+ // "\?" to "\\." e.g., "dir\??.c"
+ // "\+" to "\+" e.g., "fileX\+.c"
if ((vim_isfilec(p[1]) || p[1] == '*' || p[1] == '?')
&& p[1] != '+')
{
@@ -5081,16 +5077,15 @@ file_pat_to_reg_pat(
}
}
#endif
- /* Undo escaping from ExpandEscape():
- * foo\?bar -> foo?bar
- * foo\%bar -> foo%bar
- * foo\,bar -> foo,bar
- * foo\ bar -> foo bar
- * Don't unescape \, * and others that are also special in a
- * regexp.
- * An escaped { must be unescaped since we use magic not
- * verymagic. Use "\\\{n,m\}"" to get "\{n,m}".
- */
+ // Undo escaping from ExpandEscape():
+ // foo\?bar -> foo?bar
+ // foo\%bar -> foo%bar
+ // foo\,bar -> foo,bar
+ // foo\ bar -> foo bar
+ // Don't unescape \, * and others that are also special in a
+ // regexp.
+ // An escaped { must be unescaped since we use magic not
+ // verymagic. Use "\\\{n,m\}"" to get "\{n,m}".
if (*++p == '?'
#ifdef BACKSLASH_IN_FILENAME
&& no_bslash
@@ -5200,8 +5195,8 @@ write_eintr(int fd, void *buf, size_t bufsize)
long ret = 0;
long wlen;
- /* Repeat the write() so long it didn't fail, other than being interrupted
- * by a signal. */
+ // Repeat the write() so long it didn't fail, other than being interrupted
+ // by a signal.
while (ret < (long)bufsize)
{
wlen = vim_write(fd, (char *)buf + ret, bufsize - ret);