[AD] file_select_ex patch |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
- To: alleg-developers@xxxxxxxxxx
- Subject: [AD] file_select_ex patch
- From: Chris <chris.kcat@xxxxxxxxxx>
- Date: Sun, 11 Sep 2005 16:53:57 -0700
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:from:to:subject:date:user-agent:mime-version:content-type:message-id; b=cQyLVjsUH3dudiyNQWPtjh6YZaWUn+TtGle583Y0DR5Sd0ss6oBc3DIHrHqagrW3zLxTK4J0dCDKhnt8KSjl2c1m0WTbv13AtzulNfnmMg072STR/uxF1AnqxzVZRMt6P23LDh/8/5LSkn5fJ+th5eImaAnreI8tAOqfxXpPpik=
This patch fixes file_select_ex so that passing an empty string for the
extension doesn't append a '.' to the end of the selected file, and so that
clicking Cancel restores the original path string.
Index: src/fsel.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/fsel.c,v
retrieving revision 1.42
diff -u -r1.42 fsel.c
--- src/fsel.c 12 Mar 2005 05:59:51 -0000 1.42
+++ src/fsel.c 11 Sep 2005 23:47:07 -0000
@@ -843,11 +843,15 @@
{
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,11 +922,19 @@
fext_p = NULL;
}
- if ((ret == FS_CANCEL) || (!ugetc(get_filename(path))))
+ if (ret == FS_CANCEL) {
+ ustrcpy(path, backup);
+ free(backup);
+ return FALSE;
+ }
+
+ free(backup);
+
+ if (!ugetc(get_filename(path)))
return FALSE;
p = get_extension(path);
- if ((!ugetc(p)) && (ext) && (!ustrpbrk(ext, uconvert_ascii(" ,;", tmp)))) {
+ 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, '.');