Re: [Libclc-developers] Some more comments to the current CVS tree
Status: Planning
Brought to you by:
augestad
|
From: Hallvard B F. <h.b...@us...> - 2003-04-02 17:15:38
|
Jan Engelhardt writes:
> whilst looking through the current CVS snapshots, I stumbled over
> these issues:
Now that it has been posted to c.l.c, it might be better to discuss it
there. maybe that would liven c.l.c a bit. However,
> doc/string/clc_stralloc.txt:
> char *s = clc_stralloc("foo", "bar", (char *)0);
>
> Can't we assume that NULL is (something casted) 0?
No. See Regis' reply, or the documentation.
> src/clc_stralloc.c:
> va_start() is used two times. IIRC, such use is not recommended,
> for whatever reason. IIRC.
> They propose va_copy() instead.
Can't. va_copy() is a C99 macro. It's not defined in C89.
> src/clc_strcasecmp.c:
> for (;; s1++, s2++)
>
> Euh, maybe written as while(1) { ...; ++s1; ++s2 } ?
Well, I like it the way it is. If I'm voted down, I'll change it.
> src/clc_stpcpy.c:
> It is using its own copy mechanism. Since strcpy() is defined in ISO
> 9899 (is that C 89 or C 99 ?), oh well. If strcpy() is C89, wouldn't
> it be wiser to stick to that?
I'm not quite sure what you mean - is that a vote against the function,
or the implementation? The function exists because its result can be
faster to use than strcat(), which must traverse the first argument.
The implementation does its own copying rather than
strcpy(s1, s2);
return s1 + strlen(s1);
beacuse the former hopefully is quicker.
> src/clc_strdup.c:
> I am a great destroyer of readability >:-)
So you are:-)
> so I propose
> if((size = strlen(s) + 1) == 0) { p = NULL; }
> instead of the two lines
> size = strlen(s) + 1
> if(size == 0) { p = NULL; }
Why?
> src/clc_strlcpy.c:
> You cannot get rid of me.
> - while(*src)
> - ++src
> + while(*src++);
That doesn't help, then we must do --src; afterwards.
> src/clc_strltrim.c:
> (...)
> while(... && isspace((unsigned char)*cptr))
> What if you would make cptr unsigned at the beginning?
Well, it's one cast in either case. I have no preference.
However, there is a difference between the two in case char is signed
and either sign/magnitude or one's complement. I have no idea which is
right in that case. Looks like c.l.c material.
> doc/string/clc_strrev.txt
> small indent problem if you care ;)
>
> doc/string/*
> General indent question. Some files have 4 some have 2 leading.
8 and 4, that is. Fixed.
--
Hallvard
|