diff options
author | jozan <jozan@noemail.net> | 2020-11-12 19:02:18 +0000 |
---|---|---|
committer | jozan <jozan@noemail.net> | 2020-11-12 19:02:18 +0000 |
commit | ff28ca95c0744bbcd30536faa169a12b1fbe5b32 (patch) | |
tree | 54e2ee2540544e8793ce313f20091da893ef3fe7 | |
parent | In progress (diff) | |
download | unixize-ff28ca95c0744bbcd30536faa169a12b1fbe5b32.tar.gz unixize-ff28ca95c0744bbcd30536faa169a12b1fbe5b32.tar.bz2 unixize-ff28ca95c0744bbcd30536faa169a12b1fbe5b32.tar.xz unixize-ff28ca95c0744bbcd30536faa169a12b1fbe5b32.tar.zst unixize-ff28ca95c0744bbcd30536faa169a12b1fbe5b32.zip |
Unicode in progress
FossilOrigin-Name: 9ec5167660a62e37c261456bc1b5d371c403803fec309dd855aa4e128ab4cfef
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | src/c_subst.c | 66 | ||||
-rw-r--r-- | src/c_subst.h | 12 | ||||
-rw-r--r-- | src/u_utils.c | 6 | ||||
-rw-r--r-- | src/u_utils.h | 2 |
5 files changed, 73 insertions, 14 deletions
@@ -28,7 +28,6 @@ CFLAGS = -std=c89 CFLAGS += -Wall CFLAGS += -Wextra CFLAGS += -Werror -CFLAGS += -Wno-unicode CFLAGS += -pedantic RM = rm -rf diff --git a/src/c_subst.c b/src/c_subst.c index 116336c..cc9823c 100644 --- a/src/c_subst.c +++ b/src/c_subst.c @@ -209,13 +209,71 @@ c_unicode_subst(char filename[]) p = (unsigned char*)filename; while (*p != 0x00) { if (*p == 0xc3) { - if (u_isucharset((unsigned char)*(p + 1), "\xa0\xb6") == TRUE) { - printf(">>>>{%hhx}\n", *p); - printf(">>>>{%hhx}\n", *(p + 1)); + if ( + u_isucharset((unsigned char)*(p + 1), C_CHARSET_A_MAJ) == TRUE || + u_isucharset((unsigned char)*(p + 1), C_CHARSET_A_MIN) == TRUE + ) { *p = 'a'; - memmove(p + 1, p + 2, (strlen((const char*)p + 2) + 1) * sizeof(char)); + memmove( + p + 1, + p + 2, + (strlen((const char*)p + 2) + 1) * sizeof(char) + ); c_unicode_subst(filename); } + if ( + u_isucharset((unsigned char)*(p + 1), C_CHARSET_O_MAJ) == TRUE || + u_isucharset((unsigned char)*(p + 1), C_CHARSET_O_MIN) == TRUE + ) { + *p = 'o'; + memmove( + p + 1, + p + 2, + (strlen((const char*)p + 2) + 1) * sizeof(char) + ); + c_unicode_subst(filename); + } + if (u_isucharset((unsigned char)*(p + 1), C_CHARSET_AE) == TRUE) { + *p = 'a'; + *(p + 1) = 'e'; + c_unicode_subst(filename); + } + if (u_isucharset((unsigned char)*(p + 1), C_CHARSET_N) == TRUE) { + *p = 'n'; + memmove( + p + 1, + p + 2, + (strlen((const char*)p + 2) + 1) * sizeof(char) + ); + c_unicode_subst(filename); + } + if (*(p + 1) == 0x72) { + *p = '2'; + memmove( + p + 1, + p + 2, + (strlen((const char*)p + 2) + 1) * sizeof(char) + ); + c_unicode_subst(filename); + } + if (*(p + 1) == 0x73) { + *p = '3'; + memmove( + p + 1, + p + 2, + (strlen((const char*)p + 2) + 1) * sizeof(char) + ); + c_unicode_subst(filename); + } + if (*(p + 1) == 0x75) { + *p = 'u'; + memmove( + p + 1, + p + 2, + (strlen((const char*)p + 2) + 1) * sizeof(char) + ); + c_unicode_subst(filename); + } } p++; } diff --git a/src/c_subst.h b/src/c_subst.h index fb4f16a..1a64621 100644 --- a/src/c_subst.h +++ b/src/c_subst.h @@ -50,11 +50,13 @@ #include "c_unixize.h" -#define C_CHARSET_VALID "_-." -#define C_CHARSET_A_MAJ "\u00c0\u00c1\u00c2\u00c3\u00c4\u00c5" -#define C_CHARSET_A_MIN "\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5" -#define C_CHARSET_O_MAJ "\u00d2\u00d3\u00d4\u00d5\u00d6\u00d8" -#define C_CHARSET_O_MIN "\u00f2\u00f3\u00f4\u00f5\u00f6\u00f8" +#define C_CHARSET_VALID "_-." +#define C_CHARSET_A_MAJ "\x80\x81\x82\x83\x84\x85" +#define C_CHARSET_A_MIN "\xa0\xa1\xa2\xa3\xa4\xa5" +#define C_CHARSET_O_MAJ "\x92\x93\x94\x95\x96\x98" +#define C_CHARSET_O_MIN "\xb2\xb3\xb4\xb5\xb6\xb8" +#define C_CHARSET_AE "\x86\xa6" +#define C_CHARSET_N "\x91\xb1" struct lfiles_s* c_subst_filenames(struct lfiles_s*, const bool_t, const bool_t, const unsigned char); diff --git a/src/u_utils.c b/src/u_utils.c index 88f768c..a2ad0a4 100644 --- a/src/u_utils.c +++ b/src/u_utils.c @@ -260,11 +260,11 @@ u_ischarset bool_t u_isucharset (const unsigned char c, - const unsigned char cs[]) + const char cs[]) { - char *p; + unsigned char *p; - p = (char*)cs; + p = (unsigned char*)cs; while (*p != 0x00 && *p != c) { p++; } diff --git a/src/u_utils.h b/src/u_utils.h index 9c04055..c966cf2 100644 --- a/src/u_utils.h +++ b/src/u_utils.h @@ -55,4 +55,4 @@ char** u_get_nargv(struct opts_s*); void u_increase_subpath(char[], const char[]); void u_decrease_subpath(char[]); bool_t u_ischarset(const int, const char[]); -bool_t u_isucharset(const unsigned char, const unsigned char[]); +bool_t u_isucharset(const unsigned char, const char[]); |