KiCad PCB EDA Suite
kicad_string.h File Reference
#include "config.h"
#include <wx/string.h>
#include <wx/filename.h>

Go to the source code of this file.

Functions

int ReadDelimitedText (char *aDest, const char *aSource, int aDestSize)
 Function ReadDelimitedText copies bytes from aSource delimited string segment to aDest buffer. More...
 
int ReadDelimitedText (wxString *aDest, const char *aSource)
 Function ReadDelimitedText copies bytes from aSource delimited string segment to aDest wxString. More...
 
std::string EscapedUTF8 (const wxString &aString)
 Function EscapedUTF8 returns an 8 bit UTF8 string given aString in unicode form. More...
 
wxString EscapedHTML (const wxString &aString)
 Return a new wxString escaped for embedding in HTML. More...
 
char * GetLine (FILE *aFile, char *Line, int *LineNum=NULL, int SizeLine=255)
 Function GetLine reads one line line from aFile. More...
 
char * StrPurge (char *text)
 Function StrPurge removes leading and training spaces, tabs and end of line chars in text return a pointer on the first n char in text. More...
 
wxString DateAndTime ()
 Function DateAndTime. More...
 
int StrNumCmp (const wxString &aString1, const wxString &aString2, int aLength=INT_MAX, bool aIgnoreCase=false)
 Function StrNumCmp is a routine compatible with qsort() to sort by alphabetical order. More...
 
bool WildCompareString (const wxString &pattern, const wxString &string_to_tst, bool case_sensitive=true)
 Function WildCompareString compares a string against wild card (* and ?) pattern using the usual rules. More...
 
int ValueStringCompare (const wxString &strFWord, const wxString &strSWord)
 Function ValueStringCompare acts just like the strcmp function but handles numbers and modifiers within the string text correctly for sorting. More...
 
int RefDesStringCompare (const wxString &lhs, const wxString &rhs)
 Function RefDesStringCompare acts just like the strcmp function but treats numbers within the string text correctly for sorting. More...
 
int SplitString (wxString strToSplit, wxString *strBeginning, wxString *strDigits, wxString *strEnd)
 Function SplitString breaks a string into three parts. More...
 
wxString GetIllegalFileNameWxChars ()
 Function GetIllegalFileNameWxChars. More...
 
bool ReplaceIllegalFileNameChars (std::string *aName, int aReplaceChar=0)
 Function ReplaceIllegalFileNameChars checks aName for illegal file name characters. More...
 
bool ReplaceIllegalFileNameChars (wxString &aName, int aReplaceChar=0)
 
char * strtok_r (char *str, const char *delim, char **nextp)
 

Detailed Description

See also
common.h, string.cpp

Definition in file kicad_string.h.

Function Documentation

wxString DateAndTime ( )

Function DateAndTime.

Returns
a string giving the current date and time.

Definition at line 229 of file string.cpp.

Referenced by PROJECT::ConfigSave(), PCB_EDIT_FRAME::DoGenFootprintsPositionFile(), PCB_EDIT_FRAME::DoGenFootprintsReport(), GENDRILL_WRITER_BASE::GenDrillReportFile(), NETLIST_EXPORTER_GENERIC::makeDesignHeader(), RecreateCmpFile(), GERBER_PLOTTER::StartPlot(), WriteDiagnosticERC(), EXCELLON_WRITER::writeEXCELLONHeader(), NETLIST_EXPORTER_ORCADPCB2::WriteNetlist(), and NETLIST_EXPORTER_CADSTAR::WriteNetlist().

230 {
231  wxDateTime datetime = wxDateTime::Now();
232 
233  datetime.SetCountry( wxDateTime::Country_Default );
234  return datetime.Format( wxDefaultDateTimeFormat, wxDateTime::Local );
235 }
wxString EscapedHTML ( const wxString &  aString)

Return a new wxString escaped for embedding in HTML.

Definition at line 170 of file string.cpp.

Referenced by ALIAS_INFO_GENERATOR::GetHtmlFieldRow(), ALIAS_INFO_GENERATOR::SetHtmlAliasOf(), ALIAS_INFO_GENERATOR::SetHtmlDesc(), ALIAS_INFO_GENERATOR::SetHtmlKeywords(), and ALIAS_INFO_GENERATOR::SetHtmlName().

