Re: [AD] Re: file_select_ex patch |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
- To: alleg-developers@xxxxxxxxxx
- Subject: Re: [AD] Re: file_select_ex patch
- From: Chris <chris.kcat@xxxxxxxxxx>
- Date: Sun, 18 Sep 2005 15:40:57 -0700
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:from:to:subject:date:user-agent:references:in-reply-to:mime-version:content-type:message-id; b=jACEIKVV6G0wsteOdYo8FHq+fHvX99bFVLHy5fj4JMefRc36DL5DSg8hAaM5fXZC/DE94t6XwDjZ1h8NJq7zukNAai9Uj8NhBjTMkDcAjJlAu7GOmmmhWnXj+UAfQoG/9+3bJoQz/U+Hhx2934NVHurFrkU4/pRcE+nQ7Aa0ha0=
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);
+ }
}
}