Skip to content

Commit

Permalink
patch 8.0.1757: unnecessary changes in libvterm
Browse files Browse the repository at this point in the history
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 b691de0
Show file tree
Hide file tree
Showing 16 changed files with 322 additions and 322 deletions.
8 changes: 4 additions & 4 deletions src/libvterm/bin/unterm.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "vterm.h" #include "vterm.h"


#define DEFINE_INLINES #define DEFINE_INLINES
#include "../src/utf8.h" /* fill_utf8 */ #include "../src/utf8.h" // fill_utf8


#define streq(a,b) (!strcmp(a,b)) #define streq(a,b) (!strcmp(a,b))


Expand All @@ -21,7 +21,7 @@ static int rows;


static enum { static enum {
FORMAT_PLAIN, FORMAT_PLAIN,
FORMAT_SGR FORMAT_SGR,
} format = FORMAT_PLAIN; } format = FORMAT_PLAIN;


static int col2index(VTermColor target) static int col2index(VTermColor target)
Expand All @@ -44,8 +44,8 @@ static void dump_cell(const VTermScreenCell *cell, const VTermScreenCell *prevce
break; break;
case FORMAT_SGR: case FORMAT_SGR:
{ {
/* If all 7 attributes change, that means 7 SGRs max */ // If all 7 attributes change, that means 7 SGRs max
/* Each colour could consume up to 3 */ // Each colour could consume up to 3
int sgr[7 + 2*3]; int sgri = 0; int sgr[7 + 2*3]; int sgri = 0;


if(!prevcell->attrs.bold && cell->attrs.bold) if(!prevcell->attrs.bold && cell->attrs.bold)
Expand Down
14 changes: 7 additions & 7 deletions src/libvterm/bin/vterm-ctrl.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static int getchoice(int *argip, int argc, char *argv[], const char *options[])
typedef enum { typedef enum {
OFF, OFF,
ON, ON,
QUERY QUERY,
} BoolQuery; } BoolQuery;


static BoolQuery getboolq(int *argip, int argc, char *argv[]) static BoolQuery getboolq(int *argip, int argc, char *argv[])
Expand Down Expand Up @@ -105,7 +105,7 @@ static char *read_csi()
unsigned char csi[32]; unsigned char csi[32];
int i = 0; int i = 0;


await_c1(0x9B); /* CSI */ await_c1(0x9B); // CSI


/* TODO: This really should be a more robust CSI parser /* TODO: This really should be a more robust CSI parser
*/ */
Expand All @@ -116,7 +116,7 @@ static char *read_csi()
} }
csi[++i] = 0; csi[++i] = 0;


/* TODO: returns longer than 32? */ // TODO: returns longer than 32?


return strdup((char *)csi); return strdup((char *)csi);
} }
Expand All @@ -131,7 +131,7 @@ static char *read_dcs()


