iomenu

interactive text selection menu
Log | Files | Refs | README | LICENSE

commit 1a93ead7868deeeb790f1382615f5bd20d5033fc
parent d039d19d82cc89665d453180d25007bf2329c3e6
Author: Josuah Demangeonā  ā µ <mail@josuah.net>
Date:   Tue,  4 Apr 2017 00:19:57 +0200

fixed functions declarations

Diffstat:
Mutf.c | 17+++++++++--------
Mutf.h | 14++++++++------
2 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/utf.c b/utf.c @@ -119,14 +119,14 @@ utftorune(long *r, char *s, int n) * Return the length of `i`. */ size_t -utftorunes(long *runev, char *utf, size_t n) +utftorunes(long *runes, char *utf, size_t n) { size_t i, j; for (i = 0, j = 0; n > 0; i++) - j += utftorune(runev + i, utf[j], n - j); + j += utftorune(runes + i, utf + j, n - j); - runev[i] = '\0'; + runes[i] = '\0'; return i; } @@ -200,7 +200,7 @@ runetoprint(char *s, long r) } else if (r == 0x7f || r < ' ') { return sprintf(s, "[%02lx]", r); - } else if (!isprintrune(r)) { + } else if (!runeisprint(r)) { return sprintf(s, "[%04lx]", r); } else { @@ -219,10 +219,11 @@ runetoprint(char *s, long r) * Returns 1 if the rune is a printable character and 0 if not. */ int -isprintrune(long r) +runeisprint(long r) { return !( - (r < ' ' || r == 0x7f) || /* ascii control */ + (r != '\t' && r < ' ') || /* ascii control */ + (r == 0x7f) || (0x80 <= r && r < 0xa0) || /* unicode control */ @@ -267,7 +268,7 @@ getrunes(long **r, FILE *f) (*r)[rlen] = '\0'; free(s); - return feof(f) ? -1 : rlen; + if (feof(f)) return -1; else return rlen; } @@ -317,7 +318,7 @@ main() long *r; int len, i; - for (len = 0; (len = getutf(&r, stdin)) >= 0 && !feof(stdin); free(r)) { + for (len = 0; (len = getrunes(&r, stdin)) >= 0 && !feof(stdin); free(r)) { for (i = 0; i < len; i++) { runetoprint(s, r[i]); fputs(s, stdout); diff --git a/utf.h b/utf.h @@ -1,16 +1,18 @@ -/* rune / utf length */ +/* lengths */ int utflen(char *, int); int runelen(long); -/* conversion */ +/* conversions */ +int utftorune(long *, char *, int); int utftorune(long *, char *, int); int runetoutf(char *, long); int runetoprint(char *, long); -/* input/output */ - -size_t getutf(long **, FILE *); /* standard library */ + int runeisprint(long); -long *runestrcpy(); +size_t getrunes(long **, FILE *); +long * runescpy(long *, long *); +long * runeschr(long *, long); +long * runescat(long *, long *);