Code quality and examples from open source C code

D

Diomidis Spinellis

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>.
 
A

Al Balmer

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?
 
C

CBFalconer

Diomidis 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. 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/>
 
D

Diomidis Spinellis

Al said:
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
 
A

Al Balmer

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
 
D

Diomidis Spinellis

CBFalconer said:
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
 
R

Richard Heathfield

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!
 
A

Al Balmer

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.
 
C

CBFalconer

Richard said:
Diomidis Spinellis said:


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/>
 
D

Diomidis Spinellis

Richard said:
Diomidis Spinellis said:


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
 
R

Richard Heathfield

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?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,539
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top