This commit is contained in:
Wanne
2006-10-04 12:24:10 +00:00
parent 0c0f6eafad
commit 4341409ded
22 changed files with 481 additions and 285 deletions
+74
View File
@@ -23,6 +23,80 @@ extern BOOLEAN GetCDromDriveLetter( STR8 pString );
BOOLEAN PerformTimeLimitedCheck();
// WANNE:
/* Given a string, replaces all instances of "oldpiece" with "newpiece".
*
* Modified this routine to eliminate recursion and to avoid infinite
* expansion of string when newpiece contains oldpiece. --Byron
*/
char *Replace(char *string, char *oldpiece, char *newpiece) {
int str_index, newstr_index, oldpiece_index, end,
new_len, old_len, cpy_len;
char *c;
static char newstring[MAXLINE];
if ((c = (char *) strstr(string, oldpiece)) == NULL)
return string;
new_len = strlen(newpiece);
old_len = strlen(oldpiece);
end = strlen(string) - old_len;
oldpiece_index = c - string;
newstr_index = 0;
str_index = 0;
while(str_index <= end && c != NULL)
{
/* Copy characters from the left of matched pattern occurence */
cpy_len = oldpiece_index-str_index;
strncpy(newstring+newstr_index, string+str_index, cpy_len);
newstr_index += cpy_len;
str_index += cpy_len;
/* Copy replacement characters instead of matched pattern */
strcpy(newstring+newstr_index, newpiece);
newstr_index += new_len;
str_index += old_len;
/* Check for another pattern match */
if((c = (char *) strstr(string+str_index, oldpiece)) != NULL)
oldpiece_index = c - string;
}
/* Copy remaining characters from the right of last matched pattern */
strcpy(newstring+newstr_index, string+str_index);
return newstring;
}
// WANNE: Replaces german specific characters
char *ReplaceGermanSpecialCharacters(char *text)
{
// ä
text = Replace(text, "ä", "ä");
// Ä
text = Replace(text, "Ä", "Ä");
// ö
text = Replace(text, "ö", "ö");
// Ö
text = Replace(text, "Ö", "Ö");
// ü
text = Replace(text, "ü", "ü");
// Ü
text = Replace(text, "Ü", "Ü");
// ß
text = Replace(text, "ß", "ß");
return text;
}
//#define TIME_LIMITED_VERSION
void FilenameForBPP(STR pFilename, STR pDestination)