sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

commit 18850f5dfa80bbc78038c147de5a85bf8878ec3e
parent 5b5bb82ec00cb7b7b02ac97550683e2f377e6f13
Author: sin <sin@2f30.org>
Date:   Fri, 21 Nov 2014 16:34:44 +0000

writerune() should operate on a FILE *

Diffstat:
Mexpand.c | 6+++---
Mlibutf/writerune.c | 10+++++-----
Mutf.h | 2+-
3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/expand.c b/expand.c @@ -74,18 +74,18 @@ expand(const char *file, FILE *fp, int tabstop) if (col) col--; bol = 0; - writerune(&r); + writerune("<stdout>", stdout, &r); break; case '\n': col = 0; bol = 1; - writerune(&r); + writerune("<stdout>", stdout, &r); break; default: col++; if (r != ' ') bol = 0; - writerune(&r); + writerune("<stdout>", stdout, &r); break; } } diff --git a/libutf/writerune.c b/libutf/writerune.c @@ -7,16 +7,16 @@ #include "../utf.h" void -writerune(Rune *r) +writerune(const char *file, FILE *fp, 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)); + fwrite(buf, n, 1, fp); + if (ferror(fp)) { + fprintf(stderr, "%s: write error: %s\n", + file, strerror(errno)); exit(1); } } diff --git a/utf.h b/utf.h @@ -50,4 +50,4 @@ int isupperrune(Rune); int isdigitrune(Rune); int readrune(const char *, FILE *, Rune *); -void writerune(Rune *); +void writerune(const char *, FILE *, Rune *);