Skip to content

Commit

Permalink
WIP BROKEN libticonv, libtifiles, libticables, libticalcs: attempt to…
Browse files Browse the repository at this point in the history
… 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 .
  • Loading branch information
debrouxl committed Mar 12, 2024
1 parent a381501 commit 2c8a710
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 19 deletions.
1 change: 1 addition & 0 deletions libticonv/trunk/src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions libticonv/trunk/src/charset.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
10 changes: 5 additions & 5 deletions libticonv/trunk/src/filename.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions libticonv/trunk/src/ticonv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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:
{
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
}
82 changes: 74 additions & 8 deletions libticonv/trunk/src/tokens.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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
{
Expand Down Expand Up @@ -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
{
Expand All @@ -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
{
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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("________");
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion libticonv/trunk/tests/test_ticonv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand Down
7 changes: 4 additions & 3 deletions libticonv/trunk/tests/torture_ticonv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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\""

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 2c8a710

Please sign in to comment.