Re: [AD] Re: file_select_ex patch

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


For the time being, here's a patch that simply restores the path when Cnacel 
is clicked, and makes selecting a directory and clicking Ok return TRUE (why 
would Ok'ing a dir return FALSE, anyway?)
Index: src/fsel.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/fsel.c,v
retrieving revision 1.42
diff -u -p -r1.42 fsel.c
--- src/fsel.c	12 Mar 2005 05:59:51 -0000	1.42
+++ src/fsel.c	18 Sep 2005 22:37:59 -0000
@@ -843,11 +843,15 @@ int file_select_ex(AL_CONST char *messag
 {
    static attrb_state_t default_attrb_state[ATTRB_MAX] = DEFAULT_ATTRB_STATE;
    int ret;
-   char *p;
+   char *p, *backup;
    char tmp[32];
    ASSERT(message);
    ASSERT(path);
 
+   backup = ustrdup(path);
+   if (!backup)
+      return FALSE;
+
    if (width == OLD_FILESEL_WIDTH)
       width = 305;
 
@@ -918,15 +922,22 @@ int file_select_ex(AL_CONST char *messag
       fext_p = NULL;
    }
 
-   if ((ret == FS_CANCEL) || (!ugetc(get_filename(path))))
+   if (ret == FS_CANCEL) {
+      ustrcpy(path, backup);
+      free(backup);
       return FALSE;
+   }
+
+   free(backup);
 
-   p = get_extension(path);
-   if ((!ugetc(p)) && (ext) && (!ustrpbrk(ext, uconvert_ascii(" ,;", tmp)))) {
-      size -= ((long)p - (long)path + ucwidth('.'));
-      if (size >= uwidth_max(U_CURRENT) + ucwidth(0)) {  /* do not end with '.' */
-         p += usetc(p, '.');
-         ustrzcpy(p, size, ext);
+   if (ugetc(get_filename(path))) {
+      p = get_extension(path);
+      if ((!ugetc(p)) && (ext) && (ugetc(ext)) && (!ustrpbrk(ext, uconvert_ascii(" ,;", tmp)))) {
+         size -= ((long)p - (long)path + ucwidth('.'));
+         if (size >= uwidth_max(U_CURRENT) + ucwidth(0)) {  /* do not end with '.' */
+            p += usetc(p, '.');
+            ustrzcpy(p, size, ext);
+         }
       }
    }
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/