for(i = 0; i < sizeof(dcs)-1; ) { for(i = 0; i < sizeof(dcs)-1; ) {
char c = getchar(); char c = getchar();
if(c == 0x9c) /* ST */ if(c == 0x9c) // ST
break; break;
if(in_esc && c == 0x5c) if(in_esc && c == 0x5c)
break; break;
Expand Down Expand Up @@ -301,12 +301,12 @@ int main(int argc, char *argv[])
do_dec_mode(12, getboolq(&argi, argc, argv), "curblink"); do_dec_mode(12, getboolq(&argi, argc, argv), "curblink");
} }
else if(streq(arg, "curshape")) { else if(streq(arg, "curshape")) {
/* TODO: This ought to query the current value of DECSCUSR because it */ // TODO: This ought to query the current value of DECSCUSR because it
/* may need blinking on or off */ // may need blinking on or off
const char *choices[] = {"block", "under", "bar", "query", NULL}; const char *choices[] = {"block", "under", "bar", "query", NULL};
int shape = getchoice(&argi, argc, argv, choices); int shape = getchoice(&argi, argc, argv, choices);
switch(shape) { switch(shape) {
case 3: /* query */ case 3: // query
shape = query_rqss_numeric(" q"); shape = query_rqss_numeric(" q");
switch(shape) { switch(shape) {
case 1: case 2: case 1: case 2:
Expand Down
22 changes: 11 additions & 11 deletions src/libvterm/bin/vterm-dump.c
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Require getopt(3) */ // Require getopt(3)
#define _XOPEN_SOURCE #define _XOPEN_SOURCE


#include <stdio.h> #include <stdio.h>
Expand All @@ -22,28 +22,28 @@ static int parser_text(const char bytes[], size_t len, void *user)


int i; int i;
for(i = 0; i < len; /* none */) { for(i = 0; i < len; /* none */) {
if(b[i] < 0x20) /* C0 */ if(b[i] < 0x20) // C0
break; break;
else if(b[i] < 0x80) /* ASCII */ else if(b[i] < 0x80) // ASCII
i++; i++;
else if(b[i] < 0xa0) /* C1 */ else if(b[i] < 0xa0) // C1
break; break;
else if(b[i] < 0xc0) /* UTF-8 continuation */ else if(b[i] < 0xc0) // UTF-8 continuation
break; break;
else if(b[i] < 0xe0) { /* UTF-8 2-byte */ else if(b[i] < 0xe0) { // UTF-8 2-byte
/* 2-byte UTF-8 */ // 2-byte UTF-8
if(len < i+2) break; if(len < i+2) break;
i += 2; 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; if(len < i+3) break;
i += 3; 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; if(len < i+4) break;
i += 4; i += 4;
} }
else /* otherwise invalid */ else // otherwise invalid
break; break;
} }


Expand Down Expand Up @@ -200,7 +200,7 @@ int main(int argc, char *argv[])
file = argv[optind++]; file = argv[optind++];


if(!file || streq(file, "-")) if(!file || streq(file, "-"))
fd = 0; /* stdin */ fd = 0; // stdin
else { else {
fd = open(file, O_RDONLY); fd = open(file, O_RDONLY);
if(fd == -1) { if(fd == -1) {
Expand Down
64 changes: 32 additions & 32 deletions src/libvterm/include/vterm.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -110,30 +110,30 @@ typedef union {


typedef enum { typedef enum {
/* VTERM_ATTR_NONE = 0 */ /* VTERM_ATTR_NONE = 0 */
VTERM_ATTR_BOLD = 1, /* bool: 1, 22 */ VTERM_ATTR_BOLD = 1, // bool: 1, 22
VTERM_ATTR_UNDERLINE, /* number: 4, 21, 24 */ VTERM_ATTR_UNDERLINE, // number: 4, 21, 24
VTERM_ATTR_ITALIC, /* bool: 3, 23 */ VTERM_ATTR_ITALIC, // bool: 3, 23
VTERM_ATTR_BLINK, /* bool: 5, 25 */ VTERM_ATTR_BLINK, // bool: 5, 25
VTERM_ATTR_REVERSE, /* bool: 7, 27 */ VTERM_ATTR_REVERSE, // bool: 7, 27
VTERM_ATTR_STRIKE, /* bool: 9, 29 */ VTERM_ATTR_STRIKE, // bool: 9, 29
VTERM_ATTR_FONT, /* number: 10-19 */ VTERM_ATTR_FONT, // number: 10-19
VTERM_ATTR_FOREGROUND, /* color: 30-39 90-97 */ VTERM_ATTR_FOREGROUND, // color: 30-39 90-97
VTERM_ATTR_BACKGROUND, /* color: 40-49 100-107 */ VTERM_ATTR_BACKGROUND, // color: 40-49 100-107


VTERM_N_ATTRS VTERM_N_ATTRS
} VTermAttr; } VTermAttr;


typedef enum { typedef enum {
/* VTERM_PROP_NONE = 0 */ /* VTERM_PROP_NONE = 0 */
VTERM_PROP_CURSORVISIBLE = 1, /* bool */ VTERM_PROP_CURSORVISIBLE = 1, // bool
VTERM_PROP_CURSORBLINK, /* bool */ VTERM_PROP_CURSORBLINK, // bool
VTERM_PROP_ALTSCREEN, /* bool */ VTERM_PROP_ALTSCREEN, // bool
VTERM_PROP_TITLE, /* string */ VTERM_PROP_TITLE, // string
VTERM_PROP_ICONNAME, /* string */ VTERM_PROP_ICONNAME, // string
VTERM_PROP_REVERSE, /* bool */ VTERM_PROP_REVERSE, // bool
VTERM_PROP_CURSORSHAPE, /* number */ VTERM_PROP_CURSORSHAPE, // number
VTERM_PROP_MOUSE, /* number */ VTERM_PROP_MOUSE, // number
VTERM_PROP_CURSORCOLOR, /* string */ VTERM_PROP_CURSORCOLOR, // string


VTERM_N_PROPS VTERM_N_PROPS
} VTermProp; } VTermProp;
Expand Down Expand Up @@ -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. */ * Button 4 is scroll wheel down, button 5 is scroll wheel up. */
void vterm_mouse_button(VTerm *vt, int button, int pressed, VTermModifier mod); 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
Expand Down Expand Up @@ -249,9 +249,9 @@ typedef struct {
void vterm_parser_set_callbacks(VTerm *vt, const VTermParserCallbacks *callbacks, void *user); void vterm_parser_set_callbacks(VTerm *vt, const VTermParserCallbacks *callbacks, void *user);
void *vterm_parser_get_cbdata(VTerm *vt); void *vterm_parser_get_cbdata(VTerm *vt);


/* ----------- // -----------
* State layer // State layer
* ----------- */ // -----------


typedef struct { typedef struct {
int (*putglyph)(VTermGlyphInfo *info, VTermPos pos, void *user); int (*putglyph)(VTermGlyphInfo *info, VTermPos pos, void *user);
Expand Down Expand Up @@ -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_set_callbacks(VTermState *state, const VTermStateCallbacks *callbacks, void *user);
void *vterm_state_get_cbdata(VTermState *state); 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_set_unrecognised_fallbacks(VTermState *state, const VTermParserCallbacks *fallbacks, void *user);
void *vterm_state_get_unrecognised_fbdata(VTermState *state); void *vterm_state_get_unrecognised_fbdata(VTermState *state);


Expand All @@ -307,9 +307,9 @@ void vterm_state_focus_in(VTermState *state);
void vterm_state_focus_out(VTermState *state); void vterm_state_focus_out(VTermState *state);
const VTermLineInfo *vterm_state_get_lineinfo(const VTermState *state, int row); const VTermLineInfo *vterm_state_get_lineinfo(const VTermState *state, int row);


/* ------------ // ------------
* Screen layer // Screen layer
* ------------ */ // ------------


typedef struct { typedef struct {
unsigned int bold : 1; unsigned int bold : 1;
Expand Down Expand Up @@ -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_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);


Expand Down Expand Up @@ -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); int vterm_screen_is_eol(const VTermScreen *screen, VTermPos pos);


/* --------- // ---------
* Utilities // Utilities
* --------- */ // ---------


VTermValueType vterm_get_attr_type(VTermAttr attr); VTermValueType vterm_get_attr_type(VTermAttr attr);
VTermValueType vterm_get_prop_type(VTermProp prop); VTermValueType vterm_get_prop_type(VTermProp prop);
Expand Down
2 changes: 1 addition & 1 deletion src/libvterm/include/vterm_keycodes.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ typedef enum {
VTERM_KEY_KP_ENTER, VTERM_KEY_KP_ENTER,
VTERM_KEY_KP_EQUAL, VTERM_KEY_KP_EQUAL,


VTERM_KEY_MAX, /* Must be last */ VTERM_KEY_MAX, // Must be last
VTERM_N_KEYS = VTERM_KEY_MAX VTERM_N_KEYS = VTERM_KEY_MAX
} VTermKey; } VTermKey;


Expand Down
14 changes: 7 additions & 7 deletions src/libvterm/src/encoding.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
#endif #endif


struct UTF8DecoderData { struct UTF8DecoderData {
/* number of bytes remaining in this codepoint */ // number of bytes remaining in this codepoint
int bytes_remaining; int bytes_remaining;


/* number of bytes total in this codepoint once it's finished // number of bytes total in this codepoint once it's finished
(for detecting overlongs) */ // (for detecting overlongs)
int bytes_total; int bytes_total;


int this_cp; int this_cp;
Expand Down Expand Up @@ -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); printf(" pos=%zd c=%02x rem=%d\n", *pos, c, data->bytes_remaining);
#endif #endif


if(c < 0x20) /* C0 */ if(c < 0x20) // C0
return; return;


else if(c >= 0x20 && c < 0x7f) { else if(c >= 0x20 && c < 0x7f) {
Expand All @@ -58,7 +58,7 @@ static void decode_utf8(VTermEncoding *enc UNUSED, void *data_,
#endif #endif
} }


else if(c == 0x7f) /* DEL */ else if(c == 0x7f) // DEL
return; return;


else if(c >= 0x80 && c < 0xc0) { else if(c >= 0x80 && c < 0xc0) {
Expand All @@ -75,7 +75,7 @@ static void decode_utf8(VTermEncoding *enc UNUSED, void *data_,
#ifdef DEBUG_PRINT_UTF8 #ifdef DEBUG_PRINT_UTF8
printf(" UTF-8 raw char U+%04x bytelen=%d ", data->this_cp, data->bytes_total); printf(" UTF-8 raw char U+%04x bytelen=%d ", data->this_cp, data->bytes_total);
#endif #endif
/* Check for overlong sequences */ // Check for overlong sequences
switch(data->bytes_total) { switch(data->bytes_total) {
case 2: case 2:
if(data->this_cp < 0x0080) data->this_cp = UNICODE_INVALID; if(data->this_cp < 0x0080) data->this_cp = UNICODE_INVALID;
Expand All @@ -93,7 +93,7 @@ static void decode_utf8(VTermEncoding *enc UNUSED, void *data_,
if(data->this_cp < 0x4000000) data->this_cp = UNICODE_INVALID; if(data->this_cp < 0x4000000) data->this_cp = UNICODE_INVALID;
break; break;
} }
/* Now look for plain invalid ones */ // Now look for plain invalid ones
if((data->this_cp >= 0xD800 && data->this_cp <= 0xDFFF) || if((data->this_cp >= 0xD800 && data->this_cp <= 0xDFFF) ||
data->this_cp == 0xFFFE || data->this_cp == 0xFFFE ||
data->this_cp == 0xFFFF) data->this_cp == 0xFFFF)
Expand Down
Loading

0 comments on commit b691de0

Please sign in to comment.