tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Allow configuration of tcc libraries search path


From: grischka
Subject: Re: [Tinycc-devel] Allow configuration of tcc libraries search path
Date: Thu, 07 Jul 2011 00:06:37 +0200
User-agent: Thunderbird 2.0.0.24 (Windows/20100228)

Thomas Preud'homme wrote:
Also, I'd claim that using strtok is somehow un-tcc'ish, seen that
there are zero occurrences anywhere else. ;)
Ah. Then what tcc'ish function should I use?

The one that you write yourself ;)  Say along the lines of

   while (*p && *p != ':')
        ++p;

Reason why strtok is bad is because it does non-obvious things
which in turn leads to non-obvious code and bugs.

For example all those variables called 'tok_somthing'

      char *tok, *tok_extra_libdir = NULL, *tok_save_ptr,
      size_t toklen = 0, old_toklen = 0;

is more or less stuff that literally nobody really wants to read,
including the person who wrote it.  Which means that bugs will
stay undetected more likely.

Now thank you for proving this point as with missing free,  missing
buffer space for terminating '\0' (as with 'toklen'), missing statement
'old_toklen = toklen' somewhere.  Aside from the fact that strtok_r
does not seem to be part of the C standard which (I think) is effectively
a problem if someone wants to build the cross compilers on windows.

So, considered the extra stuff that you need to setup for 'strtok',
(variables, copying the const string to rw memory) plus the extra
bugs that need to be fixed each, the extra email text to get there,
plus that even then the code will still be ugly, and considered that
strtok doesn't do really much, it is very likely much more effective
not to use strtok.

Anyway, this was the long version of:  Why I hate strtok.  Or say
strncpy, for that matter.  (Incidentally tcc has 'pstrcpy'.)

Btw, I'm still thinking about 0.9.26.
Great :) Please wait this is fixed then. I did a snapshot of the master branch for distribution in Debian. I plan to let it stay in Debian experimental for a few weeks (my initial plan is 1 month but I could do 2 weeks) and then upload it in Debian unstable where it will have more coverage. So if you want you can wait a month and I'll tell you if I have any bug report when it hit unstable. Note that I'm also fine for releasing now, especially since it would simplify my work.

Not sure how this would simplify your work but surely I can wait a month ;)

Thanks,

--- grischka




reply via email to

[Prev in Thread] Current Thread [Next in Thread]