summaryrefslogtreecommitdiffstats
path: root/src/fileio.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-12-01 21:41:28 +0100
committerBram Moolenaar <Bram@vim.org>2019-12-01 21:41:28 +0100
commit217e1b8359447f5550dcb0d1ee43380a90c253c5 (patch)
tree137e8b7d6f27848c95caa47e2fc13a4dc4c50d29 /src/fileio.c
parent5d18efecfd6c45d69f55268948a22cd0465bb955 (diff)
patch 8.1.2379: using old C style commentsv8.1.2379
Problem: Using old C style comments. Solution: Use // comments where appropriate.
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 c15c7bd28d..6600b5920c 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".
i