From 4e3a9fbc8c964c227f9ec8f1cf120154522fa304 Mon Sep 17 00:00:00 2001 From: Bill Kendrick Date: Sat, 13 Apr 2019 12:00:44 -0700 Subject: [PATCH] Re-ran `indent` on .c files Also, added a few places where indent is disabled (via `/* *INDENT-OFF* */`). See https://sourceforge.net/p/tuxpaint/mailman/message/36077409/ from Oct. 2017. --- src/i18n.c | 2 + src/im.c | 8 +- src/macos.c | 40 +++++---- src/playsound.c | 9 +- src/postscript_print.c | 35 +++++--- src/tuxpaint.c | 181 ++++++++++++++++++++++------------------- src/win32_dirent.c | 57 ++++++------- 7 files changed, 184 insertions(+), 148 deletions(-) diff --git a/src/i18n.c b/src/i18n.c index 57eb7daa6..37c95c1c9 100644 --- a/src/i18n.c +++ b/src/i18n.c @@ -979,7 +979,9 @@ static void mysetenv(const char *name, const char *value) * @param loc Locale * @return The Y-nudge value for font rendering in the language. */ +/* *INDENT-OFF* */ static int set_current_language(const char *restrict locale_choice) MUST_CHECK; +/* *INDENT-ON* */ static int set_current_language(const char *restrict loc) { diff --git a/src/im.c b/src/im.c index 45a971b49..f30b653fc 100644 --- a/src/im.c +++ b/src/im.c @@ -971,7 +971,7 @@ static int im_event_zh_tw(IM_DATA * im, SDL_keysym ks) /* Left-Alt & Right-Alt mapped to mode-switch */ case SDLK_RALT: case SDLK_LALT: - cm.section = ((cm.section + 1) % SEC_TOTAL); /* Change section */ + cm.section = ((cm.section + 1) % SEC_TOTAL); /* Change section */ im_softreset(im); /* Soft reset */ /* Set tip text */ @@ -1190,7 +1190,7 @@ static int im_event_th(IM_DATA * im, SDL_keysym ks) /* Right-Alt mapped to mode-switch */ case SDLK_RALT: - cm.section = ((cm.section + 1) % SEC_TOTAL); /* Change section */ + cm.section = ((cm.section + 1) % SEC_TOTAL); /* Change section */ im_softreset(im); /* Soft reset */ /* Set tip text */ @@ -1409,7 +1409,7 @@ static int im_event_ja(IM_DATA * im, SDL_keysym ks) /* Right-Alt mapped to mode-switch */ case SDLK_RALT: - cm.section = ((cm.section + 1) % SEC_TOTAL); /* Change section */ + cm.section = ((cm.section + 1) % SEC_TOTAL); /* Change section */ im_softreset(im); /* Soft reset */ /* Set tip text */ @@ -1656,7 +1656,7 @@ static int im_event_ko(IM_DATA * im, SDL_keysym ks) /* Right-Alt mapped to mode-switch */ case SDLK_LALT: case SDLK_RALT: - cm.section = ((cm.section + 1) % SEC_TOTAL); /* Change section */ + cm.section = ((cm.section + 1) % SEC_TOTAL); /* Change section */ im_softreset(im); /* Soft reset */ /* Set tip text */ diff --git a/src/macos.c b/src/macos.c index 1cb2a7f58..ae405aba5 100644 --- a/src/macos.c +++ b/src/macos.c @@ -12,18 +12,21 @@ /** * FIXME */ -const char* macos_fontsPath() +const char *macos_fontsPath() { - static char* p = NULL; + static char *p = NULL; - if(!p) { - const char* home = getenv("HOME"); + if (!p) + { + const char *home = getenv("HOME"); - p = malloc(strlen(home) + strlen(MACOS_FONTS_PATH) + 1); + p = malloc(strlen(home) + strlen(MACOS_FONTS_PATH) + 1); - if(p) sprintf(p, MACOS_FONTS_PATH, getenv("HOME")); - else perror("macos_fontsPath"); - } + if (p) + sprintf(p, MACOS_FONTS_PATH, getenv("HOME")); + else + perror("macos_fontsPath"); + } return p; } @@ -32,18 +35,21 @@ const char* macos_fontsPath() /** * FIXME */ -const char* macos_preferencesPath() +const char *macos_preferencesPath() { - static char* p = NULL; + static char *p = NULL; - if(!p) { - const char* home = getenv("HOME"); + if (!p) + { + const char *home = getenv("HOME"); - p = malloc(strlen(home) + strlen(MACOS_PREFERENCES_PATH) + 1); + p = malloc(strlen(home) + strlen(MACOS_PREFERENCES_PATH) + 1); - if(p) sprintf(p, MACOS_PREFERENCES_PATH, getenv("HOME")); - else perror("macos_preferencesPath"); - } + if (p) + sprintf(p, MACOS_PREFERENCES_PATH, getenv("HOME")); + else + perror("macos_preferencesPath"); + } return p; } @@ -52,7 +58,7 @@ const char* macos_preferencesPath() /** * FIXME */ -const char* macos_globalPreferencesPath() +const char *macos_globalPreferencesPath() { return MACOS_GLOBAL_PREFERENCES_PATH; } diff --git a/src/playsound.c b/src/playsound.c index b5bbe0db4..56aef1131 100644 --- a/src/playsound.c +++ b/src/playsound.c @@ -55,8 +55,9 @@ void playsound(SDL_Surface * screen, int chan, int s, int override, int x, int y if (!mute && use_sound && s != SND_NONE) { #ifdef DEBUG - printf("playsound #%d in channel %d, pos (%d,%d), %soverride, ptr=%p\n", s, chan, x, y, override ? "" : "no ", sounds[s]); - fflush(stdout); + printf("playsound #%d in channel %d, pos (%d,%d), %soverride, ptr=%p\n", s, chan, x, y, override ? "" : "no ", + sounds[s]); + fflush(stdout); #endif if (override || !Mix_Playing(chan)) { @@ -96,8 +97,8 @@ void playsound(SDL_Surface * screen, int chan, int s, int override, int x, int y } #ifdef DEBUG - printf("Panning of sound #%d in channel %d, left=%d, right=%d\n", s, chan, left, (255-dist)-left); - fflush(stdout); + printf("Panning of sound #%d in channel %d, left=%d, right=%d\n", s, chan, left, (255 - dist) - left); + fflush(stdout); #endif Mix_SetPanning(chan, left, (255 - dist) - left); } diff --git a/src/postscript_print.c b/src/postscript_print.c index e54594364..d2b3bdfbe 100644 --- a/src/postscript_print.c +++ b/src/postscript_print.c @@ -306,8 +306,10 @@ int do_ps_save(FILE * fi, child_pid = pclose(fi); #ifdef DEBUG - printf("pclose returned %d\n", child_pid); fflush(stdout); - printf("errno = %d\n", errno); fflush(stdout); + printf("pclose returned %d\n", child_pid); + fflush(stdout); + printf("errno = %d\n", errno); + fflush(stdout); #endif if (child_pid < 0 || (errno != 0 && errno != EAGAIN)) @@ -324,15 +326,26 @@ int do_ps_save(FILE * fi, w = waitpid(child_pid, &status, 0); #ifdef DEBUG - if (w == -1) { perror("waitpid"); exit(EXIT_FAILURE); } - if (WIFEXITED(status)) { - printf("exited, status=%d\n", WEXITSTATUS(status)); - } else if (WIFSIGNALED(status)) { - printf("killed by signal %d\n", WTERMSIG(status)); - } else if (WIFSTOPPED(status)) { - printf("stopped by signal %d\n", WSTOPSIG(status)); - } else if (WIFCONTINUED(status)) { - printf("continued\n"); + if (w == -1) + { + perror("waitpid"); + exit(EXIT_FAILURE); + } + if (WIFEXITED(status)) + { + printf("exited, status=%d\n", WEXITSTATUS(status)); + } + else if (WIFSIGNALED(status)) + { + printf("killed by signal %d\n", WTERMSIG(status)); + } + else if (WIFSTOPPED(status)) + { + printf("stopped by signal %d\n", WSTOPSIG(status)); + } + else if (WIFCONTINUED(status)) + { + printf("continued\n"); } #endif } diff --git a/src/tuxpaint.c b/src/tuxpaint.c index 095d85b11..1ddc269c9 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -47,21 +47,21 @@ #endif #ifndef VIDEO_BPP - /*# define VIDEO_BPP 15 *//* saves memory */ - /*# define VIDEO_BPP 16 *//* causes discoloration */ - /*# define VIDEO_BPP 24 *//* compromise */ + /*# define VIDEO_BPP 15 *//* saves memory */ + /*# define VIDEO_BPP 16 *//* causes discoloration */ + /*# define VIDEO_BPP 24 *//* compromise */ #define VIDEO_BPP 32 /* might be fastest, if conversion funcs removed */ #endif - /* #define CORNER_SHAPES *//* need major work! */ + /* #define CORNER_SHAPES *//* need major work! */ /* Method for printing images: */ #define PRINTMETHOD_PS /* Direct to PostScript */ - /*#define PRINTMETHOD_PNM_PS*//* Output PNM, assuming it gets printed */ - /*#define PRINTMETHOD_PNG_PNM_PS*//* Output PNG, assuming it gets printed */ + /*#define PRINTMETHOD_PNM_PS *//* Output PNM, assuming it gets printed */ + /*#define PRINTMETHOD_PNG_PNM_PS *//* Output PNG, assuming it gets printed */ #define MAX_PATH 256 @@ -557,7 +557,7 @@ static void mtw(wchar_t * wtok, char *tok) int TP_EventFilter(const SDL_Event * event); -/* #define fmemopen_alternative */ /* Uncomment this to test the fmemopen alternative in systems were fmemopen exists */ + /* #define fmemopen_alternative *//* Uncomment this to test the fmemopen alternative in systems were fmemopen exists */ #if defined (WIN32) || defined (__APPLE__) || defined(__NetBSD__) || defined(__sun) /* MINGW/MSYS, NetBSD, and MacOSX need it, at least for now */ #define fmemopen_alternative @@ -641,7 +641,7 @@ enum LABEL_OFF, LABEL_LABEL, LABEL_SELECT - /* , LABEL_ROTATE */ + /* , LABEL_ROTATE */ }; @@ -685,7 +685,7 @@ typedef struct Uint8 rows, cols; } grid_dims; - /* static SDL_Rect r_screen; *//* was 640x480 @ 0,0 -- but this isn't so useful */ + /* static SDL_Rect r_screen; *//* was 640x480 @ 0,0 -- but this isn't so useful */ static SDL_Rect r_canvas; /* was 448x376 @ 96,0 */ static SDL_Rect r_tools; /* was 96x336 @ 0,40 */ static SDL_Rect r_sfx; @@ -710,7 +710,7 @@ static grid_dims gd_tools; /* was 2x7 */ static grid_dims gd_sfx; static grid_dims gd_toolopt; /* was 2x7 */ - /* static grid_dims gd_open; *//* was 4x4 */ + /* static grid_dims gd_open; *//* was 4x4 */ static grid_dims gd_colors; /* was 17x1 */ #define HEIGHTOFFSET (((WINDOW_HEIGHT - 480) / 48) * 48) @@ -1960,7 +1960,8 @@ static void get_new_file_id(void); static int do_quit(int tool); static int do_open(void); static int do_new_dialog(void); -static int do_new_dialog_add_colors(SDL_Surface * * thumbs, int num_files, int * d_places, char * * d_names, char * * d_exts, int * white_in_palette); +static int do_new_dialog_add_colors(SDL_Surface * *thumbs, int num_files, int *d_places, char * *d_names, + char * *d_exts, int *white_in_palette); static int do_color_picker(void); static int do_color_sel(void); static int do_slideshow(void); @@ -2722,7 +2723,7 @@ static void mainloop(void) add_label_node(0, 0, 0, 0, NULL); derender_node(&label_node_to_edit); label_node_to_edit = NULL; - /* playsound(screen, 0, SND_DELETE_LABEL, 0, SNDPOS_CENTER); */ /* FIXME lack of specific sound */ + /* playsound(screen, 0, SND_DELETE_LABEL, 0, SNDPOS_CENTER); *//* FIXME lack of specific sound */ if (been_saved) { @@ -2836,7 +2837,7 @@ static void mainloop(void) add_label_node(0, 0, 0, 0, NULL); derender_node(&label_node_to_edit); label_node_to_edit = NULL; - /* playsound(screen, 0, SND_DELETE_LABEL, 0, SNDPOS_CENTER); */ /* FIXME lack of specific sound */ + /* playsound(screen, 0, SND_DELETE_LABEL, 0, SNDPOS_CENTER); *//* FIXME lack of specific sound */ if (been_saved) { @@ -3546,11 +3547,9 @@ static void mainloop(void) old_size = stamp_data[stamp_group][cur_stamp[stamp_group]]->size; stamp_data[stamp_group][cur_stamp[stamp_group]]->size = - (((MAX_STAMP_SIZE - MIN_STAMP_SIZE + - 1 + (((MAX_STAMP_SIZE - MIN_STAMP_SIZE + 1 /* +1 to address lack of ability to get back to max default stamp size (SF Bug #1668235 -bjk 2011.01.08) */ - ) * (event.button.x - - (WINDOW_WIDTH - 96))) / 96) + MIN_STAMP_SIZE; + ) * (event.button.x - (WINDOW_WIDTH - 96))) / 96) + MIN_STAMP_SIZE; #ifdef DEBUG printf("Old size = %d, Chose %0.4f, New size =%d\n", old_size, choice, @@ -3975,11 +3974,11 @@ static void mainloop(void) /* FIXME */ /* - snprintf(font_tux_text, sizeof font_tux_text, "%s (%s).", - TTF_FontFaceFamilyName(getfonthandle(cur_font)), - TTF_FontFaceStyleName(getfonthandle(cur_font))); - draw_tux_text(TUX_GREAT, font_tux_text, 1); - */ + snprintf(font_tux_text, sizeof font_tux_text, "%s (%s).", + TTF_FontFaceFamilyName(getfonthandle(cur_font)), + TTF_FontFaceStyleName(getfonthandle(cur_font))); + draw_tux_text(TUX_GREAT, font_tux_text, 1); + */ if (do_draw) draw_fonts(); @@ -5362,12 +5361,11 @@ static void mainloop(void) w = CUR_STAMP_W; h = CUR_STAMP_H; - stamp_data[stamp_group][cur_stamp[stamp_group]]->size = - (((MAX_STAMP_SIZE - MIN_STAMP_SIZE + - 1 - /* +1 to address lack of ability to get back to max default stamp size (SF Bug #1668235 -bjk 2011.01.08) */ - ) * (event.button.x - - (WINDOW_WIDTH - 96))) / 96) + MIN_STAMP_SIZE; + stamp_data[stamp_group][cur_stamp[stamp_group]]->size = (((MAX_STAMP_SIZE - MIN_STAMP_SIZE + 1 + /* +1 to address lack of ability to get back to max default stamp size (SF Bug #1668235 -bjk 2011.01.08) */ + ) * (event.button.x - + (WINDOW_WIDTH - 96))) / 96) + + MIN_STAMP_SIZE; #ifdef DEBUG printf("Old size = %d, Chose %0.4f, New size =%d\n", old_size, choice, @@ -6399,6 +6397,7 @@ void show_usage(int exitcode) { FILE *f = exitcode ? stderr : stdout; + /* *INDENT-OFF* */ fprintf(f, "\n" "Usage: %s {--usage | --help | --version | --verbose-version | --copying}\n" @@ -6483,6 +6482,7 @@ void show_usage(int exitcode) /* FIXME: "--joystick-btn-help" to list available commands, like "--lang help" */ "\n", progname); + /* *INDENT-ON* */ } @@ -7539,13 +7539,14 @@ static void loadstamp_callback(SDL_Surface * screen, #endif /* - * Showing the progress bar across the screen can be CPU-intensive, so - * update infrequently. - */ - if((i % 32) == 0) show_progress_bar(screen); + * Showing the progress bar across the screen can be CPU-intensive, so + * update infrequently. + */ + if ((i % 32) == 0) + show_progress_bar(screen); if (dotext > files[i].str && !strcasecmp(dotext, ext) - && (dotext - files[i].str + 1 + dirlen < (int) (sizeof fname)) + && (dotext - files[i].str + 1 + dirlen < (int)(sizeof fname)) && !strcasestr(files[i].str, mirror_ext) && !strcasestr(files[i].str, flip_ext) && !strcasestr(files[i].str, mirrorflip_ext)) { @@ -7736,16 +7737,20 @@ static int generate_fontconfig_cache(void *vp) static void signal_handler(int sig) { // It is not legal to call printf or most other functions here! - if (sig == SIGUSR1 || sig == SIGUSR2) { - autosave_on_quit = 1; - no_prompt_on_quit = 1; - if (sig == SIGUSR1) { - promptless_save = SAVE_OVER_NO; - } else { - promptless_save = SAVE_OVER_ALWAYS; + if (sig == SIGUSR1 || sig == SIGUSR2) + { + autosave_on_quit = 1; + no_prompt_on_quit = 1; + if (sig == SIGUSR1) + { + promptless_save = SAVE_OVER_NO; + } + else + { + promptless_save = SAVE_OVER_ALWAYS; + } + raise(SIGTERM); } - raise(SIGTERM); - } } #endif @@ -11885,14 +11890,16 @@ static int do_prompt_image_flash_snd(const char *const text, int valhat_x, valhat_y, hatmotioner; #ifdef DEBUG - if(snd >= 0) { - printf("Prompt and play sound #%d: %s\n", snd, sound_fnames[snd]); - fflush(stdout); - } - else { - printf("Prompt without sound\n"); - fflush(stdout); - } + if (snd >= 0) + { + printf("Prompt and play sound #%d: %s\n", snd, sound_fnames[snd]); + fflush(stdout); + } + else + { + printf("Prompt without sound\n"); + fflush(stdout); + } #endif val_x = val_y = motioner = 0; @@ -18716,10 +18723,11 @@ static int do_new_dialog(void) white_in_palette = -1; - if (!new_colors_last) { - first_color = 0; - num_files = do_new_dialog_add_colors(thumbs, num_files, d_places, d_names, d_exts, &white_in_palette); - } + if (!new_colors_last) + { + first_color = 0; + num_files = do_new_dialog_add_colors(thumbs, num_files, d_places, d_names, d_exts, &white_in_palette); + } first_starter = num_files; first_template = -1; /* In case there are none... */ @@ -19024,16 +19032,18 @@ static int do_new_dialog(void) /* Throw the color palette at the end (alternative option): */ - if (new_colors_last) { - first_color = num_files; - num_files = do_new_dialog_add_colors(thumbs, num_files, d_places, d_names, d_exts, &white_in_palette); - } + if (new_colors_last) + { + first_color = num_files; + num_files = do_new_dialog_add_colors(thumbs, num_files, d_places, d_names, d_exts, &white_in_palette); + } #ifdef DEBUG printf("%d files and colors were found!\n", num_files); #endif - printf("first_color = %d\nfirst_starter = %d\nfirst_template = %d\nnum_files = %d\n\n", first_color, first_starter, first_template, num_files); + printf("first_color = %d\nfirst_starter = %d\nfirst_template = %d\nnum_files = %d\n\n", first_color, first_starter, + first_template, num_files); /* Let user choose a color or image: */ @@ -19477,7 +19487,8 @@ static int do_new_dialog(void) label_node_to_edit = NULL; have_to_rec_label_node = FALSE; - if (which >= first_starter && (first_template == -1 || which < first_template) && (!new_colors_last || which < first_color)) + if (which >= first_starter && (first_template == -1 || which < first_template) + && (!new_colors_last || which < first_color)) { /* Load a starter: */ @@ -19601,7 +19612,7 @@ static int do_new_dialog(void) starter_personal = 0; starter_modified = 0; - which = which - first_color; + which = which - first_color; /* Launch color picker if they chose that: */ @@ -19682,7 +19693,9 @@ static int do_new_dialog(void) normally appears at the beginning (above Starts & Templates), but may be placed at the end with the "--newcolorslast" option. */ -static int do_new_dialog_add_colors(SDL_Surface * * thumbs, int num_files, int * d_places, char * * d_names, char * * d_exts, int * white_in_palette) { +static int do_new_dialog_add_colors(SDL_Surface * *thumbs, int num_files, int *d_places, char * *d_names, + char * *d_exts, int *white_in_palette) +{ int j; int added; Uint8 r, g, b; @@ -21217,7 +21230,7 @@ static void load_info_about_label_surface(FILE * lfi) int new_pos; int x, y; int tmp_fscanf_return; - char * tmp_fgets_return; + char *tmp_fgets_return; Uint8 a; /* Clear label surface */ @@ -21914,10 +21927,10 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf) /* First we search for the things that usually were in the .dat file, so if a starter or a template is found and if it is not modified, we can load it clean (i.e. not rebluring a - blured when scaled one)*/ + blured when scaled one) */ for (u = 0; u < num_unknowns; u++) { - printf("%s, %d\n", unknowns[u].name, (int) unknowns[u].size); + printf("%s, %d\n", unknowns[u].name, (int)unknowns[u].size); if (chunk_is_valid("tpDT", unknowns[u])) { @@ -22435,6 +22448,7 @@ static void setup_config(char *argv[]) savedir = strdup(macos_preferencesPath()); #else int tmp; + tmp = asprintf((char **)&savedir, "%s/%s", home, ".tuxpaint"); if (tmp < 0) { @@ -22484,7 +22498,7 @@ static void setup_config(char *argv[]) /* EP added this conditional section for Mac to fix folder & extension inconsistency with Tux Paint Config application) */ /* Mac OS X: Use a "tuxpaint.cfg" file in the *global* Tux Paint -application support folder */ + application support folder */ snprintf(str, sizeof(str), "%s/tuxpaint.cfg", macos_globalPreferencesPath()); parse_file_options(&tmpcfg_sys, str); #else @@ -22596,9 +22610,9 @@ application support folder */ } /* FIXME: make this dynamic (accelerometer or OLPC XO-1 rotation button) */ if (tmpcfg.rotate_orientation) - rotate_orientation = !strcmp(tmpcfg.rotate_orientation, "portrait"); /* alternative is "landscape" */ + rotate_orientation = !strcmp(tmpcfg.rotate_orientation, "portrait"); /* alternative is "landscape" */ if (tmpcfg.colorfile) - strcpy(colorfile, tmpcfg.colorfile); /* FIXME can overflow */ + strcpy(colorfile, tmpcfg.colorfile); /* FIXME can overflow */ if (tmpcfg.print_delay) { print_delay = atoi(tmpcfg.print_delay); @@ -22618,7 +22632,7 @@ application support folder */ else if (!strcmp(tmpcfg.alt_print_command_default, "never")) alt_print_command_default = ALTPRINT_NEVER; else - alt_print_command_default = ALTPRINT_MOD; /* default ("mod") */ + alt_print_command_default = ALTPRINT_MOD; /* default ("mod") */ } #ifdef PAPER_H if (tmpcfg.papersize) @@ -22922,16 +22936,16 @@ application support folder */ static void chdir_to_binary(char *argv0) { /* - char curdir[256]; - */ + char curdir[256]; + */ /* EP added this block to print out of current directory */ /* - getcwd(curdir, sizeof(curdir)); -#ifdef DEBUG - printf("Binary Path: %s\nCurrent directory at launchtime: %s\n", argv0, curdir); -#endif - */ + getcwd(curdir, sizeof(curdir)); + #ifdef DEBUG + printf("Binary Path: %s\nCurrent directory at launchtime: %s\n", argv0, curdir); + #endif + */ #if defined(__BEOS__) || defined(WIN32) || defined(__APPLE__) /* if run from gui, like OpenTracker in BeOS or Explorer in Windows, @@ -22953,12 +22967,12 @@ static void chdir_to_binary(char *argv0) // E.g., "/Applications/TuxPaint.app/Contents/MacOS/tuxpaint" // But we want to point somewhere higher up, say to "Contents", so we can access // the resources in Resources folder. So move up one level. - int levels = 1; /* we need to back up 1 level */ + int levels = 1; /* we need to back up 1 level */ while ((levels-- > 0) && (slash)) { - *slash = '\0'; /* this overwrites the \0 at end of string */ - slash = strrchr(app_path, '/'); /* so we can carry on our back-pedaling... */ + *slash = '\0'; /* this overwrites the \0 at end of string */ + slash = strrchr(app_path, '/'); /* so we can carry on our back-pedaling... */ } #endif @@ -22973,9 +22987,9 @@ static void chdir_to_binary(char *argv0) } free(app_path); /* - getcwd(curdir, sizeof(curdir)); - printf("New current directory for runtime: %s\n", curdir); - */ + getcwd(curdir, sizeof(curdir)); + printf("New current directory for runtime: %s\n", curdir); + */ } #else (void)argv0; @@ -24381,7 +24395,7 @@ int main(int argc, char *argv[]) * file may not exist on the runtime system, however, so we copy the file * into our app bundle at compile time, and tell Fontconfig here to look for * the file within the app bundle. */ - putenv((char*) "FONTCONFIG_PATH=Resources/etc"); + putenv((char *)"FONTCONFIG_PATH=Resources/etc"); #endif #ifdef FORKED_FONTS @@ -24959,4 +24973,3 @@ static void handle_joybuttonupdownscl(SDL_Event event, int oldpos_x, int oldpos_ if (!ignore) SDL_PushEvent(&ev); } - diff --git a/src/win32_dirent.c b/src/win32_dirent.c index bba2992d2..461a5cdb4 100644 --- a/src/win32_dirent.c +++ b/src/win32_dirent.c @@ -1,16 +1,16 @@ -/****************************************************/ -/* */ -/* For Win32 that lacks Unix direct support. */ -/* - avoids including "windows.h" */ -/* */ -/* Copyright (c) 2002 John Popplewell */ -/* john@johnnypops.demon.co.uk */ -/* */ -/* Version 1.0.1 - fixed bug in opendir() */ -/* Version 1.0.0 - initial version */ -/* */ -/****************************************************/ - +/****************************************************/ +/* */ +/* For Win32 that lacks Unix direct support. */ +/* - avoids including "windows.h" */ +/* */ +/* Copyright (c) 2002 John Popplewell */ +/* john@johnnypops.demon.co.uk */ +/* */ +/* Version 1.0.1 - fixed bug in opendir() */ +/* Version 1.0.0 - initial version */ +/* */ +/****************************************************/ + /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,14 +25,14 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -/* $Id$ */ - +*/ + +/* $Id$ */ + #include #include #include - + #include "win32_dirent.h" #include "debug.h" @@ -42,11 +42,12 @@ * @param pSpec Path of directory to open * @return Opened directory, or NULL on failure */ -DIR * opendir(const char *pSpec) +DIR *opendir(const char *pSpec) { char pathname[MAX_PATH + 2]; - DIR * pDir = calloc(1, sizeof(DIR)); + DIR *pDir = calloc(1, sizeof(DIR)); + if (!pDir) return NULL; strcpy(pathname, pSpec); @@ -65,7 +66,7 @@ DIR * opendir(const char *pSpec) * * @param pDir Opened directory to close. */ -void closedir(DIR * pDir) +void closedir(DIR * pDir) { assert(pDir != NULL); free(pDir); @@ -77,15 +78,15 @@ void closedir(DIR * pDir) * @param pDir Opened directory from which to read. * @return The next entry from the directory */ -struct dirent *readdir(struct DIR *pDir) +struct dirent *readdir(struct DIR *pDir) { assert(pDir != NULL); if (pDir->hFind) - + { strcpy(pDir->de.d_name, (const char *)pDir->wfd.cFileName); if (!FindNextFile(pDir->hFind, &pDir->wfd)) - + { FindClose(pDir->hFind); pDir->hFind = NULL; @@ -104,7 +105,7 @@ struct dirent *readdir(struct DIR *pDir) * filename of dir entry 'a' is found, respectively, to be less than, * to match, or be greater than that of 'b'. */ -int alphasort(const void *a, const void *b) +int alphasort(const void *a, const void *b) { return (strcmp((*(const struct dirent **)a)->d_name, (*(const struct dirent **)b)->d_name)); } @@ -118,7 +119,7 @@ int alphasort(const void *a, const void *b) * @param entry The directory entry to add to 'namelist' * @return New count of items, or -1 on error (e.g., failed malloc()) */ -static int addToList(int i, struct dirent ***namelist, struct dirent *entry) +static int addToList(int i, struct dirent ***namelist, struct dirent *entry) { int size; struct dirent *block; @@ -144,9 +145,9 @@ static int addToList(int i, struct dirent ***namelist, struct dirent *entry) * @param compar Callback for sorting items in the list (via qsort()). * @return Count of items, or -1 on error. */ -int scandir(const char *dir, struct dirent ***namelist, selectCB select, comparCB compar) +int scandir(const char *dir, struct dirent ***namelist, selectCB select, comparCB compar) { - DIR * pDir; + DIR *pDir; int count; struct dirent *entry;