1
0
Fork 0
forked from len0rd/rockbox

[BugFix] itoa conflicts with mingw rename to itoa_buf

Change-Id: Ife361f2fd8c8946db5bb2e0e58c0981b2ed3c5f3
This commit is contained in:
William Wilgus 2025-02-18 10:34:18 -05:00
parent ee4591d9e7
commit 50da856992
9 changed files with 45 additions and 46 deletions

View file

@ -256,7 +256,7 @@ const char *get_id3_token(struct wps_token *token, struct mp3entry *id3,
if (id3->disc_string) if (id3->disc_string)
return id3->disc_string; return id3->disc_string;
if (id3->discnum) { if (id3->discnum) {
itoa(buf, buf_size, id3->discnum); itoa_buf(buf, buf_size, id3->discnum);
return buf; return buf;
} }
return NULL; return NULL;
@ -264,7 +264,7 @@ const char *get_id3_token(struct wps_token *token, struct mp3entry *id3,
if (id3->track_string) if (id3->track_string)
return id3->track_string; return id3->track_string;
if (id3->tracknum) { if (id3->tracknum) {
itoa(buf, buf_size, id3->tracknum); itoa_buf(buf, buf_size, id3->tracknum);
return buf; return buf;
} }
return NULL; return NULL;
@ -291,7 +291,7 @@ const char *get_id3_token(struct wps_token *token, struct mp3entry *id3,
if( id3->year_string ) if( id3->year_string )
return id3->year_string; return id3->year_string;
if (id3->year) { if (id3->year) {
itoa(buf, buf_size, id3->year); itoa_buf(buf, buf_size, id3->year);
return buf; return buf;
} }
return NULL; return NULL;
@ -299,7 +299,7 @@ const char *get_id3_token(struct wps_token *token, struct mp3entry *id3,
return id3->comment; return id3->comment;
case SKIN_TOKEN_FILE_BITRATE: case SKIN_TOKEN_FILE_BITRATE:
if(id3->bitrate) if(id3->bitrate)
itoa(buf, buf_size, id3->bitrate); itoa_buf(buf, buf_size, id3->bitrate);
else else
return "?"; return "?";
return buf; return buf;
@ -360,12 +360,12 @@ const char *get_id3_token(struct wps_token *token, struct mp3entry *id3,
return get_codectype(id3); return get_codectype(id3);
case SKIN_TOKEN_FILE_FREQUENCY: case SKIN_TOKEN_FILE_FREQUENCY:
itoa(buf, buf_size, id3->frequency); itoa_buf(buf, buf_size, id3->frequency);
return buf; return buf;
case SKIN_TOKEN_FILE_FREQUENCY_KHZ: case SKIN_TOKEN_FILE_FREQUENCY_KHZ:
/* ignore remainders < 100, so 22050 Hz becomes just 22k */ /* ignore remainders < 100, so 22050 Hz becomes just 22k */
if ((id3->frequency % 1000) < 100) if ((id3->frequency % 1000) < 100)
itoa(buf, buf_size, id3->frequency / 1000); itoa_buf(buf, buf_size, id3->frequency / 1000);
else else
snprintf(buf, buf_size, "%ld.%lu", snprintf(buf, buf_size, "%ld.%lu",
id3->frequency / 1000, id3->frequency / 1000,
@ -374,24 +374,24 @@ const char *get_id3_token(struct wps_token *token, struct mp3entry *id3,
case SKIN_TOKEN_FILE_VBR: case SKIN_TOKEN_FILE_VBR:
return (id3->vbr) ? "(avg)" : NULL; return (id3->vbr) ? "(avg)" : NULL;
case SKIN_TOKEN_FILE_SIZE: case SKIN_TOKEN_FILE_SIZE:
itoa(buf, buf_size, id3->filesize / 1024); itoa_buf(buf, buf_size, id3->filesize / 1024);
return buf; return buf;
#ifdef HAVE_TAGCACHE #ifdef HAVE_TAGCACHE
case SKIN_TOKEN_DATABASE_PLAYCOUNT: case SKIN_TOKEN_DATABASE_PLAYCOUNT:
if (intval) if (intval)
*intval = id3->playcount + 1; *intval = id3->playcount + 1;
itoa(buf, buf_size, id3->playcount); itoa_buf(buf, buf_size, id3->playcount);
return buf; return buf;
case SKIN_TOKEN_DATABASE_RATING: case SKIN_TOKEN_DATABASE_RATING:
if (intval) if (intval)
*intval = id3->rating + 1; *intval = id3->rating + 1;
itoa(buf, buf_size, id3->rating); itoa_buf(buf, buf_size, id3->rating);
return buf; return buf;
case SKIN_TOKEN_DATABASE_AUTOSCORE: case SKIN_TOKEN_DATABASE_AUTOSCORE:
if (intval) if (intval)
*intval = id3->score + 1; *intval = id3->score + 1;
itoa(buf, buf_size, id3->score); itoa_buf(buf, buf_size, id3->score);
return buf; return buf;
#endif #endif
@ -473,7 +473,7 @@ const char *get_radio_token(struct wps_token *token, int preset_offset,
region_data->freq_step, buf, buf_size); region_data->freq_step, buf, buf_size);
#ifdef HAVE_RADIO_RSSI #ifdef HAVE_RADIO_RSSI
case SKIN_TOKEN_TUNER_RSSI: case SKIN_TOKEN_TUNER_RSSI:
itoa(buf, buf_size,tuner_get(RADIO_RSSI)); itoa_buf(buf, buf_size,tuner_get(RADIO_RSSI));
if (intval) if (intval)
{ {
int val = tuner_get(RADIO_RSSI); int val = tuner_get(RADIO_RSSI);
@ -490,10 +490,10 @@ const char *get_radio_token(struct wps_token *token, int preset_offset,
} }
return buf; return buf;
case SKIN_TOKEN_TUNER_RSSI_MIN: case SKIN_TOKEN_TUNER_RSSI_MIN:
itoa(buf, buf_size,tuner_get(RADIO_RSSI_MIN)); itoa_buf(buf, buf_size,tuner_get(RADIO_RSSI_MIN));
return buf; return buf;
case SKIN_TOKEN_TUNER_RSSI_MAX: case SKIN_TOKEN_TUNER_RSSI_MAX:
itoa(buf, buf_size,tuner_get(RADIO_RSSI_MAX)); itoa_buf(buf, buf_size,tuner_get(RADIO_RSSI_MAX));
return buf; return buf;
#endif #endif
case SKIN_TOKEN_PRESET_NAME: case SKIN_TOKEN_PRESET_NAME:
@ -515,11 +515,11 @@ const char *get_radio_token(struct wps_token *token, int preset_offset,
format_freq_MHz(radio_get_preset_freq(preset), format_freq_MHz(radio_get_preset_freq(preset),
region_data->freq_step, buf, buf_size); region_data->freq_step, buf, buf_size);
else else
itoa(buf, buf_size, preset + 1); itoa_buf(buf, buf_size, preset + 1);
return buf; return buf;
} }
case SKIN_TOKEN_PRESET_COUNT: case SKIN_TOKEN_PRESET_COUNT:
itoa(buf, buf_size, radio_preset_count()); itoa_buf(buf, buf_size, radio_preset_count());
if (intval) if (intval)
*intval = radio_preset_count(); *intval = radio_preset_count();
return buf; return buf;
@ -777,7 +777,7 @@ static const char* get_rtc_token_value(struct wps_token *token,
case SKIN_TOKEN_RTC_12HOUR_CFG: case SKIN_TOKEN_RTC_12HOUR_CFG:
itoa(buf, buf_size, global_settings.timeformat); itoa_buf(buf, buf_size, global_settings.timeformat);
numeric_ret = global_settings.timeformat + 1; numeric_ret = global_settings.timeformat + 1;
break; break;
case SKIN_TOKEN_RTC_DAY_OF_MONTH: case SKIN_TOKEN_RTC_DAY_OF_MONTH:
@ -1110,14 +1110,14 @@ const char *get_token_value(struct gui_wps *gwps,
case SKIN_TOKEN_PLAYLIST_ENTRIES: case SKIN_TOKEN_PLAYLIST_ENTRIES:
numeric_ret = playlist_amount(); numeric_ret = playlist_amount();
itoa(buf, buf_size, numeric_ret); itoa_buf(buf, buf_size, numeric_ret);
numeric_buf = buf; numeric_buf = buf;
goto gtv_ret_numeric_tag_info; goto gtv_ret_numeric_tag_info;
case SKIN_TOKEN_LIST_TITLE_TEXT: case SKIN_TOKEN_LIST_TITLE_TEXT:
return sb_get_title(gwps->display->screen_type); return sb_get_title(gwps->display->screen_type);
case SKIN_TOKEN_LIST_TITLE_ICON: case SKIN_TOKEN_LIST_TITLE_ICON:
numeric_ret = sb_get_icon(gwps->display->screen_type); numeric_ret = sb_get_icon(gwps->display->screen_type);
itoa(buf, buf_size, numeric_ret); itoa_buf(buf, buf_size, numeric_ret);
numeric_buf = buf; numeric_buf = buf;
goto gtv_ret_numeric_tag_info; goto gtv_ret_numeric_tag_info;
case SKIN_TOKEN_LIST_ITEM_TEXT: case SKIN_TOKEN_LIST_ITEM_TEXT:
@ -1128,17 +1128,17 @@ const char *get_token_value(struct gui_wps *gwps,
} }
case SKIN_TOKEN_LIST_ITEM_ROW: case SKIN_TOKEN_LIST_ITEM_ROW:
numeric_ret = skinlist_get_item_row() + 1; numeric_ret = skinlist_get_item_row() + 1;
itoa(buf, buf_size, numeric_ret); itoa_buf(buf, buf_size, numeric_ret);
numeric_buf = buf; numeric_buf = buf;
goto gtv_ret_numeric_tag_info; goto gtv_ret_numeric_tag_info;
case SKIN_TOKEN_LIST_ITEM_COLUMN: case SKIN_TOKEN_LIST_ITEM_COLUMN:
numeric_ret = skinlist_get_item_column() + 1; numeric_ret = skinlist_get_item_column() + 1;
itoa(buf, buf_size, numeric_ret); itoa_buf(buf, buf_size, numeric_ret);
numeric_buf = buf; numeric_buf = buf;
goto gtv_ret_numeric_tag_info; goto gtv_ret_numeric_tag_info;
case SKIN_TOKEN_LIST_ITEM_NUMBER: case SKIN_TOKEN_LIST_ITEM_NUMBER:
numeric_ret = skinlist_get_item_number() + 1; numeric_ret = skinlist_get_item_number() + 1;
itoa(buf, buf_size, numeric_ret); itoa_buf(buf, buf_size, numeric_ret);
numeric_buf = buf; numeric_buf = buf;
goto gtv_ret_numeric_tag_info; goto gtv_ret_numeric_tag_info;
case SKIN_TOKEN_LIST_ITEM_IS_SELECTED: case SKIN_TOKEN_LIST_ITEM_IS_SELECTED:
@ -1149,7 +1149,7 @@ const char *get_token_value(struct gui_wps *gwps,
if (!li) return NULL; if (!li) return NULL;
int icon = skinlist_get_item_icon(li->offset, li->wrap); int icon = skinlist_get_item_icon(li->offset, li->wrap);
numeric_ret = icon; numeric_ret = icon;
itoa(buf, buf_size, numeric_ret); itoa_buf(buf, buf_size, numeric_ret);
numeric_buf = buf; numeric_buf = buf;
goto gtv_ret_numeric_tag_info; goto gtv_ret_numeric_tag_info;
} }
@ -1160,7 +1160,7 @@ const char *get_token_value(struct gui_wps *gwps,
case SKIN_TOKEN_PLAYLIST_POSITION: case SKIN_TOKEN_PLAYLIST_POSITION:
numeric_ret = playlist_get_display_index()+offset; numeric_ret = playlist_get_display_index()+offset;
itoa(buf, buf_size, numeric_ret); itoa_buf(buf, buf_size, numeric_ret);
numeric_buf = buf; numeric_buf = buf;
goto gtv_ret_numeric_tag_info; goto gtv_ret_numeric_tag_info;
@ -1248,7 +1248,7 @@ const char *get_token_value(struct gui_wps *gwps,
} }
if (l > -1) { if (l > -1) {
itoa(buf, buf_size, l); itoa_buf(buf, buf_size, l);
numeric_buf = buf; numeric_buf = buf;
goto gtv_ret_numeric_tag_info; goto gtv_ret_numeric_tag_info;
} else { } else {
@ -1327,13 +1327,13 @@ const char *get_token_value(struct gui_wps *gwps,
break; break;
} }
itoa(buf, buf_size, numeric_ret-1); itoa_buf(buf, buf_size, numeric_ret-1);
numeric_buf = buf; numeric_buf = buf;
goto gtv_ret_numeric_tag_info; goto gtv_ret_numeric_tag_info;
} }
case SKIN_TOKEN_REPEAT_MODE: case SKIN_TOKEN_REPEAT_MODE:
itoa(buf, buf_size, global_settings.repeat_mode); itoa_buf(buf, buf_size, global_settings.repeat_mode);
numeric_ret = global_settings.repeat_mode + 1; numeric_ret = global_settings.repeat_mode + 1;
numeric_buf = buf; numeric_buf = buf;
goto gtv_ret_numeric_tag_info; goto gtv_ret_numeric_tag_info;
@ -1354,7 +1354,7 @@ const char *get_token_value(struct gui_wps *gwps,
left : right; left : right;
val = peak_meter_scale_value(val, limit==1 ? MAX_PEAK : limit); val = peak_meter_scale_value(val, limit==1 ? MAX_PEAK : limit);
numeric_ret = val; numeric_ret = val;
itoa(buf, buf_size, numeric_ret); itoa_buf(buf, buf_size, numeric_ret);
data->peak_meter_enabled = true; data->peak_meter_enabled = true;
numeric_buf = buf; numeric_buf = buf;
goto gtv_ret_numeric_tag_info; goto gtv_ret_numeric_tag_info;
@ -1362,10 +1362,10 @@ const char *get_token_value(struct gui_wps *gwps,
case SKIN_TOKEN_CROSSFADE: case SKIN_TOKEN_CROSSFADE:
#ifdef HAVE_CROSSFADE #ifdef HAVE_CROSSFADE
itoa(buf, buf_size, global_settings.crossfade); itoa_buf(buf, buf_size, global_settings.crossfade);
numeric_ret = global_settings.crossfade + 1; numeric_ret = global_settings.crossfade + 1;
#else #else
itoa(buf, buf_size, 0); itoa_buf(buf, buf_size, 0);
#endif #endif
numeric_buf = buf; numeric_buf = buf;
goto gtv_ret_numeric_tag_info; goto gtv_ret_numeric_tag_info;
@ -1753,7 +1753,7 @@ const char *get_token_value(struct gui_wps *gwps,
{ {
int curr_screen = get_current_activity(); int curr_screen = get_current_activity();
numeric_ret = curr_screen; numeric_ret = curr_screen;
itoa(buf, buf_size, numeric_ret); itoa_buf(buf, buf_size, numeric_ret);
numeric_buf = buf; numeric_buf = buf;
goto gtv_ret_numeric_tag_info; goto gtv_ret_numeric_tag_info;
} }
@ -1767,7 +1767,7 @@ const char *get_token_value(struct gui_wps *gwps,
char *skin_base = get_skin_buffer(data); char *skin_base = get_skin_buffer(data);
struct skin_var* var = SKINOFFSETTOPTR(skin_base, token->value.data); struct skin_var* var = SKINOFFSETTOPTR(skin_base, token->value.data);
numeric_ret = var->value; numeric_ret = var->value;
itoa(buf, buf_size, numeric_ret); itoa_buf(buf, buf_size, numeric_ret);
numeric_buf = buf; numeric_buf = buf;
goto gtv_ret_numeric_tag_info; goto gtv_ret_numeric_tag_info;
} }

View file

@ -611,7 +611,7 @@ static int write_bitmap_number(struct screen * display, int value,
int x, int y) int x, int y)
{ {
char buf[12], *ptr; char buf[12], *ptr;
itoa(buf, sizeof(buf), value); itoa_buf(buf, sizeof(buf), value);
for (ptr = buf; *ptr != '\0'; ptr++, x += BM_GLYPH_WIDTH) for (ptr = buf; *ptr != '\0'; ptr++, x += BM_GLYPH_WIDTH)
display->mono_bitmap(bitmap_glyphs_4x8[*ptr - '0'], x, y, display->mono_bitmap(bitmap_glyphs_4x8[*ptr - '0'], x, y,

View file

@ -519,7 +519,7 @@ static const char * id3_get_or_speak_info(int selected_item, void* data,
case LANG_TAGNAVI_ALL_TRACKS: case LANG_TAGNAVI_ALL_TRACKS:
if (info->track_ct <= 1) if (info->track_ct <= 1)
return NULL; return NULL;
itoa(buffer, buffer_len, info->track_ct); itoa_buf(buffer, buffer_len, info->track_ct);
val = buffer; val = buffer;
if(say_it) if(say_it)
talk_number(info->track_ct, true); talk_number(info->track_ct, true);
@ -558,7 +558,7 @@ static const char * id3_get_or_speak_info(int selected_item, void* data,
} }
else if (id3->discnum) else if (id3->discnum)
{ {
itoa(buffer, buffer_len, id3->discnum); itoa_buf(buffer, buffer_len, id3->discnum);
val = buffer; val = buffer;
if(say_it) if(say_it)
talk_number(id3->discnum, true); talk_number(id3->discnum, true);
@ -573,7 +573,7 @@ static const char * id3_get_or_speak_info(int selected_item, void* data,
} }
else if (id3->tracknum) else if (id3->tracknum)
{ {
itoa(buffer, buffer_len, id3->tracknum); itoa_buf(buffer, buffer_len, id3->tracknum);
val = buffer; val = buffer;
if(say_it) if(say_it)
talk_number(id3->tracknum, true); talk_number(id3->tracknum, true);
@ -602,7 +602,7 @@ static const char * id3_get_or_speak_info(int selected_item, void* data,
} }
else if (id3->year) else if (id3->year)
{ {
itoa(buffer, buffer_len, id3->year); itoa_buf(buffer, buffer_len, id3->year);
val = buffer; val = buffer;
if(say_it) if(say_it)
talk_value(id3->year, UNIT_DATEYEAR, true); talk_value(id3->year, UNIT_DATEYEAR, true);

View file

@ -479,7 +479,7 @@ void cfg_to_string(const struct settings_list *setting, char* buf, int buf_len)
break; /* we got a value */ break; /* we got a value */
} }
itoa(buf, buf_len, *(int*)setting->setting); itoa_buf(buf, buf_len, *(int*)setting->setting);
break; break;
case F_T_BOOL: case F_T_BOOL:
cfg_int_to_string(setting, *(bool*)setting->setting, buf, buf_len); cfg_int_to_string(setting, *(bool*)setting->setting, buf, buf_len);

View file

@ -806,7 +806,7 @@ static void volume_limit_load_from_cfg(void* var, char*value)
static char* volume_limit_write_to_cfg(void* setting, char*buf, int buf_len) static char* volume_limit_write_to_cfg(void* setting, char*buf, int buf_len)
{ {
int current = *(int*)setting; int current = *(int*)setting;
itoa(buf, buf_len, current); itoa_buf(buf, buf_len, current);
return buf; return buf;
} }
static bool volume_limit_is_changed(void* setting, void* defaultval) static bool volume_limit_is_changed(void* setting, void* defaultval)

View file

@ -242,15 +242,14 @@ static const char * const tag_type_str[] = {
#define logf_clauses logf #define logf_clauses logf
#endif /* ndef LOGF_ENABLE */ #endif /* ndef LOGF_ENABLE */
#if !defined(itoa) #if defined(PLUGIN)
char *itoa(char *buf, size_t bufsz, long int i) char *itoa_buf(char *buf, size_t bufsz, long int i)
{ {
snprintf(buf, bufsz, "%ld", i); snprintf(buf, bufsz, "%ld", i);
return buf; return buf;
} }
#endif #endif
/* Status information of the tagcache. */ /* Status information of the tagcache. */
static struct tagcache_stat tc_stat; static struct tagcache_stat tc_stat;
@ -1931,7 +1930,7 @@ static bool get_next(struct tagcache_search *tcs, bool is_numeric, char *buf, lo
if (is_numeric) if (is_numeric)
{ {
itoa(buf, bufsz, tcs->position); itoa_buf(buf, bufsz, tcs->position);
tcs->result = buf; tcs->result = buf;
tcs->result_len = strlen(buf) + 1; tcs->result_len = strlen(buf) + 1;
return true; return true;
@ -4001,7 +4000,7 @@ bool tagcache_create_changelog(struct tagcache_search *tcs)
{ {
if (TAGCACHE_IS_NUMERIC(j)) if (TAGCACHE_IS_NUMERIC(j))
{ {
itoa(temp, sizeof temp, (int)idx.tag_seek[j]); itoa_buf(temp, sizeof temp, (int)idx.tag_seek[j]);
write_tag(clfd, tagcache_tag_to_str(j), temp); write_tag(clfd, tagcache_tag_to_str(j), temp);
continue; continue;
} }

View file

@ -219,7 +219,7 @@ target/hosted/maemo/maemo-thread.c
#ifndef BOOTLOADER #ifndef BOOTLOADER
chunk_alloc.c chunk_alloc.c
common/strptokspn.c common/strptokspn.c
common/itoa.c common/itoa_buf.c
common/ap_int.c common/ap_int.c
#endif #endif
common/version.c common/version.c

View file

@ -22,7 +22,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#define INT_DIGITS 19 /* enough for 64 bit integer */ #define INT_DIGITS 19 /* enough for 64 bit integer */
char *itoa(char *buf, size_t bufsz, long int i) char *itoa_buf(char *buf, size_t bufsz, long int i)
{ {
/* Room for INT_DIGITS digits, - and '\0' */ /* Room for INT_DIGITS digits, - and '\0' */
static char intbuf[INT_DIGITS + 2]; static char intbuf[INT_DIGITS + 2];

View file

@ -70,6 +70,6 @@ static inline char * strmemcpy(char *dst, const char *src, size_t len)
strmemdupa(__s, MIN(__n, __len)); }) strmemdupa(__s, MIN(__n, __len)); })
#endif /* strndupa */ #endif /* strndupa */
char *itoa(char *buf, size_t bufsz, long int i); /* Not std */ char *itoa_buf(char *buf, size_t bufsz, long int i);
#endif /* STRING_EXTRA_H */ #endif /* STRING_EXTRA_H */