On Thursday 14 June 2007 00:29, souf wrote:
> I tried to rewrite libbb/trim.c by adding new functions, a similar
> functions are dispersed in busybox:
> coreutils/cal.c
> miscutils/crond.c
> procps/sysctl.c
> shell/lash.c
> shell/ash.c
> applets/applets.c
> 
> trim.c =========================================================
> #include "libbb.h"
> 
> char *bb_strtrim(char *s, int c)

>From name I can infer that this function trims something from a string.
What does it trim? where (from the start, end, both)?

Try to have more descriptive names. This helps in understanding code,
especially _at _callsites_.

> {
>       char *t = NULL;
> 
>       if (!s) return NULL;
> 
>       if (c)
>               t = strchr(s, c);
>       else
>               t = s;

First t = NULL is superfluous.

> 
>       t = skip_whitespace(t);

If c!=0 and it is not found, we're toast (t==NULL).

>       memmove(s, t, strlen(t));
>       memset(s+strlen(t), 0, strlen(s)-strlen(t));
>       return s;

Maybe just return strcpy(s,t) ?

> }

--
vda
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to