Updated file chooser and matching from Bill (better for WIN32).
git-svn-id: file:///fltk/svn/fltk/trunk@205 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
75e439ebbf
commit
27b2249266
@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// "$Id: filename_match.cxx,v 1.4 1999/01/07 19:17:35 mike Exp $"
|
// "$Id: filename_match.cxx,v 1.5 1999/01/07 21:22:28 mike Exp $"
|
||||||
//
|
//
|
||||||
// Pattern matching routines for the Fast Light Tool Kit (FLTK).
|
// Pattern matching routines for the Fast Light Tool Kit (FLTK).
|
||||||
//
|
//
|
||||||
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
/* Adapted from Rich Salz. */
|
/* Adapted from Rich Salz. */
|
||||||
#include <FL/filename.H>
|
#include <FL/filename.H>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
int filename_match(const char *s, const char *p) {
|
int filename_match(const char *s, const char *p) {
|
||||||
int matched;
|
int matched;
|
||||||
@ -88,15 +89,25 @@ int filename_match(const char *s, const char *p) {
|
|||||||
case 0: // end of pattern
|
case 0: // end of pattern
|
||||||
return !*s;
|
return !*s;
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
case '\\': // quote next character
|
case '\\': // quote next character
|
||||||
if (*p) p++;
|
if (*p) p++;
|
||||||
default : // other characters
|
|
||||||
if (*s++ != *(p-1)) return 0;
|
if (*s++ != *(p-1)) return 0;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
if (tolower(*s) != tolower(*(p-1))) return 0;
|
||||||
|
s++;
|
||||||
|
#else
|
||||||
|
case '\\': // quote next character
|
||||||
|
if (*p) p++;
|
||||||
|
default :
|
||||||
|
if (*s++ != *(p-1)) return 0;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// End of "$Id: filename_match.cxx,v 1.4 1999/01/07 19:17:35 mike Exp $".
|
// End of "$Id: filename_match.cxx,v 1.5 1999/01/07 21:22:28 mike Exp $".
|
||||||
//
|
//
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// "$Id: fl_file_chooser.cxx,v 1.9 1999/01/07 19:17:39 mike Exp $"
|
// "$Id: fl_file_chooser.cxx,v 1.10 1999/01/07 21:22:28 mike Exp $"
|
||||||
//
|
//
|
||||||
// File chooser widget for the Fast Light Tool Kit (FLTK).
|
// File chooser widget for the Fast Light Tool Kit (FLTK).
|
||||||
//
|
//
|
||||||
@ -305,7 +305,11 @@ void FCB::set(const char* buf) {
|
|||||||
any = 1;
|
any = 1;
|
||||||
const char* a = (*q)->d_name;
|
const char* a = (*q)->d_name;
|
||||||
const char* b = buf+bufdirend;
|
const char* b = buf+bufdirend;
|
||||||
|
#ifdef WIN32
|
||||||
|
while (*b && tolower(*a)==tolower(*b)) {a++; b++;}
|
||||||
|
#else
|
||||||
while (*b && *a==*b) {a++; b++;}
|
while (*b && *a==*b) {a++; b++;}
|
||||||
|
#endif
|
||||||
if (!*b && (*a==0 || /* *a=='/' ||*/ *a==1)) break;
|
if (!*b && (*a==0 || /* *a=='/' ||*/ *a==1)) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -323,7 +327,11 @@ void FCB::set(const char* buf) {
|
|||||||
any = 1;
|
any = 1;
|
||||||
const char* a = (*q)->d_name;
|
const char* a = (*q)->d_name;
|
||||||
const char* b = buf+bufdirend;
|
const char* b = buf+bufdirend;
|
||||||
|
#ifdef WIN32
|
||||||
|
while (*b && tolower(*a)==tolower(*b)) {a++; b++;}
|
||||||
|
#else
|
||||||
while (*b && *a==*b) {a++; b++;}
|
while (*b && *a==*b) {a++; b++;}
|
||||||
|
#endif
|
||||||
if (!*b && (*a==0 || /* *a=='/' ||*/ *a==1)) break;
|
if (!*b && (*a==0 || /* *a=='/' ||*/ *a==1)) break;
|
||||||
}
|
}
|
||||||
new_list();
|
new_list();
|
||||||
@ -614,5 +622,5 @@ char* fl_file_chooser(const char* message, const char* pat, const char* fname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// End of "$Id: fl_file_chooser.cxx,v 1.9 1999/01/07 19:17:39 mike Exp $".
|
// End of "$Id: fl_file_chooser.cxx,v 1.10 1999/01/07 21:22:28 mike Exp $".
|
||||||
//
|
//
|
||||||
|
Loading…
Reference in New Issue
Block a user