comparison src/libvterm/bin/vterm-dump.c @ 13770:2449b6ce1456 v8.0.1757

patch 8.0.1757: unnecessary changes in libvterm commit https://github.com/vim/vim/commit/b691de05f69905fe417f583083d7e3cc16eb865e Author: Bram Moolenaar <Bram@vim.org> Date: Tue Apr 24 18:39:14 2018 +0200 patch 8.0.1757: unnecessary changes in libvterm Problem: Unnecessary changes in libvterm. Solution: Bring back // comments and trailing comma in enums.
author Christian Brabandt <cb@256bit.org>
date Tue, 24 Apr 2018 18:45:07 +0200
parents 9f857e6310b6
children 811a12a78164
comparison
equal deleted inserted replaced
13769:804c3b21ce59 13770:2449b6ce1456
1 /* Require getopt(3) */ 1 // Require getopt(3)
2 #define _XOPEN_SOURCE 2 #define _XOPEN_SOURCE
3 3
4 #include <stdio.h> 4 #include <stdio.h>
5 #include <string.h> 5 #include <string.h>
6 #define streq(a,b) (strcmp(a,b)==0) 6 #define streq(a,b) (strcmp(a,b)==0)
20 { 20 {
21 unsigned char *b = (unsigned char *)bytes; 21 unsigned char *b = (unsigned char *)bytes;
22 22
23 int i; 23 int i;
24 for(i = 0; i < len; /* none */) { 24 for(i = 0; i < len; /* none */) {
25 if(b[i] < 0x20) /* C0 */ 25 if(b[i] < 0x20) // C0
26 break; 26 break;
27 else if(b[i] < 0x80) /* ASCII */ 27 else if(b[i] < 0x80) // ASCII
28 i++; 28 i++;
29 else if(b[i] < 0xa0) /* C1 */ 29 else if(b[i] < 0xa0) // C1
30 break; 30 break;
31 else if(b[i] < 0xc0) /* UTF-8 continuation */ 31 else if(b[i] < 0xc0) // UTF-8 continuation
32 break; 32 break;
33 else if(b[i] < 0xe0) { /* UTF-8 2-byte */ 33 else if(b[i] < 0xe0) { // UTF-8 2-byte
34 /* 2-byte UTF-8 */ 34 // 2-byte UTF-8
35 if(len < i+2) break; 35 if(len < i+2) break;
36 i += 2; 36 i += 2;
37 } 37 }
38 else if(b[i] < 0xf0) { /* UTF-8 3-byte */ 38 else if(b[i] < 0xf0) { // UTF-8 3-byte
39 if(len < i+3) break; 39 if(len < i+3) break;
40 i += 3; 40 i += 3;
41 } 41 }
42 else if(b[i] < 0xf8) { /* UTF-8 4-byte */ 42 else if(b[i] < 0xf8) { // UTF-8 4-byte
43 if(len < i+4) break; 43 if(len < i+4) break;
44 i += 4; 44 i += 4;
45 } 45 }
46 else /* otherwise invalid */ 46 else // otherwise invalid
47 break; 47 break;
48 } 48 }
49 49
50 printf("%.*s", i, b); 50 printf("%.*s", i, b);
51 return i; 51 return i;
198 } 198 }
199 199
200 file = argv[optind++]; 200 file = argv[optind++];
201 201
202 if(!file || streq(file, "-")) 202 if(!file || streq(file, "-"))
203 fd = 0; /* stdin */ 203 fd = 0; // stdin
204 else { 204 else {
205 fd = open(file, O_RDONLY); 205 fd = open(file, O_RDONLY);
206 if(fd == -1) { 206 if(fd == -1) {
207 fprintf(stderr, "Cannot open %s - %s\n", file, strerror(errno)); 207 fprintf(stderr, "Cannot open %s - %s\n", file, strerror(errno));
208 exit(1); 208 exit(1);