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.
  • Loading branch information
debrouxl committed Jun 9, 2024
1 parent 3e91d44 commit 0f95c42
Show file tree
Hide file tree
Showing 14 changed files with 74 additions and 66 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;
}
}
15 changes: 8 additions & 7 deletions libticonv/trunk/src/tokens.cc
Original file line number Diff line number Diff line change
Expand Up @@ -172,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 @@ -335,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 @@ -350,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 @@ -489,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 @@ -555,6 +555,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
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
4 changes: 2 additions & 2 deletions libtifiles/trunk/src/cert.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ int TICALL tifiles_cert_field_get(const uint8_t *data, uint32_t length, uint16_t
}

// Retrieve field ID and number of additional bytes we need to read for the field's size.
const uint16_t field_id = (((uint16_t)data[0]) << 8) | data[1];
const uint16_t field_id = (((uint16_t)data[0]) << 8) | (uint16_t)data[1];
switch (field_id & 0xF)
{
case 0xD: additional_len = 1; break;
Expand Down Expand Up @@ -145,7 +145,7 @@ int TICALL tifiles_cert_field_next(const uint8_t **data, uint32_t *length)
const int ret = tifiles_cert_field_get(*data, *length, nullptr, &contents, &field_size);
if (!ret)
{
*length -= contents + field_size - *data;
*length -= (uint32_t)((contents + field_size) - *data);
*data = contents + field_size;
}

Expand Down
Loading

0 comments on commit 0f95c42

Please sign in to comment.