Re: Way OT programming question

2004-08-02 Thread Jerry McAllister
 
 I've been muddling through some of the source files for FreeBSD 
 5.2.1-RELEASE, and I've noticed that a large number of .c files 
 in /usr/src have something similar to below in them:
 
 #ifndef lint
 #if 0
 static char sccsid[] = @(#)cat.c   8.2 (Berkeley) 4/27/95;
 #endif
 #endif /* not lint */
 #include sys/cdefs.h
 __FBSDID($FreeBSD: src/bin/cat/cat.c,v 1.29 2003/04/30 17:40:28 
 obrien Exp $);
 
 1) Isn't 'if 0' always negative?

In a boolean usage like above, yes.   Anyway, FALSE usually gets
defined to be 0.   So, the above piece of code is disabled - sort
of commented out, so to speak.

 2) What is the __FBSDID line doing?

Looks like it sets or checks some version information.  Guess I could 
look it up, but then, so could you.

jerry

 
 -- 
 Thanks,
 
 Josh Paetzel
 ___
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Way OT programming question

2004-08-01 Thread Josh Paetzel
I've been muddling through some of the source files for FreeBSD 
5.2.1-RELEASE, and I've noticed that a large number of .c files 
in /usr/src have something similar to below in them:

#ifndef lint
#if 0
static char sccsid[] = @(#)cat.c   8.2 (Berkeley) 4/27/95;
#endif
#endif /* not lint */
#include sys/cdefs.h
__FBSDID($FreeBSD: src/bin/cat/cat.c,v 1.29 2003/04/30 17:40:28 
obrien Exp $);

1) Isn't 'if 0' always negative?
2) What is the __FBSDID line doing?

-- 
Thanks,

Josh Paetzel
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Way OT programming question

2004-08-01 Thread Simon Barner
Josh Paetzel wrote:
 I've been muddling through some of the source files for FreeBSD 
 5.2.1-RELEASE, and I've noticed that a large number of .c files 
 in /usr/src have something similar to below in them:
 
 #ifndef lint
 #if 0
 static char sccsid[] = @(#)cat.c   8.2 (Berkeley) 4/27/95;
 #endif
 #endif /* not lint */
 #include sys/cdefs.h
 __FBSDID($FreeBSD: src/bin/cat/cat.c,v 1.29 2003/04/30 17:40:28 
 obrien Exp $);
 
 1) Isn't 'if 0' always negative?

Yes, has the same effect as using comments. I don't know why #if 0 was
used here, but the line was probably kept in order to document the
(version) history of the file.

 2) What is the __FBSDID line doing?

It has the same purpose as the static char sccsid[] line: Each and every
source file adds an id line to the resulting binary executable. Thus it
is possible to determine the exact version of file.

Example:

% ident /bin/ls

/bin/ls:
 $FreeBSD: src/lib/csu/i386-elf/crti.S,v 1.6 2002/05/15 04:19:49 obrien Exp $
 $FreeBSD: src/lib/csu/i386-elf/crtn.S,v 1.5 2002/05/15 04:19:49 obrien Exp $
 $FreeBSD: src/lib/csu/common/crtbrand.c,v 1.4 2003/10/17 15:43:13 peter Exp $
 $FreeBSD: src/lib/csu/i386-elf/crt1.c,v 1.12 2003/01/26 23:14:47 markm Exp $
 $FreeBSD: src/bin/ls/cmp.c,v 1.12 2002/06/30 05:13:54 obrien Exp $
 $FreeBSD: src/bin/ls/ls.c,v 1.75 2003/12/01 19:10:29 obrien Exp $
 $FreeBSD: src/bin/ls/print.c,v 1.66 2003/10/16 07:07:20 tjr Exp $
 $FreeBSD: src/bin/ls/util.c,v 1.32 2003/09/09 12:02:52 tjr Exp $

Btw: ident(1) also works on source files, Makefiles -- basically
everything that has a CVS id line.

__FBSDID is defined in /usr/src/sys/sys/cdefs.h

Simon

Btw: While reading the FreeBSD source can be very interesting, browsing the
 commit logs can be even more exciting: You can either use `cvs log'
 directly (on your local copy of the repository or via anoncvs),
 or use the web interface at http://cvsweb.FreeBSD.org.


signature.asc
Description: Digital signature