0
0
mirror of https://github.com/vim/vim.git synced 2025-09-10 22:33:40 -04:00

patch 8.1.2389: using old C style comments

Problem:    Using old C style comments.
Solution:   Use // comments where appropriate.
This commit is contained in:
Bram Moolenaar 2019-12-04 22:16:54 +01:00
parent 4ba37b5833
commit 707d226ac5
19 changed files with 130 additions and 128 deletions

View File

@ -216,14 +216,13 @@ void vterm_mouse_button(VTerm *vt, int button, int pressed, VTermModifier mod);
// Parser layer // Parser layer
// ------------ // ------------
/* Flag to indicate non-final subparameters in a single CSI parameter. // Flag to indicate non-final subparameters in a single CSI parameter.
* Consider // Consider
* CSI 1;2:3:4;5a // CSI 1;2:3:4;5a
* 1 4 and 5 are final. // 1 4 and 5 are final.
* 2 and 3 are non-final and will have this bit set // 2 and 3 are non-final and will have this bit set
* //
* Don't confuse this with the final byte of the CSI escape; 'a' in this case. // Don't confuse this with the final byte of the CSI escape; 'a' in this case.
*/
#define CSI_ARG_FLAG_MORE (1U<<31) #define CSI_ARG_FLAG_MORE (1U<<31)
#define CSI_ARG_MASK (~(1U<<31)) #define CSI_ARG_MASK (~(1U<<31))
@ -357,7 +356,7 @@ VTermScreen *vterm_obtain_screen(VTerm *vt);
void vterm_screen_set_callbacks(VTermScreen *screen, const VTermScreenCallbacks *callbacks, void *user); void vterm_screen_set_callbacks(VTermScreen *screen, const VTermScreenCallbacks *callbacks, void *user);
void *vterm_screen_get_cbdata(VTermScreen *screen); void *vterm_screen_get_cbdata(VTermScreen *screen);
/* Only invokes control, csi, osc, dcs */ // Only invokes control, csi, osc, dcs
void vterm_screen_set_unrecognised_fallbacks(VTermScreen *screen, const VTermParserCallbacks *fallbacks, void *user); void vterm_screen_set_unrecognised_fallbacks(VTermScreen *screen, const VTermParserCallbacks *fallbacks, void *user);
void *vterm_screen_get_unrecognised_fbdata(VTermScreen *screen); void *vterm_screen_get_unrecognised_fbdata(VTermScreen *screen);

View File

