Problem: Using old C style comments.
Solution: Use // comments where appropriate.
// Parser layer
// ------------
-/* Flag to indicate non-final subparameters in a single CSI parameter.
- * Consider
- * CSI 1;2:3:4;5a
- * 1 4 and 5 are final.
- * 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.
- */
+// Flag to indicate non-final subparameters in a single CSI parameter.
+// Consider
+// CSI 1;2:3:4;5a
+// 1 4 and 5 are final.
+// 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.
#define CSI_ARG_FLAG_MORE (1U<<31)
#define CSI_ARG_MASK (~(1U<<31))
void vterm_screen_set_callbacks(VTermScreen *screen, const VTermScreenCallbacks *callbacks, void *user);
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_get_unrecognised_fbdata(VTermScreen *screen);
cell->bg = intcell->pen.bg;
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) &&
getcell(screen, pos.row, pos.col + 1)->chars[0] == (uint32_t)-1) {
if(getcell(screen, pos.row, pos.col)->chars[0] == 0x20) {
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)
{
ScreenCell *intcell = getcell(screen, pos.row, pos.col);
}
#endif
-#if 0 /* unused */
+#if 0 // unused
static int mk_wcswidth(const uint32_t *pwcs, size_t n)
{
int w, width = 0;
static int mk_wcwidth_cjk(uint32_t ucs)
{
#endif
- /* sorted list of non-overlapping intervals of East Asian Ambiguous
- * characters, generated by "uniset +WIDTH-A -cat=Me -cat=Mn -cat=Cf c" */
+ // sorted list of non-overlapping intervals of East Asian Ambiguous
+ // characters, generated by "uniset +WIDTH-A -cat=Me -cat=Mn -cat=Cf c"
static const struct interval ambiguous[] = {
{ 0x00A1, 0x00A1 }, { 0x00A4, 0x00A4 }, { 0x00A7, 0x00A8 },
{ 0x00AA, 0x00AA }, { 0x00AE, 0x00AE }, { 0x00B0, 0x00B4 },
#include "utf8.h"
-/*****************
- * API functions *
- *****************/
+///////////////////
+// API functions //
+///////////////////
static void *default_malloc(size_t size, void *allocdata UNUSED)
{
#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 <string.h>
}
static VTermParserCallbacks parser_cbs = {
- parser_text, /* text */
- parser_control, /* control */
- parser_escape, /* escape */
- parser_csi, /* csi */
- parser_osc, /* osc */
- parser_dcs, /* dcs */
- NULL /* resize */
+ parser_text, // text
+ parser_control, // control
+ parser_escape, // escape
+ parser_csi, // csi
+ parser_osc, // osc
+ parser_dcs, // dcs
+ NULL // resize
};
-/* These callbacks are shared by State and Screen */
+// These callbacks are shared by State and Screen
static int want_movecursor = 0;
static VTermPos state_pos;
return 0;
}
-/* These callbacks are for State */
+// These callbacks are for State
static int want_state_putglyph = 0;
static int state_putglyph(VTermGlyphInfo *info, VTermPos pos, void *user)
}
VTermStateCallbacks state_cbs = {
- state_putglyph, /* putglyph */
- movecursor, /* movecursor */
- scrollrect, /* scrollrect */
- moverect, /* moverect */
- state_erase, /* erase */
- NULL, /* initpen */
- state_setpenattr, /* setpenattr */
- settermprop, /* settermprop */
- NULL, /* bell */
- NULL, /* resize */
- state_setlineinfo, /* setlineinfo */
+ state_putglyph, // putglyph
+ movecursor, // movecursor
+ scrollrect, // scrollrect
+ moverect, // moverect
+ state_erase, // erase
+ NULL, // initpen
+ state_setpenattr, // setpenattr
+ settermprop, // settermprop
+ NULL, // bell
+ NULL, // resize
+ state_setlineinfo, // setlineinfo
};
static int want_screen_damage = 0;
if(!want_screen_scrollback)
return 0;
- /* All lines of scrollback contain "ABCDE" */
+ // All lines of scrollback contain "ABCDE"
for(col = 0; col < cols; col++) {
if(col < 5)
cells[col].chars[0] = 'A' + col;
}
VTermScreenCallbacks screen_cbs = {
- screen_damage, /* damage */
- moverect, /* moverect */
- movecursor, /* movecursor */
- settermprop, /* settermprop */
- NULL, /* bell */
- NULL, /* resize */
- screen_sb_pushline, /* sb_pushline */
- screen_sb_popline /* sb_popline */
+ screen_damage, // damage
+ moverect, // moverect
+ movecursor, // movecursor
+ settermprop, // settermprop
+ NULL, // bell
+ NULL, // resize
+ screen_sb_pushline, // sb_pushline
+ screen_sb_popline // sb_popline
};
int main(int argc, char **argv)
}
else if(streq(line, "WANTENCODING")) {
- /* This isn't really external API but it's hard to get this out any
- * other way
- */
+ // This isn't really external API but it's hard to get this out any
+ // other way
encoding.enc = vterm_lookup_encoding(ENC_UTF8, 'u');
if(encoding.enc->init)
(*encoding.enc->init)(encoding.enc, encoding.data);
else if(len == 0)
printf("\n");
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 *text = buffer + 2;
text[-2] = 0x55; text[-1] = 0xAA;
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 2389,
/**/
2388,
/**/
#ifdef __cplusplus
extern "C" {
-#endif /* #ifdef __cplusplus */
+#endif // #ifdef __cplusplus
-/* xpparm_t.flags */
+// xpparm_t.flags
#define XDF_NEED_MINIMAL (1 << 0)
#define XDF_IGNORE_WHITESPACE (1 << 1)
#define XDF_INDENT_HEURISTIC (1 << 23)
-/* xdemitconf_t.flags */
+// xdemitconf_t.flags
#define XDL_EMIT_FUNCNAMES (1 << 0)
#define XDL_EMIT_FUNCCONTEXT (1 << 2)
-/* merge simplification levels */
+// merge simplification levels
#define XDL_MERGE_MINIMAL 0
#define XDL_MERGE_EAGER 1
#define XDL_MERGE_ZEALOUS 2
#define XDL_MERGE_ZEALOUS_ALNUM 3
-/* merge favor modes */
+// merge favor modes
#define XDL_MERGE_FAVOR_OURS 1
#define XDL_MERGE_FAVOR_THEIRS 2
#define XDL_MERGE_FAVOR_UNION 3
-/* merge output styles */
+// merge output styles
#define XDL_MERGE_DIFF3 1
typedef struct s_mmfile {
typedef struct s_xpparam {
unsigned long flags;
- /* See Documentation/diff-options.txt. */
+ // See Documentation/diff-options.txt.
char **anchors;
size_t anchors_nr;
} xpparam_t;
int level;
int favor;
int style;
- const char *ancestor; /* label for orig */
- const char *file1; /* label for mf1 */
- const char *file2; /* label for mf2 */
+ const char *ancestor; // label for orig
+ const char *file1; // label for mf1
+ const char *file2; // label for mf2
} xmparam_t;
#define DEFAULT_CONFLICT_MARKER_SIZE 7
#ifdef __cplusplus
}
-#endif /* #ifdef __cplusplus */
+#endif // #ifdef __cplusplus
-#endif /* #if !defined(XDIFF_H) */
+#endif // #if !defined(XDIFF_H)
ret += 1;
else if (c == '\t')
ret += 8 - ret % 8;
- /* ignore other whitespace characters */
+ // ignore other whitespace characters
if (ret >= MAX_INDENT)
return MAX_INDENT;
}
- /* The line contains only whitespace. */
+ // The line contains only whitespace.
return -1;
}
/*
- * If more than this number of consecutive blank rows are found, just return this
- * value. This avoids requiring O(N^2) work for pathological cases, and also
- * ensures that the output of score_split fits in an int.
+ * If more than this number of consecutive blank rows are found, just return
+ * this value. This avoids requiring O(N^2) work for pathological cases, and
+ * also ensures that the output of score_split fits in an int.
*/
#define MAX_BLANKS 20
-/* Characteristics measured about a hypothetical split position. */
+// Characteristics measured about a hypothetical split position.
struct split_measurement {
/*
* Is the split at the end of the file (aside from any blank lines)?
};
struct split_score {
- /* The effective indent of this split (smaller is preferred). */
+ // The effective indent of this split (smaller is preferred).
int effective_indent;
- /* Penalty for this split (smaller is preferred). */
+ // Penalty for this split (smaller is preferred).
int penalty;
};
* 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
-/* 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
-/* 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)
-/* 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
/*
post_blank = (m->indent == -1) ? 1 + m->post_blank : 0;
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 += POST_BLANK_WEIGHT * post_blank;
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;
if (indent == -1) {
- /* No additional adjustments needed. */
+ // No additional adjustments needed.
} else if (m->pre_indent == -1) {
- /* No additional adjustments needed. */
+ // No additional adjustments needed.
} else if (indent > m->pre_indent) {
/*
* The line is indented more than its predecessor.
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) -
(s1->effective_indent < s2->effective_indent));
group_init(xdfo, &go);
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)
goto next;
*/
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))
if (group_previous(xdfo, &go))
xdl_bug("group sync broken sliding up");
if (go.end > go.start)
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) {
if (group_slide_down(xdf, &g, flags))
break;
*/
if (g.end == earliest_end) {
- /* no shifting was possible */
+ // no shifting was possible
} else if (end_matching_other != -1) {
/*
* Move the possibly merged group of changes back to line
}
next:
- /* Move past the just-processed group: */
+ // Move past the just-processed group:
if (group_next(xdf, &g))
break;
if (group_next(xdfo, &go))
int xdl_do_histogram_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
xdfenv_t *env);
-#endif /* #if !defined(XDIFFI_H) */
+#endif // #if !defined(XDIFFI_H)
xdchange_t *xch, *xchp, *lxch;
long max_common = 2 * xecfg->ctxlen + xecfg->interhunkctxlen;
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) {
xch = xchp->next;
static long def_ff(const char *rec, long len, char *buf, long sz, void *priv UNUSED)
{
if (len > 0 &&
- (isalpha((unsigned char)*rec) || /* identifier? */
- *rec == '_' || /* also identifier? */
- *rec == '$')) { /* identifiers from VMS and other esoterico */
+ (isalpha((unsigned char)*rec) || // identifier?
+ *rec == '_' || // also identifier?
+ *rec == '$')) { // identifiers from VMS and other esoterico
if (len > sz)
len = sz;
while (0 < len && isspace((unsigned char)rec[len - 1]))
if (xecfg->flags & XDL_EMIT_FUNCCONTEXT) {
long fs1, i1 = xch->i1;
- /* Appended chunk? */
+ // Appended chunk?
if (i1 >= xe->xdf1.nrec) {
long i2 = xch->i2;
-#endif /* #if !defined(XEMIT_H) */
+#endif // #if !defined(XEMIT_H)
struct record {
unsigned int ptr, cnt;
struct record *next;
- } **records, /* an occurrence */
- **line_map; /* map of line to record chain */
+ } **records, // an occurrence
+ **line_map; // map of line to record chain
chastore_t rcha;
unsigned int *next_ptrs;
unsigned int table_bits,
*/
NEXT_PTR(index, ptr) = rec->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);
LINE_MAP(index, ptr) = rec;
goto continue_scan;
LINE_MAP(index, ptr) = rec;
continue_scan:
- ; /* no op */
+ ; // no op
}
return 0;
index.records = NULL;
index.line_map = NULL;
- /* in case of early xdl_cha_free() */
+ // in case of early xdl_cha_free()
index.rcha.head = NULL;
index.table_bits = xdl_hashbits(count1);
goto cleanup;
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)
goto cleanup;
*
*/
-/* defines HAVE_ATTRIBUTE_UNUSED */
+// defines HAVE_ATTRIBUTE_UNUSED
#ifdef HAVE_CONFIG_H
# ifdef VMS
# include "[.auto]config.h"
# endif
#endif
-/* Mark unused function arguments with UNUSED, so that gcc -Wunused-parameter
- * can be used to check for mistakes. */
+// Mark unused function arguments with UNUSED, so that gcc -Wunused-parameter
+// can be used to check for mistakes.
#ifdef HAVE_ATTRIBUTE_UNUSED
# define UNUSED __attribute__((unused))
#else
#include "xemit.h"
-#endif /* #if !defined(XINCLUDE_H) */
+#endif // #if !defined(XINCLUDE_H)
} while (0)
-#endif /* #if !defined(XMACROS_H) */
+#endif // #if !defined(XMACROS_H)
*/
unsigned anchor : 1;
} *entries, *first, *last;
- /* were common records found? */
+ // were common records found?
unsigned long has_matches;
mmfile_t *file1, *file2;
xdfenv_t *env;
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,
int pass)
{
result->xpp = xpp;
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->entries = (struct entry *)
xdl_malloc(result->alloc * sizeof(struct entry));
return -1;
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--)
insert_record(xpp, line1++, result, 1);
- /* Then search for matches in the second file */
+ // Then search for matches in the second file
while (count2--)
insert_record(xpp, line2++, result, 2);
while (left + 1 < right) {
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)
right = middle;
else
left = middle;
}
- /* return the index in "sequence", _not_ the sequence length */
+ // return the index in "sequence", _not_ the sequence length
return left;
}
*/
int anchor_i = -1;
- /* Added to silence Coverity. */
+ // Added to silence Coverity.
if (sequence == NULL)
return map->first;
}
}
- /* No common unique lines were found */
+ // No common unique lines were found
if (!longest) {
xdl_free(sequence);
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->next = NULL;
while (entry->previous) {
int next1, next2;
for (;;) {
- /* Try to grow the line ranges of common lines */
+ // Try to grow the line ranges of common lines
if (first) {
next1 = first->line1;
next2 = first->line2;
line2++;
}
- /* Recurse */
+ // Recurse
if (next1 > line1 || next2 > line2) {
struct hashmap submap;
struct entry *first;
int result = 0;
- /* trivial case: one side is empty */
+ // trivial case: one side is empty
if (!count1) {
while(count2--)
env->xdf2.rchg[line2++ - 1] = 1;
line1, count1, line2, count2))
return -1;
- /* are there any matching lines at all? */
+ // are there any matching lines at all?
if (!map.has_matches) {
while(count1--)
env->xdf1.rchg[line1++ - 1] = 1;
if (xdl_prepare_env(file1, file2, xpp, env) < 0)
return -1;
- /* environment is cleaned up in xdl_diff() */
+ // environment is cleaned up in xdl_diff()
return patience_diff(file1, file2, xpp, env,
1, env->xdf1.nrec, 1, env->xdf2.nrec);
}
-#endif /* #if !defined(XPREPARE_H) */
+#endif // #if !defined(XPREPARE_H)
-#endif /* #if !defined(XTYPES_H) */
+#endif // #if !defined(XTYPES_H)
s--;
if (s == i)
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')
return 1;
return 0;
} else if (flags & XDF_IGNORE_WHITESPACE_CHANGE) {
while (i1 < s1 && i2 < s2) {
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]))
i1++;
while (i2 < s2 && XDL_ISSPACE(l2[i2]))
i2++;
}
} 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]) {
i1++;
i2++;
for (; ptr < top && *ptr != '\n'; ptr++) {
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' &&
(ptr + 1 < top && ptr[1] == '\n'))
continue;
ptr++;
at_eol = (top <= ptr + 1 || ptr[1] == '\n');
if (flags & XDF_IGNORE_WHITESPACE)
- ; /* already handled */
+ ; // already handled
else if (flags & XDF_IGNORE_WHITESPACE_CHANGE
&& !at_eol) {
ha += (ha << 5);
-#endif /* #if !defined(XUTILS_H) */
+#endif // #if !defined(XUTILS_H)