171 {
172  wxString converted;
173 
174  for( wxUniChar c: aString )
175  {
176  if( c == '\"' )
177  converted += "&quot;";
178  else if( c == '\'' )
179  converted += "&apos;";
180  else if( c == '&' )
181  converted += "&amp;";
182  else if( c == '<' )
183  converted += "&lt;";
184  else if( c == '>' )
185  converted += "&gt;";
186  else
187  converted += c;
188  }
189 
190  return converted;
191 }
std::string EscapedUTF8 ( const wxString &  aString)

Function EscapedUTF8 returns an 8 bit UTF8 string given aString in unicode form.

Any double quoted or back slashes are prefixed with a '\' byte and the form of this UTF8 byte string is compatible with function ReadDelimitedText().

Parameters
aStringis the input string to convert.
Returns
std::string - the escaped input text, without the wrapping double quotes.

Definition at line 137 of file string.cpp.

References TO_UTF8.

Referenced by PCB_EDIT_FRAME::DoGenFootprintsReport(), SCH_LEGACY_PLUGIN::Format(), SCH_LEGACY_PLUGIN::saveField(), SCH_LEGACY_PLUGIN_CACHE::saveField(), LEGACY_PLUGIN::SaveModule3D(), and SCH_LEGACY_PLUGIN::saveSheet().

138 {
139  std::string utf8 = TO_UTF8( aString );
140 
141  std::string ret;
142 
143  ret += '"';
144 
145  for( std::string::const_iterator it = utf8.begin(); it!=utf8.end(); ++it )
146  {
147  // this escaping strategy is designed to be compatible with ReadDelimitedText():
148  if( *it == '"' )
149  {
150  ret += '\\';
151  ret += '"';
152  }
153  else if( *it == '\\' )
154  {
155  ret += '\\'; // double it up
156  ret += '\\';
157  }
158  else
159  {
160  ret += *it;
161  }
162  }
163 
164  ret += '"';
165 
166  return ret;
167 }
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
wxString GetIllegalFileNameWxChars ( )

Function GetIllegalFileNameWxChars.

Returns
a wString object containing the illegal file name characters for all platforms.

Definition at line 564 of file string.cpp.

References FROM_UTF8(), and illegalFileNameChars.

Referenced by ReplaceIllegalFileNameChars().

565 {
567 }
static const char illegalFileNameChars[]
Illegal file name characters used to insure file names will be valid on all supported platforms...
Definition: string.cpp:40
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes...
Definition: macros.h:53
char* GetLine ( FILE *  aFile,
char *  Line,
int *  LineNum = NULL,
int  SizeLine = 255 
)

Function GetLine reads one line line from aFile.

Returns
A pointer the first useful line read by eliminating blank lines and comments.

Definition at line 213 of file string.cpp.

Referenced by CVPCB_MAINFRAME::buildEquivalenceList().

214 {
215  do {
216  if( fgets( Line, SizeLine, File ) == NULL )
217  return NULL;
218 
219  if( LineNum )
220  *LineNum += 1;
221 
222  } while( Line[0] == '#' || Line[0] == '\n' || Line[0] == '\r' || Line[0] == 0 );
223 
224  strtok( Line, "\n\r" );
225  return Line;
226 }
int ReadDelimitedText ( char *  aDest,
const char *  aSource,
int  aDestSize 
)

Function ReadDelimitedText copies bytes from aSource delimited string segment to aDest buffer.

The extracted string will be null terminated even if truncation is necessary because aDestSize was not large enough.

Parameters
aDestis the destination byte buffer.
aSourceis the source bytes as a C string.
aDestSizeis the size of the destination byte buffer.
Returns
int - the number of bytes read from source, which may be more than the number copied, due to escaping of double quotes and the escape byte itself.
Deprecated:
should use the one which fetches a wxString, below.

Definition at line 88 of file string.cpp.

89 {
90  if( aDestSize <= 0 )
91  return 0;
92 
93  bool inside = false;
94  const char* start = aSource;
95  char* limit = aDest + aDestSize - 1;
96  char cc;
97 
98  while( (cc = *aSource++) != 0 && aDest < limit )
99  {
100  if( cc == '"' )
101  {
102  if( inside )
103  break; // 2nd double quote is end of delimited text
104 
105  inside = true; // first delimiter found, make note, do not copy
106  }
107 
108  else if( inside )
109  {
110  if( cc == '\\' )
111  {
112  cc = *aSource++;
113 
114  if( !cc )
115  break;
116 
117  // do no copy the escape byte if it is followed by \ or "
118  if( cc != '"' && cc != '\\' )
119  *aDest++ = '\\';
120 
121  if( aDest < limit )
122  *aDest++ = cc;
123  }
124  else
125  {
126  *aDest++ = cc;
127  }
128  }
129  }
130 
131  *aDest = 0;
132 
133  return aSource - start;
134 }
int ReadDelimitedText ( wxString *  aDest,
const char *  aSource 
)

