aboutsummaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
authorsuigin <suigin@national.shitposting.agency>2015-05-05 13:13:21 -0700
committerRoberto E. Vargas Caballero <k0ga@shike2.com>2015-05-06 08:15:41 +0200
commit38af006b5e4a36c77f25affbb3f7e28899db75ed (patch)
tree83ea7dc03f72f8b9219e8815dd8921d91dfbaa60 /st.c
parentc990abfedf56cb8d3176fe6d5152ff65bb68bff0 (diff)
downloadst-38af006b5e4a36c77f25affbb3f7e28899db75ed.tar.gz
st-38af006b5e4a36c77f25affbb3f7e28899db75ed.zip
Changed type for UTF-32 codepoints from long to uint_least32_t
Diffstat (limited to 'st.c')
-rw-r--r--st.c52
1 files changed, 27 insertions, 25 deletions
diff --git a/st.c b/st.c
index 3eb66fa..4add638 100644
--- a/st.c
+++ b/st.c
@@ -183,11 +183,13 @@ typedef unsigned int uint;
183typedef unsigned long ulong; 183typedef unsigned long ulong;
184typedef unsigned short ushort; 184typedef unsigned short ushort;
185 185
186typedef uint_least32_t Rune;
187
186typedef XftDraw *Draw; 188typedef XftDraw *Draw;
187typedef XftColor Color; 189typedef XftColor Color;
188 190
189typedef struct { 191typedef struct {
190 long u; /* character code */ 192 Rune u; /* character code */
191 ushort mode; /* attribute flags */ 193 ushort mode; /* attribute flags */
192 ushort fg; /* foreground */ 194 ushort fg; /* foreground */
193 ushort bg; /* background */ 195 ushort bg; /* background */
@@ -389,20 +391,20 @@ static void tmoveato(int, int);
389static void tnew(int, int); 391static void tnew(int, int);
390static void tnewline(int); 392static void tnewline(int);
391static void tputtab(int); 393static void tputtab(int);
392static void tputc(long); 394static void tputc(Rune);
393static void treset(void); 395static void treset(void);
394static void tresize(int, int); 396static void tresize(int, int);
395static void tscrollup(int, int); 397static void tscrollup(int, int);
396static void tscrolldown(int, int); 398static void tscrolldown(int, int);
397static void tsetattr(int *, int); 399static void tsetattr(int *, int);
398static void tsetchar(long, Glyph *, int, int); 400static void tsetchar(Rune, Glyph *, int, int);
399static void tsetscroll(int, int); 401static void tsetscroll(int, int);
400static void tswapscreen(void); 402static void tswapscreen(void);
401static void tsetdirt(int, int); 403static void tsetdirt(int, int);
402static void tsetdirtattr(int); 404static void tsetdirtattr(int);
403static void tsetmode(bool, bool, int *, int); 405static void tsetmode(bool, bool, int *, int);
404static void tfulldirt(void); 406static void tfulldirt(void);
405static void techo(long); 407static void techo(Rune);
406static void tcontrolcode(uchar ); 408static void tcontrolcode(uchar );
407static void tdectest(char ); 409static void tdectest(char );
408static int32_t tdefcolor(int *, int *, int); 410static int32_t tdefcolor(int *, int *, int);
@@ -465,11 +467,11 @@ static int y2row(int);
465static void getbuttoninfo(XEvent *); 467static void getbuttoninfo(XEvent *);
466static void mousereport(XEvent *); 468static void mousereport(XEvent *);
467 469
468static size_t utf8decode(char *, long *, size_t); 470static size_t utf8decode(char *, Rune *, size_t);
469static long utf8decodebyte(char, size_t *); 471static Rune utf8decodebyte(char, size_t *);
470static size_t utf8encode(long, char *); 472static size_t utf8encode(Rune, char *);
471static char utf8encodebyte(long, size_t); 473static char utf8encodebyte(Rune, size_t);
472static size_t utf8validate(long *, size_t); 474static size_t utf8validate(Rune *, size_t);
473 475
474static ssize_t xwrite(int, const char *, size_t); 476static ssize_t xwrite(int, const char *, size_t);
475static void *xmalloc(size_t); 477static void *xmalloc(size_t);
@@ -524,8 +526,8 @@ static double defaultfontsize = 0;
524 526
525static uchar utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0}; 527static uchar utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0};
526static uchar utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8}; 528static uchar utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};
527static long utfmin[UTF_SIZ + 1] = { 0, 0, 0x80, 0x800, 0x10000}; 529static Rune utfmin[UTF_SIZ + 1] = { 0, 0, 0x80, 0x800, 0x10000};
528static long utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF}; 530static Rune utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF};
529 531
530/* Font Ring Cache */ 532/* Font Ring Cache */
531enum { 533enum {
@@ -538,7 +540,7 @@ enum {
538typedef struct { 540typedef struct {
539 XftFont *font; 541 XftFont *font;
540 int flags; 542 int flags;
541 long unicodep; 543 Rune unicodep;
542} Fontcache; 544} Fontcache;
543 545
544/* Fontcache is an array now. A new font will be appended to the array. */ 546/* Fontcache is an array now. A new font will be appended to the array. */
@@ -586,9 +588,9 @@ xstrdup(char *s) {
586} 588}
587 589
588size_t 590size_t
589utf8decode(char *c, long *u, size_t clen) { 591utf8decode(char *c, Rune *u, size_t clen) {
590 size_t i, j, len, type; 592 size_t i, j, len, type;
591 long udecoded; 593 Rune udecoded;
592 594
593 *u = UTF_INVALID; 595 *u = UTF_INVALID;
594 if(!clen) 596 if(!clen)
@@ -608,7 +610,7 @@ utf8decode(char *c, long *u, size_t clen) {
608 return len; 610 return len;
609} 611}
610 612
611long 613Rune
612utf8decodebyte(char c, size_t *i) { 614utf8decodebyte(char c, size_t *i) {
613 for(*i = 0; *i < LEN(utfmask); ++(*i)) 615 for(*i = 0; *i < LEN(utfmask); ++(*i))
614 if(((uchar)c & utfmask[*i]) == utfbyte[*i]) 616 if(((uchar)c & utfmask[*i]) == utfbyte[*i])
@@ -617,7 +619,7 @@ utf8decodebyte(char c, size_t *i) {
617} 619}
618 620
619size_t 621size_t
620utf8encode(long u, char *c) { 622utf8encode(Rune u, char *c) {
621 size_t len, i; 623 size_t len, i;
622 624
623 len = utf8validate(&u, 0); 625 len = utf8validate(&u, 0);
@@ -632,12 +634,12 @@ utf8encode(long u, char *c) {
632} 634}
633 635
634char 636char
635utf8encodebyte(long u, size_t i) { 637utf8encodebyte(Rune u, size_t i) {
636 return utfbyte[i] | (u & ~utfmask[i]); 638 return utfbyte[i] | (u & ~utfmask[i]);
637} 639}
638 640
639size_t 641size_t
640utf8validate(long *u, size_t i) { 642utf8validate(Rune *u, size_t i) {
641 if(!BETWEEN(*u, utfmin[i], utfmax[i]) || BETWEEN(*u, 0xD800, 0xDFFF)) 643 if(!BETWEEN(*u, utfmin[i], utfmax[i]) || BETWEEN(*u, 0xD800, 0xDFFF))
642 *u = UTF_INVALID; 644 *u = UTF_INVALID;
643 for(i = 1; *u > utfmax[i]; ++i) 645 for(i = 1; *u > utfmax[i]; ++i)
@@ -1339,7 +1341,7 @@ ttyread(void) {
1339 static int buflen = 0; 1341 static int buflen = 0;
1340 char *ptr; 1342 char *ptr;
1341 int charsize; /* size of utf8 char in bytes */ 1343 int charsize; /* size of utf8 char in bytes */
1342 long unicodep; 1344 Rune unicodep;
1343 int ret; 1345 int ret;
1344 1346
1345 /* append read bytes to unprocessed bytes */ 1347 /* append read bytes to unprocessed bytes */
@@ -1368,7 +1370,7 @@ ttywrite(const char *s, size_t n) {
1368void 1370void
1369ttysend(char *s, size_t n) { 1371ttysend(char *s, size_t n) {
1370 int len; 1372 int len;
1371 long u; 1373 Rune u;
1372 1374
1373 ttywrite(s, n); 1375 ttywrite(s, n);
1374 if(IS_SET(MODE_ECHO)) 1376 if(IS_SET(MODE_ECHO))
@@ -1625,7 +1627,7 @@ tmoveto(int x, int y) {
1625} 1627}
1626 1628
1627void 1629void
1628tsetchar(long u, Glyph *attr, int x, int y) { 1630tsetchar(Rune u, Glyph *attr, int x, int y) {
1629 static char *vt100_0[62] = { /* 0x41 - 0x7e */ 1631 static char *vt100_0[62] = { /* 0x41 - 0x7e */
1630 "↑", "↓", "→", "←", "█", "▚", "☃", /* A - G */ 1632 "↑", "↓", "→", "←", "█", "▚", "☃", /* A - G */
1631 0, 0, 0, 0, 0, 0, 0, 0, /* H - O */ 1633 0, 0, 0, 0, 0, 0, 0, 0, /* H - O */
@@ -2440,7 +2442,7 @@ tputtab(int n) {
2440} 2442}
2441 2443
2442void 2444void
2443techo(long u) { 2445techo(Rune u) {
2444 if(ISCONTROL(u)) { /* control code */ 2446 if(ISCONTROL(u)) { /* control code */
2445 if(u & 0x80) { 2447 if(u & 0x80) {
2446 u &= 0x7f; 2448 u &= 0x7f;
@@ -2663,7 +2665,7 @@ eschandle(uchar ascii) {
2663} 2665}
2664 2666
2665void 2667void
2666tputc(long u) { 2668tputc(Rune u) {
2667 char c[UTF_SIZ]; 2669 char c[UTF_SIZ];
2668 bool control; 2670 bool control;
2669 int width, len; 2671 int width, len;
@@ -3262,7 +3264,7 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
3262 int frcflags, charexists; 3264 int frcflags, charexists;
3263 int u8fl, u8fblen, u8cblen, doesexist; 3265 int u8fl, u8fblen, u8cblen, doesexist;
3264 char *u8c, *u8fs; 3266 char *u8c, *u8fs;
3265 long unicodep; 3267 Rune unicodep;
3266 Font *font = &dc.font; 3268 Font *font = &dc.font;
3267 FcResult fcres; 3269 FcResult fcres;
3268 FcPattern *fcpattern, *fontpattern; 3270 FcPattern *fcpattern, *fontpattern;
@@ -3805,7 +3807,7 @@ kpress(XEvent *ev) {
3805 KeySym ksym; 3807 KeySym ksym;
3806 char buf[32], *customkey; 3808 char buf[32], *customkey;
3807 int len; 3809 int len;
3808 long c; 3810 Rune c;
3809 Status status; 3811 Status status;
3810 Shortcut *bp; 3812 Shortcut *bp;
3811 3813