Re: [AD] Fix description of file_select_ex()

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


> Note that
>
> /* if not a directory, we check all attributes except FA_DIREC */
> 	if (c == 3)
> 	    continue;
>
> means that '+d' has no effect, which is redundant with no occurence of
> 'd'.
>
> Does anyone see a rationale for this behaviour? If no, I propose that we
> restore the symmetry and allow '+d' to mean 'directories only' for the
> 4.1.x series.

Here's the patch, including the required blurb for api._tx . I think it is 
pretty harmless and only extends the functionality of the function.

I plan to shortly commit it unless someone opposes.

-- 
Eric Botcazou
--- /home/eric/cvs/allegro/src/fsel.c	Wed May 14 20:10:52 2003
+++ allegro/src/fsel.c	Thu May 15 01:48:06 2003
@@ -419,9 +419,6 @@
       /* Check if file attributes match. */
       if (check_attrib) {
 	 for (c=0; c<ATTRB_MAX; c++) {
-	    /* ???? We check all attributes except FA_DIREC. */
-	    if (c == ATTRB_DIREC)
-	       continue;
 	    if ((attrb_state[c] == ATTRB_SET) && (!(attrib & attrb_flag[c])))
 	       return 0;
 	    if ((attrb_state[c] == ATTRB_UNSET) && (attrib & attrb_flag[c]))
@@ -532,15 +529,16 @@
       replace_filename(flist->dir, s, uconvert_ascii("*.*", tmp), sizeof(flist->dir));
 
       /* The semantics of the attributes passed to file_select_ex() is
-       * different from that of for_each_file_ex() because directories
-       * are always all included regardless of the other specified
-       * attributes, unless they are all excluded. So we can't filter
-       * with for_each_file_ex() unless we are in the latter case.
+       * different from that of for_each_file_ex() in one case: when
+       * the 'd' attribute is not mentioned in the set of characters,
+       * the other attributes are not taken into account for directories,
+       * i.e the directories are all included. So we can't filter with
+       * for_each_file_ex() in that case.
        */
-      if (attrb_state[ATTRB_DIREC] == ATTRB_UNSET)
-	 for_each_file_ex(flist->dir, build_attrb_flag(ATTRB_SET), build_attrb_flag(ATTRB_UNSET) | FA_LABEL, fs_flist_putter, (void *)FALSE /* don't check */);
-      else
+      if (attrb_state[ATTRB_DIREC] == ATTRB_ABSENT)
 	 for_each_file_ex(flist->dir, 0 /* accept all dirs */, FA_LABEL, fs_flist_putter, (void *)TRUE /* check */);
+      else
+	 for_each_file_ex(flist->dir, build_attrb_flag(ATTRB_SET), build_attrb_flag(ATTRB_UNSET) | FA_LABEL, fs_flist_putter, (void *)FALSE /* don't check */);
 
       usetc(get_filename(flist->dir), 0);
       d->d1 = d->d2 = 0;
--- /home/eric/cvs/allegro/docs/src/allegro._tx	Thu May 15 01:21:34 2003
+++ allegro/docs/src/allegro._tx	Thu May 15 00:55:41 2003
@@ -8002,15 +8002,14 @@
    example, an extension string of "PCX;BMP;/+r-h" will display only PCX or
    BMP files that are read-only and not hidden. The directories are not
    affected in the same way as the other files by the extension string: the
-   extensions and other attributes are never taken into account for them and
-   the 'd' character has no effect unless preceded by '-'; in other words,
-   all directories are included when '(+)d' is passed or when 'd' is not
-   mentioned in the string. The file selector is stretched to the width and
-   height specified in the w and h parameters, and to the size of the
-   standard Allegro font. If either the width or height argument is set to
-   zero, it is stretched to the corresponding screen dimension. This
-   function returns zero if it was closed with the Cancel button or non-zero
-   if it was OK'd.
+   extensions are never taken into account for them and the other attributes
+   are taken into account only when 'd' is mentioned in the string; in other
+   words, all directories are included when 'd' is not mentioned in the
+   string. The file selector is stretched to the width and height specified
+   in the w and h parameters, and to the size of the standard Allegro font.
+   If either the width or height argument is set to zero, it is stretched
+   to the corresponding screen dimension. This function returns zero if it
+   was closed with the Cancel button or non-zero if it was OK'd.
 
 @@int @gfx_mode_select(int *card, int *w, int *h);
 @xref gfx_mode_select_ex, set_gfx_mode, gui_fg_color
--- /home/eric/cvs/allegro/docs/src/api._tx	Thu Jan 23 14:13:07 2003
+++ allegro/docs/src/api._tx	Thu May 15 01:44:11 2003
@@ -93,6 +93,10 @@
 <li>
    object_message() now takes care of scaring and unscaring the mouse if the
    message to be sent is MSG_DRAW.
+<li>
+   file_select_ex() now treats '(+)d' as it does for any other attributes in
+   the extension string which is passed to it: only directories are included
+   and, among them, only those with the correct set of attributes.
 </ul>
 
 @heading


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