From: Keith M. <kei...@us...> - 2007-05-09 22:43:57
|
Update of /cvsroot/mingw/catgets In directory sc8-pr-cvs16:/tmp/cvs-serv23041 Modified Files: ChangeLog catopen.c Log Message: Provide more robust handling of possibly incomplete LC_MESSAGES macro expansions, when parsing NLSPATH. Index: catopen.c =================================================================== RCS file: /cvsroot/mingw/catgets/catopen.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** catopen.c 20 Apr 2007 22:24:02 -0000 1.2 --- catopen.c 9 May 2007 22:43:51 -0000 1.3 *************** *** 127,130 **** --- 127,157 ---- static + int mc_check_break_code( wchar_t chk, wchar_t *break_code ) + { + /* Helper function, called by `mc_nlspath_open; + * it checks a given character against each of the + * contextually valid delimiters, to establish where + * to split the LC_MESSAGES string into components. + */ + if( chk ) + { + /* If we haven't run out of characters to parse... + */ + while( *break_code ) + { + /* Check the current character against each valid delimiter, + * and return the character code if a match is found. + */ + if( chk == *break_code++ ) + return (int)(chk); + } + } + /* Fall through on no match, + * returning zero, to tell `mc_nlspath_open' to keep parsing. + */ + return 0; + } + + static int mc_nlspath_open( __const char *msgcat, unsigned flags ) { *************** *** 276,297 **** || ((nls_locale = setlocale( LC_MESSAGES, NULL )) != NULL) ) { - wchar_t break_code = L'\0'; subst = nls_locale; ! if( chk == L'l' ) { ! break_code = L'_'; } else if( (chk == L't') || (chk == L'c') ) { ! break_code = (chk == L't') ? L'_' : L'.'; do subst += (copy_index = mbtowc( &chk, subst, MB_CUR_MAX )); ! while( (copy_index > 0) && (chk != break_code) ); ! break_code = (break_code == L'_') ? L'.' : L'\0'; } while( ((copy_index = mbtowc( &chk, subst, MB_CUR_MAX )) > 0) ! && (chk != break_code) ) { if( headroom > copy_index ) --- 303,326 ---- || ((nls_locale = setlocale( LC_MESSAGES, NULL )) != NULL) ) { subst = nls_locale; + wchar_t *break_code = L"_.@"; ! if( chk == L'L' ) { ! break_code += 3; } else if( (chk == L't') || (chk == L'c') ) { ! if( chk == L'c' ) ! ++break_code; do subst += (copy_index = mbtowc( &chk, subst, MB_CUR_MAX )); ! while( (copy_index > 0) && (chk != *break_code) ); ! if( *++break_code == L'@' ) ! ++break_code; } while( ((copy_index = mbtowc( &chk, subst, MB_CUR_MAX )) > 0) ! && ! mc_check_break_code( chk, break_code ) ) { if( headroom > copy_index ) Index: ChangeLog =================================================================== RCS file: /cvsroot/mingw/catgets/ChangeLog,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ChangeLog 20 Apr 2007 22:24:02 -0000 1.2 --- ChangeLog 9 May 2007 22:43:51 -0000 1.3 *************** *** 1,2 **** --- 1,11 ---- + 2007-05-09 Keith Marshall <kei...@us...> + + Provide more robust handling of possibly incomplete LC_MESSAGES macro + expansions, when parsing NLSPATH. + + * catopen.c (mc_check_break_code): New function. + (mc_nlspath_open): Use it to identify break points, when splitting + LC_MESSAGES string into its component parts. + 2007-04-20 Keith Marshall <kei...@us...> |