1
0
mirror of https://github.com/libretro/RetroArch synced 2024-07-01 07:54:27 +00:00

Style nits - turn macro names into upper-case - some while style nits

This commit is contained in:
twinaphex 2020-06-26 20:00:19 +02:00
parent fa50695b89
commit 1ae20ea17c
44 changed files with 221 additions and 201 deletions

View File

@ -109,7 +109,7 @@ static INLINE void copy_swapped(uint32_t * restrict dst,
{
uint32_t s = *src++;
*dst++ = (s >> 16) | (s << 16);
}while(--size);
} while (--size);
}
static ssize_t gx_audio_write(void *data, const void *buf_, size_t size)

View File

@ -67,7 +67,7 @@ static void opensl_callback(SLAndroidSimpleBufferQueueItf bq, void *ctx)
#define GOTO_IF_FAIL(x) do { \
if ((res = (x)) != SL_RESULT_SUCCESS) \
goto error; \
} while(0)
} while (0)
static void sl_free(void *data)
{

View File

@ -241,7 +241,7 @@ static ssize_t libnx_audren_audio_write(void *data,
if (aud->nonblock)
{
while(written < size)
while (written < size)
{
written += libnx_audren_audio_append(
aud, buf + written, size - written);
@ -251,7 +251,7 @@ static ssize_t libnx_audren_audio_write(void *data,
}
else
{
while(written < size)
while (written < size)
{
written += libnx_audren_audio_append(
aud, buf + written, size - written);

View File

@ -219,7 +219,7 @@ static ssize_t ax_audio_write(void* data, const void* buf, size_t size)
else if (count_avail < count)
{
/* Sync, wait for free memory */
while(AXIsMultiVoiceRunning(ax->mvoice) && (count_avail < count))
while (AXIsMultiVoiceRunning(ax->mvoice) && (count_avail < count))
{
OSYieldThread(); /* Gives threads with same priority time to run */
count_avail = (ax->written > AX_AUDIO_MAX_FREE ? 0 : (AX_AUDIO_MAX_FREE - ax->written));

View File

@ -145,10 +145,10 @@ static void frontend_ps2_init(void *data)
SifInitRpc(0);
#if !defined(DEBUG) || defined(BUILD_FOR_PCSX2)
/* Comment this line if you don't wanna debug the output */
while(!SifIopReset(NULL, 0)){};
while (!SifIopReset(NULL, 0)) { };
#endif
while(!SifIopSync()){};
while (!SifIopSync()) { };
SifInitRpc(0);
sbv_patch_enable_lmb();

View File

@ -606,28 +606,32 @@ void net_print_exp(const char *str)
sendto(wiiu_log_socket, str, strlen(str), 0, (struct sockaddr *)&broadcast, sizeof(broadcast));
}
/* RFC 791 specifies that any IP host must be able to receive a datagram of 576 bytes.
* Since we're generally never logging more than a line or two's worth of data (~100 bytes)
/* RFC 791 specifies that any IP host must be able
* to receive a datagram of 576 bytes.
* Since we're generally never logging more than a
* line or two's worth of data (~100 bytes)
* this is a reasonable size for our use. */
#define DGRAM_SIZE 576
static ssize_t wiiu_log_write(struct _reent *r, void *fd, const char *ptr, size_t len)
static ssize_t wiiu_log_write(struct _reent *r,
void *fd, const char *ptr, size_t len)
{
int remaining;
if (wiiu_log_socket < 0)
return len;
while(wiiu_log_lock)
while (wiiu_log_lock)
OSSleepTicks(((248625000 / 4)) / 1000);
wiiu_log_lock = 1;
int sent;
int remaining = len;
remaining = len;
while(remaining > 0)
while (remaining > 0)
{
int block = remaining < DGRAM_SIZE ? remaining : DGRAM_SIZE;
sent = sendto(wiiu_log_socket, ptr, block, 0, (struct sockaddr *)&broadcast, sizeof(broadcast));
int sent = sendto(wiiu_log_socket, ptr, block, 0,
(struct sockaddr *)&broadcast, sizeof(broadcast));
if (sent < 0)
break;

View File

@ -582,7 +582,7 @@ static bool ctr_frame(void* data, const void* frame,
#if 0
ctr->vsync_event_pending = true;
#endif
while(ctr->vsync_event_pending)
while (ctr->vsync_event_pending)
{
task_queue_check();
svcSleepThread(0);

View File

@ -261,7 +261,7 @@ waitFinish(gcmContextData *context, u32 sLabelVal)
rsxFlushBuffer (context);
while(*(vu32 *) gcmGetLabelAddress (GCM_LABEL_INDEX) != sLabelVal)
while (*(vu32 *) gcmGetLabelAddress (GCM_LABEL_INDEX) != sLabelVal)
usleep(30);
sLabelVal++;

View File

@ -2666,7 +2666,9 @@ static void gl2_video_layout_layer_begin(const video_layout_render_info_t *info)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
static void gl2_video_layout_image(const video_layout_render_info_t *info, void *image_handle, void *alpha_handle)
static void gl2_video_layout_image(
const video_layout_render_info_t *info,
void *image_handle, void *alpha_handle)
{
/* TODO alpha_handle */
int i;
@ -2690,7 +2692,7 @@ static void gl2_video_layout_image(const video_layout_render_info_t *info, void
coord[7] = 1.f - (b.y + b.h);
i = 0;
while(i < 16)
while (i < 16)
{
color[i++] = info->color.r;
color[i++] = info->color.g;
@ -2698,10 +2700,10 @@ static void gl2_video_layout_image(const video_layout_render_info_t *info, void
color[i++] = info->color.a;
}
gl->coords.vertex = coord;
gl->coords.vertex = coord;
gl->coords.tex_coord = tex_coords;
gl->coords.color = color;
gl->coords.vertices = 4;
gl->coords.color = color;
gl->coords.vertices = 4;
gl->shader->set_coords(gl->shader_data, &gl->coords);
gl->shader->set_mvp(gl->shader_data, &gl->mvp_no_rot);

View File

@ -28,24 +28,20 @@
/* TODO: Move viewport side effects to the caller: it's a source of bugs. */
#define gl1_raster_font_emit(c, vx, vy) do { \
font_vertex[ 2 * (6 * i + c) + 0] = (x + (delta_x + off_x + vx * width) * scale) * inv_win_width; \
font_vertex[ 2 * (6 * i + c) + 1] = (y + (delta_y - off_y - vy * height) * scale) * inv_win_height; \
font_tex_coords[ 2 * (6 * i + c) + 0] = (tex_x + vx * width) * inv_tex_size_x; \
font_tex_coords[ 2 * (6 * i + c) + 1] = (tex_y + vy * height) * inv_tex_size_y; \
font_color[ 4 * (6 * i + c) + 0] = color[0]; \
font_color[ 4 * (6 * i + c) + 1] = color[1]; \
font_color[ 4 * (6 * i + c) + 2] = color[2]; \
font_color[ 4 * (6 * i + c) + 3] = color[3]; \
#define GL1_RASTER_FONT_EMIT(c, vx, vy) \
font_vertex[ 2 * (6 * i + c) + 0] = (x + (delta_x + off_x + vx * width) * scale) * inv_win_width; \
font_vertex[ 2 * (6 * i + c) + 1] = (y + (delta_y - off_y - vy * height) * scale) * inv_win_height; \
font_tex_coords[ 2 * (6 * i + c) + 0] = (tex_x + vx * width) * inv_tex_size_x; \
font_tex_coords[ 2 * (6 * i + c) + 1] = (tex_y + vy * height) * inv_tex_size_y; \
font_color[ 4 * (6 * i + c) + 0] = color[0]; \
font_color[ 4 * (6 * i + c) + 1] = color[1]; \
font_color[ 4 * (6 * i + c) + 2] = color[2]; \
font_color[ 4 * (6 * i + c) + 3] = color[3]; \
font_lut_tex_coord[ 2 * (6 * i + c) + 0] = gl->coords.lut_tex_coord[0]; \
font_lut_tex_coord[ 2 * (6 * i + c) + 1] = gl->coords.lut_tex_coord[1]; \
} while(0)
font_lut_tex_coord[ 2 * (6 * i + c) + 1] = gl->coords.lut_tex_coord[1]
#define MAX_MSG_LEN_CHUNK 64
#ifdef VITA
static float *vertices3 = NULL;
#endif
typedef struct
{
@ -248,6 +244,10 @@ static int gl1_get_message_width(void *data, const char *msg,
static void gl1_raster_font_draw_vertices(gl1_raster_t *font,
const video_coords_t *coords)
{
#ifdef VITA
static float *vertices3 = NULL;
#endif
if (font->atlas->dirty)
{
gl1_raster_font_upload_atlas(font);
@ -270,10 +270,13 @@ static void gl1_raster_font_draw_vertices(gl1_raster_t *font,
if (vertices3)
free(vertices3);
vertices3 = (float*)malloc(sizeof(float) * 3 * coords->vertices);
int i;
for (i = 0; i < coords->vertices; i++) {
memcpy(&vertices3[i*3], &coords->vertex[i*2], sizeof(float) * 2);
vertices3[i*3+2] = 0.0f;
{
int i;
for (i = 0; i < coords->vertices; i++)
{
memcpy(&vertices3[i*3], &coords->vertex[i*2], sizeof(float) * 2);
vertices3[i*3+2] = 0.0f;
}
}
glVertexPointer(3, GL_FLOAT, 0, vertices3);
#else
@ -350,13 +353,13 @@ static void gl1_raster_font_render_line(
width = glyph->width;
height = glyph->height;
gl1_raster_font_emit(0, 0, 1); /* Bottom-left */
gl1_raster_font_emit(1, 1, 1); /* Bottom-right */
gl1_raster_font_emit(2, 0, 0); /* Top-left */
GL1_RASTER_FONT_EMIT(0, 0, 1); /* Bottom-left */
GL1_RASTER_FONT_EMIT(1, 1, 1); /* Bottom-right */
GL1_RASTER_FONT_EMIT(2, 0, 0); /* Top-left */
gl1_raster_font_emit(3, 1, 0); /* Top-right */
gl1_raster_font_emit(4, 0, 0); /* Top-left */
gl1_raster_font_emit(5, 1, 1); /* Bottom-right */
GL1_RASTER_FONT_EMIT(3, 1, 0); /* Top-right */
GL1_RASTER_FONT_EMIT(4, 0, 0); /* Top-left */
GL1_RASTER_FONT_EMIT(5, 1, 1); /* Bottom-right */
i++;

View File

@ -29,7 +29,7 @@
/* TODO: Move viewport side effects to the caller: it's a source of bugs. */
#define gl_core_raster_font_emit(c, vx, vy) do { \
#define GL_CORE_RASTER_FONT_EMIT(c, vx, vy) \
font_vertex[ 2 * (6 * i + c) + 0] = (x + (delta_x + off_x + vx * width) * scale) * inv_win_width; \
font_vertex[ 2 * (6 * i + c) + 1] = (y + (delta_y - off_y - vy * height) * scale) * inv_win_height; \
font_tex_coords[ 2 * (6 * i + c) + 0] = (tex_x + vx * width) * inv_tex_size_x; \
@ -37,8 +37,7 @@
font_color[ 4 * (6 * i + c) + 0] = color[0]; \
font_color[ 4 * (6 * i + c) + 1] = color[1]; \
font_color[ 4 * (6 * i + c) + 2] = color[2]; \
font_color[ 4 * (6 * i + c) + 3] = color[3]; \
} while(0)
font_color[ 4 * (6 * i + c) + 3] = color[3]
#define MAX_MSG_LEN_CHUNK 64
@ -261,13 +260,13 @@ static void gl_core_raster_font_render_line(
width = glyph->width;
height = glyph->height;
gl_core_raster_font_emit(0, 0, 1); /* Bottom-left */
gl_core_raster_font_emit(1, 1, 1); /* Bottom-right */
gl_core_raster_font_emit(2, 0, 0); /* Top-left */
GL_CORE_RASTER_FONT_EMIT(0, 0, 1); /* Bottom-left */
GL_CORE_RASTER_FONT_EMIT(1, 1, 1); /* Bottom-right */
GL_CORE_RASTER_FONT_EMIT(2, 0, 0); /* Top-left */
gl_core_raster_font_emit(3, 1, 0); /* Top-right */
gl_core_raster_font_emit(4, 0, 0); /* Top-left */
gl_core_raster_font_emit(5, 1, 1); /* Bottom-right */
GL_CORE_RASTER_FONT_EMIT(3, 1, 0); /* Top-right */
GL_CORE_RASTER_FONT_EMIT(4, 0, 0); /* Top-left */
GL_CORE_RASTER_FONT_EMIT(5, 1, 1); /* Bottom-right */
i++;

View File

@ -28,7 +28,7 @@
/* TODO: Move viewport side effects to the caller: it's a source of bugs. */
#define gl_raster_font_emit(c, vx, vy) do { \
#define GL_RASTER_FONT_EMIT(c, vx, vy) \
font_vertex[ 2 * (6 * i + c) + 0] = (x + (delta_x + off_x + vx * width) * scale) * inv_win_width; \
font_vertex[ 2 * (6 * i + c) + 1] = (y + (delta_y - off_y - vy * height) * scale) * inv_win_height; \
font_tex_coords[ 2 * (6 * i + c) + 0] = (tex_x + vx * width) * inv_tex_size_x; \
@ -38,8 +38,7 @@
font_color[ 4 * (6 * i + c) + 2] = color[2]; \
font_color[ 4 * (6 * i + c) + 3] = color[3]; \
font_lut_tex_coord[ 2 * (6 * i + c) + 0] = gl->coords.lut_tex_coord[0]; \
font_lut_tex_coord[ 2 * (6 * i + c) + 1] = gl->coords.lut_tex_coord[1]; \
} while(0)
font_lut_tex_coord[ 2 * (6 * i + c) + 1] = gl->coords.lut_tex_coord[1]
#define MAX_MSG_LEN_CHUNK 64
@ -330,13 +329,13 @@ static void gl_raster_font_render_line(
width = glyph->width;
height = glyph->height;
gl_raster_font_emit(0, 0, 1); /* Bottom-left */
gl_raster_font_emit(1, 1, 1); /* Bottom-right */
gl_raster_font_emit(2, 0, 0); /* Top-left */
GL_RASTER_FONT_EMIT(0, 0, 1); /* Bottom-left */
GL_RASTER_FONT_EMIT(1, 1, 1); /* Bottom-right */
GL_RASTER_FONT_EMIT(2, 0, 0); /* Top-left */
gl_raster_font_emit(3, 1, 0); /* Top-right */
gl_raster_font_emit(4, 0, 0); /* Top-left */
gl_raster_font_emit(5, 1, 1); /* Bottom-right */
GL_RASTER_FONT_EMIT(3, 1, 0); /* Top-right */
GL_RASTER_FONT_EMIT(4, 0, 0); /* Top-left */
GL_RASTER_FONT_EMIT(5, 1, 1); /* Bottom-right */
i++;

View File

@ -81,10 +81,11 @@
length:(NSUInteger)(_stride * _atlas->height)
options:MTLResourceStorageModeManaged];
// Even though newBufferWithBytes will copy the initial contents
// from our atlas, it doesn't seem to invalidate the buffer when
// doing so, causing corrupted text rendering if we hit this code
// path. To work around it we manually invalidate the buffer.
/* Even though newBufferWithBytes will copy the initial contents
* from our atlas, it doesn't seem to invalidate the buffer when
* doing so, causing corrupted text rendering if we hit this code
* path. To work around it we manually invalidate the buffer.
*/
[_buffer didModifyRange:NSMakeRange(0, _buffer.length)];
}
else

View File

@ -39,7 +39,42 @@ typedef struct
unsigned vertices;
} vulkan_raster_t;
static void vulkan_raster_font_free_font(void *data, bool is_threaded);
static INLINE void vulkan_raster_font_update_glyph(
vulkan_raster_t *font, const struct font_glyph *glyph)
{
if(font->atlas->dirty)
{
unsigned row;
for (row = glyph->atlas_offset_y; row < (glyph->atlas_offset_y + glyph->height); row++)
{
uint8_t *src = font->atlas->buffer + row * font->atlas->width + glyph->atlas_offset_x;
uint8_t *dst = (uint8_t*)font->texture.mapped + row * font->texture.stride + glyph->atlas_offset_x;
memcpy(dst, src, glyph->width);
}
font->atlas->dirty = false;
font->needs_update = true;
}
}
static void vulkan_raster_font_free_font(void *data, bool is_threaded)
{
vulkan_raster_t *font = (vulkan_raster_t*)data;
if (!font)
return;
if (font->font_driver && font->font_data)
font->font_driver->free(font->font_data);
vkQueueWaitIdle(font->vk->context->queue);
vulkan_destroy_texture(
font->vk->context->device, &font->texture);
vulkan_destroy_texture(
font->vk->context->device, &font->texture_optimal);
free(font);
}
static void *vulkan_raster_font_init_font(void *data,
const char *font_path, float font_size,
@ -90,41 +125,6 @@ static void *vulkan_raster_font_init_font(void *data,
return font;
}
static void vulkan_raster_font_free_font(void *data, bool is_threaded)
{
vulkan_raster_t *font = (vulkan_raster_t*)data;
if (!font)
return;
if (font->font_driver && font->font_data)
font->font_driver->free(font->font_data);
vkQueueWaitIdle(font->vk->context->queue);
vulkan_destroy_texture(
font->vk->context->device, &font->texture);
vulkan_destroy_texture(
font->vk->context->device, &font->texture_optimal);
free(font);
}
static INLINE void vulkan_raster_font_update_glyph(vulkan_raster_t *font, const struct font_glyph *glyph)
{
if(font->atlas->dirty)
{
unsigned row;
for (row = glyph->atlas_offset_y; row < (glyph->atlas_offset_y + glyph->height); row++)
{
uint8_t *src = font->atlas->buffer + row * font->atlas->width + glyph->atlas_offset_x;
uint8_t *dst = (uint8_t*)font->texture.mapped + row * font->texture.stride + glyph->atlas_offset_x;
memcpy(dst, src, glyph->width);
}
font->atlas->dirty = false;
font->needs_update = true;
}
}
static int vulkan_get_message_width(void *data, const char *msg,
unsigned msg_len, float scale)
{
@ -444,7 +444,8 @@ static const struct font_glyph *vulkan_raster_font_get_glyph(
return glyph;
}
static bool vulkan_get_line_metrics(void* data, struct font_line_metrics **metrics)
static bool vulkan_get_line_metrics(void* data,
struct font_line_metrics **metrics)
{
vulkan_raster_t *font = (vulkan_raster_t*)data;

View File

@ -97,7 +97,7 @@ static freetype_atlas_slot_t* font_renderer_get_slot(ft_font_renderer_t *handle)
else if (handle->uc_map[map_id])
{
freetype_atlas_slot_t* ptr = handle->uc_map[map_id];
while(ptr->next && ptr->next != &handle->atlas_slots[oldest])
while (ptr->next && ptr->next != &handle->atlas_slots[oldest])
ptr = ptr->next;
ptr->next = handle->atlas_slots[oldest].next;
}
@ -120,7 +120,7 @@ static const struct font_glyph *font_renderer_ft_get_glyph(
map_id = charcode & 0xFF;
atlas_slot = handle->uc_map[map_id];
while(atlas_slot)
while (atlas_slot)
{
if (atlas_slot->charcode == charcode)
{

View File

@ -87,18 +87,18 @@ static stb_unicode_atlas_slot_t* font_renderer_stb_unicode_get_slot(stb_unicode_
unsigned oldest = 0;
for (i = 1; i < STB_UNICODE_ATLAS_SIZE; i++)
if((handle->usage_counter - handle->atlas_slots[i].last_used) >
if ((handle->usage_counter - handle->atlas_slots[i].last_used) >
(handle->usage_counter - handle->atlas_slots[oldest].last_used))
oldest = i;
/* remove from map */
map_id = handle->atlas_slots[oldest].charcode & 0xFF;
if(handle->uc_map[map_id] == &handle->atlas_slots[oldest])
if (handle->uc_map[map_id] == &handle->atlas_slots[oldest])
handle->uc_map[map_id] = handle->atlas_slots[oldest].next;
else if (handle->uc_map[map_id])
{
stb_unicode_atlas_slot_t* ptr = handle->uc_map[map_id];
while(ptr->next && ptr->next != &handle->atlas_slots[oldest])
while (ptr->next && ptr->next != &handle->atlas_slots[oldest])
ptr = ptr->next;
ptr->next = handle->atlas_slots[oldest].next;
}
@ -121,15 +121,15 @@ static const struct font_glyph *font_renderer_stb_unicode_get_glyph(
float glyph_advance_x = 0.0f;
float glyph_draw_offset_y = 0.0f;
if(!self)
if (!self)
return NULL;
map_id = charcode & 0xFF;
atlas_slot = self->uc_map[map_id];
while(atlas_slot)
while (atlas_slot)
{
if(atlas_slot->charcode == charcode)
if (atlas_slot->charcode == charcode)
{
atlas_slot->last_used = self->usage_counter++;
return &atlas_slot->glyph;
@ -222,7 +222,7 @@ static bool font_renderer_stb_unicode_create_atlas(
for (i = 0; i < 256; i++)
{
if(isalnum(i))
if (isalnum(i))
font_renderer_stb_unicode_get_glyph(self, i);
}
@ -242,7 +242,7 @@ static void *font_renderer_stb_unicode_init(const char *font_path, float font_si
font_size = STBTT_POINT_SIZE(font_size);
#ifdef WIIU
if(!*font_path)
if (!*font_path)
{
uint32_t size = 0;
if (!OSGetSharedData(SHARED_FONT_DEFAULT, 0, (void**)&self->font_data, &size))

View File

@ -217,7 +217,8 @@ static void fill_content_img(gfx_thumbnail_path_data_t *path_data)
* No-Intro filename standard:
* http://datomatic.no-intro.org/stuff/The%20Official%20No-Intro%20Convention%20(20071030).zip
* Replace these characters in the entry name with underscores */
while((scrub_char_pointer = strpbrk(path_data->content_img, "&*/:`\"<>?\\|")))
while ((scrub_char_pointer =
strpbrk(path_data->content_img, "&*/:`\"<>?\\|")))
*scrub_char_pointer = '_';
/* Add PNG extension */

View File

@ -512,7 +512,7 @@ static void libusb_hid_free(const void *data)
{
libusb_hid_t *hid = (libusb_hid_t*)data;
while(adapters.next)
while (adapters.next)
if (remove_adapter(hid, adapters.next->device) == -1)
RARCH_ERR("could not remove device %p\n",
adapters.next->device);

View File

@ -136,7 +136,7 @@ static void wiiu_hid_free(const void *data)
if (events.list)
{
wiiu_attach_event *event = NULL;
while( (event = events.list) != NULL)
while ((event = events.list) != NULL)
{
events.list = event->next;
delete_attach_event(event);
@ -593,7 +593,7 @@ static void wiiu_hid_polling_thread_cleanup(OSThread *thread, void *stack)
if (incomplete == 0)
{
RARCH_LOG("All in-flight reads complete.\n");
while(adapters.list != NULL)
while (adapters.list)
{
RARCH_LOG("[hid]: shutting down adapter..\n");
adapter = adapters.list;
@ -610,7 +610,7 @@ static void wiiu_hid_polling_thread_cleanup(OSThread *thread, void *stack)
RARCH_WARN("[hid]: timed out waiting for in-flight read to finish.\n");
incomplete = 0;
}
} while(incomplete);
} while (incomplete);
}
static void wiiu_handle_attach_events(wiiu_hid_t *hid, wiiu_attach_event *list)
@ -667,7 +667,7 @@ static int wiiu_hid_polling_thread(int argc, const char **argv)
RARCH_LOG("[hid]: polling thread is starting\n");
while(!hid->polling_thread_quit)
while (!hid->polling_thread_quit)
{
wiiu_handle_attach_events(hid, synchronized_get_events_list());
wiiu_poll_adapters(hid);

View File

@ -40,11 +40,11 @@ static void resampler_nearest_process(
audio_frame_float_t *outp = (audio_frame_float_t*)data->data_out;
float ratio = 1.0 / data->ratio;
while(inp != inp_max)
while (inp != inp_max)
{
while(re->fraction > 1)
while (re->fraction > 1)
{
*outp++ = *inp;
*outp++ = *inp;
re->fraction -= ratio;
}
re->fraction++;

View File

@ -37,6 +37,8 @@
#include <xtl.h>
#endif
#define UTF8_WALKBYTE(string) (*((*(string))++))
static unsigned leading_ones(uint8_t c)
{
unsigned ones = 0;
@ -89,13 +91,14 @@ size_t utf8_conv_utf32(uint32_t *out, size_t out_chars,
bool utf16_conv_utf8(uint8_t *out, size_t *out_chars,
const uint16_t *in, size_t in_size)
{
static uint8_t kUtf8Limits[5] = { 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
size_t out_pos = 0;
size_t in_pos = 0;
size_t out_pos = 0;
size_t in_pos = 0;
static const
uint8_t utf8_limits[5] = { 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
for (;;)
{
unsigned numAdds;
unsigned num_adds;
uint32_t value;
if (in_pos == in_size)
@ -124,21 +127,21 @@ bool utf16_conv_utf8(uint8_t *out, size_t *out_chars,
value = (((value - 0xD800) << 10) | (c2 - 0xDC00)) + 0x10000;
}
for (numAdds = 1; numAdds < 5; numAdds++)
if (value < (((uint32_t)1) << (numAdds * 5 + 6)))
for (num_adds = 1; num_adds < 5; num_adds++)
if (value < (((uint32_t)1) << (num_adds * 5 + 6)))
break;
if (out)
out[out_pos] = (char)(kUtf8Limits[numAdds - 1]
+ (value >> (6 * numAdds)));
out[out_pos] = (char)(utf8_limits[num_adds - 1]
+ (value >> (6 * num_adds)));
out_pos++;
do
{
numAdds--;
num_adds--;
if (out)
out[out_pos] = (char)(0x80
+ ((value >> (6 * numAdds)) & 0x3F));
+ ((value >> (6 * num_adds)) & 0x3F));
out_pos++;
}while (numAdds != 0);
}while (num_adds != 0);
}
*out_chars = out_pos;
@ -166,13 +169,15 @@ size_t utf8cpy(char *d, size_t d_len, const char *s, size_t chars)
while (*sb && chars-- > 0)
{
sb++;
while ((*sb & 0xC0) == 0x80) sb++;
while ((*sb & 0xC0) == 0x80)
sb++;
}
if ((size_t)(sb - sb_org) > d_len-1 /* NUL */)
{
sb = sb_org + d_len-1;
while ((*sb & 0xC0) == 0x80) sb--;
while ((*sb & 0xC0) == 0x80)
sb--;
}
memcpy(d, sb_org, sb-sb_org);
@ -184,14 +189,18 @@ size_t utf8cpy(char *d, size_t d_len, const char *s, size_t chars)
const char *utf8skip(const char *str, size_t chars)
{
const uint8_t *strb = (const uint8_t*)str;
if (!chars)
return str;
do
{
strb++;
while ((*strb & 0xC0)==0x80) strb++;
while ((*strb & 0xC0)==0x80)
strb++;
chars--;
} while(chars);
}while (chars);
return (const char*)strb;
}
@ -211,24 +220,22 @@ size_t utf8len(const char *string)
return ret;
}
#define utf8_walkbyte(string) (*((*(string))++))
/* Does not validate the input, returns garbage if it's not UTF-8. */
uint32_t utf8_walk(const char **string)
{
uint8_t first = utf8_walkbyte(string);
uint8_t first = UTF8_WALKBYTE(string);
uint32_t ret = 0;
if (first < 128)
return first;
ret = (ret << 6) | (utf8_walkbyte(string) & 0x3F);
ret = (ret << 6) | (UTF8_WALKBYTE(string) & 0x3F);
if (first >= 0xE0)
{
ret = (ret << 6) | (utf8_walkbyte(string) & 0x3F);
ret = (ret << 6) | (UTF8_WALKBYTE(string) & 0x3F);
if (first >= 0xF0)
{
ret = (ret << 6) | (utf8_walkbyte(string) & 0x3F);
ret = (ret << 6) | (UTF8_WALKBYTE(string) & 0x3F);
return ret | (first & 7) << 18;
}
return ret | (first & 15) << 12;
@ -379,13 +386,13 @@ char* local_to_utf8_string_alloc(const char *str)
wchar_t* utf8_to_utf16_string_alloc(const char *str)
{
#ifdef _WIN32
int len = 0;
int out_len = 0;
int len = 0;
int out_len = 0;
#else
size_t len = 0;
size_t len = 0;
size_t out_len = 0;
#endif
wchar_t *buf = NULL;
wchar_t *buf = NULL;
if (!str || !*str)
return NULL;

View File

@ -648,7 +648,7 @@ bool file_archive_perform_mode(const char *path, const char *valid_exts,
{
ret = handle.backend->stream_decompress_data_to_file_iterate(
handle.stream);
}while(ret == 0);
}while (ret == 0);
if (!file_archive_decompress_data_to_file(&handle,
ret, path, valid_exts,

View File

@ -142,7 +142,7 @@ static bool zip_file_decompressed_handle(
{
ret = handle->backend->stream_decompress_data_to_file_iterate(
handle->stream);
}while(ret == 0);
}while (ret == 0);
#if 0
handle->real_checksum = handle->backend->stream_crc_calculate(0,
@ -272,7 +272,7 @@ static int zip_file_read(
"", zip_file_decompressed, &userdata);
if (!returnerr)
break;
}while(ret == 0 && !userdata.decomp_state.found);
} while (ret == 0 && !userdata.decomp_state.found);
file_archive_parse_file_iterate_stop(&zlib);

View File

@ -735,7 +735,7 @@ static void rbmp_convert_frame(uint32_t *frame, unsigned width, unsigned height)
{
uint32_t *end = frame + (width * height * sizeof(uint32_t))/4;
while(frame < end)
while (frame < end)
{
uint32_t pixel = *frame;
*frame = (pixel & 0xff00ff00) | ((pixel << 16) & 0x00ff0000) | ((pixel >> 16) & 0xff);

View File

@ -220,7 +220,7 @@ static bool image_texture_load_internal(
ret = image_transfer_process(img, type,
(uint32_t**)&out_img->pixels, len, &out_img->width,
&out_img->height);
}while(ret == IMAGE_PROCESS_NEXT);
} while (ret == IMAGE_PROCESS_NEXT);
if (ret == IMAGE_PROCESS_ERROR || ret == IMAGE_PROCESS_ERROR_END)
goto end;

View File

@ -705,10 +705,11 @@ static int png_reverse_filter_adam7_iterate(uint32_t **data_,
if (png_reverse_filter_init(&pngp->ihdr, pngp) == -1)
return IMAGE_PROCESS_ERROR;
do{
do
{
ret = png_reverse_filter_regular_iterate(&pngp->data,
&pngp->ihdr, pngp);
}while(ret == IMAGE_PROCESS_NEXT);
} while (ret == IMAGE_PROCESS_NEXT);
if (ret == IMAGE_PROCESS_ERROR || ret == IMAGE_PROCESS_ERROR_END)
return IMAGE_PROCESS_ERROR;

View File

@ -36,7 +36,7 @@
fprintf(stderr, "[RPNG]: Error in line %d.\n", __LINE__); \
ret = false; \
goto end; \
} while(0)
} while (0)
double DEFLATE_PADDING = 1.1;
int PNG_ROUGH_HEADER = 100;

View File

@ -32,7 +32,7 @@
fprintf(stderr, "[RPNG]: Error in line %d.\n", __LINE__); \
ret = false; \
goto end; \
} while(0)
} while (0)
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))

View File

@ -448,13 +448,13 @@ static void SHA1PadMessage(struct sha1_context *context)
if (context->Message_Block_Index > 55)
{
while(context->Message_Block_Index < 64)
while (context->Message_Block_Index < 64)
context->Message_Block[context->Message_Block_Index++] = 0;
SHA1ProcessMessageBlock(context);
}
while(context->Message_Block_Index < 56)
while (context->Message_Block_Index < 56)
context->Message_Block[context->Message_Block_Index++] = 0;
/* Store the message length as the last 8 octets */
@ -497,7 +497,7 @@ static void SHA1Input(struct sha1_context *context,
return;
}
while(length-- && !context->Corrupted)
while (length-- && !context->Corrupted)
{
context->Message_Block[context->Message_Block_Index++] =
(*message_array & 0xFF);
@ -544,7 +544,7 @@ int sha1_calculate(const char *path, char *result)
goto error;
SHA1Input(&sha, buff, rv);
}while(rv);
} while (rv);
if (!SHA1Result(&sha))
goto error;

View File

@ -148,7 +148,7 @@ char *word_wrap(char *buffer, const char *string,
* char *str = "1,2,3,4,5,6,7,,,10,";
* char **str_ptr = &str;
* char *token = NULL;
* while((token = string_tokenize(str_ptr, ",")))
* while ((token = string_tokenize(str_ptr, ",")))
* {
* printf("%s\n", token);
* free(token);

View File

@ -119,18 +119,18 @@ char *string_replace_substring(const char *in,
/* Remove leading whitespaces */
char *string_trim_whitespace_left(char *const s)
{
if(s && *s)
if (s && *s)
{
size_t len = strlen(s);
char *current = s;
while(*current && isspace((unsigned char)*current))
while (*current && isspace((unsigned char)*current))
{
++current;
--len;
}
if(s != current)
if (s != current)
memmove(s, current, len + 1);
}
@ -140,12 +140,12 @@ char *string_trim_whitespace_left(char *const s)
/* Remove trailing whitespaces */
char *string_trim_whitespace_right(char *const s)
{
if(s && *s)
if (s && *s)
{
size_t len = strlen(s);
char *current = s + len - 1;
while(current != s && isspace((unsigned char)*current))
while (current != s && isspace((unsigned char)*current))
{
--current;
--len;
@ -202,7 +202,7 @@ char *word_wrap(char* buffer, const char *string, int line_width, bool unicode,
buffer[i] = string[i];
char_len--;
i++;
} while(char_len);
} while (char_len);
/* check for newlines embedded in the original input
* and reset the index */
@ -260,7 +260,7 @@ char *word_wrap(char* buffer, const char *string, int line_width, bool unicode,
* char *str = "1,2,3,4,5,6,7,,,10,";
* char **str_ptr = &str;
* char *token = NULL;
* while((token = string_tokenize(str_ptr, ",")))
* while ((token = string_tokenize(str_ptr, ",")))
* {
* printf("%s\n", token);
* free(token);

View File

@ -191,7 +191,8 @@ void manual_content_scan_scrub_system_name_custom(void)
* and/or violate the No-Intro filename standard:
* http://datomatic.no-intro.org/stuff/The%20Official%20No-Intro%20Convention%20(20071030).zip
* Replace these characters with underscores */
while((scrub_char_pointer = strpbrk(scan_settings.system_name_custom, "&*/:`\"<>?\\|")))
while ((scrub_char_pointer =
strpbrk(scan_settings.system_name_custom, "&*/:`\"<>?\\|")))
*scrub_char_pointer = '_';
}

View File

@ -41,7 +41,7 @@
{ \
char *pos = NULL; \
strlcpy(s, label, len); \
while((pos = strchr(s, '_'))) \
while ((pos = strchr(s, '_'))) \
*pos = ' '; \
}

View File

@ -998,7 +998,7 @@ static void stripes_update_thumbnail_path(void *data, unsigned i, char pos)
tmp_new[0] = '\0';
while((scrub_char_pointer = strpbrk(tmp, "&*/:`\"<>?\\|")))
while ((scrub_char_pointer = strpbrk(tmp, "&*/:`\"<>?\\|")))
*scrub_char_pointer = '_';
/* Look for thumbnail file with this scrubbed filename */

View File

@ -4536,7 +4536,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
for(i = 0; i < 25 && *end; i++)
{
end++;
while((*end & 0xC0) == 0x80)
while ((*end & 0xC0) == 0x80)
end++;
}

View File

@ -1217,14 +1217,14 @@ static bool netplay_get_cmd(netplay_t *netplay,
#define START(which) \
do { \
ptr = which; \
ptr = which; \
dframe = &netplay->buffer[ptr]; \
} while(0)
} while (0)
#define NEXT() \
do { \
ptr = NEXT_PTR(ptr); \
ptr = NEXT_PTR(ptr); \
dframe = &netplay->buffer[ptr]; \
} while(0)
} while (0)
if (netplay->is_server)
{

View File

@ -1647,7 +1647,7 @@ static void ffmpeg_flush_buffers(ffmpeg_t *handle)
did_work = true;
}
}while(did_work);
}while (did_work);
/* Flush out last audio. */
if (handle->config.audio_enable)

View File

@ -1046,7 +1046,7 @@ static const camera_driver_t *camera_drivers[] = {
#define FAIL_CPU(simd_type) do { \
RARCH_ERR(simd_type " code is compiled in, but CPU does not support this feature. Cannot continue.\n"); \
retroarch_fail(1, "validate_cpu_features()"); \
}while(0)
} while (0)
#ifdef HAVE_ZLIB
#define DEFAULT_EXT "zip"
@ -12838,7 +12838,7 @@ static void handle_translation_cb(
do
{
retval = rpng_process_image(rpng, &raw_image_data_alpha, new_image_size, &image_width, &image_height);
}while(retval == IMAGE_PROCESS_NEXT);
} while (retval == IMAGE_PROCESS_NEXT);
/* Returned output from the png processor is an upside down RGBA
* image, so we have to change that to RGB first. This should

View File

@ -191,14 +191,14 @@ static int detect_ps1_game_sub(intfstream_t *fp,
buffer[256] = '\0';
tmp = buffer;
while(*tmp && strncasecmp((const char*)tmp, "boot", 4))
while (*tmp && strncasecmp((const char*)tmp, "boot", 4))
tmp++;
if (!*tmp)
return 0;
boot_file = tmp;
while(*tmp && *tmp != '\n')
while (*tmp && *tmp != '\n')
{
if ((*tmp == '\\') || (*tmp == ':'))
boot_file = tmp + 1;
@ -216,7 +216,7 @@ static int detect_ps1_game_sub(intfstream_t *fp,
if (!isalnum(*tmp))
tmp++;
while(isalnum(*tmp))
while (isalnum(*tmp))
{
*game_id++ = *tmp++;
if (*tmp == '.')

View File

@ -144,7 +144,7 @@ static int task_image_iterate_process_transfer(struct nbio_image_handle *image)
if (retval != IMAGE_PROCESS_NEXT)
break;
}while(cpu_features_get_time_usec() - start_time
}while (cpu_features_get_time_usec() - start_time
< image->frame_duration);
if (retval == IMAGE_PROCESS_NEXT)

View File

@ -396,7 +396,8 @@ static char **waiting_argv;
task_queue_check();
while(CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.002, FALSE) == kCFRunLoopRunHandledSource);
while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.002, FALSE)
== kCFRunLoopRunHandledSource);
if (ret == -1)
{
#ifdef HAVE_QT

View File

@ -59,7 +59,7 @@ void logger_send_v(const char *__format, va_list args);
#define RARCH_LOG(...) do { \
logger_send("RetroArch Salamander: " __VA_ARGS__); \
} while(0)
} while (0)
#define RARCH_LOG_V(tag, fmt, vp) do { \
logger_send("RetroArch Salamander: " tag); \
@ -68,7 +68,7 @@ void logger_send_v(const char *__format, va_list args);
#define RARCH_LOG_OUTPUT(...) do { \
logger_send("[OUTPUT] " __VA_ARGS__); \
} while(0)
} while (0)
#define RARCH_LOG_OUTPUT_V(tag, fmt, vp) do { \
logger_send("[OUTPUT] " tag); \
@ -77,7 +77,7 @@ void logger_send_v(const char *__format, va_list args);
#define RARCH_ERR(...) do { \
logger_send("[ERROR] " __VA_ARGS__); \
} while(0)
} while (0)
#define RARCH_ERR_V(tag, fmt, vp) do { \
logger_send("[ERROR] " tag); \
@ -86,7 +86,7 @@ void logger_send_v(const char *__format, va_list args);
#define RARCH_WARN(...) do { \
logger_send("[WARN] " __VA_ARGS__); \
} while(0)
} while (0)
#define RARCH_WARN_V(tag, fmt, vp) do { \
logger_send("[WARN] " tag); \
@ -97,7 +97,7 @@ void logger_send_v(const char *__format, va_list args);
#define RARCH_LOG(...) do { \
logger_send("" __VA_ARGS__); \
} while(0)
} while (0)
#define RARCH_LOG_V(tag, fmt, vp) do { \
logger_send("" tag); \
@ -106,7 +106,7 @@ void logger_send_v(const char *__format, va_list args);
#define RARCH_ERR(...) do { \
logger_send("[ERROR] " __VA_ARGS__); \
} while(0)
} while (0)
#define RARCH_ERR_V(tag, fmt, vp) do { \
logger_send("[ERROR] " tag); \
@ -115,7 +115,7 @@ void logger_send_v(const char *__format, va_list args);
#define RARCH_WARN(...) do { \
logger_send("[WARN] " __VA_ARGS__); \
} while(0)
} while (0)
#define RARCH_WARN_V(tag, fmt, vp) do { \
logger_send("[WARN] :: " tag); \
@ -124,7 +124,7 @@ void logger_send_v(const char *__format, va_list args);
#define RARCH_LOG_OUTPUT(...) do { \
logger_send("[OUTPUT] " __VA_ARGS__); \
} while(0)
} while (0)
#define RARCH_LOG_OUTPUT_V(tag, fmt, vp) do { \
logger_send("[OUTPUT] " tag); \
@ -132,7 +132,7 @@ void logger_send_v(const char *__format, va_list args);
} while (0)
#endif
#define RARCH_LOG_BUFFER(...) do { } while(0)
#define RARCH_LOG_BUFFER(...) do { } while (0)
#else /* HAVE_LOGGER */
void RARCH_LOG_V(const char *tag, const char *fmt, va_list ap);

View File

@ -62,11 +62,11 @@ int main(int argc, const char** argv)
bool vson = true;
bool pson = true;
while(*next)
while (*next)
{
const char* line = next;
while(*next && *next != '\n' && *next != '\r')
while (*next && *next != '\n' && *next != '\r')
next++;
if (*next == '\r')
@ -75,7 +75,7 @@ int main(int argc, const char** argv)
*next++ = '\0';
#if 0
while((*next == '\n') || (*next == '\r'))
while ((*next == '\n') || (*next == '\r'))
*next++ = '\0';
#endif
@ -101,12 +101,12 @@ int main(int argc, const char** argv)
char* layout = strstr(line, "layout(");
if(layout)
{
while(*layout != ')')
while (*layout != ')')
layout++;
layout++;
while(*layout && isspace(*layout))
while (*layout && isspace(*layout))
layout++;
if(!strncmp(layout, "uniform", 7))

View File

@ -10,7 +10,7 @@
#undef IMPORT_BEGIN
#undef IMPORT_END
#define IMPORT(name) do{if(OSDynLoad_FindExport(handle, 0, #name, &addr_##name) < 0)OSFatal("Function " # name " is NULL");} while(0)
#define IMPORT(name) do{if(OSDynLoad_FindExport(handle, 0, #name, &addr_##name) < 0)OSFatal("Function " # name " is NULL");} while (0)
#define IMPORT_BEGIN(lib) OSDynLoad_Acquire(#lib ".rpl", &handle)
/* #define IMPORT_END() OSDynLoad_Release(handle) */
#define IMPORT_END()