From 2c8a710870ddda6bb96248feb4f1df28f2c64d24 Mon Sep 17 00:00:00 2001 From: Lionel Debroux Date: Sun, 26 Nov 2023 23:48:03 +0100 Subject: [PATCH] WIP BROKEN libticonv, libtifiles, libticables, libticalcs: attempt to cope with a larger set of maintainer build flags - to be integrated to the CI later - which make GCC produce a large number of warnings. TODO move some of the hunks to earlier commits, e.g. libticonv/trunk/src/tokens.cc . --- libticonv/trunk/src/Makefile.am | 1 + libticonv/trunk/src/charset.cc | 4 +- libticonv/trunk/src/filename.cc | 10 ++-- libticonv/trunk/src/ticonv.cc | 3 + libticonv/trunk/src/tokens.cc | 82 +++++++++++++++++++++++--- libticonv/trunk/tests/test_ticonv.cc | 2 +- libticonv/trunk/tests/torture_ticonv.c | 7 ++- 7 files changed, 90 insertions(+), 19 deletions(-) diff --git a/libticonv/trunk/src/Makefile.am b/libticonv/trunk/src/Makefile.am index b97dbba42..6858532d0 100644 --- a/libticonv/trunk/src/Makefile.am +++ b/libticonv/trunk/src/Makefile.am @@ -32,4 +32,5 @@ if OS_MAC libticonv_la_LDFLAGS += -L/usr/local/opt/libiconv/lib/ libticonv_la_LIBADD += -liconv endif + libticonv_la_CPPFLAGS += -DUSE_ICONV endif \ No newline at end of file diff --git a/libticonv/trunk/src/charset.cc b/libticonv/trunk/src/charset.cc index 45c897fb8..3dc15cb25 100644 --- a/libticonv/trunk/src/charset.cc +++ b/libticonv/trunk/src/charset.cc @@ -127,14 +127,14 @@ static char * ticonv_utf16_to_nonusb(const unsigned long * charset, const unsign p++; } - *(q++) = c; + *(q++) = (unsigned char)c; // c < 256 if we come here... } else { *q = '?'; for (unsigned int i = 0; i < 256; i++) { if (charset[i] == c) { - *q = i; + *q = (unsigned char)i; break; } } diff --git a/libticonv/trunk/src/filename.cc b/libticonv/trunk/src/filename.cc index 2e86cedf0..1cdb874b2 100644 --- a/libticonv/trunk/src/filename.cc +++ b/libticonv/trunk/src/filename.cc @@ -57,7 +57,7 @@ char* TICALL ticonv_utf16_to_gfe(CalcModel model, const unsigned short *src) { const int is_utf8 = ticonv_environment_is_utf8(); const char *str; - unsigned short *utf16_src; + const unsigned short *utf16_src; unsigned short *utf16_dst; char *dst; @@ -67,7 +67,7 @@ char* TICALL ticonv_utf16_to_gfe(CalcModel model, const unsigned short *src) } // detokenization to UTF-16 - unsigned short* p = utf16_src = (unsigned short*)src; + const unsigned short* p = utf16_src = src; unsigned short* q = utf16_dst = (unsigned short*)g_malloc0(18 * ticonv_utf16_strlen(utf16_src) + 2); // conversion from UTF-16 to UTF-16 @@ -136,7 +136,7 @@ char* TICALL ticonv_utf16_to_gfe(CalcModel model, const unsigned short *src) { if (*p >= 0x2080 && *p <= 0x2089) { - *q++ = (*p++ - 0x2080) + '0'; + *q++ = (unsigned short)((*p++ - 0x2080) + '0'); } else { @@ -243,7 +243,7 @@ void TICALL ticonv_gfe_free(char *src) **/ char* TICALL ticonv_gfe_to_zfe(CalcModel model, const char *src_) { - char *src; + const char *src; char *dst; if (src_ == nullptr) @@ -256,7 +256,7 @@ char* TICALL ticonv_gfe_to_zfe(CalcModel model, const char *src_) // ticonv_utf16_to_gfe. if (!ticonv_environment_has_utf8_filenames()) return g_strdup(src_); - const char* p = src = (char*)src_; + const char* p = src = src_; char* q = dst = (char*)g_malloc0(18 * strlen(src) + 1); while(*p) diff --git a/libticonv/trunk/src/ticonv.cc b/libticonv/trunk/src/ticonv.cc index 02041d978..cc7d0e80d 100644 --- a/libticonv/trunk/src/ticonv.cc +++ b/libticonv/trunk/src/ticonv.cc @@ -221,6 +221,7 @@ char* TICALL ticonv_charset_utf16_to_ti_s(CalcModel model, const unsigned short return ti; } break; + case CALC_NONE: case CALC_TIPRESENTER: default: { @@ -343,6 +344,7 @@ unsigned short* TICALL ticonv_charset_ti_to_utf16_s(CalcModel model, const char return utf16; } break; + case CALC_NONE: case CALC_TIPRESENTER: default: utf16[0] = 0; return utf16; } @@ -1284,6 +1286,7 @@ CalcProductIDs TICALL ticonv_model_to_product_id(CalcModel model) case CALC_CBR2: return PRODUCT_ID_NONE; case CALC_LABPRO: return PRODUCT_ID_LABPRO; case CALC_TIPRESENTER: return PRODUCT_ID_TIPRESENTER; + case CALC_NONE: default: return PRODUCT_ID_NONE; } } diff --git a/libticonv/trunk/src/tokens.cc b/libticonv/trunk/src/tokens.cc index 1314c4914..f3d348ab5 100644 --- a/libticonv/trunk/src/tokens.cc +++ b/libticonv/trunk/src/tokens.cc @@ -122,7 +122,35 @@ static char *detokenize_vartype(CalcModel model, const char *src, unsigned char return (dst = g_strdup("ZRCL")); } break; - default: + case CALC_NONE: + case CALC_TI89: + case CALC_TI89T: + case CALC_TI92: + case CALC_TI92P: + case CALC_V200: + case CALC_TI89T_USB: + case CALC_NSPIRE: + case CALC_TI80: + case CALC_NSPIRE_CRADLE: + case CALC_NSPIRE_CLICKPAD: + case CALC_NSPIRE_CLICKPAD_CAS: + case CALC_NSPIRE_TOUCHPAD: + case CALC_NSPIRE_TOUCHPAD_CAS: + case CALC_NSPIRE_CX: + case CALC_NSPIRE_CX_CAS: + case CALC_NSPIRE_CMC: + case CALC_NSPIRE_CMC_CAS: + case CALC_NSPIRE_CXII: + case CALC_NSPIRE_CXII_CAS: + case CALC_NSPIRE_CXIIT: + case CALC_NSPIRE_CXIIT_CAS: + case CALC_CBL: + case CALC_CBR: + case CALC_CBL2: + case CALC_CBR2: + case CALC_LABPRO: + case CALC_TIPRESENTER: + default: break; } @@ -144,7 +172,7 @@ static char *detokenize_varname(CalcModel model, const char *src, unsigned char { if (tok2 != 0x09) { - dst = g_strdup_printf("Image%d", tok2 + 1); + dst = g_strdup_printf("Image%u", tok2 + 1); } else { @@ -307,11 +335,11 @@ static char *detokenize_varname(CalcModel model, const char *src, unsigned char case 0x60: /* Pictures */ if (model == CALC_TI73) { - dst = g_strdup_printf("Pic%d", tok2); + dst = g_strdup_printf("Pic%u", tok2); } else if (tok2 != 0x09) { - dst = g_strdup_printf("Pic%d", tok2 + 1); + dst = g_strdup_printf("Pic%u", tok2 + 1); } else { @@ -322,11 +350,11 @@ static char *detokenize_varname(CalcModel model, const char *src, unsigned char case 0x61: /* GDB */ if (model == CALC_TI73) { - dst = g_strdup_printf("GDB%d", tok2); + dst = g_strdup_printf("GDB%u", tok2); } else if (tok2 != 0x09) { - dst = g_strdup_printf("GDB%d", tok2 + 1); + dst = g_strdup_printf("GDB%u", tok2 + 1); } else { @@ -461,11 +489,11 @@ static char *detokenize_varname(CalcModel model, const char *src, unsigned char case 0xAA: if (model == CALC_TI73) { - dst = g_strdup_printf("Str%d", tok2); + dst = g_strdup_printf("Str%u", tok2); } else if (tok2 != 0x09) { - dst = g_strdup_printf("Str%d", tok2 + 1); + dst = g_strdup_printf("Str%u", tok2 + 1); } else { @@ -509,6 +537,7 @@ char* TICALL ticonv_varname_detokenize(CalcModel model, const char *src, unsigne case CALC_TI83P: case CALC_TI84P: case CALC_TI84PC: + case CALC_TI80: case CALC_CBL: // FIXME is that correct ? case CALC_CBR: case CALC_CBL2: @@ -527,6 +556,7 @@ char* TICALL ticonv_varname_detokenize(CalcModel model, const char *src, unsigne { return dst; } + return g_strdup(src); case CALC_TI89: case CALC_TI89T: case CALC_TI92: @@ -557,6 +587,7 @@ char* TICALL ticonv_varname_detokenize(CalcModel model, const char *src, unsigne case CALC_NSPIRE_CXIIT: case CALC_NSPIRE_CXIIT_CAS: return g_strdup(src); + case CALC_NONE: case CALC_TIPRESENTER: default: return g_strdup("________"); @@ -655,6 +686,41 @@ char* TICALL ticonv_varname_tokenize(CalcModel model, const char *src_, unsigned return g_strdup(""); } break; + case CALC_NONE: + case CALC_TI89: + case CALC_TI89T: + case CALC_TI92: + case CALC_TI92P: + case CALC_V200: + case CALC_TI84P_USB: + case CALC_TI89T_USB: + case CALC_NSPIRE: + case CALC_TI80: + case CALC_TI84PC_USB: + case CALC_TI83PCE_USB: + case CALC_TI84PCE_USB: + case CALC_TI82A_USB: + case CALC_TI84PT_USB: + case CALC_NSPIRE_CRADLE: + case CALC_NSPIRE_CLICKPAD: + case CALC_NSPIRE_CLICKPAD_CAS: + case CALC_NSPIRE_TOUCHPAD: + case CALC_NSPIRE_TOUCHPAD_CAS: + case CALC_NSPIRE_CX: + case CALC_NSPIRE_CX_CAS: + case CALC_NSPIRE_CMC: + case CALC_NSPIRE_CMC_CAS: + case CALC_NSPIRE_CXII: + case CALC_NSPIRE_CXII_CAS: + case CALC_NSPIRE_CXIIT: + case CALC_NSPIRE_CXIIT_CAS: + case CALC_TI82AEP_USB: + case CALC_CBL: + case CALC_CBR: + case CALC_CBL2: + case CALC_CBR2: + case CALC_LABPRO: + case CALC_TIPRESENTER: default: break; } diff --git a/libticonv/trunk/tests/test_ticonv.cc b/libticonv/trunk/tests/test_ticonv.cc index b2c4c8b41..43d3d9606 100644 --- a/libticonv/trunk/tests/test_ticonv.cc +++ b/libticonv/trunk/tests/test_ticonv.cc @@ -74,7 +74,7 @@ int main(int argc, char **argv) printf(" 0 1 2 3 4 5 6 7 8 9 A B C D E F\n"); - for(int i = 0; i < 16; i++) + for (unsigned int i = 0; i < 16; i++) { printf("%x ", i); for(int j = 0; j < 16; j++) diff --git a/libticonv/trunk/tests/torture_ticonv.c b/libticonv/trunk/tests/torture_ticonv.c index 87eaab224..92af2e550 100644 --- a/libticonv/trunk/tests/torture_ticonv.c +++ b/libticonv/trunk/tests/torture_ticonv.c @@ -14,7 +14,8 @@ fprintf(stderr, "%d\t" TYPE "\n", __LINE__, FUNCTION(__VA_ARGS__)) FUNCTION(__VA_ARGS__); fprintf(stderr, "%d\n", __LINE__) #define INT "%d" -#define SIZE "%zd" +#define UINT "%u" +#define SIZE "%zu" #define PTR "%p" #define STR "\"%s\"" @@ -84,7 +85,7 @@ int main(int argc, char **argv) PRINTF(ticonv_model_has_real_screen, INT, CALC_NONE); PRINTF(ticonv_model_has_monochrome_screen, INT, CALC_NONE); PRINTF(ticonv_model_has_color_screen, INT, CALC_NONE); - PRINTF(ticonv_model_to_product_id, INT, CALC_NONE); + PRINTF(ticonv_model_to_product_id, UINT, CALC_NONE); PRINTF(ticonv_varname_to_utf16_s, PTR, -1, NULL, (void *)0x12345678, 0); PRINTF(ticonv_varname_to_utf16_s, PTR, -1, (void *)0x12345678, NULL, 0); PRINTF(ticonv_varname_to_utf16, PTR, -1, NULL, 0); @@ -112,7 +113,7 @@ int main(int argc, char **argv) PRINTF(ticonv_varname_from_tifile, STR, -1, NULL, 0); PRINTF(ticonv_model_to_string, STR, CALC_NONE); - PRINTF(ticonv_string_to_model, INT, NULL); + PRINTF(ticonv_string_to_model, UINT, NULL); fprintf(stderr, "%d\t%p\n", __LINE__, ti73_charset); fprintf(stderr, "%d\t%p\n", __LINE__, ti80_charset); fprintf(stderr, "%d\t%p\n", __LINE__, ti82_charset);