* read.h (s_vendor_attribute): Move to...
[deliverable/binutils-gdb.git] / gdb / observer.sh
index 2cc0e7fe90a42fc55c9d61d454cd1e5f8a97c3a9..c98afd07ce0bb276e3405e7f0d70a801bc26c5c3 100755 (executable)
@@ -1,5 +1,10 @@
 #!/bin/sh -e
 
+# Make certain that the script is not running in an internationalized
+# environment.
+LANG=C ; export LANG
+LC_ALL=C ; export LC_ALL
+
 if test $# -ne 3
 then
     echo "Usage: $0 <h|inc> <observer.texi> <observer.out>" 1>&2
@@ -8,35 +13,38 @@ fi
 
 lang=$1 ; shift
 texi=$1 ; shift
-o=$1 ; shift
-echo "Creating ${o}-tmp" 1>&2
-rm -f ${o}-tmp
+o=$1
+case $lang in
+  h) tmp=htmp ;;
+  inc) tmp=itmp ;;
+esac
+otmp="`echo $1 | sed -e 's,\.[^.]*$,,'`.$tmp"; shift
+echo "Creating ${otmp}" 1>&2
+rm -f ${otmp}
 
 # Can use any of the following: cat cmp cp diff echo egrep expr false
 # grep install-info ln ls mkdir mv pwd rm rmdir sed sleep sort tar
 # test touch true
 
-cat <<EOF >>${o}-tmp
+cat <<EOF >>${otmp}
 /* GDB Notifications to Observers.
 
-   Copyright 2004 Free Software Foundation, Inc.
+   Copyright (C) 2004-2005, 2007-2012 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
-
+  
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-
+  
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
    --
 
@@ -46,16 +54,27 @@ EOF
 
 
 case $lang in
-    h) cat <<EOF >>${o}-tmp
+    h) cat <<EOF >>${otmp}
 #ifndef OBSERVER_H
 #define OBSERVER_H
 
 struct observer;
 struct bpstats;
+struct so_list;
+struct objfile;
+struct thread_info;
+struct inferior;
 EOF
         ;;
 esac
 
+# We are about to set IFS=:, so DOS-style file names with a drive
+# letter and a colon will be in trouble.
+
+if test -n "$DJGPP"
+then
+     texi=`echo $texi | sed -e 's,^\([a-zA-Z]\):/,/dev/\1/,'`
+fi
 
 # generate a list of events that can be observed
 
@@ -86,7 +105,7 @@ sed -n '
 ' $texi | while read event formal actual
 do
   case $lang in
-      h) cat <<EOF >>${o}-tmp
+      h) cat <<EOF >>${otmp}
 
 /* ${event} notifications.  */
 
@@ -99,20 +118,35 @@ EOF
        ;;
 
       inc)
-       cat <<EOF >>${o}-tmp
+       cat <<EOF >>${otmp}
 
 /* ${event} notifications.  */
 
 static struct observer_list *${event}_subject = NULL;
 
+EOF
+       if test "$formal" != "void"; then
+           cat<<EOF >>${otmp}
 struct ${event}_args { `echo "${formal}" | sed -e 's/,/;/g'`; };
 
+EOF
+       fi
+       cat <<EOF >>${otmp}
 static void
 observer_${event}_notification_stub (const void *data, const void *args_data)
 {
   observer_${event}_ftype *notify = (observer_${event}_ftype *) data;
+EOF
+
+       notify_args=`echo ${actual} | sed -e 's/\([a-z0-9_][a-z0-9_]*\)/args->\1/g'`
+
+       if test ! -z "${notify_args}"; then
+           cat<<EOF >>${otmp}
   const struct ${event}_args *args = args_data;
-  notify (`echo ${actual} | sed -e 's/\([a-z0-9_][a-z0-9_]*\)/args->\1/g'`);
+EOF
+       fi
+       cat <<EOF >>${otmp}
+  notify (${notify_args});
 }
 
 struct observer *
@@ -132,8 +166,17 @@ observer_detach_${event} (struct observer *observer)
 void
 observer_notify_${event} (${formal})
 {
+EOF
+       if test "$formal" != "void"; then
+           cat<<EOF >>${otmp}
   struct ${event}_args args;
   `echo ${actual} | sed -e 's/\([a-z0-9_][a-z0-9_]*\)/args.\1 = \1/g'`;
+
+EOF
+       else
+           echo "char *args = NULL;" >> ${otmp}
+       fi
+       cat<<EOF >>${otmp}
   if (observer_debug)
     fprintf_unfiltered (gdb_stdlog, "observer_notify_${event}() called\n");
   generic_observer_notify (${event}_subject, &args);
@@ -145,12 +188,12 @@ done
 
 
 case $lang in
-    h) cat <<EOF >>${o}-tmp
+    h) cat <<EOF >>${otmp}
 
 #endif /* OBSERVER_H */
 EOF
 esac
 
 
-echo Moving ${o}-tmp to ${o}
-mv ${o}-tmp ${o}
+echo Moving ${otmp} to ${o}
+mv ${otmp} ${o}
This page took 0.025282 seconds and 4 git commands to generate.