PERFORCE change 148588 for review
Konrad Jankowski
konrad at FreeBSD.org
Wed Aug 27 07:44:59 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=148588
Change 148588 by konrad at vspredator on 2008/08/27 07:44:00
Now print the names of all the characters.
Affected files ...
.. //depot/projects/soc2008/konrad_collation/test/analyze/analyze.c#2 edit
Differences ...
==== //depot/projects/soc2008/konrad_collation/test/analyze/analyze.c#2 (text+ko) ====
@@ -30,12 +30,32 @@
}
void
+grep_name(char *str, int len)
+{
+ char grepbuf[30] = { 0 }, cmd[120], tmp[10];
+ int i;
+
+ for (i = 0; i < len; i++) {
+ snprintf(tmp, sizeof(tmp), "\\\\x%2X", (unsigned char)str[i]);
+ strlcat(grepbuf, tmp, sizeof(grepbuf));
+ }
+ fflush(stdout);
+ snprintf(cmd, sizeof(cmd), "grep ' %s$' /usr/home/versus/p4/posix/UTF-8.cm"
+ " | head -n 1 | awk ' { print $1 } '"
+ " | tr -d '\n'", grepbuf);
+#if 0
+ printf("cmd: %s\n", cmd);
+#else
+ system(cmd);
+#endif
+}
+
+void
show(char *line)
{
char *p;
int delta, i, len, chars, max = 0;
wchar_t wc;
- char grepbuf[20], tmpbuf[5], cmd[50];
for (p = line, i = 1; *p; p += delta, i++) {
delta = mbtowc(&wc, p, -1);
@@ -58,13 +78,8 @@
putchar('\n');
for (p = line; *p; p += delta) {
delta = mbtowc(&wc, p, -1);
- grepbuf[0] = '\0';
- for (i = 0; i < delta; i++) {
+ for (i = 0; i < delta; i++)
printf("%X", (unsigned char)p[i]);
- snprintf(tmpbuf, sizeof(tmpbuf),
- ".x%X", (unsigned char)p[i]);
- strcat(grepbuf, tmpbuf);
- }
adjust(max, delta << 1);
}
putchar('\n');
@@ -74,9 +89,11 @@
adjust(max, len);
}
putchar('\n');
- /* printf("grepbuf: %s\n", grepbuf); */
- snprintf(cmd, sizeof(cmd), "grep %s /usr/home/versus/p4/posix/UTF-8.cm", grepbuf);
- system(cmd);
+ for (p = line; *p; p += delta) {
+ delta = mbtowc(&wc, p, -1);
+ grep_name(p, delta);
+ }
+ putchar('\n');
}
int
More information about the p4-projects
mailing list