Code quality and examples from open source C code

Discussion in 'C Programming' started by Diomidis Spinellis, Apr 11, 2006.

  1. A quick note to inform my fellow C programmers that my new book "Code
    Quality: The Open Source Perspective" (Addison-Wesley, 2006) has just
    been published. All 623 examples I use in the book are drawn from
    real-world open source code; most use C, as the lowest common
    denominator. For more details you can visit the book's web site at
    <http://www.spinellis.gr/codequality?clc>.

    --
    Diomidis Spinellis Associate Professor
    Department of Management Science and Technology (DMST)
    Athens University of Economics and Business (AUEB)
    http://www.dmst.aueb.gr/dds/ mailto:
    Diomidis Spinellis, Apr 11, 2006
    #1
    1. Advertising

  2. Diomidis Spinellis

    Al Balmer Guest

    On Tue, 11 Apr 2006 17:28:36 +0300, Diomidis Spinellis <>
    wrote:

    >A quick note to inform my fellow C programmers that my new book "Code


    So, your first-ever posting to your "fellow C programmers" in this
    group is an advertisement. Will it be your last? Will you even check
    back for responses?

    --
    Al Balmer
    Sun City, AZ
    Al Balmer, Apr 11, 2006
    #2
    1. Advertising

  3. Diomidis Spinellis

    CBFalconer Guest

    Diomidis Spinellis wrote:
    >
    > A quick note to inform my fellow C programmers that my new book
    > "Code Quality: The Open Source Perspective" (Addison-Wesley, 2006)
    > has just been published. All 623 examples I use in the book are
    > drawn from real-world open source code; most use C, as the lowest
    > common denominator. For more details you can visit the book's
    > web site at <http://www.spinellis.gr/codequality?clc>.


    I may be all wet here, but while there is nothing wrong with your
    charging for a book, I consider the material in a book based on
    open source code should also be freely available. Is it? Open
    source is not public domain, it remains copyright and carries some
    form of license.

    --
    "If you want to post a followup via groups.google.com, don't use
    the broken "Reply" link at the bottom of the article. Click on
    "show options" at the top of the article, then click on the
    "Reply" at the bottom of the article headers." - Keith Thompson
    More details at: <http://cfaj.freeshell.org/google/>
    Also see <http://www.safalra.com/special/googlegroupsreply/>
    CBFalconer, Apr 11, 2006
    #3
  4. Al Balmer wrote:
    > On Tue, 11 Apr 2006 17:28:36 +0300, Diomidis Spinellis <>
    > wrote:
    >
    >> A quick note to inform my fellow C programmers that my new book "Code

    >
    > So, your first-ever posting to your "fellow C programmers" in this
    > group is an advertisement. Will it be your last? Will you even check
    > back for responses?


    I first posted in comp.lang.c in 1990:

    * Re: popen() (5 Mar 90 09:35:40 GMT)
    * Re: isalpha in ctype.h (Tue, 26 Mar 1991 10:59:25 GMT)

    (you can find the articles here
    http://www.spinellis.gr/news/comp_lang_c.html), and, yes, I'm back to
    check for responses.

    Diomidis
    Diomidis Spinellis, Apr 11, 2006
    #4
  5. Diomidis Spinellis

    Al Balmer Guest

    On Tue, 11 Apr 2006 23:24:11 +0300, Diomidis Spinellis <>
    wrote:

    >Al Balmer wrote:
    >> On Tue, 11 Apr 2006 17:28:36 +0300, Diomidis Spinellis <>
    >> wrote:
    >>
    >>> A quick note to inform my fellow C programmers that my new book "Code

    >>
    >> So, your first-ever posting to your "fellow C programmers" in this
    >> group is an advertisement. Will it be your last? Will you even check
    >> back for responses?

    >
    >I first posted in comp.lang.c in 1990:
    >
    > * Re: popen() (5 Mar 90 09:35:40 GMT)
    > * Re: isalpha in ctype.h (Tue, 26 Mar 1991 10:59:25 GMT)
    >

    First and last, eh? Pre-dejanews, apparently, or at least pre-Google
    archives.

    >(you can find the articles here
    >http://www.spinellis.gr/news/comp_lang_c.html), and, yes, I'm back to
    >check for responses.


    OK, here's a response: Advertisements are not welcomed in comp.lang.c,
    even when peripherally related to the C language, the topic of this
    group.

    The accepted way to "advertise" in this (and many other technical
    groups) is to participate and contribute, confining your advertising
    to a short signature block.
    Alan Balmer
    Sun City, AZ

    clc wiki: http://clc-wiki.net/wiki/Main_Page
    Al Balmer, Apr 11, 2006
    #5
  6. CBFalconer wrote:
    > Diomidis Spinellis wrote:
    >> A quick note to inform my fellow C programmers that my new book
    >> "Code Quality: The Open Source Perspective" (Addison-Wesley, 2006)
    >> has just been published. All 623 examples I use in the book are
    >> drawn from real-world open source code; most use C, as the lowest
    >> common denominator. For more details you can visit the book's
    >> web site at <http://www.spinellis.gr/codequality?clc>.

    >
    > I may be all wet here, but while there is nothing wrong with your
    > charging for a book, I consider the material in a book based on
    > open source code should also be freely available.


    You could make such a case for GPL-licensed code, although even in that
    case one would probably argue that the excerpting of code for criticism
    and commenting falls under the copyright's fair use doctrine
    <http://en.wikipedia.org/wiki/Fair_use>. Nevertheless, to be extra
    safe, all the source code used in both "Code Reading" and "Code Quality"
    is licensed under the more liberal BSD and similar licenses. For "Code
    Reading", which included the source code on a CD-ROM, the book had all
    the relevant licenses printed as an appendix (this is a requirement of
    many licenses).

    This discussion has nothing to do with comp.lang.c, and I feel guilty
    for (unwittingly) inciting it. If I didn't answer your question, maybe
    we should discuss it further by email.

    Diomidis
    Diomidis Spinellis, Apr 12, 2006
    #6
  7. Diomidis Spinellis said:

    > A quick note to inform my fellow C programmers that my new book "Code
    > Quality: The Open Source Perspective" (Addison-Wesley, 2006) has just
    > been published.


    Thanks, Diomidis.

    It's a bit of a shame that you've met with a rather frosty response
    from Al and Chuck. In their defence, we do get a lot of junk posted
    in this group.

    I am grateful to you for taking the trouble to write a book which,
    to judge by its title and author, will be well worth adding to
    one's collection.

    And just to trash your reputation completely amongst those who don't
    know, I cannot resist posting a typical Diomidis Spinellis program
    which, I think, perfectly demonstrates the importance of ensuring
    the quality of Open Source code. ;-)


    (Word wrap turned off for this bit)


    #define O(b,f,u,s,c,a)b(){int o=f();switch(*p++){X u:_ o s b();X c:_ o a b();default:p--;_ o;}}
    #define t(e,d,_,C)X e:f=fopen(B+d,_);C;fclose(f)
    #define U(y,z)while(p=Q(s,y))*p++=z,*p=' '
    #define N for(i=0;i<11*R;i++)m&&
    #define I "%d %s\n",i,m
    #define X ;break;case
    #define _ return
    #define R 999
    typedef char*A;int*C,E[R],L[R],M[R],P[R],l,i,j;char B[R],F[2];A m[12*R],malloc
    (),p,q,x,y,z,s,d,f,fopen();A Q(s,o)A s,o;{for(x=s;*x;x++){for(y=x,z=o;*z&&*y==
    *z;y++)z++;if(z>o&&!*z)_ x;}_ 0;}main(){m[11*R]="E";while(puts("Ok"),gets(B)
    )switch(*B){X'R':C=E;l=1;for(i=0;i<R;P[i++]=0);while(l){while(!(s=m[l]))l++;if
    (!Q(s,"\"")){U("<>",'#');U("<=",'$');U(">=",'!');}d=B;while(*F=*s){*s=='"'&&j
    ++;if(j&1||!Q(" \t",F))*d++=*s;s++;}*d--=j=0;if(B[1]!='=')switch(*B){X'E':l=-1
    X'R':B[2]!='M'&&(l=*--C)X'I':B[1]=='N'?gets(p=B),P[*d]=S():(*(q=Q(B,"TH"))=0,p
    =B+2,S()&&(p=q+4,l=S()-1))X'P':B[5]=='"'?*d=0,puts(B+6):(p=B+5,printf("%d\n",S
    ()))X'G':p=B+4,B[2]=='S'&&(*C++=l,p++),l=S()-1 X'F':*(q=Q(B,"TO"))=0;p=B+5;P[i
    =B[3]]=S();p=q+2;M=S();L=l X'N':++P[*d]<=M[*d]&&(l=L[*d]);}else p=B+2,P[
    *B]=S();l++;}X'L':N printf(I)X'N':N free(m),m=0 X'B':_ 0 t('S',5,"w",N
    fprintf(f,I))t('O',4,"r",while(fgets(B,R,f))(*Q(B,"\n")=0,G()))X 0:default:G()
    ;}_ 0;}G(){l=atoi(B);m[l]&&free(m[l]);(p=Q(B," "))?strcpy(m[l]=malloc(strlen(p
    )),p+1):(m[l]=0,0);}O(S,J,'=',==,'#',!=)O(J,K,'<',<,'>',>)O(K,V,'$',<=,'!',>=)
    O(V,W,'+',+,'-',-)O(W,Y,'*',*,'/',/)Y(){int o;_*p=='-'?p++,-Y():*p>='0'&&*p<=
    '9'?strtol(p,&p,0):*p=='('?p++,o=S(),p++,o:p[*p++];}


    If anyone yells at the use of gets(), I have two things to say to them:

    (a) yeah, I know, it's bad and I wish he hadn't done it;
    (b) forget it - put that complaint back on the shelf, and grok the code!


    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999
    http://www.cpax.org.uk
    Richard Heathfield, Apr 13, 2006
    #7
  8. Diomidis Spinellis

    Al Balmer Guest

    On Thu, 13 Apr 2006 00:26:32 +0000, Richard Heathfield
    <> wrote:

    >It's a bit of a shame that you've met with a rather frosty response
    >from Al and Chuck. In their defence, we do get a lot of junk posted
    >in this group.


    You now compel me to defend my remarks by pointing out to their highly
    desirable outcome: Dr. Spinellis has contributed at least one good
    topical article to the group, and I hope there will be many more.

    --
    Al Balmer
    Sun City, AZ
    Al Balmer, Apr 13, 2006
    #8
  9. Diomidis Spinellis

    CBFalconer Guest

    Richard Heathfield wrote:
    > Diomidis Spinellis said:
    >
    >> A quick note to inform my fellow C programmers that my new book
    >> "Code Quality: The Open Source Perspective" (Addison-Wesley, 2006)
    >> has just been published.

    >
    > It's a bit of a shame that you've met with a rather frosty response
    > from Al and Chuck. In their defence, we do get a lot of junk posted
    > in this group.


    Note that he replied to my concerns, with suitable assurances.

    --
    "If you want to post a followup via groups.google.com, don't use
    the broken "Reply" link at the bottom of the article. Click on
    "show options" at the top of the article, then click on the
    "Reply" at the bottom of the article headers." - Keith Thompson
    More details at: <http://cfaj.freeshell.org/google/>
    Also see <http://www.safalra.com/special/googlegroupsreply/>
    CBFalconer, Apr 13, 2006
    #9
  10. Richard Heathfield wrote:
    > Diomidis Spinellis said:
    >
    >> A quick note to inform my fellow C programmers that my new book "Code
    >> Quality: The Open Source Perspective" (Addison-Wesley, 2006) has just
    >> been published.

    >
    > Thanks, Diomidis.
    >
    > It's a bit of a shame that you've met with a rather frosty response
    > from Al and Chuck. In their defence, we do get a lot of junk posted
    > in this group.


    No problem. These are the risks of posting to a public forum,
    especially after a very long absence. From the replies to this message
    it is obvious that Al and Chuck were trying to protect the newsgroup,
    rather than attack me. Anyway, as you will have noticed, to redeem
    myself I've started posting replies to some questions I feel I could
    address. Hopefully this will restore the signal/noise ratio of my
    contributions; however, I doubt I can address the damage done by your
    posting of my obfuscated C code :) In two cases I found that I could
    provide answers to questions by posting excerpts from open-source code.
    I'll continue to do that, until I start writing another book or
    somebody here tells me to shut up.

    Diomidis
    Diomidis Spinellis, Apr 13, 2006
    #10
  11. Diomidis Spinellis said:

    > In two cases I found that I could
    > provide answers to questions by posting excerpts from open-source code.
    > I'll continue to do that, until I start writing another book or
    > somebody here tells me to shut up.


    As someone famous once said:

    Welcome to hell. Here's your handbasket. Say, can you
    work 70 hours this week?

    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999
    http://www.cpax.org.uk
    email: rjh at above domain (but drop the www, obviously)
    Richard Heathfield, Apr 13, 2006
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Xah Lee
    Replies:
    80
    Views:
    1,647
    Claudio Grondi
    Feb 16, 2006
  2. Elhanan
    Replies:
    15
    Views:
    561
    Tris Orendorff
    Apr 28, 2006
  3. kaens
    Replies:
    3
    Views:
    1,159
    kaens
    Jun 2, 2007
  4. Dave
    Replies:
    8
    Views:
    307
    Steve Holden
    Oct 13, 2008
  5. Diomidis Spinellis

    Code Quality and examples from the Perl source code

    Diomidis Spinellis, Apr 11, 2006, in forum: Perl Misc
    Replies:
    0
    Views:
    156
    Diomidis Spinellis
    Apr 11, 2006
Loading...

Share This Page