diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2019-12-17 16:33:01 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2019-12-17 16:33:01 +1300 |
commit | 95436ec7ec45ff058de75a3b9cf6f762d06bc1df (patch) | |
tree | c3ed65685064fd3181c9cc972ed1f1630f06d7e3 | |
parent | Refactor Makefile a bit (diff) | |
parent | Bump VERSION, switch to semver (diff) | |
download | wtf8-95436ec7ec45ff058de75a3b9cf6f762d06bc1df.tar.gz wtf8-95436ec7ec45ff058de75a3b9cf6f762d06bc1df.zip |
Merge branch 'release/v1.2.0'v1.2.0
* release/v1.2.0:
Bump VERSION, switch to semver
Add VERSION
Add option terminator to Makefile clean target
Switch to tabs
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | VERSION | 1 | ||||
-rw-r--r-- | wtf8.c | 100 |
3 files changed, 52 insertions, 51 deletions
@@ -7,4 +7,4 @@ install: all cp -- $(ALL) $(PREFIX)/bin wtf8: wtf8.c wtf8.h clean: - rm -f $(ALL) + rm -f -- $(ALL) @@ -0,0 +1 @@ +1.2.0 @@ -5,7 +5,7 @@ * continuation character */ int is_utf8_cont(unsigned char c) { - return (c & 0xC0) == 0x80; + return (c & 0xC0) == 0x80; } /* @@ -13,16 +13,16 @@ int is_utf8_cont(unsigned char c) { * trailing space, ending with a newline */ void print_octets(char *s) { - unsigned char c; + unsigned char c; - /* - * Iterate through the string, printing each octet, ending with a newline - */ - while ((c = *s++)) - printf("%c%02x", (is_utf8_cont(c) ? '-' : ' '), c); - putchar('\n'); + /* + * Iterate through the string, printing each octet, ending with a newline + */ + while ((c = *s++)) + printf("%c%02x", (is_utf8_cont(c) ? '-' : ' '), c); + putchar('\n'); - return; + return; } /* @@ -32,36 +32,36 @@ void print_octets(char *s) { */ void print_characters(char *s) { - /* - * We need a short counter to find how long each character is - */ - int c; + /* + * We need a short counter to find how long each character is + */ + int c; - /* - * Iterate through the string - */ - while (*s) { + /* + * Iterate through the string + */ + while (*s) { - /* - * Print blanks and increment a counter until we find how long this - * character is - */ - for (c = 1; is_utf8_cont(s[c]); c++) - printf(" "); + /* + * Print blanks and increment a counter until we find how long this + * character is + */ + for (c = 1; is_utf8_cont(s[c]); c++) + printf(" "); - /* - * Print two spaces, and then the full character - */ - printf(" "); - while (c--) - putchar(*s++); - } + /* + * Print two spaces, and then the full character + */ + printf(" "); + while (c--) + putchar(*s++); + } - /* - * End with a newline - */ - putchar('\n'); - return; + /* + * End with a newline + */ + putchar('\n'); + return; } /* @@ -69,21 +69,21 @@ void print_characters(char *s) { */ int main(int argc, char **argv) { - /* - * Check we have one and only one argument - */ - if (argc != 2) - exit(EXIT_FAILURE); + /* + * Check we have one and only one argument + */ + if (argc != 2) + exit(EXIT_FAILURE); - /* - * Print the sole argument first as hex octets, then as characters, spaced - * accordingly - */ - print_octets(argv[1]); - print_characters(argv[1]); + /* + * Print the sole argument first as hex octets, then as characters, spaced + * accordingly + */ + print_octets(argv[1]); + print_characters(argv[1]); - /* - * Done! - */ - exit(EXIT_SUCCESS); + /* + * Done! + */ + exit(EXIT_SUCCESS); } |