aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/yahoo/yahoo_util.c
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/yahoo/yahoo_util.c')
-rw-r--r--protocols/yahoo/yahoo_util.c37
1 files changed, 22 insertions, 15 deletions
diff --git a/protocols/yahoo/yahoo_util.c b/protocols/yahoo/yahoo_util.c
index 1b6168aa..7fc50fda 100644
--- a/protocols/yahoo/yahoo_util.c
+++ b/protocols/yahoo/yahoo_util.c
@@ -26,10 +26,10 @@
# define strchr index
# define strrchr rindex
# endif
-char *strchr (), *strrchr ();
+char *strchr(), *strrchr();
# if !HAVE_MEMCPY
-# define memcpy(d, s, n) bcopy ((s), (d), (n))
-# define memmove(d, s, n) bcopy ((s), (d), (n))
+# define memcpy(d, s, n) bcopy((s), (d), (n))
+# define memmove(d, s, n) bcopy((s), (d), (n))
# endif
#endif
@@ -56,7 +56,8 @@ char *y_string_append(char *string, char *append)
void y_strfreev(char ** vector)
{
char **v;
- for(v = vector; *v; v++) {
+
+ for (v = vector; *v; v++) {
FREE(*v);
}
FREE(vector);
@@ -66,31 +67,35 @@ char ** y_strsplit(char * str, char * sep, int nelem)
{
char ** vector;
char *s, *p;
- int i=0;
+ int i = 0;
int l = strlen(sep);
- if(nelem <= 0) {
+
+ if (nelem <= 0) {
char * s;
- nelem=0;
+ nelem = 0;
if (*str) {
- for(s=strstr(str, sep); s; s=strstr(s+l, sep),nelem++)
+ for (s = strstr(str, sep); s; s = strstr(s + l, sep), nelem++) {
;
- if(strcmp(str+strlen(str)-l, sep))
+ }
+ if (strcmp(str + strlen(str) - l, sep)) {
nelem++;
+ }
}
}
vector = y_new(char *, nelem + 1);
- for(p=str, s=strstr(p,sep); i<nelem && s; p=s+l, s=strstr(p,sep), i++) {
- int len = s-p;
- vector[i] = y_new(char, len+1);
+ for (p = str, s = strstr(p, sep); i < nelem && s; p = s + l, s = strstr(p, sep), i++) {
+ int len = s - p;
+ vector[i] = y_new(char, len + 1);
strncpy(vector[i], p, len);
vector[i][len] = '\0';
}
- if(i<nelem && *str) /* str didn't end with sep, and str isn't empty */
+ if (i < nelem && *str) { /* str didn't end with sep, and str isn't empty */
vector[i++] = strdup(p);
-
+ }
+
vector[i] = NULL;
return vector;
@@ -99,8 +104,10 @@ char ** y_strsplit(char * str, char * sep, int nelem)
void * y_memdup(const void * addr, int n)
{
void * new_chunk = malloc(n);
- if(new_chunk)
+
+ if (new_chunk) {
memcpy(new_chunk, addr, n);
+ }
return new_chunk;
}