mirror of
https://github.com/1dot13/source.git
synced 2026-07-29 13:52:17 +02:00
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@590 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user