From: Owen Shepherd Date: Tue, 30 Apr 2013 21:16:55 +0000 (+0100) Subject: PDCLIB-25 #resolve #comment Made ctype, wctype and codec data const.(This may be... X-Git-Url: https://pd.if.org/git/?p=pdclib;a=commitdiff_plain;h=4b1f856ea2b21f30b6af8d4cca7129ebc84d3d6f PDCLIB-25 #resolve #comment Made ctype, wctype and codec data const.(This may be re-evaluated when implementing newlocale+setlocale) --- diff --git a/functions/locale/UnicodeData.py b/functions/locale/UnicodeData.py index 7de35bd..eb0f3c3 100644 --- a/functions/locale/UnicodeData.py +++ b/functions/locale/UnicodeData.py @@ -109,7 +109,7 @@ try: #ifndef REGTEST #include <_PDCLIB_locale.h> - _PDCLIB_wcinfo_t _PDCLIB_wcinfo[] = { +const _PDCLIB_wcinfo_t _PDCLIB_wcinfo[] = { // { value,\tflags,\tlower,\tupper\t}, // name """) for line in in_file: @@ -129,7 +129,7 @@ try: num, bits, lower_case, upper_case, name)) out_file.write('};\n\n') out_file.write(""" -size_t _PDCLIB_wcinfo_size = sizeof(_PDCLIB_wcinfo) / sizeof(_PDCLIB_wcinfo[0]); +const size_t _PDCLIB_wcinfo_size = sizeof(_PDCLIB_wcinfo) / sizeof(_PDCLIB_wcinfo[0]); #endif #ifdef TEST diff --git a/internals/_PDCLIB_locale.h b/internals/_PDCLIB_locale.h index fd47c9a..861b486 100644 --- a/internals/_PDCLIB_locale.h +++ b/internals/_PDCLIB_locale.h @@ -80,13 +80,14 @@ typedef struct _PDCLIB_wcinfo } _PDCLIB_wcinfo_t; struct _PDCLIB_locale { - _PDCLIB_charcodec_t _Codec; + const _PDCLIB_charcodec_t _Codec; struct lconv _Conv; /* ctype / wctype */ - _PDCLIB_wcinfo_t *_WCType; + /* XXX: Maybe re-evaluate constness of these later on? */ + const _PDCLIB_wcinfo_t *_WCType; _PDCLIB_size_t _WCTypeSize; - _PDCLIB_ctype_t *_CType; + const _PDCLIB_ctype_t *_CType; /* perror/strerror */ char *_ErrnoStr[_PDCLIB_ERRNO_MAX]; diff --git a/opt/basecodecs/_PDCLIB_ascii.c b/opt/basecodecs/_PDCLIB_ascii.c index efbc581..7c73d1b 100644 --- a/opt/basecodecs/_PDCLIB_ascii.c +++ b/opt/basecodecs/_PDCLIB_ascii.c @@ -62,7 +62,7 @@ static bool c32toascii( return true; } -struct _PDCLIB_charcodec _PDCLIB_ascii_codec = { +const struct _PDCLIB_charcodec _PDCLIB_ascii_codec = { .__mbsinit = ascii_mbsinit, .__mbstoc32s = asciitoc32, .__c32stombs = c32toascii, diff --git a/opt/basecodecs/_PDCLIB_latin1.c b/opt/basecodecs/_PDCLIB_latin1.c index 00d2f26..b9de8ca 100644 --- a/opt/basecodecs/_PDCLIB_latin1.c +++ b/opt/basecodecs/_PDCLIB_latin1.c @@ -60,7 +60,7 @@ static bool c32tolatin1( return true; } -struct _PDCLIB_charcodec _PDCLIB_latin1_codec = { +const struct _PDCLIB_charcodec _PDCLIB_latin1_codec = { .__mbsinit = latin1_mbsinit, .__mbstoc32s = latin1toc32, .__c32stombs = c32tolatin1, diff --git a/opt/basecodecs/_PDCLIB_utf8.c b/opt/basecodecs/_PDCLIB_utf8.c index a934541..22fa808 100644 --- a/opt/basecodecs/_PDCLIB_utf8.c +++ b/opt/basecodecs/_PDCLIB_utf8.c @@ -232,7 +232,7 @@ static bool c32toutf8( END_CONVERSION; } -struct _PDCLIB_charcodec _PDCLIB_utf8_codec = { +const struct _PDCLIB_charcodec _PDCLIB_utf8_codec = { .__mbsinit = utf8_mbsinit, .__mbstoc32s = utf8toc32, .__c32stombs = c32toutf8, diff --git a/platform/posix/functions/_PDCLIB/_PDCLIB_stdinit.c b/platform/posix/functions/_PDCLIB/_PDCLIB_stdinit.c index 0e562c6..77b5918 100644 --- a/platform/posix/functions/_PDCLIB/_PDCLIB_stdinit.c +++ b/platform/posix/functions/_PDCLIB/_PDCLIB_stdinit.c @@ -88,8 +88,7 @@ FILE * _PDCLIB_filelist = &_PDCLIB_sin; 1 kByte (+ 4 byte) of data. Each line: flags, lowercase, uppercase, collation. */ -static -_PDCLIB_ctype_t global_ctype[] = { +static const _PDCLIB_ctype_t global_ctype[] = { { /* EOF */ 0, 0, 0, 0 }, { /* NUL */ _PDCLIB_CTYPE_CNTRL, 0x00, 0x00, 0x00 }, { /* SOH */ _PDCLIB_CTYPE_CNTRL, 0x01, 0x01, 0x01 }, @@ -349,7 +348,7 @@ _PDCLIB_ctype_t global_ctype[] = { { 0x00, 0xFF, 0xFF, 0xFF } }; -extern struct _PDCLIB_charcodec _PDCLIB_ascii_codec; +extern const struct _PDCLIB_charcodec _PDCLIB_ascii_codec; struct _PDCLIB_locale _PDCLIB_global_locale = { ._Codec = &_PDCLIB_ascii_codec, ._Conv = { diff --git a/platform/win32/functions/_PDCLIB/_PDCLIB_stdinit.c b/platform/win32/functions/_PDCLIB/_PDCLIB_stdinit.c index 2d44fc3..b9c9109 100644 --- a/platform/win32/functions/_PDCLIB/_PDCLIB_stdinit.c +++ b/platform/win32/functions/_PDCLIB/_PDCLIB_stdinit.c @@ -85,8 +85,7 @@ tss_t _PDCLIB_locale_tss; 1 kByte (+ 4 byte) of data. Each line: flags, lowercase, uppercase, collation. */ -static -_PDCLIB_ctype_t global_ctype[] = { +static const _PDCLIB_ctype_t global_ctype[] = { { /* EOF */ 0, 0, 0, 0 }, { /* NUL */ _PDCLIB_CTYPE_CNTRL, 0x00, 0x00, 0x00 }, { /* SOH */ _PDCLIB_CTYPE_CNTRL, 0x01, 0x01, 0x01 }, @@ -346,7 +345,7 @@ _PDCLIB_ctype_t global_ctype[] = { { 0x00, 0xFF, 0xFF, 0xFF } }; -extern struct _PDCLIB_charcodec _PDCLIB_ascii_codec; +extern const struct _PDCLIB_charcodec _PDCLIB_ascii_codec; struct _PDCLIB_locale _PDCLIB_global_locale = { ._Codec = &_PDCLIB_ascii_codec, ._Conv = {