mirror of
https://github.com/RubyMetric/chsrc
synced 2025-12-21 03:25:43 +08:00
Merge hengG
This commit is contained in:
33
helper.h
33
helper.h
@@ -98,6 +98,39 @@ xy_log (int level, const char* str)
|
||||
#define xy_error(str) xy_log (XY_ERROR, str)
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* */
|
||||
static char*
|
||||
xy_strch (const char* str, char src,const char* dest)
|
||||
{
|
||||
size_t str_len = strlen(str);
|
||||
size_t dest_len = strlen(dest);
|
||||
size_t size = str_len*dest_len;
|
||||
char* ret = (char*)malloc(size);
|
||||
int i=0;
|
||||
int j=0;
|
||||
while(i<str_len) {
|
||||
if(str[i]==src) {
|
||||
int k=0;
|
||||
while(k<dest_len){
|
||||
ret[j++] = dest[k++];
|
||||
}
|
||||
i++;
|
||||
}
|
||||
else {
|
||||
ret[j++] = str[i++];
|
||||
}
|
||||
}
|
||||
ret[j] = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
xy_success (const char* str1)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user