From d8bb1e1d55022893498e17b6ca5325103262feb4 Mon Sep 17 00:00:00 2001 From: Yves Rizoud Date: Thu, 3 May 2012 21:32:59 +0000 Subject: [PATCH] Fix some mostly harmless warnings and re-generated dependencies. Now compiles with zero warnings on Linux (gcc 4.1.2) git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1945 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- src/Makefile.dep | 133 ++++++++++++++------------- src/engine.c | 1 + src/fileformats.c | 3 +- src/filesel.c | 81 +++++++++-------- src/io.c | 2 + src/miscfileformats.c | 6 +- src/oldies.c | 5 +- src/operatio.c | 2 +- src/pages.c | 1 + src/readline.c | 206 +++++++++++++++++++++--------------------- src/sdlscreen.c | 20 ++-- 11 files changed, 235 insertions(+), 225 deletions(-) diff --git a/src/Makefile.dep b/src/Makefile.dep index 16655cc1..f4b95883 100644 --- a/src/Makefile.dep +++ b/src/Makefile.dep @@ -1,113 +1,112 @@ -$(OBJDIR)/SFont.o: SFont.c SFont.h $(OBJDIR)/brush.o: brush.c global.h struct.h const.h graph.h misc.h errors.h \ - windows.h sdlscreen.h brush.h tiles.h + windows.h sdlscreen.h brush.h tiles.h $(OBJDIR)/brush_ops.o: brush_ops.c brush.h struct.h const.h buttons.h engine.h \ - global.h graph.h misc.h operatio.h pages.h sdlscreen.h windows.h + global.h graph.h misc.h operatio.h pages.h sdlscreen.h windows.h $(OBJDIR)/buttons.o: buttons.c const.h struct.h global.h misc.h graph.h engine.h \ - readline.h filesel.h loadsave.h init.h buttons.h operatio.h pages.h \ - palette.h errors.h readini.h saveini.h shade.h io.h help.h text.h \ - sdlscreen.h windows.h brush.h input.h special.h tiles.h setup.h + readline.h filesel.h loadsave.h init.h buttons.h operatio.h pages.h \ + palette.h errors.h readini.h saveini.h shade.h io.h help.h text.h \ + sdlscreen.h windows.h brush.h input.h special.h tiles.h setup.h $(OBJDIR)/buttons_effects.o: buttons_effects.c brush.h struct.h const.h buttons.h \ - engine.h global.h graph.h help.h input.h misc.h pages.h readline.h \ - sdlscreen.h windows.h tiles.h + engine.h global.h graph.h help.h input.h misc.h pages.h readline.h \ + sdlscreen.h windows.h tiles.h $(OBJDIR)/colorred.o: colorred.c colorred.h struct.h const.h $(OBJDIR)/engine.o: engine.c const.h struct.h global.h graph.h misc.h special.h \ - buttons.h operatio.h shade.h errors.h sdlscreen.h windows.h brush.h \ - input.h engine.h pages.h layers.h factory.h loadsave.h io.h pxsimple.h + buttons.h operatio.h shade.h errors.h sdlscreen.h windows.h brush.h \ + input.h engine.h pages.h layers.h factory.h loadsave.h io.h pxsimple.h \ + oldies.h $(OBJDIR)/factory.o: factory.c brush.h struct.h const.h buttons.h engine.h errors.h \ - filesel.h loadsave.h global.h graph.h io.h misc.h pages.h readline.h \ - sdlscreen.h windows.h palette.h input.h help.h realpath.h setup.h \ - tiles.h + filesel.h loadsave.h global.h graph.h io.h misc.h pages.h readline.h \ + sdlscreen.h windows.h palette.h input.h help.h realpath.h setup.h \ + tiles.h $(OBJDIR)/fileformats.o: fileformats.c errors.h global.h struct.h const.h \ - loadsave.h misc.h io.h windows.h + loadsave.h misc.h io.h pages.h windows.h $(OBJDIR)/filesel.o: filesel.c const.h struct.h global.h misc.h errors.h io.h \ - windows.h sdlscreen.h loadsave.h mountlist.h engine.h readline.h input.h \ - help.h filesel.h + windows.h sdlscreen.h loadsave.h mountlist.h engine.h readline.h \ + input.h help.h filesel.h $(OBJDIR)/graph.o: graph.c global.h struct.h const.h engine.h buttons.h pages.h \ - errors.h sdlscreen.h graph.h misc.h pxsimple.h pxtall.h pxwide.h \ - pxdouble.h pxtriple.h pxwide2.h pxtall2.h pxquad.h windows.h input.h \ - brush.h tiles.h + errors.h sdlscreen.h graph.h misc.h pxsimple.h pxtall.h pxwide.h \ + pxdouble.h pxtriple.h pxwide2.h pxtall2.h pxquad.h windows.h input.h \ + brush.h tiles.h $(OBJDIR)/help.o: help.c const.h struct.h global.h misc.h engine.h helpfile.h \ - help.h sdlscreen.h text.h keyboard.h windows.h input.h hotkeys.h \ - errors.h pages.h + help.h sdlscreen.h text.h keyboard.h windows.h input.h hotkeys.h \ + errors.h pages.h $(OBJDIR)/hotkeys.o: hotkeys.c struct.h const.h global.h hotkeys.h $(OBJDIR)/init.o: init.c buttons.h struct.h const.h errors.h global.h graph.h \ - init.h io.h factory.h help.h hotkeys.h keyboard.h loadsave.h misc.h \ - mountlist.h operatio.h palette.h sdlscreen.h setup.h transform.h \ - windows.h layers.h special.h + init.h io.h factory.h help.h hotkeys.h keyboard.h loadsave.h misc.h \ + mountlist.h operatio.h palette.h sdlscreen.h setup.h transform.h \ + windows.h layers.h special.h $(OBJDIR)/input.o: input.c global.h struct.h const.h keyboard.h sdlscreen.h \ - windows.h errors.h misc.h buttons.h input.h loadsave.h + windows.h errors.h misc.h buttons.h input.h loadsave.h $(OBJDIR)/io.o: io.c struct.h const.h io.h realpath.h $(OBJDIR)/keyboard.o: keyboard.c global.h struct.h const.h keyboard.h $(OBJDIR)/layers.o: layers.c const.h struct.h global.h windows.h engine.h pages.h \ - sdlscreen.h input.h help.h misc.h readline.h graph.h + sdlscreen.h input.h help.h misc.h readline.h graph.h $(OBJDIR)/libraw2crtc.o: libraw2crtc.c const.h global.h struct.h loadsave.h $(OBJDIR)/loadsave.o: loadsave.c buttons.h struct.h const.h errors.h global.h io.h \ - loadsave.h misc.h graph.h op_c.h colorred.h pages.h palette.h \ - sdlscreen.h windows.h engine.h brush.h setup.h + loadsave.h misc.h graph.h op_c.h colorred.h pages.h palette.h \ + sdlscreen.h windows.h engine.h brush.h setup.h $(OBJDIR)/main.o: main.c const.h struct.h global.h graph.h misc.h init.h buttons.h \ - engine.h pages.h loadsave.h sdlscreen.h errors.h readini.h saveini.h \ - io.h text.h setup.h windows.h brush.h palette.h realpath.h input.h \ - help.h + engine.h pages.h loadsave.h sdlscreen.h errors.h readini.h saveini.h \ + io.h text.h setup.h windows.h brush.h palette.h realpath.h input.h \ + help.h $(OBJDIR)/misc.o: misc.c struct.h const.h sdlscreen.h global.h errors.h buttons.h \ - engine.h misc.h keyboard.h windows.h palette.h input.h graph.h pages.h + engine.h misc.h keyboard.h windows.h palette.h input.h graph.h pages.h $(OBJDIR)/miscfileformats.o: miscfileformats.c engine.h struct.h const.h errors.h \ - global.h io.h libraw2crtc.h loadsave.h misc.h sdlscreen.h windows.h \ - oldies.h -$(OBJDIR)/mountlist.o: mountlist.c -$(OBJDIR)/oldies.o: oldies.c struct.h const.h global.h errors.h misc.h palette.h + global.h io.h libraw2crtc.h loadsave.h misc.h sdlscreen.h windows.h \ + oldies.h +$(OBJDIR)/mountlist.o: mountlist.c mountlist.h +$(OBJDIR)/oldies.o: oldies.c struct.h const.h global.h errors.h misc.h palette.h \ + pages.h windows.h layers.h $(OBJDIR)/op_c.o: op_c.c op_c.h struct.h const.h colorred.h errors.h global.h \ - engine.h windows.h + engine.h windows.h $(OBJDIR)/operatio.o: operatio.c const.h struct.h global.h misc.h engine.h graph.h \ - operatio.h buttons.h pages.h errors.h sdlscreen.h brush.h windows.h \ - input.h + operatio.h buttons.h pages.h errors.h sdlscreen.h brush.h windows.h \ + input.h special.h tiles.h $(OBJDIR)/pages.o: pages.c global.h struct.h const.h pages.h errors.h loadsave.h \ - misc.h windows.h tiles.h + misc.h windows.h tiles.h graph.h $(OBJDIR)/palette.o: palette.c const.h struct.h global.h misc.h engine.h readline.h \ - buttons.h pages.h help.h sdlscreen.h errors.h op_c.h colorred.h \ - windows.h input.h palette.h shade.h -$(OBJDIR)/palette_test.o: palette_test.c const.h struct.h global.h misc.h engine.h \ - readline.h buttons.h pages.h help.h sdlscreen.h errors.h op_c.h \ - colorred.h windows.h input.h palette.h shade.h + buttons.h pages.h help.h sdlscreen.h errors.h op_c.h colorred.h \ + windows.h input.h palette.h shade.h $(OBJDIR)/pversion.o: pversion.c $(OBJDIR)/pxdouble.o: pxdouble.c global.h struct.h const.h sdlscreen.h misc.h \ - graph.h pxdouble.h pxwide.h + graph.h pxdouble.h pxwide.h $(OBJDIR)/pxquad.o: pxquad.c global.h struct.h const.h sdlscreen.h misc.h graph.h \ - pxquad.h + pxquad.h $(OBJDIR)/pxsimple.o: pxsimple.c global.h struct.h const.h sdlscreen.h misc.h \ - graph.h pxsimple.h -$(OBJDIR)/pxtall.o: pxtall.c global.h struct.h const.h sdlscreen.h misc.h graph.h \ - pxtall.h pxsimple.h + graph.h pxsimple.h $(OBJDIR)/pxtall2.o: pxtall2.c global.h struct.h const.h sdlscreen.h misc.h graph.h \ - pxtall2.h + pxtall2.h +$(OBJDIR)/pxtall.o: pxtall.c global.h struct.h const.h sdlscreen.h misc.h graph.h \ + pxtall.h pxsimple.h $(OBJDIR)/pxtriple.o: pxtriple.c global.h struct.h const.h sdlscreen.h misc.h \ - graph.h pxtriple.h -$(OBJDIR)/pxwide.o: pxwide.c global.h struct.h const.h sdlscreen.h misc.h graph.h \ - pxwide.h + graph.h pxtriple.h $(OBJDIR)/pxwide2.o: pxwide2.c global.h struct.h const.h sdlscreen.h misc.h graph.h \ - pxwide2.h + pxwide2.h +$(OBJDIR)/pxwide.o: pxwide.c global.h struct.h const.h sdlscreen.h misc.h graph.h \ + pxwide.h $(OBJDIR)/readini.o: readini.c const.h errors.h global.h struct.h misc.h readini.h \ - setup.h realpath.h io.h windows.h + setup.h realpath.h io.h windows.h $(OBJDIR)/readline.o: readline.c const.h struct.h global.h misc.h errors.h \ - sdlscreen.h readline.h windows.h input.h engine.h + sdlscreen.h readline.h windows.h input.h engine.h $(OBJDIR)/realpath.o: realpath.c $(OBJDIR)/saveini.o: saveini.c const.h global.h struct.h readini.h io.h errors.h \ - misc.h saveini.h setup.h windows.h + misc.h saveini.h setup.h windows.h $(OBJDIR)/sdlscreen.o: sdlscreen.c global.h struct.h const.h sdlscreen.h errors.h \ - misc.h + misc.h $(OBJDIR)/setup.o: setup.c struct.h const.h io.h setup.h +$(OBJDIR)/SFont.o: SFont.c SFont.h $(OBJDIR)/shade.o: shade.c global.h struct.h const.h graph.h engine.h errors.h \ - misc.h readline.h help.h sdlscreen.h windows.h input.h shade.h + misc.h readline.h help.h sdlscreen.h windows.h input.h shade.h $(OBJDIR)/special.o: special.c const.h struct.h global.h graph.h engine.h windows.h \ - special.h pages.h misc.h buttons.h + special.h pages.h misc.h buttons.h $(OBJDIR)/text.o: text.c SFont.h struct.h const.h global.h sdlscreen.h io.h \ - errors.h windows.h misc.h setup.h + errors.h windows.h misc.h setup.h $(OBJDIR)/tiles.o: tiles.c struct.h const.h global.h graph.h sdlscreen.h engine.h \ - windows.h input.h misc.h tiles.h + windows.h input.h misc.h tiles.h $(OBJDIR)/transform.o: transform.c global.h struct.h const.h transform.h engine.h \ - sdlscreen.h windows.h input.h help.h misc.h readline.h buttons.h pages.h \ - tiles.h + sdlscreen.h windows.h input.h help.h misc.h readline.h buttons.h \ + pages.h tiles.h $(OBJDIR)/version.o: version.c $(OBJDIR)/windows.o: windows.c windows.h struct.h const.h engine.h errors.h \ - global.h graph.h input.h misc.h op_c.h colorred.h readline.h sdlscreen.h \ - palette.h + global.h graph.h input.h misc.h op_c.h colorred.h readline.h \ + sdlscreen.h palette.h diff --git a/src/engine.c b/src/engine.c index 36d00cd0..d0ea51d9 100644 --- a/src/engine.c +++ b/src/engine.c @@ -44,6 +44,7 @@ #include "loadsave.h" #include "io.h" #include "pxsimple.h" +#include "oldies.h" // we need this as global diff --git a/src/fileformats.c b/src/fileformats.c index 70c0be90..73b88ddf 100644 --- a/src/fileformats.c +++ b/src/fileformats.c @@ -59,6 +59,7 @@ #include "misc.h" #include "struct.h" #include "io.h" +#include "pages.h" #include "windows.h" // Best_color() //////////////////////////////////// IMG //////////////////////////////////// @@ -4237,7 +4238,7 @@ void Save_PNG(T_IO_Context * context) // Give it to libpng png_set_unknown_chunks(png_ptr, info_ptr, &crng_chunk, 1); // libpng seems to ignore the location I provided earlier. - png_set_unknown_chunk_location(png_ptr, info_ptr, 0, PNG_HAVE_PLTE); + png_set_unknown_chunk_location(png_ptr, info_ptr, 0, PNG_HAVE_PLTE); } diff --git a/src/filesel.c b/src/filesel.c index 1d0559b0..7231bf26 100644 --- a/src/filesel.c +++ b/src/filesel.c @@ -67,33 +67,33 @@ #include "filesel.h" #define NORMAL_FILE_COLOR MC_Light // color du texte pour une ligne de - // fichier non sélectionné + // fichier non sélectionné #define NORMAL_DIRECTORY_COLOR MC_Dark // color du texte pour une ligne de - // répertoire non sélectionné + // répertoire non sélectionné #define NORMAL_BACKGROUND_COLOR MC_Black // color du fond pour une ligne - // non sélectionnée + // non sélectionnée #define SELECTED_FILE_COLOR MC_White // color du texte pour une ligne de - // fichier sélectionnée + // fichier sélectionnée #define SELECTED_DIRECTORY_COLOR MC_Light // color du texte pour une ligne de - // repértoire sélectionnée + // repértoire sélectionnée #define SELECTED_BACKGROUND_COLOR MC_Dark // color du fond pour une ligne - // sélectionnée + // sélectionnée // -- Native fileselector for WIN32 // Returns 0 if all ok, something else if failed byte Native_filesel(byte load) { - //load = load; + //load = load; #ifdef __WIN32__ OPENFILENAME ofn; char szFileName[MAX_PATH] = ""; - SDL_SysWMinfo wminfo; - HWND hwnd; - - SDL_VERSION(&wminfo.version); - SDL_GetWMInfo(&wminfo); - hwnd = wminfo.window; + SDL_SysWMinfo wminfo; + HWND hwnd; + + SDL_VERSION(&wminfo.version); + SDL_GetWMInfo(&wminfo); + hwnd = wminfo.window; ZeroMemory(&ofn, sizeof(ofn)); @@ -121,6 +121,7 @@ byte Native_filesel(byte load) return CommDlgExtendedError(); } #else + (void)load; // unused #ifndef __linux__ // This makes no sense on X11-oriented platforms. Nothing is really native there. #warning "EXPERIMENTAL function for native fileselector not available for this platform!" #endif @@ -435,7 +436,7 @@ void Read_list_of_files(T_Fileselector *list, byte selected_format) for (item = list->First; (((item != NULL) && (bFound==false))); item = item->Next){ if (item->Type == 1){ - if(strncmp(item->Full_name,"..",(sizeof(char)*2))==0) bFound=true; + if(strncmp(item->Full_name,"..",(sizeof(char)*2))==0) bFound=true; } } @@ -1292,7 +1293,7 @@ byte Button_Load_or_Save(byte load, T_IO_Context *context) byte save_or_load_image=0; byte has_clicked_ok=0;// Indique si on a clické sur Load ou Save ou sur //un bouton enclenchant Load ou Save juste après. - byte initial_back_color; // preview destroys it (how nice) + byte initial_back_color; // preview destroys it (how nice) char previous_directory[MAX_PATH_CHARACTERS]; // Répertoire d'où l'on vient après un CHDIR char save_filename[MAX_PATH_CHARACTERS]; char initial_comment[COMMENT_SIZE+1]; @@ -1590,31 +1591,31 @@ byte Button_Load_or_Save(byte load, T_IO_Context *context) Reset_quicksearch(); break; - case 6 : // Scroller des formats - // On met à jour le format de browsing du fileselect: - if (Main_format != Window_attribute2) { - char* savename = (char *)strdup(Selector_filename); - int nameLength = strlen(savename); - Main_format = Window_attribute2; - // Comme on change de liste, on se place en début de liste: - Main_fileselector_position = 0; - Main_fileselector_offset = 0; - // Affichage des premiers fichiers visibles: - Hide_cursor(); - Reload_list_of_files(Main_format, file_scroller); - New_preview_is_needed = 1; - Reset_quicksearch(); - strcpy(Selector_filename, savename); - if (Get_fileformat(Main_format)->Default_extension[0] != '\0' && - Selector_filename[nameLength - 4] == '.') - { - strcpy(Selector_filename + nameLength - 3, - Get_fileformat(Main_format)->Default_extension); - } - free(savename); - Print_filename_in_fileselector(); - Display_cursor(); - } + case 6 : // Scroller des formats + // On met à jour le format de browsing du fileselect: + if (Main_format != Window_attribute2) { + char* savename = (char *)strdup(Selector_filename); + int nameLength = strlen(savename); + Main_format = Window_attribute2; + // Comme on change de liste, on se place en début de liste: + Main_fileselector_position = 0; + Main_fileselector_offset = 0; + // Affichage des premiers fichiers visibles: + Hide_cursor(); + Reload_list_of_files(Main_format, file_scroller); + New_preview_is_needed = 1; + Reset_quicksearch(); + strcpy(Selector_filename, savename); + if (Get_fileformat(Main_format)->Default_extension[0] != '\0' && + Selector_filename[nameLength - 4] == '.') + { + strcpy(Selector_filename + nameLength - 3, + Get_fileformat(Main_format)->Default_extension); + } + free(savename); + Print_filename_in_fileselector(); + Display_cursor(); + } break; case 7 : // Saisie d'un commentaire pour la sauvegarde if ( (!load) && (Get_fileformat(Main_format)->Comment) ) diff --git a/src/io.c b/src/io.c index 171cb853..b499ad8d 100644 --- a/src/io.c +++ b/src/io.c @@ -317,6 +317,7 @@ int File_is_hidden(FILE_IS_HIDDEN_ATTRIBUTE const char *fname, const char *full_ { #if defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__) || defined(__MINT__) // False (unable to determine, or irrrelevent for platform) + (void)full_name;//unused return 0; #elif defined(__WIN32__) unsigned long att; @@ -328,6 +329,7 @@ int File_is_hidden(FILE_IS_HIDDEN_ATTRIBUTE const char *fname, const char *full_ return 0; return (att&FILE_ATTRIBUTE_HIDDEN)?1:0; #else + (void)full_name;//unused return fname[0]=='.'; #endif diff --git a/src/miscfileformats.c b/src/miscfileformats.c index 258c026a..cf79268c 100644 --- a/src/miscfileformats.c +++ b/src/miscfileformats.c @@ -2086,8 +2086,8 @@ void Test_C64(T_IO_Context * context) file_size = File_length_file(file); switch (file_size) { - // case 1000: // screen or color - // case 1002: // (screen or color) + loadaddr + // case 1000: // screen or color + // case 1002: // (screen or color) + loadaddr case 8000: // raw bitmap case 8002: // raw bitmap with loadaddr case 9000: // bitmap + ScreenRAM @@ -2434,7 +2434,7 @@ void Load_C64(T_IO_Context * context) // get load address word load_addr; load_addr = file_buffer[0] | (file_buffer[1] << 8); - sprintf(context->Comment+strlen(context->Comment),", load at $%04.4X",load_addr); + sprintf(context->Comment+strlen(context->Comment),", load at $%4.4X",load_addr); } else { diff --git a/src/oldies.c b/src/oldies.c index d78f098d..4bbccd44 100644 --- a/src/oldies.c +++ b/src/oldies.c @@ -30,6 +30,9 @@ #include "errors.h" #include "misc.h" #include "palette.h" +#include "pages.h" +#include "windows.h" +#include "layers.h" void Pixel_in_layer(word x,word y, byte layer, byte color) { @@ -408,4 +411,4 @@ byte C64_FLI_enforcer(void) return 0; -} +} diff --git a/src/operatio.c b/src/operatio.c index 2247d22e..232b74b0 100644 --- a/src/operatio.c +++ b/src/operatio.c @@ -4126,4 +4126,4 @@ void Pan_view_0_2(void) Start_operation_stack(Operation_before_interrupt); Display_cursor(); } -} \ No newline at end of file +} diff --git a/src/pages.c b/src/pages.c index 3779af48..46f62224 100644 --- a/src/pages.c +++ b/src/pages.c @@ -34,6 +34,7 @@ #include "misc.h" #include "windows.h" #include "tiles.h" +#include "graph.h" // -- Layers data diff --git a/src/readline.c b/src/readline.c index dd2953d9..cf6f020d 100644 --- a/src/readline.c +++ b/src/readline.c @@ -89,133 +89,133 @@ int Prepend_string(char* dest, char* src, int max) // Insert a string at the start of another. Up to MAX characters only // Returns actual number of chars inserted { - // Insert src before dest - int sized = strlen(dest); - int sizes = strlen(src); + // Insert src before dest + int sized = strlen(dest); + int sizes = strlen(src); - if (sized + sizes >= max) - { - sizes = max - sized; - } + if (sized + sizes >= max) + { + sizes = max - sized; + } - memmove(dest+sizes, dest, sized); - memcpy(dest, src, sizes); + memmove(dest+sizes, dest, sized); + memcpy(dest, src, sizes); - return sizes; + return sizes; } int Valid_character(word c, int input_type) - // returns 0 = Not allowed - // returns 1 = Allowed - // returns 2 = Allowed only once at start of string (for - sign in numbers) + // returns 0 = Not allowed + // returns 1 = Allowed + // returns 2 = Allowed only once at start of string (for - sign in numbers) { - // On va regarder si l'utilisateur le droit de se servir de cette touche - switch(input_type) - { - case INPUT_TYPE_STRING : - if ((c>=' ' && c<= 255) || c=='\n') - return 1; - break; - case INPUT_TYPE_INTEGER : - if ( (c>='0') && (c<='9') ) - return 1; - break; - case INPUT_TYPE_DECIMAL: - if ( (c>='0') && (c<='9') ) - return 1; - else if (c=='-') - return 2; - else if (c=='.') - return 1; - break; - case INPUT_TYPE_FILENAME: - { - // On regarde si la touche est autorisée - // Sous Linux: Seul le / est strictement interdit, mais beaucoup - // d'autres poseront des problèmes au shell, alors on évite. - // Sous Windows : c'est moins grave car le fopen() échouerait de toutes façons. - // AmigaOS4: Pas de ':' car utilisé pour les volumes. + // On va regarder si l'utilisateur le droit de se servir de cette touche + switch(input_type) + { + case INPUT_TYPE_STRING : + if ((c>=' ' && c<= 255) || c=='\n') + return 1; + break; + case INPUT_TYPE_INTEGER : + if ( (c>='0') && (c<='9') ) + return 1; + break; + case INPUT_TYPE_DECIMAL: + if ( (c>='0') && (c<='9') ) + return 1; + else if (c=='-') + return 2; + else if (c=='.') + return 1; + break; + case INPUT_TYPE_FILENAME: + { + // On regarde si la touche est autorisée + // Sous Linux: Seul le / est strictement interdit, mais beaucoup + // d'autres poseront des problèmes au shell, alors on évite. + // Sous Windows : c'est moins grave car le fopen() échouerait de toutes façons. + // AmigaOS4: Pas de ':' car utilisé pour les volumes. #if defined(__WIN32__) - char forbidden_char[] = {'/', '|', '?', '*', '<', '>', ':', '\\'}; + char forbidden_char[] = {'/', '|', '?', '*', '<', '>', ':', '\\'}; #elif defined (__amigaos4__) - char forbidden_char[] = {'/', '|', '?', '*', '<', '>', ':'}; + char forbidden_char[] = {'/', '|', '?', '*', '<', '>', ':'}; #else - char forbidden_char[] = {'/', '|', '?', '*', '<', '>'}; + char forbidden_char[] = {'/', '|', '?', '*', '<', '>'}; #endif - int position; + int position; - if (c < ' ' || c > 255) - return 0; + if (c < ' ' || c > 255) + return 0; - for (position=0; position<(long)sizeof(forbidden_char); position++) - if (c == forbidden_char[position]) - return 0; - return 1; - } - case INPUT_TYPE_HEXA: - if ( (c>='0') && (c<='9') ) - return 1; - else if ( (c>='A') && (c<='F') ) - return 1; - else if ( (c>='a') && (c<='f') ) - return 1; - break; - } // End du "switch(input_type)" - return 0; + for (position=0; position<(long)sizeof(forbidden_char); position++) + if (c == forbidden_char[position]) + return 0; + return 1; + } + case INPUT_TYPE_HEXA: + if ( (c>='0') && (c<='9') ) + return 1; + else if ( (c>='A') && (c<='F') ) + return 1; + else if ( (c>='a') && (c<='f') ) + return 1; + break; + } // End du "switch(input_type)" + return 0; } void Cleanup_string(char* str, int input_type) { - int i,j=0; - - for(i=0; str[i]!='\0'; i++) - { - if (Valid_character((unsigned char)(str[i]), input_type)) - { - str[j]=str[i]; - j++; - } - } - str[j] = '\0'; + int i,j=0; + + for(i=0; str[i]!='\0'; i++) + { + if (Valid_character((unsigned char)(str[i]), input_type)) + { + str[j]=str[i]; + j++; + } + } + str[j] = '\0'; } void Display_whole_string(word x_pos,word y_pos,char * str,byte position) { - char cursor[2]; - Print_general(x_pos,y_pos,str,TEXT_COLOR,BACKGROUND_COLOR); + char cursor[2]; + Print_general(x_pos,y_pos,str,TEXT_COLOR,BACKGROUND_COLOR); - cursor[0]=str[position] ? str[position] : ' '; - cursor[1]='\0'; - Print_general(x_pos+(position<<3)*Menu_factor_X,y_pos,cursor,CURSOR_COLOR,CURSOR_BACKGROUND_COLOR); + cursor[0]=str[position] ? str[position] : ' '; + cursor[1]='\0'; + Print_general(x_pos+(position<<3)*Menu_factor_X,y_pos,cursor,CURSOR_COLOR,CURSOR_BACKGROUND_COLOR); } void Init_virtual_keyboard(word y_pos, word keyboard_width, word keyboard_height) { - int h_pos; - int v_pos; - int parent_window_x=Window_pos_X+2; + int h_pos; + int v_pos; + int parent_window_x=Window_pos_X+2; - h_pos= Window_pos_X+(keyboard_width-Window_width)*Menu_factor_X/-2; - if (h_pos<0) - h_pos=0; - else if (h_pos+keyboard_width*Menu_factor_X>Screen_width) - h_pos=Screen_width-keyboard_width*Menu_factor_X; - v_pos=Window_pos_Y+(y_pos+9)*Menu_factor_Y; - if (v_pos+(keyboard_height*Menu_factor_Y)>Screen_height) - v_pos=Window_pos_Y+(y_pos-keyboard_height-4)*Menu_factor_Y; + h_pos= Window_pos_X+(keyboard_width-Window_width)*Menu_factor_X/-2; + if (h_pos<0) + h_pos=0; + else if (h_pos+keyboard_width*Menu_factor_X>Screen_width) + h_pos=Screen_width-keyboard_width*Menu_factor_X; + v_pos=Window_pos_Y+(y_pos+9)*Menu_factor_Y; + if (v_pos+(keyboard_height*Menu_factor_Y)>Screen_height) + v_pos=Window_pos_Y+(y_pos-keyboard_height-4)*Menu_factor_Y; - Hide_cursor(); - Open_popup(h_pos,v_pos,keyboard_width,keyboard_height); - Window_rectangle(1,0,Window_width-1, Window_height-1, MC_Light); - Window_rectangle(0,0,1,Window_height-2, MC_White); - // white border on top left angle, when it exceeds border. - if (parent_window_x>Window_pos_X) - Window_rectangle(0,0,(parent_window_x-Window_pos_X)/Menu_factor_X, 1, MC_White); - Window_rectangle(2,Window_height-2,Window_width-2, 2, MC_Black); - if(keyboard_width<320) - { - Window_rectangle(Window_width-2,2,2,Window_height-2, MC_Black); - } + Hide_cursor(); + Open_popup(h_pos,v_pos,keyboard_width,keyboard_height); + Window_rectangle(1,0,Window_width-1, Window_height-1, MC_Light); + Window_rectangle(0,0,1,Window_height-2, MC_White); + // white border on top left angle, when it exceeds border. + if (parent_window_x>Window_pos_X) + Window_rectangle(0,0,(parent_window_x-Window_pos_X)/Menu_factor_X, 1, MC_White); + Window_rectangle(2,Window_height-2,Window_width-2, 2, MC_Black); + if(keyboard_width<320) + { + Window_rectangle(Window_width-2,2,2,Window_height-2, MC_Black); + } } @@ -223,8 +223,8 @@ void Init_virtual_keyboard(word y_pos, word keyboard_width, word keyboard_height // TODO X11 and others char* getClipboard() { - char* dst = NULL; #ifdef __WIN32__ + char* dst = NULL; SDL_SysWMinfo info; HWND SDL_Window; @@ -250,11 +250,11 @@ char* getClipboard() } } #elif defined __HAIKU__ - return haiku_get_clipboard(); + return haiku_get_clipboard(); #else - #warning "Missing platform-specific code in getClipboard function" + // Not implemented (no standard) on Linux systems. Maybe someday... + return NULL; #endif - return dst; } diff --git a/src/sdlscreen.c b/src/sdlscreen.c index ee1127e6..7b479948 100644 --- a/src/sdlscreen.c +++ b/src/sdlscreen.c @@ -338,13 +338,15 @@ void Allow_drag_and_drop(int flag) { // Inform Windows that we accept drag-n-drop events or not #ifdef __WIN32__ - SDL_SysWMinfo wminfo; - HWND hwnd; - - SDL_VERSION(&wminfo.version); - SDL_GetWMInfo(&wminfo); - hwnd = wminfo.window; - DragAcceptFiles(hwnd,flag?TRUE:FALSE); - SDL_EventState (SDL_SYSWMEVENT,flag?SDL_ENABLE:SDL_DISABLE ); + SDL_SysWMinfo wminfo; + HWND hwnd; + + SDL_VERSION(&wminfo.version); + SDL_GetWMInfo(&wminfo); + hwnd = wminfo.window; + DragAcceptFiles(hwnd,flag?TRUE:FALSE); + SDL_EventState (SDL_SYSWMEVENT,flag?SDL_ENABLE:SDL_DISABLE ); + #else + (void)flag; // unused #endif -} \ No newline at end of file +}