avstring: K&R formatting cosmetics

Signed-off-by: Diego Biurrun <diego@biurrun.de>
This commit is contained in:
Luca Barbato 2013-01-24 19:00:57 +01:00 committed by Diego Biurrun
parent 2c10e2a2f6
commit 4333df6355
1 changed files with 56 additions and 59 deletions

View File

@ -24,10 +24,11 @@
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "avstring.h"
#include "config.h"
#include "common.h"
#include "mem.h"
#include "avstring.h"
int av_strstart(const char *str, const char *pfx, const char **ptr)
{
@ -56,10 +57,10 @@ char *av_stristr(const char *s1, const char *s2)
if (!*s2)
return s1;
do {
do
if (av_stristart(s1, s2, NULL))
return s1;
} while (*s1++);
while (*s1++);
return NULL;
}
@ -97,7 +98,8 @@ size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...)
char *av_d2str(double d)
{
char *str = av_malloc(16);
if(str) snprintf(str, 16, "%f", d);
if (str)
snprintf(str, 16, "%f", d);
return str;
}
@ -108,7 +110,8 @@ char *av_get_token(const char **buf, const char *term)
char *out = av_malloc(strlen(*buf) + 1);
char *ret = out, *end = out;
const char *p = *buf;
if (!out) return NULL;
if (!out)
return NULL;
p += strspn(p, WHITESPACES);
while (*p && !strspn(p, term)) {
@ -128,9 +131,9 @@ char *av_get_token(const char **buf, const char *term)
}
}
do{
do
*out-- = 0;
}while(out >= end && strspn(out, WHITESPACES));
while (out >= end && strspn(out, WHITESPACES));
*buf = p;
@ -196,17 +199,11 @@ const char *av_dirname(char *path)
return path;
}
#ifdef TEST
#include "common.h"
int main(void)
{
int i;
printf("Testing av_get_token()\n");
{
const char *strings[] = {
"''",
"",
@ -236,6 +233,7 @@ int main(void)
"\\'fo\\o\\:': foo ' :blahblah"
};
printf("Testing av_get_token()\n");
for (i = 0; i < FF_ARRAY_ELEMS(strings); i++) {
const char *p = strings[i], *q;
printf("|%s|", p);
@ -244,7 +242,6 @@ int main(void)
printf(" + |%s|\n", p);
av_free(q);
}
}
return 0;
}