WIP Windows fix
This commit is contained in:
parent
5e3b8b3b12
commit
5d268b1f36
7 changed files with 64 additions and 21 deletions
|
|
@ -36,7 +36,6 @@ elseif(SJ4_EMBED)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
sj4_library(sj4rkcv)
|
sj4_library(sj4rkcv)
|
||||||
sj4_library(sj4ime)
|
|
||||||
|
|
||||||
if(NOT SJ4_GLOBAL)
|
if(NOT SJ4_GLOBAL)
|
||||||
sj4_library(sj4lib)
|
sj4_library(sj4lib)
|
||||||
|
|
@ -46,6 +45,11 @@ if(NOT SJ4_GLOBAL)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT SJ4_GLOBAL)
|
||||||
|
sj4_library(sj4ime)
|
||||||
|
target_link_libraries(sj4ime PUBLIC sj4lib)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(SJ4_BUILD_TOOLS OR (NOT CMAKE_BINARY_DIR MATCHES CMAKE_CURRENT_SOURCE_DIR AND NOT SJ4_BUILD_ONLY_LIB))
|
if(SJ4_BUILD_TOOLS OR (NOT CMAKE_BINARY_DIR MATCHES CMAKE_CURRENT_SOURCE_DIR AND NOT SJ4_BUILD_ONLY_LIB))
|
||||||
file(GLOB_RECURSE SJ4MKDIC_SRCS src/sj4mkdic/**.c)
|
file(GLOB_RECURSE SJ4MKDIC_SRCS src/sj4mkdic/**.c)
|
||||||
add_executable(sj4mkdic ${SJ4MKDIC_SRCS})
|
add_executable(sj4mkdic ${SJ4MKDIC_SRCS})
|
||||||
|
|
|
||||||
18
include/sj4ime/sj4ime.h
Normal file
18
include/sj4ime/sj4ime.h
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
#ifndef __SJ4IME_H__
|
||||||
|
#define __SJ4IME_H__
|
||||||
|
|
||||||
|
#include <sj4lib.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct sj4ime Sj4Ime;
|
||||||
|
|
||||||
|
Sj4Ime* sj4_ime(int charset, const char* dict);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
#ifndef __SJ_IME_H__
|
|
||||||
#define __SJ_IME_H__
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1 +1,19 @@
|
||||||
#include <sj_ime.h>
|
#include <sj4ime.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
struct sj4ime {
|
||||||
|
Sj4Lib* lib;
|
||||||
|
};
|
||||||
|
|
||||||
|
Sj4Ime* sj4_ime(int charset, const char* dict) {
|
||||||
|
Sj4Ime* ime;
|
||||||
|
|
||||||
|
if((ime = calloc(1, sizeof(*ime))) == NULL) return NULL;
|
||||||
|
|
||||||
|
if((ime->lib = sj4_open(charset, dict)) == NULL) {
|
||||||
|
free(ime);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -209,12 +209,13 @@ void output_knj(FILE* fp, u_char* p, int l) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef UTF8
|
#ifdef UTF8
|
||||||
to[TO(to, euc, strlen(euc))] = 0;
|
if(fp == stdout || fp == stderr) {
|
||||||
|
to[TO(to, euc, strlen(euc))] = 0;
|
||||||
|
|
||||||
fputs(to, fp);
|
fputs(to, fp);
|
||||||
#else
|
} else
|
||||||
fputs(euc, fp);
|
|
||||||
#endif
|
#endif
|
||||||
|
fputs(euc, fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void output_str(FILE* fp, char* p) {
|
void output_str(FILE* fp, char* p) {
|
||||||
|
|
@ -302,15 +303,18 @@ void output_yomi(FILE* fp, u_char* p) {
|
||||||
i = yomi2zen(*p++);
|
i = yomi2zen(*p++);
|
||||||
|
|
||||||
#ifdef UTF8
|
#ifdef UTF8
|
||||||
euc[0] = (i >> 8) & 0xff;
|
if(fp == stdout || fp == stderr) {
|
||||||
euc[1] = i & 0xff;
|
euc[0] = (i >> 8) & 0xff;
|
||||||
|
euc[1] = i & 0xff;
|
||||||
|
|
||||||
to[TO(to, euc, 2)] = 0;
|
to[TO(to, euc, 2)] = 0;
|
||||||
|
|
||||||
fputs(to, fp);
|
fputs(to, fp);
|
||||||
#else
|
} else
|
||||||
fputc((i >> 8) & 0xff, fp);
|
|
||||||
fputc(i & 0xff, fp);
|
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
|
fputc((i >> 8) & 0xff, fp);
|
||||||
|
fputc(i & 0xff, fp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -110,8 +110,6 @@ readchar() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if((cod = unicode_to_eucjp(n)) == -1) {
|
if((cod = unicode_to_eucjp(n)) == -1) {
|
||||||
code = n;
|
|
||||||
|
|
||||||
return '[';
|
return '[';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -156,6 +154,8 @@ skip_blank() {
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "sj_charset.h"
|
||||||
|
|
||||||
static int
|
static int
|
||||||
readhinsi() {
|
readhinsi() {
|
||||||
static int c = 0;
|
static int c = 0;
|
||||||
|
|
@ -175,8 +175,6 @@ retry:
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; !Isblank(c);) {
|
for(i = 0; !Isblank(c);) {
|
||||||
int j = 0, k;
|
|
||||||
|
|
||||||
if(c == '\n' || c == ':')
|
if(c == '\n' || c == ':')
|
||||||
break;
|
break;
|
||||||
if(Isillegal(c))
|
if(Isillegal(c))
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
#else
|
#else
|
||||||
#define CHARSET SJ4UTF8
|
#define CHARSET SJ4UTF8
|
||||||
#endif
|
#endif
|
||||||
|
#define CHARSET SJ4UTF8
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
char c[8 * 1024];
|
char c[8 * 1024];
|
||||||
|
|
@ -39,7 +40,11 @@ int main(int argc, char** argv) {
|
||||||
while((strlen(c) - i) > 0 && (n = sj4_getkan(ctx, c + i, strlen(c + i), &kouho)) != 0) {
|
while((strlen(c) - i) > 0 && (n = sj4_getkan(ctx, c + i, strlen(c + i), &kouho)) != 0) {
|
||||||
printf(">");
|
printf(">");
|
||||||
do {
|
do {
|
||||||
|
#ifdef _WIN32
|
||||||
|
printf(" %s", kouho.buffer.sjis);
|
||||||
|
#else
|
||||||
printf(" %s", kouho.buffer.utf8);
|
printf(" %s", kouho.buffer.utf8);
|
||||||
|
#endif
|
||||||
} while(sj4_nextkan(ctx) != 0);
|
} while(sj4_nextkan(ctx) != 0);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue