diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2020-07-01 18:03:10 +0200 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2020-07-06 20:28:20 +0200 |
| commit | f09e17c3c564e8310125a10c03397cbf473ff643 (patch) | |
| tree | 8d0fd4a28e3686c33aaa140d07ddba26ab28bdc2 /src/Fl_Native_File_Chooser_WIN32.cxx | |
| parent | b0e0c355edaa2e23148cb0260ada907aec930f05 (diff) | |
Remove $Id$ tags, update URL's, and more
- remove obsolete svn '$Id$' tags from all source files
- update .fl files and generated files accordingly
- replace 'http://www.fltk.org' URL's with 'https://...'
- replace bug report URL 'str.php' with 'bugs.php'
- remove trailing whitespace
- fix other whitespace errors flagged by Git
- add and/or fix missing or wrong standard headers
- convert tabs to spaces in all source files
The only relevant code changes are in the fluid/ folder where
some .fl files and other source files were used to generate
the '$Id' headers and footers.
Diffstat (limited to 'src/Fl_Native_File_Chooser_WIN32.cxx')
| -rw-r--r-- | src/Fl_Native_File_Chooser_WIN32.cxx | 405 |
1 files changed, 200 insertions, 205 deletions
diff --git a/src/Fl_Native_File_Chooser_WIN32.cxx b/src/Fl_Native_File_Chooser_WIN32.cxx index 3f6b6d9e7..594afd53e 100644 --- a/src/Fl_Native_File_Chooser_WIN32.cxx +++ b/src/Fl_Native_File_Chooser_WIN32.cxx @@ -1,4 +1,3 @@ -// "$Id$" // // FLTK native OS file chooser widget // @@ -10,65 +9,65 @@ // the file "COPYING" which should have been included with this file. If this // file is missing or damaged, see the license at: // -// http://www.fltk.org/COPYING.php +// https://www.fltk.org/COPYING.php // -// Please report all bugs and problems to: +// Please see the following page on how to report bugs and issues: // -// http://www.fltk.org/str.php +// https://www.fltk.org/bugs.php // // Any application to multi-folder implementation: // http://www.codeproject.com/dialog/selectfolder.asp // -#ifndef FL_DOXYGEN // PREVENT DOXYGEN'S USE OF THIS FILE +#ifndef FL_DOXYGEN // PREVENT DOXYGEN'S USE OF THIS FILE #include <FL/Enumerations.H> -#include <stdlib.h> // malloc -#include <stdio.h> // sprintf +#include <stdlib.h> // malloc +#include <stdio.h> // sprintf #include <wchar.h> -#define FNFC_MAX_PATH 32768 // XXX: MAX_PATH under win32 is 260, too small for modern use +#define FNFC_MAX_PATH 32768 // XXX: MAX_PATH under win32 is 260, too small for modern use #include <FL/Fl_Native_File_Chooser.H> # include <windows.h> -# include <commdlg.h> // OPENFILENAMEW, GetOpenFileName() -# include <shlobj.h> // BROWSEINFOW, SHBrowseForFolder() -# include <FL/filename.H> // FL_EXPORT -#include <FL/platform.H> // fl_open_display +# include <commdlg.h> // OPENFILENAMEW, GetOpenFileName() +# include <shlobj.h> // BROWSEINFOW, SHBrowseForFolder() +# include <FL/filename.H> // FL_EXPORT +#include <FL/platform.H> // fl_open_display class Fl_WinAPI_Native_File_Chooser_Driver : public Fl_Native_File_Chooser_Driver { private: - int _btype; // kind-of browser to show() - int _options; // general options - OPENFILENAMEW *_ofn_ptr; // GetOpenFileName() & GetSaveFileName() struct - BROWSEINFOW *_binf_ptr; // SHBrowseForFolder() struct - WCHAR *_wpattern; // pattern buffer for filter - char **_pathnames; // array of pathnames - int _tpathnames; // total pathnames - char *_directory; // default pathname to use - char *_title; // title for window - char *_filter; // user-side search filter - char *_parsedfilt; // filter parsed for Windows dialog - int _nfilters; // number of filters parse_filter counted - char *_preset_file; // the file to preselect - char *_errmsg; // error message - + int _btype; // kind-of browser to show() + int _options; // general options + OPENFILENAMEW *_ofn_ptr; // GetOpenFileName() & GetSaveFileName() struct + BROWSEINFOW *_binf_ptr; // SHBrowseForFolder() struct + WCHAR *_wpattern; // pattern buffer for filter + char **_pathnames; // array of pathnames + int _tpathnames; // total pathnames + char *_directory; // default pathname to use + char *_title; // title for window + char *_filter; // user-side search filter + char *_parsedfilt; // filter parsed for Windows dialog + int _nfilters; // number of filters parse_filter counted + char *_preset_file; // the file to preselect + char *_errmsg; // error message + // Private methods void errmsg(const char *msg); - + void clear_pathnames(); void set_single_pathname(const char *s); void add_pathname(const char *s); - + void ClearOFN(); void ClearBINF(); void Win2Unix(char *s); void Unix2Win(char *s); int showfile(); int showdir(); - + void parse_filter(const char *); void clear_filters(); void add_filter(const char *, const char *); @@ -107,10 +106,10 @@ static LPCWSTR utf8towchar(const char *in); static char *wchartoutf8(LPCWSTR in); -#define LCURLY_CHR '{' -#define RCURLY_CHR '}' -#define LBRACKET_CHR '[' -#define RBRACKET_CHR ']' +#define LCURLY_CHR '{' +#define RCURLY_CHR '}' +#define LBRACKET_CHR '[' +#define RBRACKET_CHR ']' // STATIC: PRINT WINDOWS 'DOUBLE NULL' STRING (DEBUG) #ifdef DEBUG @@ -165,9 +164,9 @@ static void dnullcat(char*&wp, const char *string, int n = -1 ) { int wplen = dnulllen(wp); // Make copy of wp into larger buffer char *tmp = new char[wplen + inlen + 4]; - memcpy(tmp, wp, wplen+2); // copy of wp plus doublenull - delete[] wp; // delete old wp - wp = tmp; // use new copy + memcpy(tmp, wp, wplen+2); // copy of wp plus doublenull + delete[] wp; // delete old wp + wp = tmp; // use new copy //DEBUG printf("DEBUG: dnullcat COPY: <"); dnullprint(wp); printf("> (wplen=%d)\n", wplen); } @@ -290,11 +289,11 @@ void Fl_WinAPI_Native_File_Chooser_Driver::add_pathname(const char *s) { _pathnames = new char*[_tpathnames]; } else { // Grow array by 1 - char **tmp = new char*[_tpathnames+1]; // create new buffer + char **tmp = new char*[_tpathnames+1]; // create new buffer memcpy((void*)tmp, (void*)_pathnames, - sizeof(char*)*_tpathnames); // copy old - delete[] _pathnames; // delete old - _pathnames = tmp; // use new + sizeof(char*)*_tpathnames); // copy old + delete[] _pathnames; // delete old + _pathnames = tmp; // use new ++_tpathnames; } _pathnames[_tpathnames-1] = strnew(s); @@ -321,8 +320,8 @@ void Fl_WinAPI_Native_File_Chooser_Driver::ClearOFN() { delete[] (TCHAR*) _ofn_ptr->lpstrInitialDir; //msvc6 compilation fix _ofn_ptr->lpstrInitialDir = NULL; } - _ofn_ptr->lpstrFilter = NULL; // (deleted elsewhere) - int temp = _ofn_ptr->nFilterIndex; // keep the filter_value + _ofn_ptr->lpstrFilter = NULL; // (deleted elsewhere) + int temp = _ofn_ptr->nFilterIndex; // keep the filter_value memset((void*)_ofn_ptr, 0, sizeof(OPENFILENAMEW)); _ofn_ptr->lStructSize = sizeof(OPENFILENAMEW); _ofn_ptr->nFilterIndex = temp; @@ -379,18 +378,18 @@ int Fl_WinAPI_Native_File_Chooser_Driver::showfile() { ClearOFN(); clear_pathnames(); size_t fsize = FNFC_MAX_PATH; - _ofn_ptr->Flags |= OFN_NOVALIDATE; // prevent disabling of front slashes - _ofn_ptr->Flags |= OFN_HIDEREADONLY; // hide goofy readonly flag + _ofn_ptr->Flags |= OFN_NOVALIDATE; // prevent disabling of front slashes + _ofn_ptr->Flags |= OFN_HIDEREADONLY; // hide goofy readonly flag // USE NEW BROWSER - _ofn_ptr->Flags |= OFN_EXPLORER; // use newer explorer windows - _ofn_ptr->Flags |= OFN_ENABLESIZING; // allow window to be resized (hey, why not?) - _ofn_ptr->Flags |= OFN_NOCHANGEDIR; // XXX: docs say ineffective on XP/2K/NT, but set it anyway.. + _ofn_ptr->Flags |= OFN_EXPLORER; // use newer explorer windows + _ofn_ptr->Flags |= OFN_ENABLESIZING; // allow window to be resized (hey, why not?) + _ofn_ptr->Flags |= OFN_NOCHANGEDIR; // XXX: docs say ineffective on XP/2K/NT, but set it anyway.. switch ( _btype ) { case Fl_Native_File_Chooser::BROWSE_DIRECTORY: case Fl_Native_File_Chooser::BROWSE_MULTI_DIRECTORY: case Fl_Native_File_Chooser::BROWSE_SAVE_DIRECTORY: - abort(); // never happens: handled by showdir() + abort(); // never happens: handled by showdir() case Fl_Native_File_Chooser::BROWSE_FILE: break; case Fl_Native_File_Chooser::BROWSE_MULTI_FILE: @@ -398,7 +397,7 @@ int Fl_WinAPI_Native_File_Chooser_Driver::showfile() { break; case Fl_Native_File_Chooser::BROWSE_SAVE_FILE: if ( options() & Fl_Native_File_Chooser::SAVEAS_CONFIRM && type() == Fl_Native_File_Chooser::BROWSE_SAVE_FILE ) { - _ofn_ptr->Flags |= OFN_OVERWRITEPROMPT; + _ofn_ptr->Flags |= OFN_OVERWRITEPROMPT; } break; } @@ -406,7 +405,7 @@ int Fl_WinAPI_Native_File_Chooser_Driver::showfile() { _ofn_ptr->lpstrFile = new WCHAR[fsize]; _ofn_ptr->nMaxFile = (DWORD) fsize-1; _ofn_ptr->lpstrFile[0] = 0; - _ofn_ptr->lpstrFile[1] = 0; // dnull + _ofn_ptr->lpstrFile[1] = 0; // dnull // PARENT WINDOW _ofn_ptr->hwndOwner = GetForegroundWindow(); // DIALOG TITLE @@ -419,7 +418,7 @@ int Fl_WinAPI_Native_File_Chooser_Driver::showfile() { _ofn_ptr->lpstrTitle = NULL; } // FILTER - if (_parsedfilt != NULL) { // to convert a null-containing char string into a widechar string + if (_parsedfilt != NULL) { // to convert a null-containing char string into a widechar string // NEW if ( !_wpattern ) _wpattern = new WCHAR[FNFC_MAX_PATH]; const char *p = _parsedfilt; @@ -444,7 +443,7 @@ int Fl_WinAPI_Native_File_Chooser_Driver::showfile() { wcscpy(_ofn_ptr->lpstrFile, utf8towchar(_preset_file)); // Unix2Win(_ofn_ptr->lpstrFile); len = wcslen(_ofn_ptr->lpstrFile); - _ofn_ptr->lpstrFile[len+0] = 0; // multiselect needs dnull + _ofn_ptr->lpstrFile[len+0] = 0; // multiselect needs dnull _ofn_ptr->lpstrFile[len+1] = 0; } if ( _directory ) { @@ -459,7 +458,7 @@ int Fl_WinAPI_Native_File_Chooser_Driver::showfile() { // SAVE THE CURRENT DIRECTORY // See above warning (XXX) for OFN_NOCHANGEDIR // - char *save_cwd = SaveCWD(); // must be freed with RestoreCWD() + char *save_cwd = SaveCWD(); // must be freed with RestoreCWD() // OPEN THE DIALOG WINDOW int err; if ( _btype == Fl_Native_File_Chooser::BROWSE_SAVE_FILE ) { @@ -470,10 +469,10 @@ int Fl_WinAPI_Native_File_Chooser_Driver::showfile() { // GET EXTENDED ERROR int exterr = CommDlgExtendedError(); // RESTORE CURRENT DIRECTORY - RestoreCWD(save_cwd); save_cwd = 0; // also frees save_cwd + RestoreCWD(save_cwd); save_cwd = 0; // also frees save_cwd // ERROR OR CANCEL? if ( err == 0 ) { - if ( exterr == 0 ) return(1); // user hit cancel + if ( exterr == 0 ) return(1); // user hit cancel // Otherwise, an error occurred.. char msg[80]; sprintf(msg, "CommDlgExtendedError() code=%d", err); @@ -492,17 +491,17 @@ int Fl_WinAPI_Native_File_Chooser_Driver::showfile() { const WCHAR *dirname = _ofn_ptr->lpstrFile; size_t dirlen = wcslen(dirname); if ( dirlen > 0 ) { - // WALK STRING SEARCHING FOR 'DOUBLE-NULL' - // eg. "/dir/name\0foo1\0foo2\0foo3\0\0" - // - char pathname[FNFC_MAX_PATH]; - for ( const WCHAR *s = dirname + dirlen + 1; - *s; s+= (wcslen(s)+1)) { - strcpy(pathname, wchartoutf8(dirname)); - strcat(pathname, "\\"); - strcat(pathname, wchartoutf8(s)); - add_pathname(pathname); - } + // WALK STRING SEARCHING FOR 'DOUBLE-NULL' + // eg. "/dir/name\0foo1\0foo2\0foo3\0\0" + // + char pathname[FNFC_MAX_PATH]; + for ( const WCHAR *s = dirname + dirlen + 1; + *s; s+= (wcslen(s)+1)) { + strcpy(pathname, wchartoutf8(dirname)); + strcat(pathname, "\\"); + strcat(pathname, wchartoutf8(s)); + add_pathname(pathname); + } } // XXX // Work around problem where pasted forward-slash pathname @@ -510,15 +509,15 @@ int Fl_WinAPI_Native_File_Chooser_Driver::showfile() { // not to grok forward slashes, passing back as a 'filename'..! // if ( _tpathnames == 0 ) { - add_pathname(wchartoutf8(dirname)); - // Win2Unix(_pathnames[_tpathnames-1]); + add_pathname(wchartoutf8(dirname)); + // Win2Unix(_pathnames[_tpathnames-1]); } break; } case Fl_Native_File_Chooser::BROWSE_DIRECTORY: case Fl_Native_File_Chooser::BROWSE_MULTI_DIRECTORY: case Fl_Native_File_Chooser::BROWSE_SAVE_DIRECTORY: - abort(); // never happens: handled by showdir() + abort(); // never happens: handled by showdir() } return(0); } @@ -535,10 +534,10 @@ static int CALLBACK Dir_CB(HWND win, UINT msg, LPARAM param, LPARAM data) { case BFFM_SELCHANGED: TCHAR path[FNFC_MAX_PATH]; if ( SHGetPathFromIDList((ITEMIDLIST*)param, path) ) { - ::SendMessage(win, BFFM_ENABLEOK, 0, 1); + ::SendMessage(win, BFFM_ENABLEOK, 0, 1); } else { - // disable ok button if not a path - ::SendMessage(win, BFFM_ENABLEOK, 0, 0); + // disable ok button if not a path + ::SendMessage(win, BFFM_ENABLEOK, 0, 0); } break; case BFFM_VALIDATEFAILED: @@ -554,7 +553,7 @@ static int CALLBACK Dir_CB(HWND win, UINT msg, LPARAM param, LPARAM data) { // SHOW DIRECTORY BROWSER int Fl_WinAPI_Native_File_Chooser_Driver::showdir() { // initialize OLE only once - fl_open_display(); // init needed by BIF_USENEWUI + fl_open_display(); // init needed by BIF_USENEWUI ClearBINF(); clear_pathnames(); // PARENT WINDOW @@ -571,7 +570,7 @@ int Fl_WinAPI_Native_File_Chooser_Driver::showdir() { } // FLAGS - _binf_ptr->ulFlags = 0; // initialize + _binf_ptr->ulFlags = 0; // initialize // TBD: make sure matches to runtime system, if need be. //(what if _WIN32_IE doesn't match system? does the program not run?) @@ -588,16 +587,16 @@ int Fl_WinAPI_Native_File_Chooser_Driver::showdir() { // drives, and with BIF_SHAREABLE set I do not. // --- -#if defined(BIF_NONEWFOLDERBUTTON) // Version 6.0 +#if defined(BIF_NONEWFOLDERBUTTON) // Version 6.0 if ( _btype == Fl_Native_File_Chooser::BROWSE_DIRECTORY ) _binf_ptr->ulFlags |= BIF_NONEWFOLDERBUTTON; _binf_ptr->ulFlags |= BIF_USENEWUI | BIF_RETURNONLYFSDIRS; -#elif defined(BIF_USENEWUI) // Version 5.0 +#elif defined(BIF_USENEWUI) // Version 5.0 if ( _btype == Fl_Native_File_Chooser::BROWSE_DIRECTORY ) _binf_ptr->ulFlags |= BIF_EDITBOX; else if ( _btype == Fl_Native_File_Chooser::BROWSE_SAVE_DIRECTORY ) _binf_ptr->ulFlags |= BIF_USENEWUI; _binf_ptr->ulFlags |= BIF_RETURNONLYFSDIRS; -#elif defined(BIF_EDITBOX) // Version 4.71 +#elif defined(BIF_EDITBOX) // Version 4.71 _binf_ptr->ulFlags |= BIF_RETURNONLYFSDIRS | BIF_EDITBOX; -#else // Version Old +#else // Version Old _binf_ptr->ulFlags |= BIF_RETURNONLYFSDIRS; #endif @@ -721,7 +720,7 @@ void Fl_WinAPI_Native_File_Chooser_Driver::filter(const char *val) { _filter = strnew(val); parse_filter(_filter); } - add_filter("All Files", "*.*"); // always include 'all files' option + add_filter("All Files", "*.*"); // always include 'all files' option #ifdef DEBUG dnullprint(_parsedfilt); @@ -742,8 +741,8 @@ void Fl_WinAPI_Native_File_Chooser_Driver::clear_filters() { } // ADD A FILTER -void Fl_WinAPI_Native_File_Chooser_Driver::add_filter(const char *name_in, // name of filter (optional: can be null) - const char *winfilter) { // windows style filter (eg. "*.cxx;*.h") +void Fl_WinAPI_Native_File_Chooser_Driver::add_filter(const char *name_in, // name of filter (optional: can be null) + const char *winfilter) { // windows style filter (eg. "*.cxx;*.h") // No name? Make one.. char name[1024]; if ( !name_in || name_in[0] == '\0' ) { @@ -771,40 +770,40 @@ static int count_filters(const char *filter) { const char *in = filter; while (*in) { switch(*in) { - case '\\': // escape next character - ++in; if ( *in == 0 ) continue; // skip escape. EOL? done - ++in; // skip escaped char - continue; - case LCURLY_CHR: // start "{aaa,bbb}" - mode = *in; // set mode, parse over curly - ++count; // at least +1 wildcard - break; - case RCURLY_CHR: // end "{aaa,bbb}" - if ( mode == LCURLY_CHR ) // disable curly mode (if on) - mode = 0; - break; - case LBRACKET_CHR: // start "[xyz]" - mode = *in; // set mode, parse over bracket - break; - case RBRACKET_CHR: // end "[xyz]" - if ( mode == LBRACKET_CHR ) // disable bracket mode (if on) - mode = 0; - break; - default: // any other char - switch (mode) { // handle {} or [] modes - case LCURLY_CHR: // handle "{aaa,bbb}" - if (*in==',' || *in=='|') // ',' and '|' adds filters - ++count; - break; - case LBRACKET_CHR: // handle "[xyz]" - ++count; // all chars in []'s add new filter - break; - } - break; + case '\\': // escape next character + ++in; if ( *in == 0 ) continue; // skip escape. EOL? done + ++in; // skip escaped char + continue; + case LCURLY_CHR: // start "{aaa,bbb}" + mode = *in; // set mode, parse over curly + ++count; // at least +1 wildcard + break; + case RCURLY_CHR: // end "{aaa,bbb}" + if ( mode == LCURLY_CHR ) // disable curly mode (if on) + mode = 0; + break; + case LBRACKET_CHR: // start "[xyz]" + mode = *in; // set mode, parse over bracket + break; + case RBRACKET_CHR: // end "[xyz]" + if ( mode == LBRACKET_CHR ) // disable bracket mode (if on) + mode = 0; + break; + default: // any other char + switch (mode) { // handle {} or [] modes + case LCURLY_CHR: // handle "{aaa,bbb}" + if (*in==',' || *in=='|') // ',' and '|' adds filters + ++count; + break; + case LBRACKET_CHR: // handle "[xyz]" + ++count; // all chars in []'s add new filter + break; + } + break; } - ++in; // parse past char + ++in; // parse past char } - return count > 0 ? count : 1; // return at least 1 + return count > 0 ? count : 1; // return at least 1 } // CONVERT FLTK STYLE PATTERN MATCHES TO WINDOWS 'DOUBLENULL' PATTERN @@ -837,7 +836,7 @@ void Fl_WinAPI_Native_File_Chooser_Driver::parse_filter(const char *in) { if ( ! in || in[0] == '\0' ) return; int has_name = strchr(in, '\t') ? 1 : 0; - char mode = has_name ? 'n' : 'w'; // parse mode: n=name, w=wildcard + char mode = has_name ? 'n' : 'w'; // parse mode: n=name, w=wildcard // whatever input string is, our output won't be much longer in length.. // use double length just for safety. @@ -848,8 +847,8 @@ void Fl_WinAPI_Native_File_Chooser_Driver::parse_filter(const char *in) { // Init int nwildcards = 0; - int maxfilters = count_filters(in) + 1; // count wildcard seps - char **wildcards = new char*[maxfilters]; // parsed wildcards (can be several) + int maxfilters = count_filters(in) + 1; // count wildcard seps + char **wildcards = new char*[maxfilters]; // parsed wildcards (can be several) int t; for ( t=0; t<maxfilters; t++ ) { wildcards[t] = new char[slen+1]; @@ -866,114 +865,114 @@ void Fl_WinAPI_Native_File_Chooser_Driver::parse_filter(const char *in) { switch (*in) { case ',': case '|': - if ( mode == LCURLY_CHR ) { - // create new wildcard, copy in prefix - strcat(wildcards[nwildcards++], wildprefix); - continue; - } else { - goto regchar; - } - continue; + if ( mode == LCURLY_CHR ) { + // create new wildcard, copy in prefix + strcat(wildcards[nwildcards++], wildprefix); + continue; + } else { + goto regchar; + } + continue; // FINISHED PARSING A NAME? case '\t': - if ( mode != 'n' ) goto regchar; - // finish parsing name? switch to wildcard mode - mode = 'w'; - break; + if ( mode != 'n' ) goto regchar; + // finish parsing name? switch to wildcard mode + mode = 'w'; + break; // ESCAPE NEXT CHAR case '\\': - ++in; - goto regchar; + ++in; + goto regchar; // FINISHED PARSING ONE OF POSSIBLY SEVERAL FILTERS? case '\r': case '\n': case '\0': { - if ( mode == 'w' ) { // finished parsing wildcard? - if ( nwildcards == 0 ) { - strcpy(wildcards[nwildcards++], wildprefix); - } - // Append wildcards in Microsoft's "*.one;*.two" format - comp[0] = 0; - for ( t=0; t<nwildcards; t++ ) { - if ( t != 0 ) strcat(comp, ";"); - strcat(comp, wildcards[t]); - } - // Add if not empty - if ( comp[0] ) { - add_filter(name, comp); - } - } - // RESET - for ( t=0; t<maxfilters; t++ ) { - wildcards[t][0] = '\0'; - } - nwildcards = 0; - wildprefix[0] = name[0] = '\0'; - mode = strchr(in,'\t') ? 'n' : 'w'; - // DONE? - if ( *in == '\0' ) { // done - // Free everything - delete[] wildprefix; - delete[] comp; - delete[] name; - for ( t=0; t<maxfilters; t++ ) delete[] wildcards[t]; - delete[] wildcards; - return; - } - continue; // not done yet, more filters + if ( mode == 'w' ) { // finished parsing wildcard? + if ( nwildcards == 0 ) { + strcpy(wildcards[nwildcards++], wildprefix); + } + // Append wildcards in Microsoft's "*.one;*.two" format + comp[0] = 0; + for ( t=0; t<nwildcards; t++ ) { + if ( t != 0 ) strcat(comp, ";"); + strcat(comp, wildcards[t]); + } + // Add if not empty + if ( comp[0] ) { + add_filter(name, comp); + } + } + // RESET + for ( t=0; t<maxfilters; t++ ) { + wildcards[t][0] = '\0'; + } + nwildcards = 0; + wildprefix[0] = name[0] = '\0'; + mode = strchr(in,'\t') ? 'n' : 'w'; + // DONE? + if ( *in == '\0' ) { // done + // Free everything + delete[] wildprefix; + delete[] comp; + delete[] name; + for ( t=0; t<maxfilters; t++ ) delete[] wildcards[t]; + delete[] wildcards; + return; + } + continue; // not done yet, more filters } // STARTING A WILDCARD? case LBRACKET_CHR: case LCURLY_CHR: - mode = *in; - if ( *in == LCURLY_CHR ) { - // create new wildcard - strcat(wildcards[nwildcards++], wildprefix); - } - continue; + mode = *in; + if ( *in == LCURLY_CHR ) { + // create new wildcard + strcat(wildcards[nwildcards++], wildprefix); + } + continue; // ENDING A WILDCARD? case RBRACKET_CHR: case RCURLY_CHR: - mode = 'w'; // back to wildcard mode - continue; + mode = 'w'; // back to wildcard mode + continue; // ALL OTHER NON-SPECIAL CHARACTERS default: - regchar: // handle regular char - switch ( mode ) { - case LBRACKET_CHR: - // create new wildcard - ++nwildcards; - // copy in prefix - strcpy(wildcards[nwildcards-1], wildprefix); - // append search char - chrcat(wildcards[nwildcards-1], *in); - continue; - - case LCURLY_CHR: - if ( nwildcards > 0 ) { - chrcat(wildcards[nwildcards-1], *in); - } - continue; - - case 'n': - chrcat(name, *in); - continue; - - case 'w': - chrcat(wildprefix, *in); - for ( t=0; t<nwildcards; t++ ) { - chrcat(wildcards[t], *in); - } - continue; - } - break; + regchar: // handle regular char + switch ( mode ) { + case LBRACKET_CHR: + // create new wildcard + ++nwildcards; + // copy in prefix + strcpy(wildcards[nwildcards-1], wildprefix); + // append search char + chrcat(wildcards[nwildcards-1], *in); + continue; + + case LCURLY_CHR: + if ( nwildcards > 0 ) { + chrcat(wildcards[nwildcards-1], *in); + } + continue; + + case 'n': + chrcat(name, *in); + continue; + + case 'w': + chrcat(wildprefix, *in); + for ( t=0; t<nwildcards; t++ ) { + chrcat(wildcards[t], *in); + } + continue; + } + break; } } } @@ -1030,7 +1029,3 @@ static LPCWSTR utf8towchar(const char *in) { } #endif /* !FL_DOXYGEN */ - -// -// End of "$Id$". -// |
