Function changes

pull/43/head
parent f88af8fde2
commit 5571741e0a

@ -1,7 +1,5 @@
#include "libublsettings.h"
int yon_char_find_last(char *source, char find){
int size = strlen(source);
int i=size;
@ -14,10 +12,14 @@ char *yon_char_append(const char *source, const char *append)
{
if (source && append)
{
int size = strlen(source) + strlen(append) + 1;
int source_size = strlen(source);
int append_size = strlen(append);
int size = source_size + append_size + 1;
char *final = malloc(size);
memset(final, 0, size);
sprintf(final, "%s%s", source, append);
memcpy(final,source,source_size);
memcpy(final+source_size,append,append_size);
// sprintf(final, "%s%s", source, append);
return final;
}
return NULL;
@ -155,16 +157,16 @@ char *yon_char_divide(char *source, int dividepos)
return NULL;
}
int yon_char_find_count(char *source, char *find){
char *working_string=yon_char_new(source);
int i=0;
int size=0;
int pos=0;
config_str rtn = yon_char_parse(working_string,&size,find);
free(working_string);
yon_char_parsed_free(rtn,size);
return size-1;
}
// int yon_char_find_count(char *source, char *find){
// char *working_string=yon_char_new(source);
// int i=0;
// int size=0;
// int pos=0;
// config_str rtn = yon_char_parse(working_string,&size,find);
// free(working_string);
// yon_char_parsed_free(rtn,size);
// return size-1;
// }
int yon_char_count(char *source, char *find){
char *working_string=yon_char_new(source);
@ -246,13 +248,16 @@ char *yon_char_from_long(long int_to_convert)
char *yon_char_replace(char *source, char *find, char*replace){
if (!strstr(replace,find)){
int source_size = strlen(source);
int replace_size = strlen(replace);
char *final=NULL;
char *temp=NULL;
if(!strstr(replace,find)){
while ((final=strstr(source,find))){
temp=malloc(strlen(source)-strlen(final)+strlen(replace));
memset(temp,0,strlen(source)-strlen(final)+strlen(replace));
memcpy(temp,source,strlen(source)-strlen(final));
int final_size = strlen(final);
temp=malloc(-final_size+replace_size);
memset(temp,0,source_size-final_size+replace_size);
memcpy(temp,source,source_size-final_size);
temp=yon_char_append(temp,replace);
source=yon_char_append(temp,final+strlen(find));
}

Loading…
Cancel
Save