Add support for multibyte characters.
This commit is contained in:
parent
794adb75ee
commit
507e8f1644
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=132245
@ -50,21 +50,26 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <locale.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <wchar.h>
|
||||
|
||||
void usage(void);
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
const char *filename, *p, *t;
|
||||
const char *filename;
|
||||
wchar_t *p, *t;
|
||||
FILE *fp;
|
||||
size_t len;
|
||||
int ch, rval;
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
while ((ch = getopt(argc, argv, "")) != -1)
|
||||
switch(ch) {
|
||||
case '?':
|
||||
@ -88,13 +93,13 @@ main(int argc, char *argv[])
|
||||
}
|
||||
filename = *argv++;
|
||||
}
|
||||
while ((p = fgetln(fp, &len)) != NULL) {
|
||||
while ((p = fgetwln(fp, &len)) != NULL) {
|
||||
if (p[len - 1] == '\n')
|
||||
--len;
|
||||
t = p + len - 1;
|
||||
for (t = p + len - 1; t >= p; --t)
|
||||
putchar(*t);
|
||||
putchar('\n');
|
||||
putwchar(*t);
|
||||
putwchar('\n');
|
||||
}
|
||||
if (ferror(fp)) {
|
||||
warn("%s", filename);
|
||||
|
Loading…
Reference in New Issue
Block a user