Scrap writerune(), introducing fputrune()

Interface and function as proposed by cls.
Code is also shorter, everything else analogous to fgetrune().
This commit is contained in:
FRIGN
2015-02-11 20:58:00 +01:00
parent a5ae899a48
commit 7c578bf5b0
9 changed files with 46 additions and 40 deletions

14
paste.c
View File

@@ -26,17 +26,17 @@ sequential(struct fdescr *dsc, int fdescrlen, Rune *delim, size_t delimlen)
while (efgetrune(&c, dsc[i].fp, dsc[i].name)) {
if (last == '\n') {
if (delim[d] != '\0')
writerune("<stdout>", stdout, &delim[d]);
efputrune(&delim[d], stdout, "<stdout>");
d = (d + 1) % delimlen;
}
if (c != '\n')
writerune("<stdout>", stdout, &c);
efputrune(&c, stdout, "<stdout>");
last = c;
}
if (last == '\n')
writerune("<stdout>", stdout, &last);
efputrune(&last, stdout, "<stdout>");
}
}
@@ -56,22 +56,22 @@ nextline:
for (; efgetrune(&c, dsc[i].fp, dsc[i].name) ;) {
for (m = last + 1; m < i; m++)
writerune("<stdout>", stdout, &(delim[m % delimlen]));
efputrune(&(delim[m % delimlen]), stdout, "<stdout>");
last = i;
if (c == '\n') {
if (i != fdescrlen - 1)
c = d;
writerune("<stdout>", stdout, &c);
efputrune(&c, stdout, "<stdout>");
break;
}
writerune("<stdout>", stdout, &c);
efputrune(&c, stdout, "<stdout>");
}
if (c == 0 && last != -1) {
if (i == fdescrlen - 1)
putchar('\n');
else
writerune("<stdout>", stdout, &d);
efputrune(&d, stdout, "<stdout>");
last++;
}
}