writerune() should operate on a FILE *

This commit is contained in:
sin 2014-11-21 16:34:44 +00:00
parent 5b5bb82ec0
commit 18850f5dfa
3 changed files with 9 additions and 9 deletions

View File

@ -74,18 +74,18 @@ expand(const char *file, FILE *fp, int tabstop)
if (col) if (col)
col--; col--;
bol = 0; bol = 0;
writerune(&r); writerune("<stdout>", stdout, &r);
break; break;
case '\n': case '\n':
col = 0; col = 0;
bol = 1; bol = 1;
writerune(&r); writerune("<stdout>", stdout, &r);
break; break;
default: default:
col++; col++;
if (r != ' ') if (r != ' ')
bol = 0; bol = 0;
writerune(&r); writerune("<stdout>", stdout, &r);
break; break;
} }
} }

View File

@ -7,16 +7,16 @@
#include "../utf.h" #include "../utf.h"
void void
writerune(Rune *r) writerune(const char *file, FILE *fp, Rune *r)
{ {
char buf[UTFmax]; char buf[UTFmax];
int n; int n;
if ((n = runetochar(buf, r)) > 0) { if ((n = runetochar(buf, r)) > 0) {
fwrite(buf, n, 1, stdout); fwrite(buf, n, 1, fp);
if (ferror(stdout)) { if (ferror(fp)) {
fprintf(stderr, "stdout: write error: %s\n", fprintf(stderr, "%s: write error: %s\n",
strerror(errno)); file, strerror(errno));
exit(1); exit(1);
} }
} }

2
utf.h
View File

@ -50,4 +50,4 @@ int isupperrune(Rune);
int isdigitrune(Rune); int isdigitrune(Rune);
int readrune(const char *, FILE *, Rune *); int readrune(const char *, FILE *, Rune *);
void writerune(Rune *); void writerune(const char *, FILE *, Rune *);