Permalink
Browse files

patch 8.0.1757: unnecessary changes in libvterm

Problem:    Unnecessary changes in libvterm.
Solution:   Bring back // comments and trailing comma in enums.
  • Loading branch information...
brammool committed Apr 24, 2018
1 parent 7365831 commit b691de05f69905fe417f583083d7e3cc16eb865e
@@ -9,7 +9,7 @@
#include "vterm.h"
#define DEFINE_INLINES
#include "../src/utf8.h" /* fill_utf8 */
#include "../src/utf8.h" // fill_utf8
#define streq(a,b) (!strcmp(a,b))
@@ -21,7 +21,7 @@ static int rows;
static enum {
FORMAT_PLAIN,
FORMAT_SGR
FORMAT_SGR,
} format = FORMAT_PLAIN;
static int col2index(VTermColor target)
@@ -44,8 +44,8 @@ static void dump_cell(const VTermScreenCell *cell, const VTermScreenCell *prevce
break;
case FORMAT_SGR:
{
/* If all 7 attributes change, that means 7 SGRs max */
/* Each colour could consume up to 3 */
// If all 7 attributes change, that means 7 SGRs max
// Each colour could consume up to 3
int sgr[7 + 2*3]; int sgri = 0;
if(!prevcell->attrs.bold && cell->attrs.bold)
@@ -35,7 +35,7 @@ static int getchoice(int *argip, int argc, char *argv[], const char *options[])
typedef enum {
OFF,
ON,
QUERY
QUERY,
} BoolQuery;
static BoolQuery getboolq(int *argip, int argc, char *argv[])
@@ -105,7 +105,7 @@ static char *read_csi()
unsigned char csi[32];
int i = 0;
await_c1(0x9B); /* CSI */
await_c1(0x9B); // CSI
/* TODO: This really should be a more robust CSI parser
*/
@@ -116,7 +116,7 @@ static char *read_csi()
}
csi[++i] = 0;
/* TODO: returns longer than 32? */
// TODO: returns longer than 32?
return strdup((char *)csi);
}
@@ -131,7 +131,7 @@ static char *read_dcs()
for(i = 0; i < sizeof(dcs)-1; ) {
char c = getchar();
if(c == 0x9c) /* ST */
if(c == 0x9c) // ST
break;
if(in_esc && c == 0x5c)
break;
@@ -301,12 +301,12 @@ int main(int argc, char *argv[])
do_dec_mode(12, getboolq(&argi, argc, argv), "curblink");
}
else if(streq(arg, "curshape")) {
/* TODO: This ought to query the current value of DECSCUSR because it */
/* may need blinking on or off */
// TODO: This ought to query the current value of DECSCUSR because it
// may need blinking on or off
const char *choices[] = {"block", "under", "bar", "query", NULL};
int shape = getchoice(&argi, argc, argv, choices);
switch(shape) {
case 3: /* query */
case 3: // query
shape = query_rqss_numeric(" q");
switch(shape) {
case 1: case 2:
@@ -1,4 +1,4 @@
/* Require getopt(3) */
// Require getopt(3)
#define _XOPEN_SOURCE
#include <stdio.h>
@@ -22,28 +22,28 @@ static int parser_text(const char bytes[], size_t len, void *user)
int i;
for(i = 0; i < len; /* none */) {
if(b[i] < 0x20) /* C0 */
if(b[i] < 0x20) // C0
break;
else if(b[i] < 0x80) /* ASCII */
else if(b[i] < 0x80) // ASCII
i++;
else if(b[i] < 0xa0) /* C1 */
else if(b[i] < 0xa0) // C1
break;
else if(b[i] < 0xc0) /* UTF-8 continuation */
else if(b[i] < 0xc0) // UTF-8 continuation
break;
else if(b[i] < 0xe0) { /* UTF-8 2-byte */
/* 2-byte UTF-8 */
else if(b[i] < 0xe0) { // UTF-8 2-byte
// 2-byte UTF-8
if(len < i+2) break;
i += 2;
}
else if(b[i] < 0xf0) { /* UTF-8 3-byte */
else if(b[i] < 0xf0) { // UTF-8 3-byte
if(len < i+3) break;
i += 3;
}
else if(b[i] < 0xf8) { /* UTF-8 4-byte */
else if(b[i] < 0xf8) { // UTF-8 4-byte
if(len < i+4) break;
i += 4;
}
else /* otherwise invalid */
else // otherwise invalid
break;
}
@@ -200,7 +200,7 @@ int main(int argc, char *argv[])
file = argv[optind++];
if(!file || streq(file, "-"))
fd = 0; /* stdin */
fd = 0; // stdin
else {
fd = open(file, O_RDONLY);
if(fd == -1) {
@@ -110,30 +110,30 @@ typedef union {
typedef enum {
/* VTERM_ATTR_NONE = 0 */
VTERM_ATTR_BOLD = 1, /* bool: 1, 22 */
VTERM_ATTR_UNDERLINE, /* number: 4, 21, 24 */
VTERM_ATTR_ITALIC, /* bool: 3, 23 */
VTERM_ATTR_BLINK, /* bool: 5, 25 */
VTERM_ATTR_REVERSE, /* bool: 7, 27 */
VTERM_ATTR_STRIKE, /* bool: 9, 29 */
VTERM_ATTR_FONT, /* number: 10-19 */
VTERM_ATTR_FOREGROUND, /* color: 30-39 90-97 */
VTERM_ATTR_BACKGROUND, /* color: 40-49 100-107 */
VTERM_ATTR_BOLD = 1, // bool: 1, 22
VTERM_ATTR_UNDERLINE, // number: 4, 21, 24
VTERM_ATTR_ITALIC, // bool: 3, 23
VTERM_ATTR_BLINK, // bool: 5, 25
VTERM_ATTR_REVERSE, // bool: 7, 27
VTERM_ATTR_STRIKE, // bool: 9, 29
VTERM_ATTR_FONT, // number: 10-19
VTERM_ATTR_FOREGROUND, // color: 30-39 90-97
VTERM_ATTR_BACKGROUND, // color: 40-49 100-107
VTERM_N_ATTRS
} VTermAttr;
typedef enum {
/* VTERM_PROP_NONE = 0 */
VTERM_PROP_CURSORVISIBLE = 1, /* bool */
VTERM_PROP_CURSORBLINK, /* bool */
VTERM_PROP_ALTSCREEN, /* bool */
VTERM_PROP_TITLE, /* string */
VTERM_PROP_ICONNAME, /* string */
VTERM_PROP_REVERSE, /* bool */
VTERM_PROP_CURSORSHAPE, /* number */
VTERM_PROP_MOUSE, /* number */
VTERM_PROP_CURSORCOLOR, /* string */
VTERM_PROP_CURSORVISIBLE = 1, // bool
VTERM_PROP_CURSORBLINK, // bool
VTERM_PROP_ALTSCREEN, // bool
VTERM_PROP_TITLE, // string
VTERM_PROP_ICONNAME, // string
VTERM_PROP_REVERSE, // bool
VTERM_PROP_CURSORSHAPE, // number
VTERM_PROP_MOUSE, // number
VTERM_PROP_CURSORCOLOR, // string
VTERM_N_PROPS
} VTermProp;
@@ -211,9 +211,9 @@ void vterm_mouse_move(VTerm *vt, int row, int col, VTermModifier mod);
* Button 4 is scroll wheel down, button 5 is scroll wheel up. */
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.
* Consider
@@ -249,9 +249,9 @@ typedef struct {
void vterm_parser_set_callbacks(VTerm *vt, const VTermParserCallbacks *callbacks, void *user);
void *vterm_parser_get_cbdata(VTerm *vt);
/* -----------
* State layer
* ----------- */
// -----------
// State layer
// -----------
typedef struct {
int (*putglyph)(VTermGlyphInfo *info, VTermPos pos, void *user);
@@ -287,7 +287,7 @@ VTermState *vterm_obtain_state(VTerm *vt);
void vterm_state_set_callbacks(VTermState *state, const VTermStateCallbacks *callbacks, void *user);
void *vterm_state_get_cbdata(VTermState *state);
/* Only invokes control, csi, osc, dcs */
// Only invokes control, csi, osc, dcs
void vterm_state_set_unrecognised_fallbacks(VTermState *state, const VTermParserCallbacks *fallbacks, void *user);
void *vterm_state_get_unrecognised_fbdata(VTermState *state);
@@ -307,9 +307,9 @@ void vterm_state_focus_in(VTermState *state);
void vterm_state_focus_out(VTermState *state);
const VTermLineInfo *vterm_state_get_lineinfo(const VTermState *state, int row);
/* ------------
* Screen layer
* ------------ */
// ------------
// Screen layer
// ------------
typedef struct {
unsigned int bold : 1;
@@ -356,7 +356,7 @@ VTermScreen *vterm_obtain_screen(VTerm *vt);
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);
@@ -409,9 +409,9 @@ int vterm_screen_get_cell(const VTermScreen *screen, VTermPos pos, VTermScreenCe
int vterm_screen_is_eol(const VTermScreen *screen, VTermPos pos);
/* ---------
* Utilities
* --------- */
// ---------
// Utilities
// ---------
VTermValueType vterm_get_attr_type(VTermAttr attr);
VTermValueType vterm_get_prop_type(VTermProp prop);
@@ -55,7 +55,7 @@ typedef enum {
VTERM_KEY_KP_ENTER,
VTERM_KEY_KP_EQUAL,
VTERM_KEY_MAX, /* Must be last */
VTERM_KEY_MAX, // Must be last
VTERM_N_KEYS = VTERM_KEY_MAX
} VTermKey;
@@ -7,11 +7,11 @@
#endif
struct UTF8DecoderData {
/* number of bytes remaining in this codepoint */
// number of bytes remaining in this codepoint
int bytes_remaining;
/* number of bytes total in this codepoint once it's finished
(for detecting overlongs) */
// number of bytes total in this codepoint once it's finished
// (for detecting overlongs)
int bytes_total;
int this_cp;
@@ -42,7 +42,7 @@ static void decode_utf8(VTermEncoding *enc UNUSED, void *data_,
printf(" pos=%zd c=%02x rem=%d\n", *pos, c, data->bytes_remaining);
#endif
if(c < 0x20) /* C0 */
if(c < 0x20) // C0
return;
else if(c >= 0x20 && c < 0x7f) {
@@ -58,7 +58,7 @@ static void decode_utf8(VTermEncoding *enc UNUSED, void *data_,
#endif
}
else if(c == 0x7f) /* DEL */
else if(c == 0x7f) // DEL
return;
else if(c >= 0x80 && c < 0xc0) {
@@ -75,7 +75,7 @@ static void decode_utf8(VTermEncoding *enc UNUSED, void *data_,
#ifdef DEBUG_PRINT_UTF8
printf(" UTF-8 raw char U+%04x bytelen=%d ", data->this_cp, data->bytes_total);
#endif
/* Check for overlong sequences */
// Check for overlong sequences
switch(data->bytes_total) {
case 2:
if(data->this_cp < 0x0080) data->this_cp = UNICODE_INVALID;
@@ -93,7 +93,7 @@ static void decode_utf8(VTermEncoding *enc UNUSED, void *data_,
if(data->this_cp < 0x4000000) data->this_cp = UNICODE_INVALID;
break;
}
/* Now look for plain invalid ones */
// Now look for plain invalid ones
if((data->this_cp >= 0xD800 && data->this_cp <= 0xDFFF) ||
data->this_cp == 0xFFFE ||
data->this_cp == 0xFFFF)
Oops, something went wrong.

0 comments on commit b691de0

Please sign in to comment.