@ -773,7 +773,7 @@ int vterm_screen_get_cell(const VTermScreen *screen, VTermPos pos, VTermScreenCe
cell->bg = intcell->pen.bg; cell->bg = intcell->pen.bg;
if(vterm_get_special_pty_type() == 2) { if(vterm_get_special_pty_type() == 2) {
/* Get correct cell width from cell information contained in line buffer */ // Get correct cell width from cell information contained in line buffer
if(pos.col < (screen->cols - 1) && if(pos.col < (screen->cols - 1) &&
getcell(screen, pos.row, pos.col + 1)->chars[0] == (uint32_t)-1) { getcell(screen, pos.row, pos.col + 1)->chars[0] == (uint32_t)-1) {
if(getcell(screen, pos.row, pos.col)->chars[0] == 0x20) { if(getcell(screen, pos.row, pos.col)->chars[0] == 0x20) {
@ -798,8 +798,10 @@ int vterm_screen_get_cell(const VTermScreen *screen, VTermPos pos, VTermScreenCe
return 1; return 1;
} }
// Copy external to internal representation of a screen cell /*
/* static because it's only used internally for sb_popline during resize */ * Copy external to internal representation of a screen cell
* static because it's only used internally for sb_popline during resize
*/
static int vterm_screen_set_cell(VTermScreen *screen, VTermPos pos, const VTermScreenCell *cell) static int vterm_screen_set_cell(VTermScreen *screen, VTermPos pos, const VTermScreenCell *cell)
{ {
ScreenCell *intcell = getcell(screen, pos.row, pos.col); ScreenCell *intcell = getcell(screen, pos.row, pos.col);

View File

@ -452,7 +452,7 @@ static int mk_wcwidth(uint32_t ucs)
} }
#endif #endif
#if 0 /* unused */ #if 0 // unused
static int mk_wcswidth(const uint32_t *pwcs, size_t n) static int mk_wcswidth(const uint32_t *pwcs, size_t n)
{ {
int w, width = 0; int w, width = 0;
@ -479,8 +479,8 @@ static int mk_wcswidth(const uint32_t *pwcs, size_t n)
static int mk_wcwidth_cjk(uint32_t ucs) static int mk_wcwidth_cjk(uint32_t ucs)
{ {
#endif #endif
/* sorted list of non-overlapping intervals of East Asian Ambiguous // sorted list of non-overlapping intervals of East Asian Ambiguous
* characters, generated by "uniset +WIDTH-A -cat=Me -cat=Mn -cat=Cf c" */ // characters, generated by "uniset +WIDTH-A -cat=Me -cat=Mn -cat=Cf c"
static const struct interval ambiguous[] = { static const struct interval ambiguous[] = {
{ 0x00A1, 0x00A1 }, { 0x00A4, 0x00A4 }, { 0x00A7, 0x00A8 }, { 0x00A1, 0x00A1 }, { 0x00A4, 0x00A4 }, { 0x00A7, 0x00A8 },
{ 0x00AA, 0x00AA }, { 0x00AE, 0x00AE }, { 0x00B0, 0x00B4 }, { 0x00AA, 0x00AA }, { 0x00AE, 0x00AE }, { 0x00B0, 0x00B4 },

View File

@ -10,9 +10,9 @@
#include "utf8.h" #include "utf8.h"
/***************** ///////////////////
* API functions * // API functions //
*****************/ ///////////////////
static void *default_malloc(size_t size, void *allocdata UNUSED) static void *default_malloc(size_t size, void *allocdata UNUSED)
{ {

View File

@ -1,5 +1,5 @@
#include "vterm.h" #include "vterm.h"
#include "../src/vterm_internal.h" /* We pull in some internal bits too */ #include "../src/vterm_internal.h" // We pull in some internal bits too
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -163,16 +163,16 @@ static int parser_dcs(const char *command, size_t cmdlen, void *user)
} }
static VTermParserCallbacks parser_cbs = { static VTermParserCallbacks parser_cbs = {
parser_text, /* text */ parser_text, // text
parser_control, /* control */ parser_control, // control
parser_escape, /* escape */ parser_escape, // escape
parser_csi, /* csi */ parser_csi, // csi
parser_osc, /* osc */ parser_osc, // osc
parser_dcs, /* dcs */ parser_dcs, // dcs
NULL /* resize */ NULL // resize
}; };
/* These callbacks are shared by State and Screen */ // These callbacks are shared by State and Screen
static int want_movecursor = 0; static int want_movecursor = 0;
static VTermPos state_pos; static VTermPos state_pos;
@ -241,7 +241,7 @@ static int settermprop(VTermProp prop, VTermValue *val, void *user)
return 0; return 0;
} }
/* These callbacks are for State */ // These callbacks are for State
static int want_state_putglyph = 0; static int want_state_putglyph = 0;
static int state_putglyph(VTermGlyphInfo *info, VTermPos pos, void *user) static int state_putglyph(VTermGlyphInfo *info, VTermPos pos, void *user)
@ -333,17 +333,17 @@ static int state_setlineinfo(int row, const VTermLineInfo *newinfo, const VTermL
} }
VTermStateCallbacks state_cbs = { VTermStateCallbacks state_cbs = {
state_putglyph, /* putglyph */ state_putglyph, // putglyph
movecursor, /* movecursor */ movecursor, // movecursor
scrollrect, /* scrollrect */ scrollrect, // scrollrect
moverect, /* moverect */ moverect, // moverect
state_erase, /* erase */ state_erase, // erase
NULL, /* initpen */ NULL, // initpen
state_setpenattr, /* setpenattr */ state_setpenattr, // setpenattr
settermprop, /* settermprop */ settermprop, // settermprop
NULL, /* bell */ NULL, // bell
NULL, /* resize */ NULL, // resize
state_setlineinfo, /* setlineinfo */ state_setlineinfo, // setlineinfo
}; };
static int want_screen_damage = 0; static int want_screen_damage = 0;
@ -427,7 +427,7 @@ static int screen_sb_popline(int cols, VTermScreenCell *cells, void *user)
if(!want_screen_scrollback) if(!want_screen_scrollback)
return 0; return 0;
/* All lines of scrollback contain "ABCDE" */ // All lines of scrollback contain "ABCDE"
for(col = 0; col < cols; col++) { for(col = 0; col < cols; col++) {
if(col < 5) if(col < 5)
cells[col].chars[0] = 'A' + col; cells[col].chars[0] = 'A' + col;
@ -442,14 +442,14 @@ static int screen_sb_popline(int cols, VTermScreenCell *cells, void *user)
} }
VTermScreenCallbacks screen_cbs = { VTermScreenCallbacks screen_cbs = {
screen_damage, /* damage */ screen_damage, // damage
moverect, /* moverect */ moverect, // moverect
movecursor, /* movecursor */ movecursor, // movecursor
settermprop, /* settermprop */ settermprop, // settermprop
NULL, /* bell */ NULL, // bell
NULL, /* resize */ NULL, // resize
screen_sb_pushline, /* sb_pushline */ screen_sb_pushline, // sb_pushline
screen_sb_popline /* sb_popline */ screen_sb_popline // sb_popline
}; };
int main(int argc, char **argv) int main(int argc, char **argv)
@ -592,9 +592,8 @@ int main(int argc, char **argv)
} }
else if(streq(line, "WANTENCODING")) { else if(streq(line, "WANTENCODING")) {
/* This isn't really external API but it's hard to get this out any // This isn't really external API but it's hard to get this out any
* other way // other way
*/
encoding.enc = vterm_lookup_encoding(ENC_UTF8, 'u'); encoding.enc = vterm_lookup_encoding(ENC_UTF8, 'u');
if(encoding.enc->init) if(encoding.enc->init)
(*encoding.enc->init)(encoding.enc, encoding.data); (*encoding.enc->init)(encoding.enc, encoding.data);
@ -833,7 +832,7 @@ int main(int argc, char **argv)
else if(len == 0) else if(len == 0)
printf("\n"); printf("\n");
else { else {
/* Put an overwrite guard at both ends of the buffer */ // Put an overwrite guard at both ends of the buffer
unsigned char *buffer = malloc(len + 4); unsigned char *buffer = malloc(len + 4);
unsigned char *text = buffer + 2; unsigned char *text = buffer + 2;
text[-2] = 0x55; text[-1] = 0xAA; text[-2] = 0x55; text[-1] = 0xAA;

View File

@ -742,6 +742,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
2389,
/**/ /**/
2388, 2388,
/**/ /**/

View File

@ -25,9 +25,9 @@
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif /* #ifdef __cplusplus */ #endif // #ifdef __cplusplus
/* xpparm_t.flags */ // xpparm_t.flags
#define XDF_NEED_MINIMAL (1 << 0) #define XDF_NEED_MINIMAL (1 << 0)
#define XDF_IGNORE_WHITESPACE (1 << 1) #define XDF_IGNORE_WHITESPACE (1 << 1)
@ -48,22 +48,22 @@ extern "C" {
#define XDF_INDENT_HEURISTIC (1 << 23) #define XDF_INDENT_HEURISTIC (1 << 23)
/* xdemitconf_t.flags */ // xdemitconf_t.flags
#define XDL_EMIT_FUNCNAMES (1 << 0) #define XDL_EMIT_FUNCNAMES (1 << 0)
#define XDL_EMIT_FUNCCONTEXT (1 << 2) #define XDL_EMIT_FUNCCONTEXT (1 << 2)
/* merge simplification levels */ // merge simplification levels
#define XDL_MERGE_MINIMAL 0 #define XDL_MERGE_MINIMAL 0
#define XDL_MERGE_EAGER 1 #define XDL_MERGE_EAGER 1
#define XDL_MERGE_ZEALOUS 2 #define XDL_MERGE_ZEALOUS 2
#define XDL_MERGE_ZEALOUS_ALNUM 3 #define XDL_MERGE_ZEALOUS_ALNUM 3
/* merge favor modes */ // merge favor modes
#define XDL_MERGE_FAVOR_OURS 1 #define XDL_MERGE_FAVOR_OURS 1
#define XDL_MERGE_FAVOR_THEIRS 2 #define XDL_MERGE_FAVOR_THEIRS 2
#define XDL_MERGE_FAVOR_UNION 3 #define XDL_MERGE_FAVOR_UNION 3
/* merge output styles */ // merge output styles
#define XDL_MERGE_DIFF3 1 #define XDL_MERGE_DIFF3 1
typedef struct s_mmfile { typedef struct s_mmfile {
@ -79,7 +79,7 @@ typedef struct s_mmbuffer {
typedef struct s_xpparam { typedef struct s_xpparam {
unsigned long flags; unsigned long flags;
/* See Documentation/diff-options.txt. */ // See Documentation/diff-options.txt.
char **anchors; char **anchors;
size_t anchors_nr; size_t anchors_nr;
} xpparam_t; } xpparam_t;
@ -130,9 +130,9 @@ typedef struct s_xmparam {
int level; int level;
int favor; int favor;
int style; int style;
const char *ancestor; /* label for orig */ const char *ancestor; // label for orig
const char *file1; /* label for mf1 */ const char *file1; // label for mf1
const char *file2; /* label for mf2 */ const char *file2; // label for mf2
} xmparam_t; } xmparam_t;
#define DEFAULT_CONFLICT_MARKER_SIZE 7 #define DEFAULT_CONFLICT_MARKER_SIZE 7
@ -142,6 +142,6 @@ int xdl_merge(mmfile_t *orig, mmfile_t *mf1, mmfile_t *mf2,
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* #ifdef __cplusplus */ #endif // #ifdef __cplusplus
#endif /* #if !defined(XDIFF_H) */ #endif // #if !defined(XDIFF_H)

View File

@ -418,24 +418,24 @@ static int xget_indent(xrecord_t *rec)
ret += 1; ret += 1;
else if (c == '\t') else if (c == '\t')
ret += 8 - ret % 8; ret += 8 - ret % 8;
/* ignore other whitespace characters */ // ignore other whitespace characters
if (ret >= MAX_INDENT) if (ret >= MAX_INDENT)
return MAX_INDENT; return MAX_INDENT;
} }
/* The line contains only whitespace. */ // The line contains only whitespace.
return -1; return -1;
} }
/* /*
* If more than this number of consecutive blank rows are found, just return this * If more than this number of consecutive blank rows are found, just return
* value. This avoids requiring O(N^2) work for pathological cases, and also * this value. This avoids requiring O(N^2) work for pathological cases, and
* ensures that the output of score_split fits in an int. * also ensures that the output of score_split fits in an int.
*/ */
#define MAX_BLANKS 20 #define MAX_BLANKS 20
/* Characteristics measured about a hypothetical split position. */ // Characteristics measured about a hypothetical split position.
struct split_measurement { struct split_measurement {
/* /*
* Is the split at the end of the file (aside from any blank lines)? * Is the split at the end of the file (aside from any blank lines)?
@ -472,10 +472,10 @@ struct split_measurement {
}; };
struct split_score { struct split_score {
/* The effective indent of this split (smaller is preferred). */ // The effective indent of this split (smaller is preferred).
int effective_indent; int effective_indent;
/* Penalty for this split (smaller is preferred). */ // Penalty for this split (smaller is preferred).
int penalty; int penalty;
}; };
@ -534,16 +534,16 @@ static void measure_split(const xdfile_t *xdf, long split,
* integer math. * integer math.
*/ */
/* Penalty if there are no non-blank lines before the split */ // Penalty if there are no non-blank lines before the split
#define START_OF_FILE_PENALTY 1 #define START_OF_FILE_PENALTY 1
/* Penalty if there are no non-blank lines after the split */ // Penalty if there are no non-blank lines after the split
#define END_OF_FILE_PENALTY 21 #define END_OF_FILE_PENALTY 21
/* Multiplier for the number of blank lines around the split */ // Multiplier for the number of blank lines around the split
#define TOTAL_BLANK_WEIGHT (-30) #define TOTAL_BLANK_WEIGHT (-30)
/* Multiplier for the number of blank lines after the split */ // Multiplier for the number of blank lines after the split
#define POST_BLANK_WEIGHT 6 #define POST_BLANK_WEIGHT 6
/* /*
@ -610,7 +610,7 @@ static void score_add_split(const struct split_measurement *m, struct split_scor
post_blank = (m->indent == -1) ? 1 + m->post_blank : 0; post_blank = (m->indent == -1) ? 1 + m->post_blank : 0;
total_blank = m->pre_blank + post_blank; total_blank = m->pre_blank + post_blank;
/* Penalties based on nearby blank lines: */ // Penalties based on nearby blank lines:
s->penalty += TOTAL_BLANK_WEIGHT * total_blank; s->penalty += TOTAL_BLANK_WEIGHT * total_blank;
s->penalty += POST_BLANK_WEIGHT * post_blank; s->penalty += POST_BLANK_WEIGHT * post_blank;
@ -621,13 +621,13 @@ static void score_add_split(const struct split_measurement *m, struct split_scor
any_blanks = (total_blank != 0); any_blanks = (total_blank != 0);
/* Note that the effective indent is -1 at the end of the file: */ // Note that the effective indent is -1 at the end of the file:
s->effective_indent += indent; s->effective_indent += indent;
if (indent == -1) { if (indent == -1) {
/* No additional adjustments needed. */ // No additional adjustments needed.
} else if (m->pre_indent == -1) { } else if (m->pre_indent == -1) {
/* No additional adjustments needed. */ // No additional adjustments needed.
} else if (indent > m->pre_indent) { } else if (indent > m->pre_indent) {
/* /*
* The line is indented more than its predecessor. * The line is indented more than its predecessor.
@ -669,7 +669,7 @@ static void score_add_split(const struct split_measurement *m, struct split_scor
static int score_cmp(struct split_score *s1, struct split_score *s2) static int score_cmp(struct split_score *s1, struct split_score *s2)
{ {
/* -1 if s1.effective_indent < s2->effective_indent, etc. */ // -1 if s1.effective_indent < s2->effective_indent, etc.
int cmp_indents = ((s1->effective_indent > s2->effective_indent) - int cmp_indents = ((s1->effective_indent > s2->effective_indent) -
(s1->effective_indent < s2->effective_indent)); (s1->effective_indent < s2->effective_indent));
@ -809,7 +809,7 @@ int xdl_change_compact(xdfile_t *xdf, xdfile_t *xdfo, long flags) {
group_init(xdfo, &go); group_init(xdfo, &go);
while (1) { while (1) {
/* If the group is empty in the to-be-compacted file, skip it: */ // If the group is empty in the to-be-compacted file, skip it:
if (g.end == g.start) if (g.end == g.start)
goto next; goto next;
@ -828,7 +828,7 @@ int xdl_change_compact(xdfile_t *xdf, xdfile_t *xdfo, long flags) {
*/ */
end_matching_other = -1; end_matching_other = -1;
/* Shift the group backward as much as possible: */ // Shift the group backward as much as possible:
while (!group_slide_up(xdf, &g, flags)) while (!group_slide_up(xdf, &g, flags))
if (group_previous(xdfo, &go)) if (group_previous(xdfo, &go))
xdl_bug("group sync broken sliding up"); xdl_bug("group sync broken sliding up");
@ -842,7 +842,7 @@ int xdl_change_compact(xdfile_t *xdf, xdfile_t *xdfo, long flags) {
if (go.end > go.start) if (go.end > go.start)
end_matching_other = g.end; end_matching_other = g.end;
/* Now shift the group forward as far as possible: */ // Now shift the group forward as far as possible:
while (1) { while (1) {
if (group_slide_down(xdf, &g, flags)) if (group_slide_down(xdf, &g, flags))
break; break;
@ -863,7 +863,7 @@ int xdl_change_compact(xdfile_t *xdf, xdfile_t *xdfo, long flags) {
*/ */
if (g.end == earliest_end) { if (g.end == earliest_end) {
/* no shifting was possible */ // no shifting was possible
} else if (end_matching_other != -1) { } else if (end_matching_other != -1) {
/* /*
* Move the possibly merged group of changes back to line * Move the possibly merged group of changes back to line
@ -921,7 +921,7 @@ int xdl_change_compact(xdfile_t *xdf, xdfile_t *xdfo, long flags) {
} }
next: next:
/* Move past the just-processed group: */ // Move past the just-processed group:
if (group_next(xdf, &g)) if (group_next(xdf, &g))
break; break;
if (group_next(xdfo, &go)) if (group_next(xdfo, &go))

View File

@ -61,4 +61,4 @@ int xdl_do_patience_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
int xdl_do_histogram_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, int xdl_do_histogram_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
xdfenv_t *env); xdfenv_t *env);
#endif /* #if !defined(XDIFFI_H) */ #endif // #if !defined(XDIFFI_H)

View File

@ -54,9 +54,9 @@ xdchange_t *xdl_get_hunk(xdchange_t **xscr, xdemitconf_t const *xecfg)
xdchange_t *xch, *xchp, *lxch; xdchange_t *xch, *xchp, *lxch;
long max_common = 2 * xecfg->ctxlen + xecfg->interhunkctxlen; long max_common = 2 * xecfg->ctxlen + xecfg->interhunkctxlen;
long max_ignorable = xecfg->ctxlen; long max_ignorable = xecfg->ctxlen;
unsigned long ignored = 0; /* number of ignored blank lines */ unsigned long ignored = 0; // number of ignored blank lines
/* remove ignorable changes that are too far before other changes */ // remove ignorable changes that are too far before other changes
for (xchp = *xscr; xchp && xchp->ignore; xchp = xchp->next) { for (xchp = *xscr; xchp && xchp->ignore; xchp = xchp->next) {
xch = xchp->next; xch = xchp->next;
@ -99,9 +99,9 @@ xdchange_t *xdl_get_hunk(xdchange_t **xscr, xdemitconf_t const *xecfg)
static long def_ff(const char *rec, long len, char *buf, long sz, void *priv UNUSED) static long def_ff(const char *rec, long len, char *buf, long sz, void *priv UNUSED)
{ {
if (len > 0 && if (len > 0 &&
(isalpha((unsigned char)*rec) || /* identifier? */ (isalpha((unsigned char)*rec) || // identifier?
*rec == '_' || /* also identifier? */ *rec == '_' || // also identifier?
*rec == '$')) { /* identifiers from VMS and other esoterico */ *rec == '$')) { // identifiers from VMS and other esoterico
if (len > sz) if (len > sz)
len = sz; len = sz;
while (0 < len && isspace((unsigned char)rec[len - 1])) while (0 < len && isspace((unsigned char)rec[len - 1]))
@ -197,7 +197,7 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
if (xecfg->flags & XDL_EMIT_FUNCCONTEXT) { if (xecfg->flags & XDL_EMIT_FUNCCONTEXT) {
long fs1, i1 = xch->i1; long fs1, i1 = xch->i1;
/* Appended chunk? */ // Appended chunk?
if (i1 >= xe->xdf1.nrec) { if (i1 >= xe->xdf1.nrec) {
long i2 = xch->i2; long i2 = xch->i2;

View File

@ -33,4 +33,4 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
#endif /* #if !defined(XEMIT_H) */ #endif // #if !defined(XEMIT_H)

View File

@ -55,8 +55,8 @@ struct histindex {
struct record { struct record {
unsigned int ptr, cnt; unsigned int ptr, cnt;
struct record *next; struct record *next;
} **records, /* an occurrence */ } **records, // an occurrence
**line_map; /* map of line to record chain */ **line_map; // map of line to record chain
chastore_t rcha; chastore_t rcha;
unsigned int *next_ptrs; unsigned int *next_ptrs;
unsigned int table_bits, unsigned int table_bits,
@ -128,7 +128,7 @@ static int scanA(struct histindex *index, int line1, int count1)
*/ */
NEXT_PTR(index, ptr) = rec->ptr; NEXT_PTR(index, ptr) = rec->ptr;
rec->ptr = ptr; rec->ptr = ptr;
/* cap rec->cnt at MAX_CNT */ // cap rec->cnt at MAX_CNT
rec->cnt = XDL_MIN(MAX_CNT, rec->cnt + 1); rec->cnt = XDL_MIN(MAX_CNT, rec->cnt + 1);
LINE_MAP(index, ptr) = rec; LINE_MAP(index, ptr) = rec;
goto continue_scan; goto continue_scan;
@ -154,7 +154,7 @@ static int scanA(struct histindex *index, int line1, int count1)
LINE_MAP(index, ptr) = rec; LINE_MAP(index, ptr) = rec;
continue_scan: continue_scan:
; /* no op */ ; // no op
} }
return 0; return 0;
@ -266,7 +266,7 @@ static int find_lcs(xpparam_t const *xpp, xdfenv_t *env,
index.records = NULL; index.records = NULL;
index.line_map = NULL; index.line_map = NULL;
/* in case of early xdl_cha_free() */ // in case of early xdl_cha_free()
index.rcha.head = NULL; index.rcha.head = NULL;
index.table_bits = xdl_hashbits(count1); index.table_bits = xdl_hashbits(count1);
@ -288,7 +288,7 @@ static int find_lcs(xpparam_t const *xpp, xdfenv_t *env,
goto cleanup; goto cleanup;
memset(index.next_ptrs, 0, sz); memset(index.next_ptrs, 0, sz);
/* lines / 4 + 1 comes from xprepare.c:xdl_prepare_ctx() */ // lines / 4 + 1 comes from xprepare.c:xdl_prepare_ctx()
if (xdl_cha_init(&index.rcha, sizeof(struct record), count1 / 4 + 1) < 0) if (xdl_cha_init(&index.rcha, sizeof(struct record), count1 / 4 + 1) < 0)
goto cleanup; goto cleanup;

View File

@ -20,7 +20,7 @@
* *
*/ */
/* defines HAVE_ATTRIBUTE_UNUSED */ // defines HAVE_ATTRIBUTE_UNUSED
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# ifdef VMS # ifdef VMS
# include "[.auto]config.h" # include "[.auto]config.h"
@ -29,8 +29,8 @@
# endif # endif
#endif #endif
/* Mark unused function arguments with UNUSED, so that gcc -Wunused-parameter // Mark unused function arguments with UNUSED, so that gcc -Wunused-parameter
* can be used to check for mistakes. */ // can be used to check for mistakes.
#ifdef HAVE_ATTRIBUTE_UNUSED #ifdef HAVE_ATTRIBUTE_UNUSED
# define UNUSED __attribute__((unused)) # define UNUSED __attribute__((unused))
#else #else
@ -62,4 +62,4 @@
#include "xemit.h" #include "xemit.h"
#endif /* #if !defined(XINCLUDE_H) */ #endif // #if !defined(XINCLUDE_H)

View File

@ -51,4 +51,4 @@ do { \
} while (0) } while (0)
#endif /* #if !defined(XMACROS_H) */ #endif // #if !defined(XMACROS_H)

View File

@ -69,7 +69,7 @@ struct hashmap {
*/ */
unsigned anchor : 1; unsigned anchor : 1;
} *entries, *first, *last; } *entries, *first, *last;
/* were common records found? */ // were common records found?
unsigned long has_matches; unsigned long has_matches;
mmfile_t *file1, *file2; mmfile_t *file1, *file2;
xdfenv_t *env; xdfenv_t *env;
@ -86,7 +86,7 @@ static int is_anchor(xpparam_t const *xpp, const char *line)
return 0; return 0;
} }
/* The argument "pass" is 1 for the first file, 2 for the second. */ // The argument "pass" is 1 for the first file, 2 for the second.
static void insert_record(xpparam_t const *xpp, int line, struct hashmap *map, static void insert_record(xpparam_t const *xpp, int line, struct hashmap *map,
int pass) int pass)
{ {
@ -155,7 +155,7 @@ static int fill_hashmap(mmfile_t *file1, mmfile_t *file2,
result->xpp = xpp; result->xpp = xpp;
result->env = env; result->env = env;
/* We know exactly how large we want the hash map */ // We know exactly how large we want the hash map
result->alloc = count1 * 2; result->alloc = count1 * 2;
result->entries = (struct entry *) result->entries = (struct entry *)
xdl_malloc(result->alloc * sizeof(struct entry)); xdl_malloc(result->alloc * sizeof(struct entry));
@ -163,11 +163,11 @@ static int fill_hashmap(mmfile_t *file1, mmfile_t *file2,
return -1; return -1;
memset(result->entries, 0, result->alloc * sizeof(struct entry)); memset(result->entries, 0, result->alloc * sizeof(struct entry));
/* First, fill with entries from the first file */ // First, fill with entries from the first file
while (count1--) while (count1--)
insert_record(xpp, line1++, result, 1); insert_record(xpp, line1++, result, 1);
/* Then search for matches in the second file */ // Then search for matches in the second file
while (count2--) while (count2--)
insert_record(xpp, line2++, result, 2); insert_record(xpp, line2++, result, 2);
@ -185,13 +185,13 @@ static int binary_search(struct entry **sequence, int longest,
while (left + 1 < right) { while (left + 1 < right) {
int middle = left + (right - left) / 2; int middle = left + (right - left) / 2;
/* by construction, no two entries can be equal */ // by construction, no two entries can be equal
if (sequence[middle]->line2 > entry->line2) if (sequence[middle]->line2 > entry->line2)
right = middle; right = middle;
else else
left = middle; left = middle;
} }
/* return the index in "sequence", _not_ the sequence length */ // return the index in "sequence", _not_ the sequence length
return left; return left;
} }
@ -216,7 +216,7 @@ static struct entry *find_longest_common_sequence(struct hashmap *map)
*/ */
int anchor_i = -1; int anchor_i = -1;
/* Added to silence Coverity. */ // Added to silence Coverity.
if (sequence == NULL) if (sequence == NULL)
return map->first; return map->first;
@ -237,13 +237,13 @@ static struct entry *find_longest_common_sequence(struct hashmap *map)
} }
} }
/* No common unique lines were found */ // No common unique lines were found
if (!longest) { if (!longest) {
xdl_free(sequence); xdl_free(sequence);
return NULL; return NULL;
} }
/* Iterate starting at the last element, adjusting the "next" members */ // Iterate starting at the last element, adjusting the "next" members
entry = sequence[longest - 1]; entry = sequence[longest - 1];
entry->next = NULL; entry->next = NULL;
while (entry->previous) { while (entry->previous) {
@ -273,7 +273,7 @@ static int walk_common_sequence(struct hashmap *map, struct entry *first,
int next1, next2; int next1, next2;
for (;;) { for (;;) {
/* Try to grow the line ranges of common lines */ // Try to grow the line ranges of common lines
if (first) { if (first) {
next1 = first->line1; next1 = first->line1;
next2 = first->line2; next2 = first->line2;
@ -292,7 +292,7 @@ static int walk_common_sequence(struct hashmap *map, struct entry *first,
line2++; line2++;
} }
/* Recurse */ // Recurse
if (next1 > line1 || next2 > line2) { if (next1 > line1 || next2 > line2) {
struct hashmap submap; struct hashmap submap;
@ -343,7 +343,7 @@ static int patience_diff(mmfile_t *file1, mmfile_t *file2,
struct entry *first; struct entry *first;
int result = 0; int result = 0;
/* trivial case: one side is empty */ // trivial case: one side is empty
if (!count1) { if (!count1) {
while(count2--) while(count2--)
env->xdf2.rchg[line2++ - 1] = 1; env->xdf2.rchg[line2++ - 1] = 1;
@ -359,7 +359,7 @@ static int patience_diff(mmfile_t *file1, mmfile_t *file2,
line1, count1, line2, count2)) line1, count1, line2, count2))
return -1; return -1;
/* are there any matching lines at all? */ // are there any matching lines at all?
if (!map.has_matches) { if (!map.has_matches) {
while(count1--) while(count1--)
env->xdf1.rchg[line1++ - 1] = 1; env->xdf1.rchg[line1++ - 1] = 1;
@ -387,7 +387,7 @@ int xdl_do_patience_diff(mmfile_t *file1, mmfile_t *file2,
if (xdl_prepare_env(file1, file2, xpp, env) < 0) if (xdl_prepare_env(file1, file2, xpp, env) < 0)
return -1; return -1;
/* environment is cleaned up in xdl_diff() */ // environment is cleaned up in xdl_diff()
return patience_diff(file1, file2, xpp, env, return patience_diff(file1, file2, xpp, env,
1, env->xdf1.nrec, 1, env->xdf2.nrec); 1, env->xdf1.nrec, 1, env->xdf2.nrec);
} }

View File

@ -31,4 +31,4 @@ void xdl_free_env(xdfenv_t *xe);
#endif /* #if !defined(XPREPARE_H) */ #endif // #if !defined(XPREPARE_H)

View File

@ -64,4 +64,4 @@ typedef struct s_xdfenv {
#endif /* #if !defined(XTYPES_H) */ #endif // #if !defined(XTYPES_H)

View File

@ -168,7 +168,7 @@ static int ends_with_optional_cr(const char *l, long s, long i)
s--; s--;
if (s == i) if (s == i)
return 1; return 1;
/* do not ignore CR at the end of an incomplete line */ // do not ignore CR at the end of an incomplete line
if (complete && s == i + 1 && l[i] == '\r') if (complete && s == i + 1 && l[i] == '\r')
return 1; return 1;
return 0; return 0;
@ -208,7 +208,7 @@ int xdl_recmatch(const char *l1, long s1, const char *l2, long s2, long flags)
} else if (flags & XDF_IGNORE_WHITESPACE_CHANGE) { } else if (flags & XDF_IGNORE_WHITESPACE_CHANGE) {
while (i1 < s1 && i2 < s2) { while (i1 < s1 && i2 < s2) {
if (XDL_ISSPACE(l1[i1]) && XDL_ISSPACE(l2[i2])) { if (XDL_ISSPACE(l1[i1]) && XDL_ISSPACE(l2[i2])) {
/* Skip matching spaces and try again */ // Skip matching spaces and try again
while (i1 < s1 && XDL_ISSPACE(l1[i1])) while (i1 < s1 && XDL_ISSPACE(l1[i1]))
i1++; i1++;
while (i2 < s2 && XDL_ISSPACE(l2[i2])) while (i2 < s2 && XDL_ISSPACE(l2[i2]))
@ -224,7 +224,7 @@ int xdl_recmatch(const char *l1, long s1, const char *l2, long s2, long flags)
i2++; i2++;
} }
} else if (flags & XDF_IGNORE_CR_AT_EOL) { } else if (flags & XDF_IGNORE_CR_AT_EOL) {
/* Find the first difference and see how the line ends */ // Find the first difference and see how the line ends
while (i1 < s1 && i2 < s2 && l1[i1] == l2[i2]) { while (i1 < s1 && i2 < s2 && l1[i1] == l2[i2]) {
i1++; i1++;
i2++; i2++;
@ -261,7 +261,7 @@ static unsigned long xdl_hash_record_with_whitespace(char const **data,
for (; ptr < top && *ptr != '\n'; ptr++) { for (; ptr < top && *ptr != '\n'; ptr++) {
if (cr_at_eol_only) { if (cr_at_eol_only) {
/* do not ignore CR at the end of an incomplete line */ // do not ignore CR at the end of an incomplete line
if (*ptr == '\r' && if (*ptr == '\r' &&
(ptr + 1 < top && ptr[1] == '\n')) (ptr + 1 < top && ptr[1] == '\n'))
continue; continue;
@ -274,7 +274,7 @@ static unsigned long xdl_hash_record_with_whitespace(char const **data,
ptr++; ptr++;
at_eol = (top <= ptr + 1 || ptr[1] == '\n'); at_eol = (top <= ptr + 1 || ptr[1] == '\n');
if (flags & XDF_IGNORE_WHITESPACE) if (flags & XDF_IGNORE_WHITESPACE)
; /* already handled */ ; // already handled
else if (flags & XDF_IGNORE_WHITESPACE_CHANGE else if (flags & XDF_IGNORE_WHITESPACE_CHANGE
&& !at_eol) { && !at_eol) {
ha += (ha << 5); ha += (ha << 5);

View File

@ -44,4 +44,4 @@ int xdl_fall_back_diff(xdfenv_t *diff_env, xpparam_t const *xpp,
#endif /* #if !defined(XUTILS_H) */ #endif // #if !defined(XUTILS_H)