Kaydet (Commit) 052c90ae authored tarafından Jens-Heiner Rechtien's avatar Jens-Heiner Rechtien

INTEGRATION: CWS ooo20040225 (1.2.2); FILE MERGED

2004/02/14 11:15:07 khendricks 1.2.2.1: syncing the 680 tree with my local lingucomponent tree
üst 3aeab860
......@@ -6,46 +6,6 @@
#include "mythes.hxx"
// some basic utility routines
#ifdef MYTHES_STANDALONE
// string duplication routine
char * mystrdup(const char * p)
{
int sl = strlen(p) + 1;
char * d = (char *)malloc(sl);
if (d) {
memcpy(d,p,sl);
return d;
}
return NULL;
}
// remove cross-platform text line end characters
void mychomp(char * s)
{
int k = strlen(s);
if ((k > 0) && ((*(s+k-1)=='\r') || (*(s+k-1)=='\n'))) *(s+k-1) = '\0';
if ((k > 1) && (*(s+k-2) == '\r')) *(s+k-2) = '\0';
}
#else
extern char * mystrdup(const char * p);
extern void mychomp(char * s);
#endif
// return index of char in string
int mystr_indexOfChar(const char * d, int c)
{
char * p = strchr((char *)d,c);
if (p) return (int)(p-d);
return -1;
}
MyThes::MyThes(const char* idxpath, const char * datpath)
......@@ -369,3 +329,33 @@ char * MyThes::get_th_encoding()
return NULL;
}
// string duplication routine
char * MyThes::mystrdup(const char * p)
{
int sl = strlen(p) + 1;
char * d = (char *)malloc(sl);
if (d) {
memcpy(d,p,sl);
return d;
}
return NULL;
}
// remove cross-platform text line end characters
void MyThes::mychomp(char * s)
{
int k = strlen(s);
if ((k > 0) && ((*(s+k-1)=='\r') || (*(s+k-1)=='\n'))) *(s+k-1) = '\0';
if ((k > 1) && (*(s+k-2) == '\r')) *(s+k-2) = '\0';
}
// return index of char in string
int MyThes::mystr_indexOfChar(const char * d, int c)
{
char * p = strchr((char *)d,c);
if (p) return (int)(p-d);
return -1;
}
......@@ -57,6 +57,15 @@ private:
// binary search on null terminated character strings
int binsearch(char * wrd, char* list[], int nlst);
// string duplication routine
char * mystrdup(const char * p);
// remove cross-platform text line end characters
void mychomp(char * s);
// return index of char in string
int mystr_indexOfChar(const char * d, int c);
};
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment