#include #include #include #include #include #include "config.h" int main (int argc, char *argv[]) { setlocale (LC_ALL, ""); if (argc != 3) { fprintf (stderr, "Usage: %s {infile} {outfile}\n", basename (argv[0])); return EXIT_FAILURE; } FILE *istream = fopen (argv[1], "r,ccs="CCS); if (istream == NULL) { perror (NULL); return EXIT_FAILURE; } FILE *ostream = fopen (argv[2], "w,ccs="CCS); // FILE *ostream = stdout; if (ostream == NULL) { perror (NULL); return EXIT_FAILURE; } wint_t current = fgetwc (istream); while (current != WEOF) { wint_t next = fgetwc (istream); if (next == current) { size_t count; fwscanf (istream, L"%llu", &count); fgetwc (istream); while (count--) fputwc (current, ostream); current = fgetwc (istream); } else { fputwc (current, ostream); current = next; } } if (fclose (ostream) == EOF) { perror (NULL); return EXIT_FAILURE; } if (fclose (istream) == EOF) { perror (NULL); return EXIT_FAILURE; } return EXIT_SUCCESS; }