#include #include #include /*#include "jctype.h"*/ #include "jstring.h" static char smp[][80] = { "a", "A", "あ", "ア", "ア", "・", "。", "!", "!", "abc", "ABC", "aAA", "abcABC12345ABCabcあいうアイウあわあabcテーブル表テーブル表", "ABCabcあいう     アイウ\\ aあわあテーブル表テーブル表   ", "                       ", "a b asdf dks あdさdf¥\\お ", "", "", "", }; static void sub1(void); static void sub2(void); int main(void) { char *p, buf[1024]; int i,n=0,c; printf("\n[%d]jstrncpy\n", ++n); for (i = 0; smp[i][0]; i++) { jstrncpy(buf, smp[i], 20); printf("%d %d> (%d) %s\n", n, i, jstrlen(buf), buf); } printf("\n[%d]btom,mtob\n", ++n); for (i = 0; smp[i][0]; i++) { p = smp[i]; for (c = 0; c < 10; c++) printf("%d %d> (%d)\n", n, i, btom(p,c), mtob(p,c)); } printf("\n[%d]jstradv\n", ++n); for (i = 0; smp[i][0]; i++) { p = smp[i]; for (c = 0; c < 10; c++) printf("%d %d> %s\n", n, i, jstradv(p,c)); } printf("\n[%d]jstrrev\n", ++n); for (i = 0; smp[i][0]; i++) { jstrncpy(buf, smp[i], 256); p = jstrrev(buf); printf("%d %d> %s\n", n, i, p); } printf("\n[%d]jstrncat 256\n", ++n); for (i = 0; smp[i][0]; i++) { p = jstrncat(buf, smp[i], 256); printf("%d %d> %s\n", n, i, p); } printf("\n[%d]jstrncat 20\n", ++n); for (i = 0; smp[i][0]; i++) { p = jstrncat(buf, smp[i], 20); printf("%d %d> %s\n", n, i, p); } printf("\n[%d]jstrchr\n", ++n); for (i = 0; smp[i][0]; i++) { strcpy(buf, smp[i]); p = jstrchr(buf,'A'); if (p) printf("%d %d> %s\n", n, i, p); p = jstrrchr(buf,'a'); if (p) printf("%d %d> %s\n", n, i, p); p = jstrchr(buf,'\\'); if (p) printf("%d %d> %s\n", n, i, p); p = jstrrchr(buf,'\\'); if (p) printf("%d %d> %s\n", n, i, p); p = jstrchr(buf,0x82a0); if (p) printf("%d %d> %s\n", n, i, p); p = jstrrchr(buf,0x82a0); if (p) printf("%d %d> %s\n", n, i, p); } printf("\n[%d]jstrstr\n", ++n); for (i = 0; smp[i][0]; i++) { strncpy(buf, smp[i], 256); p = jstrstr(buf, ""); if (p) printf("%d %d> %s\n", n, i, p); p = jstrstr(buf, "\\"); if (p) printf("%d %d> %s\n", n, i, p); p = jstrstr(buf, "abc"); if (p) printf("%d %d> %s\n", n, i, p); p = jstrstr(buf, "表"); if (p) printf("%d %d> %s\n", n, i, p); p = jstrstr(buf, "Ca"); if (p) printf("%d %d> %s\n", n, i, p); p = jstrstr(buf, "表テーブル表"); if (p) printf("%d %d> %s\n", n, i, p); p = jstrstr(buf, "   "); if (p) printf("%d %d> %s\n", n, i, p); } sub1(); return 0; } static void sub1(void) { char *p, buf[1024]; int i,n=0,c; printf("\n[%d]jstrmatch\n", ++n); for (i = 0; smp[i][0]; i++) { strncpy(buf, smp[i], 256); p = jstrmatch(buf, ""); if (p) printf("%d %d> %s\n", n, i, p); p = jstrmatch(buf, "\\"); if (p) printf("%d %d> %s\n", n, i, p); p = jstrmatch(buf, "\\abc"); if (p) printf("%d %d> %s\n", n, i, p); p = jstrmatch(buf, "\\aAbc"); if (p) printf("%d %d> %s\n", n, i, p); p = jstrmatch(buf, "あbc"); if (p) printf("%d %d> %s\n", n, i, p); p = jstrmatch(buf, "abcABC"); if (p) printf("%d %d> %s\n", n, i, p); } printf("\n[%d]jstrskip\n", ++n); for (i = 0; smp[i][0]; i++) { strncpy(buf, smp[i], 256); p = jstrskip(buf, ""); if (p) printf("%d %d> %s\n", n, i, p); p = jstrskip(buf, "\\"); if (p) printf("%d %d> %s\n", n, i, p); p = jstrskip(buf, "\\abc"); if (p) printf("%d %d> %s\n", n, i, p); p = jstrskip(buf, "\\aAbc"); if (p) printf("%d %d> %s\n", n, i, p); p = jstrskip(buf, "あbc"); if (p) printf("%d %d> %s\n", n, i, p); p = jstrskip(buf, "abcABC"); if (p) printf("%d %d> %s\n", n, i, p); } printf("\n[%d]jstrtok\n", ++n); for (i = 0; smp[i][0]; i++) { p = strncpy(buf, smp[i], 256); while ((p = jstrtok(p, "a")) != NULL) { printf("%d %d> %s\n", n, i, p); p = NULL; } p = strncpy(buf, smp[i], 256); while ((p = jstrtok(p, "AaA")) != NULL) { printf("%d %d> %s\n", n, i, p); p = NULL; } p = strncpy(buf, smp[i], 256); while ((p = jstrtok(p, "\\ 表")) != NULL) { printf("%d %d> %s\n", n, i, p); p = NULL; } } }