1 /* # skkinput (Simple Kana-Kanji Input)
2 * parseStr.c
3 * This file is part of skkinput.
4 * Copyright (C) 1997
5 * Takashi SAKAMOTO (sakamoto@yajima.kuis.kyoto-u.ac.jp)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with skkinput; see the file COPYING. If not, write to
19 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <X11/X.h>
25 #include <X11/Xlib.h>
26
27 #include "commondef.h"
28 #include "skkkey.h"
29 #include "kanji.h"
30
31 /*
32 * parseStr.c ��Ǥζɽ�Ū�������
33 */
34 struct keyToMask {
35 unsigned char *string ;
36 long mask ;
37 } ;
38
39 /*
40 * �ޥ���������
41 */
42 #define forceLowerChr(chara) \
43 (( (chara) >= 'A' && (chara) <= 'Z' )? ((chara) - 'A' + 'a') : (chara))
44
45 /*
46 * �ץ�ȥ����������
47 */
48 #if 0
49 static void dump_buffer( unsigned short *buffer, int size ) ;
50 #endif
51
52 /*
53 * ����ʸ�����ɤ����Ф��ؿ���
54 */
skip_empty_symbols(struct myChar * ptr)55 struct myChar *skip_empty_symbols( struct myChar *ptr )
56 {
57 while( !IS_END_OF_STRING( *ptr ) ){
58 if( !IS_ASCII_EQUAL( *ptr, 0x20 ) &&
59 !IS_ASCII_EQUAL( *ptr, '\t' ) &&
60 !IS_ASCII_EQUAL( *ptr, '\n' ) &&
61 !IS_ASCII_EQUAL( *ptr, '\r' ) )
62 break ;
63 ptr ++ ;
64 }
65 return ptr ;
66 }
67
68 /*
69 * Ϳ����줿ʸ�������Ƭ��ʬ�˰��פ���ʸ����Ǥ��뤫�ɤ�����Ƚ�ꤹ��
70 * �ؿ�������������ʸ����ʸ���ζ��̤Ϥ��ʤ���
71 */
isPrefixString(unsigned char * masterstring,unsigned char * prefixstring)72 static int isPrefixString
73 ( unsigned char *masterstring, unsigned char *prefixstring )
74 {
75 while( *prefixstring != '\0' ){
76 /* ��ʸ������ʸ���ζ��̤ʤ�����Ӥ��ưۤʤ��硣*/
77 if( forceLowerChr( *masterstring ) != *prefixstring )
78 return False ;
79 /* ����ʸ�����ǧ��*/
80 masterstring ++ ;
81 prefixstring ++ ;
82 }
83 return True ;
84 }
85
86 /*
87 * X Resource ���Υ���������᤹��ؿ���
88 *---
89 * �����������δؿ�����᤹��Τϰ�ʸ�������Ǥ��롣ʸ����ʤ�����
90 * �Ƥ��̣�Ϥʤ���
91 */
parseXrLikeKeyString(unsigned char * string,KeySym * r_keysym,long * r_modifiers,long * r_checkModifiers)92 int parseXrLikeKeyString
93 ( unsigned char *string, KeySym *r_keysym,
94 long *r_modifiers, long *r_checkModifiers )
95 {
96 static struct keyToMask key_masks[] = {
97 { "shift", ShiftMask }, { "lock", LockMask },
98 { "cntrl", ControlMask }, { "mod1", Mod1Mask },
99 { NULL, 0L },
100 } ;
101 struct keyToMask *kptr ;
102
103 /* �����ʤ�Υ�������Ǥʤ������餫�� mask ��¸�ߤ����硣*/
104 if( *string != '<' ){
105 for( kptr = key_masks ; kptr->string != NULL ; kptr ++ )
106 if( isPrefixString( string, kptr->string ) ){
107 *r_modifiers = *r_checkModifiers = kptr->mask ;
108 string += strlen( kptr->string ) ;
109 break ;
110 }
111 /* �⤷��mask ���ְ�äƤ����顣*/
112 if( kptr->string == NULL )
113 return False ;
114 /* ������ "<" �����ޤ��ɤ����Ф���*/
115 while( *string != '<' ){
116 if( *string == '\0' || ( *string != ' ' && *string != '\t' ) )
117 return False ;
118 string ++ ;
119 }
120 }
121 /* ������ <key> �Ƚ�뤳�ȤˤʤäƤ��뤱�ɡ��ɤ����褦���ʡ�����
122 ��ȸ���٤����ʡ�*/
123 if( !isPrefixString( string, "<key>" ) )
124 return False ;
125 /* �Ĥ��ʸ����� keysym ���Ȼפ���*/
126 *r_keysym = XStringToKeysym( string + 5 ) ;
127 return True ;
128 }
129
parseXrLikeKeyStrings(unsigned char * string,struct XrLikeKey * keytbl)130 int parseXrLikeKeyStrings
131 ( unsigned char *string, struct XrLikeKey *keytbl )
132 {
133 unsigned char *buffer, *ptr, *tmppoint ;
134 int length = strlen( string ), num ;
135
136 buffer = malloc( sizeof( unsigned char ) * ( length + 1 ) ) ;
137 if( buffer == NULL )
138 return 0 ;
139 strcpy( buffer, string ) ;
140
141 tmppoint = buffer ;
142 num = 0 ;
143 for( ptr = buffer ; ; ptr ++ ){
144 switch( *ptr ){
145 case '\\' :
146 ptr ++ ;
147 if( *ptr == '\0' )
148 goto exit_loop ;
149 break ;
150 case ',' :
151 /* �������Ƚ�λ���֤�Ʊ�����ä��顢��ʸ����ʤΤ�̵�뤹�롣*/
152 if( tmppoint == ptr ){
153 tmppoint ++ ;
154 break ;
155 }
156 /* ��Ͽ�����褬����Τʤ顢�ºݤ˲�᤹�롣*/
157 if( keytbl != NULL ){
158 /* �����ǰ�ö�ѹ������ꤹ��Τǡ�buffer �� copy ��ȤäƤ�����
159 ����櫓�Ǥ��롣�⤷������ȡ�writable �Ǥʤ�ʸ������뤫
160 �⤷��ʤ����顣�������ˤ˸ƤФ�뤳�ȤϤʤ��Τǡ�malloc ��
161 free ���֤��Ƥ�����פ�Ȧ�Ǥ��롣*/
162 *ptr = '\0' ;
163 if( parseXrLikeKeyString
164 ( tmppoint, &keytbl->keysym, &keytbl->modifiers,
165 &keytbl->checkModifiers ) ){
166 /* ̵���˲����褿�顢�������Ͽ���Ƽ���ʸ���ؤȸ�������*/
167 keytbl ++ ;
168 num ++ ;
169 }
170 /* separator �ϥ���ޤʤ櫓�Ǥ��롣*/
171 *ptr = ',' ;
172 } else {
173 num ++ ;
174 }
175 tmppoint = ptr + 1 ;
176 break ;
177 case '\0' :
178 /* �������Ƚ�λ���֤�Ʊ�����ä��顢��ʸ����ʤΤ�̵�뤹�롣*/
179 if( tmppoint != ptr ){
180 if( keytbl != NULL ){
181 if( parseXrLikeKeyString
182 ( tmppoint, &keytbl->keysym, &keytbl->modifiers,
183 &keytbl->checkModifiers ) ){
184 /* ̵���˲����褿�顢�������Ͽ���Ƽ���ʸ���ؤȸ�������*/
185 keytbl ++ ;
186 num ++ ;
187 }
188 } else {
189 num ++ ;
190 }
191 }
192 goto exit_loop ;
193 default :
194 break ;
195 }
196 }
197 exit_loop:
198 free( buffer ) ;
199 return num ;
200 }
201
202 /*
203 * �ݥ��ǻؤ������줿���ɥ쥹����³��ʸ����� 8 �ʿ��ο��ͤȤߤƲ�
204 * �᤹��ؿ���
205 *----
206 * ��������127 ��Ķ���ʤ��褦�˸��롣
207 */
parseOctNumber(struct myChar * string,struct myChar * dest)208 int parseOctNumber
209 ( struct myChar *string, struct myChar *dest )
210 {
211 int counter = 0, num = 0 ;
212 while( IS_ASCII_CHARA( *string ) &&
213 string->chara >= '0' && string->chara < '8' ){
214 num = ( num << 3 ) | ( string->chara - '0' ) ;
215 /* ����ʿ��ͤ�����ʤ��褦�ˤʤäƤ��롣����Ǥ���Τϡ�char ����
216 �������� */
217 if( num > 127 ){
218 num = num >> 3 ;
219 break ;
220 }
221 counter ++ ;
222 string ++ ;
223 }
224 if( dest != NULL ){
225 dest->charset = CHARSET_ASCII ;
226 dest->chara = num ;
227 }
228 return counter ;
229 }
230
231 /*
232 * �ݥ��ǻؤ������줿���ɥ쥹����³��ʸ����� 16 �ʿ��ο��ͤȤߤƲ�
233 * �᤹��ؿ���
234 *----
235 * ��������127 ��Ķ���ʤ��褦�˸��롣
236 */
parseHexNumber(struct myChar * string,struct myChar * dest)237 int parseHexNumber
238 ( struct myChar *string, struct myChar *dest )
239 {
240 int counter = 0, num = 0 ;
241 while( 1 ){
242 if( !IS_ASCII_CHARA( *string ) )
243 break ;
244 /* 16�ʤλ���Ȥ��Ʋ�ǽ�ʤΤϡ�0 ���� 9 �� a ���� f �ޤǡ�*/
245 if( string->chara >= '0' && string->chara <= '9' ){
246 num = ( num << 4 ) | ( string->chara - '0' ) ;
247 } else if( string->chara >= 'a' && string->chara <= 'f' ){
248 num = ( num << 4 ) | ( string->chara - 'a' + 10 ) ;
249 } else if( string->chara >= 'A' && string->chara <= 'F' ){
250 num = ( num << 4 ) | ( string->chara - 'A' + 10 ) ;
251 } else {
252 break ;
253 }
254 /* ����ʿ��ͤ�����ʤ��褦�ˤʤäƤ��롣����Ǥ���Τϡ�char ����
255 �������� */
256 if( num > 127 ){
257 num = num >> 4 ;
258 break ;
259 }
260 counter ++ ;
261 string ++ ;
262 }
263 if( dest != NULL ){
264 dest->charset = CHARSET_ASCII ;
265 dest->chara = num ;
266 }
267 return counter ;
268 }
269
270 /*
271 * backslash �θ��³���ü쵭����ڤ�Τ����Ѥ����ؿ���
272 */
parseBackslashControl(struct myChar * string,struct myChar * dest)273 int parseBackslashControl
274 ( struct myChar *string, struct myChar *dest )
275 {
276 static unsigned char *cntrlKeys = "@abcdefghijklmnopqrstuvwxyz[\\]^_" ;
277 unsigned char *ptr ;
278 static unsigned char *miscKeys[] = {
279 "Home", "Left", "Up", "Right",
280 "Down", "PageUp", "PageDown", "End",
281 "Begin", "Insert", "Clear", "Help",
282 "Break", "Henkan_Mode", "Muhenkan", "F1",
283 "F2", "F3", "F4", "F5",
284 "F6", "F7", "F8", "F9",
285 "F10", "F11", "F12", NULL,
286 } ;
287 struct myChar lchara ;
288 int i, len ;
289
290 /* ³��ʸ���� ASCII �Ǥʤ�������ܡ�*/
291 if( !IS_ASCII_CHARA( *string ) || IS_END_OF_STRING( *string ) )
292 return ERR ;
293
294 if( string->chara >= '0' && string->chara < '8' ){
295 /* ³��ʸ����� 8�ʿ��ˤ��ľ�ܥ����ɻ��ꡣ*/
296 return parseOctNumber( string, dest ) ;
297 } else if( string->chara == 'x' ){
298 /* ³��ʸ����� 16�ʿ��ˤ��ľ�ܥ����ɻ��ꡣ*/
299 string ++ ;
300 return parseHexNumber( string, dest ) ;
301 }
302 /* �����Ǥʤ����ˤϡġ�*/
303 if( IS_ASCII_EQUAL( string[ 1 ], '-' ) ){
304 if( IS_END_OF_STRING( string[ 2 ] ) ){
305 return ERR ;
306 }
307 switch( string->chara ){
308 /* ����ȥ��륭���λ���Ǥ��ä���硣*/
309 case 'C' :
310 if( IS_ASCII_EQUAL( string[ 2 ], '\\' ) ){
311 if( IS_ASCII_EQUAL( string[ 3 ], '\\' ) ){
312 /* backslash �ξ������³���ʤ������ܤ���͡�*/
313 if( dest != NULL ){
314 dest->charset = CHARSET_ASCII ;
315 dest->chara = 28 ;
316 }
317 return 4 ;
318 } else {
319 /* �⤦���١�����Ϥ��롣*/
320 len = parseBackslashControl( string + 3, &lchara ) ;
321 if( len < 0 )
322 return ERR ;
323 /* �����Υ����ξ��ˤ����̤˥���ȥ����դ����᤹�롣
324 * ���������ƤΥ����������ɤ͡ġ��Ǥ⤽���ޤǤ���ȽŤ�
325 * �ʤ�����Τ褦�ʵ������뤫�餷�ޤ����⤽�⤳����
326 * ������Τ⡢Insert ��Ȥ������ä����α�Ĺ�ʤ�Ǥ���
327 */
328 if( lchara.chara >= CHARA_HOME &&
329 lchara.chara < NUMBER_OF_KEYS ){
330 lchara.chara = lchara.chara | 1 ;
331 }
332 if( dest != NULL )
333 *dest = lchara ;
334 return ( len + 3 ) ;
335 }
336 } else {
337 /* Control �λ���Ȥ���������ʸ������Ƥ��뤫�ɤ�����Ĵ�٤롣*/
338 for( ptr = cntrlKeys ; *ptr != '\0' ; ptr ++ ){
339 if( IS_ASCII_EQUAL( string[ 2 ], *ptr ) ){
340 /* ������ʸ�����褿�� */
341 if( dest != NULL ){
342 dest->charset = CHARSET_ASCII ;
343 dest->chara = ptr - cntrlKeys ;
344 }
345 return 3 ;
346 }
347 }
348 }
349 /* �����Control+Space �� C-@ ��Ʊ����ΤȤ��ư�����*/
350 if( IS_ASCII_EQUAL( string[ 2 ], ' ' ) ){
351 if( dest != NULL ){
352 dest->charset = CHARSET_ASCII ;
353 dest->chara = '\0' ;
354 }
355 return 3 ;
356 }
357 return ERR ;
358
359 /* ESC �����λ���Ǥ��ä���硣*/
360 case 'M' :
361 if( dest != NULL ){
362 dest->charset = CHARSET_ASCII ;
363 dest->chara = 0x1b ;
364 }
365 return 2 ;
366 }
367 }
368 /* ����ʳ�������ʸ������ä����ɤ�����Ƚ�Ǥ��롣*/
369 for( i = 0 ; miscKeys[ i ] != NULL ; i ++ ){
370 int len = strlen( miscKeys[ i ] ) ;
371 if( !myCharCharStrncmp( string, miscKeys[ i ], len ) ){
372 if( dest != NULL ){
373 dest->charset = CHARSET_ASCII ;
374 dest->chara = CHARA_HOME + ( i << 1 ) ;
375 }
376 return len ;
377 }
378 }
379 return ERR ;
380 }
381
382 /*
383 * emacs-like �ʥ���������᤹��Τ����Ѥ����ؿ���
384 * buffer �� NULL �����줿���ˤ�ɬ�פȤʤ� short ��������礭������
385 * ���褦�ˤʤäƤ��롣
386 */
parseKeyString(struct myChar * string,struct myChar * buffer,int bufsize)387 int parseKeyString
388 ( struct myChar *string, struct myChar *buffer, int bufsize )
389 {
390 int i, ret, uselen ;
391
392 uselen = 0 ;
393 for( i = 0 ; !IS_END_OF_STRING( *string ) ; i ++ ){
394 /* �Хåե���Ȥ��ڤäƤʤ����ɤ��������å����롣*/
395 if( buffer != NULL && uselen >= bufsize )
396 break ;
397 /* �Хå�����å��夬�褿��硩 */
398 if( IS_ASCII_EQUAL( *string, '\\' ) ){
399 string ++ ;
400 /* �����Ǥ����ʤ�ʸ�����ڤ줿�ꤹ��Ȥ�����ѤǤ��롣*/
401 if( IS_END_OF_STRING( *string ) )
402 return 0 ;
403 if( IS_ASCII_EQUAL( *string, '\\' ) ){
404 if( buffer != NULL )
405 *buffer ++ = *string ;
406 uselen ++ ;
407 string ++ ;
408 } else {
409 /* �Хå�����³��ʸ���β��롣*/
410 if( ( ret = parseBackslashControl( string, buffer ) ) <= 0 ){
411 if( buffer != NULL )
412 *buffer ++ = *string ;
413 uselen ++ ;
414 /* �����äȼ��Ԥ����鲿����̵���ä��Τ��Τ褦�˼��ؤȰ�ư��
415 * �Ƥ���ġ�*/
416 string ++ ;
417 } else {
418 /* buffer + 0 �ˤ� parseBackslashControl �η�̤����äƤ���
419 * �Τǡ����ؤ����뤳�Ȥˤ��롣*/
420 buffer ++ ;
421 uselen ++ ;
422 /* ��ᤷ��ʬ�������롣*/
423 string += ret ;
424 }
425 }
426 } else {
427 /* ����ʳ���ʸ�����褿���ν�����*/
428 if( buffer != NULL )
429 *buffer ++ = *string ;
430 uselen ++ ;
431 string ++ ;
432 }
433 }
434 return uselen ;
435 }
436
437 /*
438 * ³�� double quote �ǰϤޤ줿ʸ����� emacs-lisp ����ʸ����������
439 * ����Ȳ�ᤷ�ơ����η�̤� short ������Ȥ����֤��ؿ���result �ˤϡ�
440 * ��������Υ����������롣����ä��饨�顼�ˤʤ롣
441 */
parseString(struct myChar * string,struct myChar ** dest,int * result)442 struct myChar *parseString
443 ( struct myChar *string, struct myChar **dest, int *result )
444 {
445 struct myChar *start, *ptr ;
446 int len ;
447
448 /* �ޤ���̤ϲ���ФƤ��ʤ������ꤷ�Ƥ�����*/
449 *dest = NULL ;
450 *result = -1 ;
451 /* �ǽ�˶���¸�ߤ��Ƥ�����פʤ褦���ɤ����Ф���*/
452 string = skip_empty_symbols( string ) ;
453 /* ʸ����γ��ϵ���Ǥ��� double quote ��̵����С����顼�Ǥ��롣*/
454 if( !IS_ASCII_EQUAL( *string, 0x22 ) )
455 return string ;
456 string ++ ;
457 start = string ;
458 /* ʸ�������Ȥ�Ĵ�٤롣*/
459 while( !IS_END_OF_STRING( *string ) &&
460 !IS_ASCII_EQUAL( *string, 0x22 ) ){
461 /* �⤷���� double quote �����줿���Ȥ���������ä����ˡġ�*/
462 if( IS_ASCII_EQUAL( *string, '\\' ) ){
463 string ++ ;
464 /* ������ʸ������äƤ��ޤä��顢�ѡ�*/
465 if( IS_END_OF_STRING( *string ) )
466 return string ;
467 }
468 string ++ ;
469 }
470 /* ���ơ��ɤ��ޤǹԤä����ʡ� */
471 if( !IS_ASCII_EQUAL( *string, 0x22 ) ){
472 return string ;
473 }
474 /* ��ʸ���������ġ�*/
475 if( string == start ){
476 /* ����ʸ�������äƤʤ�����������ȥ��֥륯�������Ȥǽ�ü���� *
477 * �Ƥʤ���*/
478 *dest = NULL ;
479 *result = 0 ;
480 string ++ ;
481 } else {
482 MYCHAR_SET_END_OF_STRING( *string ) ;
483 /* ���餫����ɬ�פ�ʸ�����Ĺ��������Ƥ�����*/
484 if( ( len = parseKeyString( start, NULL, 0 ) ) <= 0 ){
485 /* �����Ȥ��᤹��*/
486 MYCHAR_SET_CHARA( *string, 0x22 ) ;
487 string ++ ;
488 return string ;
489 }
490 /* ����ʸ�����Ĺ������malloc���ޤ���*/
491 ptr = malloc( ( len + 1 ) * sizeof( struct myChar ) ) ;
492 if( ptr != NULL ){
493 /* ��ᤷ����̤� dest ���������롣*/
494 parseKeyString( start, ptr, len ) ;
495 MYCHAR_SET_END_OF_STRING( ptr[ len ] ) ;
496 *dest = ptr ;
497 *result = len ;
498 }
499 /* ���Ѥ��Ƥ��ޤä�ʸ������Ȥ��᤹��*/
500 MYCHAR_SET_CHARA( *string, 0x22 ) ;
501 string ++ ;
502 }
503 return string ;
504 }
505
506 /*
507 * emacs-lisp �ˤ��� expand-file-name ����������ؿ���
508 *-----
509 * ���ֺǽ�� "~" �����ä����� home directory ��Ÿ�����뵡ǽ������
510 * �Ƥ��롣��������wild-card �ʤ�Ȥ��ˤ��б����Ƥ��ʤ���
511 * ���δؿ���Ƥ����̤� skk-local-jisyo-path �����뤳�Ȥˤʤ롣
512 * skk-local-jisyo-path �� NULL �Ǥʤ��ä��顢���δؿ���ƤФʤ�������
513 * ���Ȼפ����Ƥ�¦�Ǥ�¿ʬ���������å��Ǥ��ʤ��Τǡ������ǥ����å�
514 * ���롣
515 */
expand_file_name(unsigned char * path)516 unsigned char *expand_file_name( unsigned char *path )
517 {
518 unsigned char *ptr ;
519 unsigned char *home ;
520 int len = strlen( path ) ;
521
522 /* "~" �Ȥ��� home directory ��ɽ�����뵭�椬���äƤ������ν�����*/
523 if( *path == '~' ){
524 /* HOME Directory �����褫�����롣*/
525 home = getenv( "HOME" ) ;
526 /* Home directory + �Ĥ�Υѥ���Ĺ���� malloc ���롣*/
527 ptr = malloc( strlen( home ) + len + 1 ) ;
528 if( ptr == NULL ){
529 /* malloc ���ԡĤ������̿Ū�ʥ��顼�ʤΤǷ�³ư��Ϥ��ʤ���*/
530 fprintf( stderr, "Memory fault.\n" ) ;
531 exit( 1 ) ;
532 }
533 /* "~" ��Ÿ�����ơ���ľ����*/
534 strcpy( ptr, home ) ;
535 strcat( ptr, path + 1 ) ;
536 } else {
537 /* ����ɬ�פ�̵����硣*/
538 ptr = ( unsigned char *)malloc( len + 1 ) ;
539 strcpy( ptr, path ) ;
540 }
541 return ptr ;
542 }
543
544 #if 0
545 int main( int argc, char *argv[] )
546 {
547 unsigned short buffer[ 256 ] ;
548 int len ;
549 len = parseKeyString( "\\C-u\\M-xabc", buffer, 256 ) ;
550 dump_buffer( buffer, len ) ;
551 return 0 ;
552 }
553
554 #endif
555
dump_sstring(unsigned short * buffer,int size)556 void dump_sstring( unsigned short *buffer, int size )
557 {
558 int i ;
559 printf( "(dump_sstring)" ) ;
560 if( size == 0 ){
561 printf( "empty string" ) ;
562 }
563 for( i = 0 ; i < size; i ++ ){
564 printf( "%04x, ", buffer[ i ] ) ;
565 }
566 printf( "\n" ) ;
567 return ;
568 }
569
skip_charSpace(unsigned char ** string)570 static void skip_charSpace( unsigned char **string )
571 {
572 unsigned char *ptr = *string ;
573
574 while( *ptr != '\0' ){
575 if( *ptr != 0x20 && *ptr != '\t' && *ptr != '\n' &&
576 *ptr != '\r' )
577 break ;
578 ptr ++ ;
579 }
580 *string = ptr ;
581 return ;
582 }
583
getOneFontsetFromFontsetList(unsigned char ** string)584 unsigned char *getOneFontsetFromFontsetList( unsigned char **string )
585 {
586 unsigned char *ptr, *retstring = NULL ;
587 int length, next_chara_ignore ;
588
589 /* ��Ƭ�ζ���ʸ��������Ф���*/
590 skip_charSpace( string ) ;
591
592 next_chara_ignore = False ;
593 for( ptr = *string, length = 0 ; *ptr != '\0' ; ptr ++, length ++ ){
594 if( next_chara_ignore ){
595 next_chara_ignore = False ;
596 continue ;
597 }
598 /* "," �����դ���Ȥ����ޤǤ���ĤΥե���ȥ��å�̾�ˤʤ롣*/
599 if( *ptr == ',' ){
600 /* "," �����Ф����ߤ�������"," ��ޤ��ʸ���ԡ������ΤϷ�
601 * �������length �����䤵�ʤ���*/
602 ptr ++ ;
603 break ;
604 }
605 /* ����Τ��ɤ�����ʬ����ʤ����ɡ����ϼ���ʸ����̵�뤹���ΤȤ�
606 * ��ͽ�Ƥ�����*/
607 if( *ptr == '\\' ){
608 next_chara_ignore = True ;
609 }
610 }
611 /* ���դ���ޤ������� */
612 if( length > 0 ){
613 retstring = malloc( sizeof( unsigned char ) * ( length + 1 ) ) ;
614 if( retstring == NULL )
615 return NULL ;
616 strncpy( retstring, *string, length ) ;
617 retstring[ length ] = '\0' ;
618 }
619 *string = ptr ;
620 return retstring ;
621 }
622