llex.c 을 다음과 같이 수정하면 한글 변수,함수명등을 사용할수 있습니다. :) -- BL
+ #define ishan(c) (0xA0 < (c) && (c) < 0xFF)
static size_t readname (LexState *LS) {
:
- } while (isalnum(LS->current) || LS->current == '_');
+ } while (isalnum(LS->current) || ishan(LS->current) || LS->current == '_');
:
}
int luaX_lex (LexState *LS, SemInfo *seminfo) {
:
- else if (isalpha(LS->current) || LS->current == '_') {
+ else if (isalpha(LS->current) || ishan(LS->current) || LS->current == '_') {
:
}
Lua 4.0.1 에서는 int luaX_lex (...) 에 위 구문이 없다..
default:
if (!isalpha(LS->current)) {
를
default:
if (!isalpha(LS->current) && !ishan(LS->current)) {
로 바꾸면 된다. --파연
Lua 5.0 Final 에서는
int luaX_lex (LexState *LS, SemInfo *seminfo) {
:
default:
:
- else if (isalpha(LS->current) || LS->current == '_') {
+ else if (isalpha(LS->current) || ishan(LS->current) || LS->current == '_') {
:
}
로 바꾼다 ( default문 다음에 유의) --burnssun
Lua 5.1.1~Lua 5.1.4 에서는
llex.c:
+#define ishan(c) (0xA0 < (c) && (c) < 0xFF)
:
static int llex (LexState *ls, SemInfo *seminfo) {
:
default:
:
- else if (isalpha(ls->current) || ls->current == '_') {
+ else if (isalpha(ls->current) || ishan(ls->current) || ls->current == '_') {
:
- } while (isalnum(ls->current) || ls->current == '_');
+ } while (isalnum(ls->current) || ishan(ls->current) || ls->current == '_');
--Rica
KSC-5601 대신 UTF-8을 사용할 경우 ishan을 다음과 같이 수정한다:
#define ishan(c) (0x80 <= (c) && (c) <= 0xFF)
Lua 4.1 (work4) Copyright (C) 1994-2001 TeCGraf, PUC-Rio > 문자열 = "한글 루아!?" > 출력 = print > function 덧셈(왼쪽,오른쪽) >> return 왼쪽+오른쪽 >> end > 출력( 문자열, 덧셈(2000,2) ) 한글 루아!? 2002 >
ishan 매크로 수정 (KSC-5601 완성형 코드에 맞춤)
ishan 매크로 UTF-8 사용하는 경우 추가
lib/lstrlib.c 수정
static int match_class (int c, int cl) {
:
- case 'w' : res = isalnum(c) break;
+ case 'w' : res = isalnum(c) || ishan(c); break;
+ case 'h' : res = ishan(c); break;
:
}
Lua 4.1 (work4) Copyright (C) 1994-2001 TeCGraf, PUC-Rio > s = "ABC 가나다 123" > print(gsub(s, "(%w+)", "[%1]")) [ABC] [가나다] [123] 3 > print(gsub(s, "(%W+)", "[%1]")) ABC[ ]가나다[ ]123 2 > print(gsub(s, "(%h+)", "[%1]")) ABC [가나다] 123 1 > print(gsub(s, "(%H+)", "[%1]")) [ABC ]가나다[ 123] 2 >
한글패치한 실행파일을 GPG자료실 에 업로드 했습니다.
놀라워라!!!
| 제일 위로 |
| 최종 수정 일시: 02월 09일(2010년) 10:57 AM 편집 | 정보 | 차이 | 비슷한 페이지 DebugInfo |
| 유용한 페이지들: 분류 분류 | 자유로운 연습장 SandBox | 무작위 페이지들 RandomPages | 인기있는 페이지들 MostPopular |