CVS commit: src/usr.bin/genassym

2014-01-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jan  6 22:43:15 UTC 2014

Modified Files:
src/usr.bin/genassym: genassym.sh

Log Message:
- use just the basename for program name
- quote variables
- use mktemp to create directories (from jtc)
- exit on errors


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/genassym/genassym.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/genassym/genassym.sh
diff -u src/usr.bin/genassym/genassym.sh:1.7 src/usr.bin/genassym/genassym.sh:1.8
--- src/usr.bin/genassym/genassym.sh:1.7	Tue Jul  5 01:19:02 2011
+++ src/usr.bin/genassym/genassym.sh	Mon Jan  6 17:43:15 2014
@@ -1,5 +1,5 @@
 #!/bin/sh -
-#	$NetBSD: genassym.sh,v 1.7 2011/07/05 05:19:02 matt Exp $
+#	$NetBSD: genassym.sh,v 1.8 2014/01/06 22:43:15 christos Exp $
 #
 # Copyright (c) 1997 Matthias Pfaller.
 # All rights reserved.
@@ -25,7 +25,7 @@
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
 
-progname=${0}
+progname=$(basename ${0})
 : ${AWK:=awk}
 
 ccode=0		# generate temporary C file, compile it, execute result
@@ -37,6 +37,8 @@ usage()
 	echo usage: ${progname} [-c | -f] -- compiler command 2
 }
 
+set -e
+
 while getopts cf i
 do
 	case $i in
@@ -48,7 +50,7 @@ do
 		;;
 	esac
 done
-shift $(($OPTIND - 1))
+shift $(($OPTIND - 1))
 if [ $# -eq 0 ]; then
 	usage
 	exit 1
@@ -56,7 +58,7 @@ fi
 
 # Deal with any leading environment settings..
 
-while [ $1 ]
+while [ -n $1 ]
 do
 	case $1 in
 	*=*)
@@ -69,9 +71,10 @@ do
 	esac
 done
 
-genassym_temp=/tmp/genassym.$$
+genassym_temp=$(mktemp -d ${TMPDIR-/tmp}/genassym.XX)
+
 
-if ! mkdir $genassym_temp; then
+if [ ! -d $genassym_temp ]; then
 	echo ${progname}: unable to create temporary directory 2
 	exit 1
 fi
@@ -191,21 +194,21 @@ END {
 		printf(return(0); }\n);
 	}
 }
-' ccode=$ccode fcode=$fcode  ${genassym_temp}/assym.c || exit 1
+' ccode=$ccode fcode=$fcode  ${genassym_temp}/assym.c || exit 1
 
-if [ $ccode = 1 ] ; then
-	$@ ${genassym_temp}/assym.c -o ${genassym_temp}/genassym  \
-	${genassym_temp}/genassym
-elif [ $fcode = 1 ]; then
+if [ $ccode = 1 ]; then
+	$@ ${genassym_temp}/assym.c -o ${genassym_temp}/genassym  \
+	${genassym_temp}/genassym
+elif [ $fcode = 1 ]; then
 	# Kill all of the # and $ modifiers; locore.s already
 	# prepends the correct constant modifier.
-	$@ -S ${genassym_temp}/assym.c -o - | sed -e 's/\$//g' | \
+	$@ -S ${genassym_temp}/assym.c -o - | sed -e 's/\$//g' | \
 	sed -n 's/.*XYZZY//gp'
 else
 	# Kill all of the # and $ modifiers; locore.s already
 	# prepends the correct constant modifier.
-	$@ -S ${genassym_temp}/assym.c -o -  \
-	${genassym_temp}/genassym.out  \
-	sed -e 's/#//g' -e 's/\$//g'  ${genassym_temp}/genassym.out | \
+	$@ -S ${genassym_temp}/assym.c -o -  \
+	${genassym_temp}/genassym.out  \
+	sed -e 's/#//g' -e 's/\$//g'  ${genassym_temp}/genassym.out | \
 	sed -n 's/.*XYZZY/#define/gp'
 fi



CVS commit: src/usr.bin/genassym

2011-07-04 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Tue Jul  5 05:19:02 UTC 2011

Modified Files:
src/usr.bin/genassym: genassym.sh

Log Message:
Use __builtin_offsetof if __GNUC__ = 4


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/genassym/genassym.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/genassym/genassym.sh
diff -u src/usr.bin/genassym/genassym.sh:1.6 src/usr.bin/genassym/genassym.sh:1.7
--- src/usr.bin/genassym/genassym.sh:1.6	Sat Nov 28 20:30:01 2009
+++ src/usr.bin/genassym/genassym.sh	Tue Jul  5 05:19:02 2011
@@ -1,5 +1,5 @@
 #!/bin/sh -
