diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2019-12-17 16:29:13 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2019-12-17 16:29:13 +1300 |
commit | 976bbe78893b4fabea476e9350ec20298577672f (patch) | |
tree | bd3d156d84536e29a88ef8f0395d7340956f5e5d | |
parent | Refactor Makefile a bit (diff) | |
download | wtf8-976bbe78893b4fabea476e9350ec20298577672f.tar.gz wtf8-976bbe78893b4fabea476e9350ec20298577672f.zip |
Switch to tabs
-rw-r--r-- | wtf8.c | 100 |
1 files changed, 50 insertions, 50 deletions
@@ -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); } |