Factor out readrune and writerune

This commit is contained in:
sin
2014-11-21 16:20:15 +00:00
parent 3de6a7510d
commit 5b5bb82ec0
5 changed files with 80 additions and 48 deletions

23
libutf/writerune.c Normal file
View File

@@ -0,0 +1,23 @@
/* See LICENSE file for copyright and license details. */
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "../utf.h"
void
writerune(Rune *r)
{
char buf[UTFmax];
int n;
if ((n = runetochar(buf, r)) > 0) {
fwrite(buf, n, 1, stdout);
if (ferror(stdout)) {
fprintf(stderr, "stdout: write error: %s\n",
strerror(errno));
exit(1);
}
}
}