-#	$NetBSD: genassym.sh,v 1.6 2009/11/28 20:30:01 dsl Exp $
+#	$NetBSD: genassym.sh,v 1.7 2011/07/05 05:19:02 matt Exp $
 #
 # Copyright (c) 1997 Matthias Pfaller.
 # All rights reserved.
@@ -79,7 +79,11 @@
 
 $AWK '
 BEGIN {
+	printf(#if __GNUC__ = 4\n);
+	printf(#define	offsetof(type, member) __builtin_offsetof(type, member)\n);
+	printf(#else\n);
 	printf(#define	offsetof(type, member) ((size_t)(((type *)0)-member))\n);
+	printf(#endif\n);
 	defining = 0;
 	type = long;
 	asmtype = n;



CVS commit: src/usr.bin/genassym

2010-04-13 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Tue Apr 13 09:01:10 UTC 2010

Modified Files:
src/usr.bin/genassym: genassym.1

Log Message:
Split overly large paragraph.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/genassym/genassym.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/genassym/genassym.1
diff -u src/usr.bin/genassym/genassym.1:1.4 src/usr.bin/genassym/genassym.1:1.5
--- src/usr.bin/genassym/genassym.1:1.4	Sun Oct 18 18:14:00 2009
+++ src/usr.bin/genassym/genassym.1	Tue Apr 13 09:01:10 2010
@@ -1,4 +1,4 @@
-.\	$NetBSD: genassym.1,v 1.4 2009/10/18 18:14:00 snj Exp $
+.\	$NetBSD: genassym.1,v 1.5 2010/04/13 09:01:10 jruoho Exp $
 .\
 .\ Copyright (c) 1997 Matthias Pfaller.
 .\ All rights reserved.
@@ -23,7 +23,7 @@
 .\ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 .\ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\
-.Dd August 18, 2005
+.Dd April 13, 2010
 .Dt GENASSYM 1
 .Os
 .Sh NAME
@@ -44,6 +44,7 @@
 reads from stdin. The generated file is used by kernel sources
 written in assembler to gain access to information (e.g. structure
 offsets and sizes) normally only known to the C compiler.
+.Pp
 Arguments to
 .Nm
 are usually of the form
@@ -56,7 +57,9 @@
 .Ar ${CPPFLAGS}
 are flag arguments to the C compiler. The script creates a C source file
 from its input. Then the C compiler is called according to the script's
-arguments to compile this file. Normally
+arguments to compile this file.
+.Pp
+Normally
 .Nm
 instructs the C compiler to create an assembler source from the constructed
 C source. The resulting file is then processed to extract the information
@@ -81,7 +84,9 @@
 .Nm
 command appeared in
 .Nx 1.3
-as genassym.sh in
+as
+.Dq genassym.sh
+in
 .Pa /usr/src/sys/kern .
 It became a userland utility in
 .Nx 4.0 .



CVS commit: src/usr.bin/genassym

2009-11-28 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sat Nov 28 20:30:02 UTC 2009

Modified Files:
src/usr.bin/genassym: genassym.sh

Log Message:
Use shell builtin getopts instead of getopt(1).
Fixes PR/30425


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/genassym/genassym.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/genassym/genassym.sh
diff -u src/usr.bin/genassym/genassym.sh:1.5 src/usr.bin/genassym/genassym.sh:1.6
--- src/usr.bin/genassym/genassym.sh:1.5	Sun Oct 18 18:14:00 2009
+++ src/usr.bin/genassym/genassym.sh	Sat Nov 28 20:30:01 2009
@@ -1,5 +1,5 @@
 #!/bin/sh -
-#	$NetBSD: genassym.sh,v 1.5 2009/10/18 18:14:00 snj Exp $
+#	$NetBSD: genassym.sh,v 1.6 2009/11/28 20:30:01 dsl Exp $
 #
 # Copyright (c) 1997 Matthias Pfaller.
 # All rights reserved.
@@ -37,25 +37,22 @@
 	echo usage: ${progname} [-c | -f] -- compiler command 2
 }
 
-args=`getopt cf $*`
-if [ $? != 0 ]; then
-	usage;
-	exit 1;
-fi
-set -- $args
-
-for i; do
+while getopts cf i
+do
 	case $i in
-	-c)
+	c)
 		ccode=1
-		shift;;
-	-f)
+		;;
+	f)
 		fcode=1
-		shift;;
-	--)
-		shift; break;;
+		;;
 	esac
 done
+shift $(($OPTIND - 1))
+if [ $# -eq 0 ]; then
+	usage
+	exit 1
+fi
 
 # Deal with any leading environment settings..