-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Getting much closer to 'real' locale support now.
git-svn-id: svn://rootdirectory.ddns.net/pdclib/trunk@743 bcf39385-58cc-4174-9fcf-14f50f90dd47
- Loading branch information
Showing
13 changed files
with
576 additions
and
328 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* _PDCLIB_load_lc_messages( const char *, const char * ) | ||
This file is part of the Public Domain C Library (PDCLib). | ||
Permission is granted to use, modify, and / or redistribute at will. | ||
*/ | ||
|
||
#ifndef REGTEST | ||
|
||
#include <locale.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
#include "pdclib/_PDCLIB_int.h" | ||
|
||
struct _PDCLIB_lc_messages_t * _PDCLIB_load_lc_messages( const char * path, const char * locale ) | ||
{ | ||
struct _PDCLIB_lc_messages_t * rc = NULL; | ||
const char * extension = "_messages.dat"; | ||
char * file = malloc( strlen( path ) + strlen( locale ) + strlen( extension ) + 1 ); | ||
|
||
if ( file ) | ||
{ | ||
FILE * fh; | ||
|
||
strcpy( file, path ); | ||
strcat( file, locale ); | ||
strcat( file, extension ); | ||
|
||
if ( ( fh = fopen( file, "rb" ) ) != NULL ) | ||
{ | ||
if ( ( rc = malloc( sizeof( struct _PDCLIB_lc_messages_t ) ) ) != NULL ) | ||
{ | ||
char * data = _PDCLIB_load_lines( fh, _PDCLIB_ERRNO_MAX ); | ||
|
||
rc->alloced = 1; | ||
|
||
if ( data != NULL ) | ||
{ | ||
size_t i; | ||
|
||
for ( i = 0; i < _PDCLIB_ERRNO_MAX; ++i ) | ||
{ | ||
rc->errno_texts[ i ] = data; | ||
data += strlen( data ) + 1; | ||
} | ||
} | ||
else | ||
{ | ||
free( rc ); | ||
rc = NULL; | ||
} | ||
} | ||
|
||
fclose( fh ); | ||
} | ||
|
||
free( file ); | ||
} | ||
|
||
return rc; | ||
} | ||
|
||
#endif | ||
|
||
#ifdef TEST | ||
|
||
#include "_PDCLIB_test.h" | ||
|
||
int main( void ) | ||
{ | ||
#ifndef REGTEST | ||
FILE * fh = fopen( "test_numeric.dat", "wb" ); | ||
struct _PDCLIB_lc_lconv_numeric_t * lc; | ||
TESTCASE( fh != NULL ); | ||
TESTCASE( fputs( ",\n.\n\n", fh ) != EOF ); | ||
fclose( fh ); | ||
TESTCASE( ( lc = _PDCLIB_load_lc_numeric( "./", "test" ) ) ); | ||
remove( "test_numeric.dat" ); | ||
TESTCASE( strcmp( lc->decimal_point, "," ) == 0 ); | ||
TESTCASE( strcmp( lc->thousands_sep, "." ) == 0 ); | ||
TESTCASE( strcmp( lc->grouping, "" ) == 0 ); | ||
#endif | ||
|
||
return TEST_RESULTS; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.