Use the UTF8_POINT macro in cols(1)
No need for libutf any more
This commit is contained in:
parent
cc3aefa488
commit
00b579566a
2
README
2
README
@ -21,7 +21,7 @@ The following tools are implemented:
|
|||||||
0=*|x chroot .
|
0=*|x chroot .
|
||||||
0=*|o cksum .
|
0=*|o cksum .
|
||||||
0=*|o cmp .
|
0=*|o cmp .
|
||||||
#*|x cols .
|
0#*|x cols .
|
||||||
0=*|o comm .
|
0=*|o comm .
|
||||||
0=*|o cp (-i)
|
0=*|o cp (-i)
|
||||||
0=*|x cron .
|
0=*|x cron .
|
||||||
|
15
cols.c
15
cols.c
@ -9,7 +9,6 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
#include "utf.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -63,9 +62,10 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < b.nlines; i++) {
|
for (i = 0; i < b.nlines; i++) {
|
||||||
/* TODO: fix libutf to run utflen on a memory chunk
|
for (j = 0, len = 0; j < b.lines[i].len; j++) {
|
||||||
* of given size to also handle embedded NULs */
|
if (UTF8_POINT(b.lines[i].data[j]))
|
||||||
len = utflen(b.lines[i].data);
|
len++;
|
||||||
|
}
|
||||||
if (len && b.lines[i].data[b.lines[i].len - 1] == '\n') {
|
if (len && b.lines[i].data[b.lines[i].len - 1] == '\n') {
|
||||||
b.lines[i].data[--(b.lines[i].len)] = '\0';
|
b.lines[i].data[--(b.lines[i].len)] = '\0';
|
||||||
len--;
|
len--;
|
||||||
@ -79,9 +79,10 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
for (i = 0; i < rows; i++) {
|
for (i = 0; i < rows; i++) {
|
||||||
for (j = 0; j < cols && i + j * rows < b.nlines; j++) {
|
for (j = 0; j < cols && i + j * rows < b.nlines; j++) {
|
||||||
/* TODO: fix libutf to run utflen on a memory chunk
|
for (k = 0, len = 0; k < b.lines[i + j * rows].len; k++) {
|
||||||
* of given size to also handle embedded NULs */
|
if (UTF8_POINT(b.lines[i + j * rows].data[k]))
|
||||||
len = utflen(b.lines[i + j * rows].data);
|
len++;
|
||||||
|
}
|
||||||
fwrite(b.lines[i + j * rows].data, 1,
|
fwrite(b.lines[i + j * rows].data, 1,
|
||||||
b.lines[i + j * rows].len, stdout);
|
b.lines[i + j * rows].len, stdout);
|
||||||
if (j < cols - 1)
|
if (j < cols - 1)
|
||||||
|
Loading…
Reference in New Issue
Block a user