All buffers used with TokenXlat function now are of variable size

This commit is contained in:
Ianos Gnatiuc
2006-02-20 21:44:10 +00:00
parent 49e3c5a857
commit 823a7c8699
13 changed files with 610 additions and 416 deletions

View File

@@ -83,6 +83,15 @@
#define R_OK 0
#endif
// ------------------------------------------------------------------
#if defined(_MSC_VER)
#define popen(f,m) _popen(f,m)
#define pclose(fh) _pclose(fh)
#endif
// ------------------------------------------------------------------
#define GMAXPATH (FILENAME_MAX+1) /* ANSI C */

View File

@@ -62,9 +62,11 @@ int strchg(char* str, char oldch, char newch);
char* stridela(const char* substr, char* str);
int strnicmpw(const char* str1, const char* str2, int len);
const char* striinc(const char* str1, const char* str2);
std::string::iterator striinc(const char* str1, std::string &str2);
char* strins(const char* instr, char* str, int st_pos);
char* strisrep(char* str, const char* search, const char* replace);
char* strischg(char* str, const char* find, const char* replace);
void strischg(std::string &str, const char* find, const char* replace);
char* strrjust(char* str);
char* strschg(char* str, const char* find, const char* replace);
char* strsetsz(char* str, int newsize);

View File

@@ -150,6 +150,22 @@ const char* striinc(const char* str1, const char* str2) {
}
// ------------------------------------------------------------------
// Determines if string1 is included in string2
std::string::iterator striinc(const char* str1, std::string &str2)
{
int max = strlen(str1);
std::string::iterator it;
for (it = str2.begin(); it != str2.end(); it++)
if (!strnicmp(str1, it, max))
return it;
return str2.end(); // string1 not found in string2
}
// ------------------------------------------------------------------
// Inserts one string into another
@@ -211,6 +227,27 @@ char* strischg(char* str, const char* find, const char* replace) {
}
// ------------------------------------------------------------------
// Changes all occurrences of one string to another
void strischg(std::string &str, const char* find, const char* replace)
{
int lenf = strlen(find);
int lenr = strlen(replace);
std::string::iterator it;
for (it = str.begin(); it != str.end(); it++)
{
if (strnieql(find, it, lenf))
{
size_t idx = it - str.begin();
str.replace(it, it+lenf, replace, lenr);
it = str.begin() + idx + lenr - 1;
}
}
}
// ------------------------------------------------------------------
// Takes a long number and makes a string with the form x.xxx.xxx.xxx