- if (strchr(argv[1], '=')) {
- printf("%s\n", tolscolors(argv[1]));
- return (0);
- } else {
- printf("%s\n", tols_colors(argv[1]));
- return (0);
- }
+ char *input = NULL;
+ if (strcmp(argv[1], "-") == 0) {
+ char *buf = NULL;
+ size_t linecap = 0;
+ ssize_t linelen;
+ getline(&buf, &linecap, stdin);
+ if (buf[sizeof(buf) - 1] == '\n')
+ buf[sizeof(buf) - 1] = '\0';
+ input = strdup(buf);
+ free(buf);
+ } else
+ input = argv[1];
+
+ if (strchr(input, '='))
+ fprintf(stdout, "%s\n", tolscolors(input));
+ else
+ fprintf(stdout, "%s\n", tols_colors(input));