takes text and makes it worse
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

88 lines
1.5 KiB

#include <stdio.h>
#include <getopt.h>
#include <stdlib.h>
#include <regex.h>
static void help() {
printf("usage: owo [-h|-v] \n");
exit(EXIT_SUCCESS);
}
static void version() {
printf("v0.1 \n");
exit(EXIT_SUCCESS);
}
int main(int argc, char *argv[]) {
int opt;
while ((opt = getopt(argc, argv, "hv")) != -1) {
switch (opt) {
case 'h':
help();
break;
case 'v':
version();
break;
default:
help();
break;
}
}
if (optind == argc) {
char c;
char d = 0;
regex_t vowels;
regex_t vowels_cap;
int ret;
ret = regcomp(&vowels, "[aiueo]", 0);
if (ret) {
fprintf(stderr, "error while compiling vowels regex!\n");
exit(1);
}
ret = regcomp(&vowels_cap, "[AIUEO]", 0);
if (ret) {
fprintf(stderr, "error while compiling vowels_cap regex!\n");
}
while ((c = getchar()) != EOF) {
if (c == 'r' || c == 'l') c = 'w';
if (c == 'R' || c == 'L') c = 'W';
if (d == 'n' || d == 'm') {
char str[2] = { c, '\0' };
ret = regexec(&vowels, str, 0, NULL, 0);
if (!ret) putchar('y');
}
if (d == 'N' || d == 'M') {
char str[2] = { c, '\0' };
ret = regexec(&vowels_cap, str, 0, NULL, 0);
if (!ret) putchar('Y');
else if (ret == REG_NOMATCH) {
ret = regexec(&vowels, str, 0, NULL, 0);
if (!ret) putchar('y');
}
}
if ((d == 's' || d == 'S') && (c == 't' || c == 'o')) putchar('h');
if (d == 'S' && (c == 'T' || c == 'O')) putchar('H');
putchar(c);
d = c;
}
}
return 0;
}