On Tue, Mar 20, 2001 at 01:12:46AM -0800, Alfred Perlstein wrote:
...... skip .......
> > + size_t sz;
> > + wchar_t c;
>
> C has allowed for identifiers larger than 6 characters for quite
> some time, any chance on you making use of this feature? Or at
> least adding a comment here and there?
Ok.. I would add a comment here and there.
>
> > + p = s;
> > + dc = len = strlen(s);
> > + ri = r = (char *)malloc(len + 1);
>
> Where is the check for malloc failing?
Yes, it is good idea. Although, I don't think that we can't alloc
a memory block that less than 256+1 bytes.
>
> > + while (dc) {
> > + sz = mbtowc(&c, p, dc);
> > + if (sz < 0) {
> > + p++;
> > + dc--;
> > + *ri++ = '?';
> > + } else {
> > + dc -= sz;
> > + if (isprint(c)) {
> > + while(sz--)
> > + *ri++ = *p++;
> > + } else {
> > + p += sz;
> > + while(sz--)
> > + *ri++ = '?';
>
> Why didn't you use strlcpy/memcpy as suggested?
As I can see, most codeset don't use more any 4 bytes to represent
a character. For proformance reason, strlcpy/memcpy is not a good
choice. For easy reading, I don't which one is better. For size,
I think function call is more expensive. If we use strlcpy/memcpy,
it mean we use strlcpy/memcpy to copy a block of memory that less
than 4 bytes. I don't think it is good example to demo strlcpy/memcpy.
>
> > + }
> > + }
> > + }
> > + *ri = 0;
>
> *ri = '\0';
For easy reading?? ok..
>
> > + printf("%s", r);
> > + free(r);
> > + return len;
>
> return (len);
>
...... skip ..........
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message