Function ReadDelimitedText copies bytes from aSource delimited string segment to aDest wxString.

Parameters
aDestis the destination wxString
aSourceis the source C string holding utf8 encoded bytes.
Returns
int - the number of bytes read from source, which may be more than the number copied, due to escaping of double quotes and the escape byte itself.

Definition at line 43 of file string.cpp.

References FROM_UTF8().

Referenced by LEGACY_PLUGIN::load3D(), LEGACY_PLUGIN::loadDIMENSION(), LEGACY_PLUGIN::loadMODULE_TEXT(), LEGACY_PLUGIN::loadNETCLASS(), LEGACY_PLUGIN::loadNETINFO_ITEM(), LEGACY_PLUGIN::loadPAD(), LEGACY_PLUGIN::loadPCB_TEXT(), LEGACY_PLUGIN::loadSHEET(), and LEGACY_PLUGIN::loadZONE_CONTAINER().

44 {
45  std::string utf8; // utf8 but without escapes and quotes.
46  bool inside = false;
47  const char* start = aSource;
48  char cc;
49 
50  while( (cc = *aSource++) != 0 )
51  {
52  if( cc == '"' )
53  {
54  if( inside )
55  break; // 2nd double quote is end of delimited text
56 
57  inside = true; // first delimiter found, make note, do not copy
58  }
59 
60  else if( inside )
61  {
62  if( cc == '\\' )
63  {
64  cc = *aSource++;
65 
66  if( !cc )
67  break;
68 
69  // do no copy the escape byte if it is followed by \ or "
70  if( cc != '"' && cc != '\\' )
71  utf8 += '\\';
72 
73  utf8 += cc;
74  }
75  else
76  {
77  utf8 += cc;
78  }
79  }
80  }
81 
82  *aDest = FROM_UTF8( utf8.c_str() );
83 
84  return aSource - start;
85 }
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes...
Definition: macros.h:53
int RefDesStringCompare ( const wxString &  lhs,
const wxString &  rhs 
)

Function RefDesStringCompare acts just like the strcmp function but treats numbers within the string text correctly for sorting.

eg. A10 > A2 return -1 if first string is less than the second return 0 if the strings are equal return 1 if the first string is greater than the second

Definition at line 466 of file string.cpp.

References SplitString().

Referenced by FIELDS_EDITOR_GRID_DATA_MODEL::cmp(), operator<(), SCH_REFERENCE_LIST::Shorthand(), SCH_REFERENCE_LIST::sortByReferenceOnly(), sortPinsByNum(), and sortPinsByNumber().

467 {
468  // The different sections of the two strings
469  wxString strFWordBeg, strFWordMid, strFWordEnd;
470  wxString strSWordBeg, strSWordMid, strSWordEnd;
471 
472  // Split the two strings into separate parts
473  SplitString( strFWord, &strFWordBeg, &strFWordMid, &strFWordEnd );
474  SplitString( strSWord, &strSWordBeg, &strSWordMid, &strSWordEnd );
475 
476  // Compare the Beginning section of the strings
477  int isEqual = strFWordBeg.CmpNoCase( strSWordBeg );
478 
479  if( isEqual > 0 )
480  return 1;
481  else if( isEqual < 0 )
482  return -1;
483  else
484  {
485  // If the first sections are equal compare their digits
486  long lFirstDigit = 0;
487  long lSecondDigit = 0;
488 
489  strFWordMid.ToLong( &lFirstDigit );
490  strSWordMid.ToLong( &lSecondDigit );
491 
492  if( lFirstDigit > lSecondDigit )
493  return 1;
494  else if( lFirstDigit < lSecondDigit )
495  return -1;
496  // If the first two sections are equal compare the endings
497  else
498  return strFWordEnd.CmpNoCase( strSWordEnd );
499  }
500 }
int SplitString(wxString strToSplit, wxString *strBeginning, wxString *strDigits, wxString *strEnd)
Function SplitString breaks a string into three parts.
Definition: string.cpp:503
bool ReplaceIllegalFileNameChars ( std::string *  aName,
int  aReplaceChar = 0 
)

Function ReplaceIllegalFileNameChars checks aName for illegal file name characters.

The Windows (DOS) file system forbidden characters already include the forbidden file name characters for both Posix and OSX systems. The characters \/?*|"<> are illegal and are replaced with xx where xx the hexadecimal equivalent of the replaced character. This replacement may not be as elegant as using an underscore ('_') or hyphen ('-') but it guarentees that there will be no naming conflicts when fixing footprint library names. however, if aReplaceChar is given, it will replace the illegal chars

Parameters
aNameis a point to a std::string object containing the footprint name to verify.
aReplaceChar(if not 0) is the replacement char.
Returns
true if any characters have been replaced in aName.

Definition at line 570 of file string.cpp.

References illegalFileNameChars, and StrPrintf().

Referenced by EDEVICE::EDEVICE(), EELEMENT::EELEMENT(), LEGACY_PLUGIN::loadAllSections(), EAGLE_PLUGIN::loadLibrary(), LP_CACHE::LoadModules(), SCH_EAGLE_PLUGIN::loadSheet(), LIB_ID::Parse(), and LIB_FIELD::SetText().

571 {
572  bool changed = false;
573  std::string result;
574  result.reserve( aName->length() );
575 
576  for( std::string::iterator it = aName->begin(); it != aName->end(); ++it )
577  {
578  if( strchr( illegalFileNameChars, *it ) )
579  {
580  if( aReplaceChar )
581  StrPrintf( &result, "%c", aReplaceChar );
582  else
583  StrPrintf( &result, "%%%02x", *it );
584 
585  changed = true;
586  }
587  else
588  {
589  result += *it;
590  }
591  }
592 
593  if( changed )
594  *aName = result;
595 
596  return changed;
597 }
static const char illegalFileNameChars[]
Illegal file name characters used to insure file names will be valid on all supported platforms...
Definition: string.cpp:40
int StrPrintf(std::string *result, const char *format,...)
Function StrPrintf is like sprintf() but the output is appended to a std::string instead of to a char...
Definition: richio.cpp:74
bool ReplaceIllegalFileNameChars ( wxString &  aName,
int  aReplaceChar = 0 
)

Definition at line 600 of file string.cpp.

References Format(), and GetIllegalFileNameWxChars().

601 {
602  bool changed = false;
603  wxString result;
604  result.reserve( aName.Length() );
605  wxString illWChars = GetIllegalFileNameWxChars();
606 
607  for( wxString::iterator it = aName.begin(); it != aName.end(); ++it )
608  {
609  if( illWChars.Find( *it ) != wxNOT_FOUND )
610  {
611  if( aReplaceChar )
612  result += aReplaceChar;
613  else
614  result += wxString::Format( "%%%02x", *it );
615 
616  changed = true;
617  }
618  else
619  {
620  result += *it;
621  }
622  }
623 
624  if( changed )
625  aName = result;
626 
627  return changed;
628 }
wxString GetIllegalFileNameWxChars()
Function GetIllegalFileNameWxChars.
Definition: string.cpp:564
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
int SplitString ( wxString  strToSplit,
wxString *  strBeginning,
wxString *  strDigits,
wxString *  strEnd 
)

Function SplitString breaks a string into three parts.

The alphabetic preamble The numeric part Any alphabetic ending For example C10A is split to C 10 A

Definition at line 503 of file string.cpp.

Referenced by RefDesStringCompare(), and ValueStringCompare().

507 {
508  static const wxString separators( wxT( ".," ) );
509 
510  // Clear all the return strings
511  strBeginning->Empty();
512  strDigits->Empty();
513  strEnd->Empty();
514 
515  // There no need to do anything if the string is empty
516  if( strToSplit.length() == 0 )
517  return 0;
518 
519  // Starting at the end of the string look for the first digit
520  int ii;
521 
522  for( ii = (strToSplit.length() - 1); ii >= 0; ii-- )
523  {
524  if( isdigit( strToSplit[ii] ) )
525  break;
526  }
527 
528  // If there were no digits then just set the single string
529  if( ii < 0 )
530  {
531  *strBeginning = strToSplit;
532  }
533  else
534  {
535  // Since there is at least one digit this is the trailing string
536  *strEnd = strToSplit.substr( ii + 1 );
537 
538  // Go to the end of the digits
539  int position = ii + 1;
540 
541  for( ; ii >= 0; ii-- )
542  {
543  if( !isdigit( strToSplit[ii] ) && separators.Find( strToSplit[ii] ) < 0 )
544  break;
545  }
546 
547  // If all that was left was digits, then just set the digits string
548  if( ii < 0 )
549  *strDigits = strToSplit.substr( 0, position );
550 
551  /* We were only looking for the last set of digits everything else is
552  * part of the preamble */
553  else
554  {
555  *strDigits = strToSplit.substr( ii + 1, position - ii - 1 );
556  *strBeginning = strToSplit.substr( 0, ii + 1 );
557  }
558  }
559 
560  return 0;
561 }
int StrNumCmp ( const wxString &  aString1,
const wxString &  aString2,
int  aLength = INT_MAX,
bool  aIgnoreCase = false 
)

Function StrNumCmp is a routine compatible with qsort() to sort by alphabetical order.

This function is equivalent to strncmp() or strncasecmp() if aIgnoreCase is true except that strings containing numbers are compared by their integer value not by their ASCII code.

Parameters
aString1A wxString reference to the reference string.
aString2A wxString reference to the comparison string.
aLengthThe number of characters to compare. Set to -1 to compare the entire string.
aIgnoreCaseUse true to make the comparison case insensitive.
Returns
An integer value of -1 if aString1 is less than aString2, 0 if aString1 is equal to aString2, or 1 if aString1 is greater than aString2.

Definition at line 238 of file string.cpp.

References i.

Referenced by myCompareFunction(), operator<(), and sortFPlist().

239 {
240  int i;
241  int nb1 = 0, nb2 = 0;
242 
243  wxString::const_iterator str1 = aString1.begin(), str2 = aString2.begin();
244 
245  if( ( str1 == aString1.end() ) || ( str2 == aString2.end() ) )
246  return 0;
247 
248  for( i = 0; i < aLength; i++ )
249  {
250  if( isdigit( *str1 ) && isdigit( *str2 ) ) /* digit found */
251  {
252  nb1 = 0;
253  nb2 = 0;
254 
255  while( isdigit( *str1 ) )
256  {
257  nb1 = nb1 * 10 + (int) *str1 - '0';
258  ++str1;
259  }
260 
261  while( isdigit( *str2 ) )
262  {
263  nb2 = nb2 * 10 + (int) *str2 - '0';
264  ++str2;
265  }
266 
267  if( nb1 < nb2 )
268  return -1;
269 
270  if( nb1 > nb2 )
271  return 1;
272  }
273 
274  if( aIgnoreCase )
275  {
276  if( toupper( *str1 ) < toupper( *str2 ) )
277  return -1;
278 
279  if( toupper( *str1 ) > toupper( *str2 ) )
280  return 1;
281 
282  if( ( *str1 == 0 ) && ( *str2 == 0 ) )
283  return 0;
284  }
285  else
286  {
287  if( *str1 < *str2 )
288  return -1;
289 
290  if( *str1 > *str2 )
291  return 1;
292 
293  if( ( str1 == aString1.end() ) && ( str2 == aString2.end() ) )
294  return 0;
295  }
296 
297  ++str1;
298  ++str2;
299  }
300 
301  return 0;
302 }
size_t i
Definition: json11.cpp:597
char* StrPurge ( char *  text)

Function StrPurge removes leading and training spaces, tabs and end of line chars in text return a pointer on the first n char in text.

Definition at line 194 of file string.cpp.

Referenced by detect_file_type(), LEGACY_PLUGIN::loadAllSections(), EXCELLON_IMAGE::LoadFile(), GERBER_FILE_IMAGE::LoadGerberFile(), LEGACY_PLUGIN::loadMODULE(), LP_CACHE::LoadModules(), LEGACY_NETLIST_READER::LoadNetlist(), and LEGACY_PLUGIN::loadPAD().

195 {
196  static const char whitespace[] = " \t\n\r\f\v";
197 
198  if( text )
199  {
200  while( *text && strchr( whitespace, *text ) )
201  ++text;
202 
203  char* cp = text + strlen( text ) - 1;
204 
205  while( cp >= text && strchr( whitespace, *cp ) )
206  *cp-- = '\0';
207  }
208 
209  return text;
210 }
int ValueStringCompare ( const wxString &  strFWord,
const wxString &  strSWord 
)

Function ValueStringCompare acts just like the strcmp function but handles numbers and modifiers within the string text correctly for sorting.

eg. 1mF > 55uF return -1 if first string is less than the second return 0 if the strings are equal return 1 if the first string is greater than the second

Definition at line 422 of file string.cpp.

References ApplyModifier(), and SplitString().

Referenced by FIELDS_EDITOR_GRID_DATA_MODEL::cmp().

423 {
424  // The different sections of the two strings
425  wxString strFWordBeg, strFWordMid, strFWordEnd;
426  wxString strSWordBeg, strSWordMid, strSWordEnd;
427 
428  // Split the two strings into separate parts
429  SplitString( strFWord, &strFWordBeg, &strFWordMid, &strFWordEnd );
430  SplitString( strSWord, &strSWordBeg, &strSWordMid, &strSWordEnd );
431 
432  // Compare the Beginning section of the strings
433  int isEqual = strFWordBeg.CmpNoCase( strSWordBeg );
434 
435  if( isEqual > 0 )
436  return 1;
437  else if( isEqual < 0 )
438  return -1;
439  else
440  {
441  // If the first sections are equal compare their digits
442  double lFirstNumber = 0;
443  double lSecondNumber = 0;
444  bool endingIsModifier = false;
445 
446  strFWordMid.ToDouble( &lFirstNumber );
447  strSWordMid.ToDouble( &lSecondNumber );
448 
449  endingIsModifier |= ApplyModifier( lFirstNumber, strFWordEnd );
450  endingIsModifier |= ApplyModifier( lSecondNumber, strSWordEnd );
451 
452  if( lFirstNumber > lSecondNumber )
453  return 1;
454  else if( lFirstNumber < lSecondNumber )
455  return -1;
456  // If the first two sections are equal and the endings are modifiers then compare them
457  else if( !endingIsModifier )
458  return strFWordEnd.CmpNoCase( strSWordEnd );
459  // Ran out of things to compare; they must match
460  else
461  return 0;
462  }
463 }
int SplitString(wxString strToSplit, wxString *strBeginning, wxString *strDigits, wxString *strEnd)
Function SplitString breaks a string into three parts.
Definition: string.cpp:503
bool ApplyModifier(double &value, const wxString &aString)
Definition: string.cpp:365
bool WildCompareString ( const wxString &  pattern,
const wxString &  string_to_tst,
bool  case_sensitive = true 
)

Function WildCompareString compares a string against wild card (* and ?) pattern using the usual rules.

Returns
true if pattern matched otherwise false.

Definition at line 305 of file string.cpp.

Referenced by PCB_EDIT_FRAME::LockModule(), DIALOG_FIND::onButtonFindItemClick(), PCB_BASE_FRAME::ResetModuleTextSizes(), PCB_BASE_FRAME::SelectFootprint(), and PCB_EDIT_FRAME::SetIconScale().

307 {
308  const wxChar* cp = NULL, * mp = NULL;
309  const wxChar* wild, * string;
310  wxString _pattern, _string_to_tst;
311 
312  if( case_sensitive )
313  {
314  wild = pattern.GetData();
315  string = string_to_tst.GetData();
316  }
317  else
318  {
319  _pattern = pattern;
320  _pattern.MakeUpper();
321  _string_to_tst = string_to_tst;
322  _string_to_tst.MakeUpper();
323  wild = _pattern.GetData();
324  string = _string_to_tst.GetData();
325  }
326 
327  while( ( *string ) && ( *wild != '*' ) )
328  {
329  if( ( *wild != *string ) && ( *wild != '?' ) )
330  return false;
331 
332  wild++; string++;
333  }
334 
335  while( *string )
336  {
337  if( *wild == '*' )
338  {
339  if( !*++wild )
340  return 1;
341  mp = wild;
342  cp = string + 1;
343  }
344  else if( ( *wild == *string ) || ( *wild == '?' ) )
345  {
346  wild++;
347  string++;
348  }
349  else
350  {
351  wild = mp;
352  string = cp++;
353  }
354  }
355 
356  while( *wild == '*' )
357  {
358  wild++;
359  }
360 
361  return !*wild;
362 }