Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 30 Jul 1998 04:14:17 +1000 (EST)
From:      proff@iq.org
To:        peter@netplex.com.au (Peter Wemm)
Cc:        jkb@best.com, showboat@hotmail.com, security@FreeBSD.ORG
Subject:   Berg coding style (was qpopper trauma)
Message-ID:  <19980729181418.19519.qmail@iq.org>
In-Reply-To: <199807291638.AAA02315@spinner.netplex.com.au> from Peter Wemm at "Jul 30, 98 00:38:49 am"

next in thread | previous in thread | raw e-mail | index | archive | help
> The cucipop code truely has to be seen to be believed......  eg:
> =======
>      }
>    }   
>   ;{ int namelen=sizeof peername;
>      if(getpeername(fileno(sockin),(struct sockaddr*)&peername,&namelen)&&
>       !debug&&(errno==ENOTSOCK||errno==EINVAL))
>       { int serverfd,curfd; 
>         signal(SIGHUP,SIG_IGN);signal(SIGPIPE,SIG_IGN);fclose(stdin);
>         fclose(stdout);serverfd=socket(AF_INET,SOCK_STREAM,TCP_PROT);
>         peername.sin_family=AF_INET;peername.sin_addr.s_addr=INADDR_ANY;
>         peername.sin_port=htons(port);curfd=-1;
>         setsockopt(serverfd,SOL_SOCKET,SO_REUSEADDR,&curfd,sizeof curfd);
>         if(bind(serverfd,(struct sockaddr*)&peername,sizeof peername))
> =======
> 
> I've heard 'you can write fortran code in any language'..  I suspect this 
> is C written by an assembler programmer.   The handcrafted optimization 
> reminds me of dark periods in my past of trying to save every last clock 
> cycle and/or byte of memory.

That's actually pretty tame for Berg code (S. R. van den Berg). My favourite
is the following line from bregex.c (Berg's record-beating posix compatible regex
pattern matcher included in nntpcache):

                    while((jump=jt[*(jstr+=jump)]));

For the uninitiated the above is a full blown Boyer-Moore loop. regexp.c in
procmail is worth a glance too.

Cheers,
Julian.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe security" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19980729181418.19519.qmail>