while ((*d++ = *s) != 0) {
# ifndef __WXMSW__
if (*s == wxT('\\')) {
- if ((*(d - 1) = *++s)) {
+ if ((*(d - 1) = *++s)!=0) {
s++;
continue;
} else
nnm = *s ? s + 1 : s;
*s = 0;
// FIXME: wxGetUserHome could return temporary storage in Unicode mode
- if ((home = WXSTRINGCAST wxGetUserHome(wxString(nm + 1))) == NULL) {
- if (was_sep) /* replace only if it was there: */
- *s = SEP;
+ if ((home = WXSTRINGCAST wxGetUserHome(wxString(nm + 1))) == NULL)
+ {
+ if (was_sep) /* replace only if it was there: */
+ *s = SEP;
s = NULL;
- } else {
+ }
+ else
+ {
nm = nnm;
s = home;
}
bool needsANSI = true;
#if !defined(HAVE_WGETCWD) || wxUSE_UNICODE_MSLU
- // This is not legal code as the compiler
- // is allowed destroy the wxCharBuffer.
- // wxCharBuffer c_buffer(sz);
- // char *cbuf = (char*)(const char*)c_buffer;
char cbuf[_MAXPATHLEN];
#endif
#if defined( __CYGWIN__ ) && defined( __WINDOWS__ )
// another example of DOS/Unix mix (Cygwin)
wxString pathUnix = buf;
+#if wxUSE_UNICODE
+ char bufA[_MAXPATHLEN];
+ cygwin_conv_to_full_win32_path(pathUnix.mb_str(wxConvFile), bufA);
+ wxConvFile.MB2WC(buf, bufA, sz);
+#else
cygwin_conv_to_full_win32_path(pathUnix, buf);
+#endif // wxUSE_UNICODE
#endif // __CYGWIN__
}
bool wxMatchWild( const wxString& pat, const wxString& text, bool dot_special )
{
- if (text.empty())
+ if (text.empty())
+ {
+ /* Match if both are empty. */
+ return pat.empty();
+ }
+
+ const wxChar *m = pat.c_str(),
+ *n = text.c_str(),
+ *ma = NULL,
+ *na = NULL,
+ *mp = NULL,
+ *np = NULL;
+ int just = 0,
+ pcount = 0,
+ acount = 0,
+ count = 0;
+
+ if (dot_special && (*n == wxT('.')))
+ {
+ /* Never match so that hidden Unix files
+ * are never found. */
+ return false;
+ }
+
+ for (;;)
+ {
+ if (*m == wxT('*'))
{
- /* Match if both are empty. */
- return pat.empty();
+ ma = ++m;
+ na = n;
+ just = 1;
+ mp = NULL;
+ acount = count;
}
-
- const wxChar *m = pat.c_str(),
- *n = text.c_str(),
- *ma = NULL,
- *na = NULL,
- *mp = NULL,
- *np = NULL;
- int just = 0,
- pcount = 0,
- acount = 0,
- count = 0;
-
- if (dot_special && (*n == wxT('.')))
+ else if (*m == wxT('?'))
{
- /* Never match so that hidden Unix files
- * are never found. */
+ m++;
+ if (!*n++)
return false;
}
-
- for (;;)
+ else
{
- if (*m == wxT('*'))
+ if (*m == wxT('\\'))
+ {
+ m++;
+ /* Quoting "nothing" is a bad thing */
+ if (!*m)
+ return false;
+ }
+ if (!*m)
+ {
+ /*
+ * If we are out of both strings or we just
+ * saw a wildcard, then we can say we have a
+ * match
+ */
+ if (!*n)
+ return true;
+ if (just)
+ return true;
+ just = 0;
+ goto not_matched;
+ }
+ /*
+ * We could check for *n == NULL at this point, but
+ * since it's more common to have a character there,
+ * check to see if they match first (m and n) and
+ * then if they don't match, THEN we can check for
+ * the NULL of n
+ */
+ just = 0;
+ if (*m == *n)
+ {
+ m++;
+ if (*n == wxT(' '))
+ mp = NULL;
+ count++;
+ n++;
+ }
+ else
+ {
+
+ not_matched:
+
+ /*
+ * If there are no more characters in the
+ * string, but we still need to find another
+ * character (*m != NULL), then it will be
+ * impossible to match it
+ */
+ if (!*n)
+ return false;
+ if (mp)
{
- ma = ++m;
- na = n;
- just = 1;
+ m = mp;
+ if (*np == wxT(' '))
+ {
mp = NULL;
- acount = count;
- }
- else if (*m == wxT('?'))
- {
- m++;
- if (!*n++)
- return false;
+ goto check_percent;
+ }
+ n = ++np;
+ count = pcount;
}
else
- {
- if (*m == wxT('\\'))
- {
- m++;
- /* Quoting "nothing" is a bad thing */
- if (!*m)
- return false;
- }
- if (!*m)
- {
- /*
- * If we are out of both strings or we just
- * saw a wildcard, then we can say we have a
- * match
- */
- if (!*n)
- return true;
- if (just)
- return true;
- just = 0;
- goto not_matched;
- }
- /*
- * We could check for *n == NULL at this point, but
- * since it's more common to have a character there,
- * check to see if they match first (m and n) and
- * then if they don't match, THEN we can check for
- * the NULL of n
- */
- just = 0;
- if (*m == *n)
- {
- m++;
- if (*n == wxT(' '))
- mp = NULL;
- count++;
- n++;
- }
- else
- {
+ check_percent:
- not_matched:
-
- /*
- * If there are no more characters in the
- * string, but we still need to find another
- * character (*m != NULL), then it will be
- * impossible to match it
- */
- if (!*n)
- return false;
- if (mp)
- {
- m = mp;
- if (*np == wxT(' '))
- {
- mp = NULL;
- goto check_percent;
- }
- n = ++np;
- count = pcount;
- }
- else
- check_percent:
-
- if (ma)
- {
- m = ma;
- n = ++na;
- count = acount;
- }
- else
- return false;
- }
+ if (ma)
+ {
+ m = ma;
+ n = ++na;
+ count = acount;
}
+ else
+ return false;
+ }
}
+ }
}
// Return the type of an open file
(void)fp;
return wxFILE_KIND_DISK;
#else
- return wxGetFileKind(fileno(fp));
+ return fp ? wxGetFileKind(fileno(fp)) : wxFILE_KIND_UNKNOWN;
#endif
}