newer and improveder new and improved oaf-slay



Improvements over the last round:
    * does not assume locations of perl, ps, and grep
    * supports POSIX or BSD-style ps
    * uses the configure-determined default oafdir rather than searching
      for it at run-time
    * obeys GNOME_PATH and OAF_INFO_PATH

The actual commit will replace oaf-slay with oaf-slay.in: the diff
between them is shown here for ease of comparison.

-- Dan
Index: configure.in
===================================================================
RCS file: /cvs/gnome/oaf/configure.in,v
retrieving revision 1.49.4.11
diff -u -r1.49.4.11 configure.in
--- configure.in	2001/03/02 03:02:09	1.49.4.11
+++ configure.in	2001/05/10 19:53:06
@@ -180,6 +180,29 @@
 	unset option
 fi
 
+AC_PATH_PROG(PERL_PATH, perl)
+if test -n "$PERL_PATH"; then
+	OAF_SLAY=oaf-slay
+	AC_PATH_PROG(PS_PATH, ps)
+	AC_CACHE_CHECK([for POSIX ps], ac_cv_prog_ps_posix, [
+		if $PS_PATH -U $USER -opid,args >/dev/null 2>&1; then
+			ac_cv_prog_ps_posix=yes
+		else
+			ac_cv_prog_ps_posix=no
+		fi
+	])
+	if test "$ac_cv_prog_ps_posix" = yes; then
+		IF_BSD_PS=#
+	else
+		IF_POSIX_PS=#
+	fi
+fi
+AC_SUBST(PERL_PATH)
+AC_SUBST(OAF_SLAY)
+AC_SUBST(PS_PATH)
+AC_SUBST(IF_BSD_PS)
+AC_SUBST(IF_POSIX_PS)
+
 AC_OUTPUT([
 Makefile
 oaf.spec
@@ -190,6 +213,7 @@
 liboaf/liboaf-version.h
 oafd/Makefile
 test/Makefile
+test/oaf-slay
 utils/Makefile
 intl/Makefile
 po/Makefile.in
Index: test/Makefile.am
===================================================================
RCS file: /cvs/gnome/oaf/test/Makefile.am,v
retrieving revision 1.16.4.2
diff -u -r1.16.4.2 Makefile.am
--- test/Makefile.am	2001/05/09 18:51:21	1.16.4.2
+++ test/Makefile.am	2001/05/10 19:53:06
@@ -52,16 +52,17 @@
 
 INCLUDES=-I$(top_srcdir) -I$(top_builddir) -I$(top_builddir)/liboaf -DOAFINFODIR=\"$(pkgdatadir)\" \
 	@ORBIT_CFLAGS@ @XML_CFLAGS@ @GLIB_CFLAGS@
-LDADD=../liboaf/liboaf.la @ORBIT_LIBS@ @GLIB_LIBS@
+LDADD=../liboaf/liboaf.la @ORBIT_LIBS@ @GLIB_LIBS@ @INTLLIBS@
 
 oaffiles=empty.oafinfo
 
 emptydatadir=$(datadir)/oaf
 emptydata_DATA=$(oaffiles)
 
-bin_SCRIPTS=oaf-slay
+bin_SCRIPTS=$(OAF_SLAY)
+EXTRA_SCRIPTS=oaf-slay.in
 
-EXTRA_DIST=empty.idl $(oaffiles) broken.oafinfo oaf-slay
+EXTRA_DIST=empty.idl $(oaffiles) broken.oafinfo
 
 check:
 	OAF_INFO_PATH="$(top_srcdir)/test:$$OAF_INFO_PATH" PATH="$(top_builddir)/test:$$PATH" $(top_builddir)/test/oaf-test-client
--- oaf-slay	Thu May 10 15:53:56 2001
+++ oaf-slay.in	Thu May 10 15:40:42 2001
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#! PERL_PATH@
 # 
 # oaf-slay
 # 
@@ -44,27 +44,32 @@
 # Build ps command.
 #
 $username = $ENV{'USER'};
-
 chomp($username);
-$ps_cmd = "/bin/ps -e -opid,user,args | /bin/grep ".$username;
+
+ IF_POSIX_PS@ $ps_cmd = "@PS_PATH@ -U $username -opid,args";
+ IF_BSD_PS@   $ps_cmd = "@PS_PATH@ -U $username -xww -opid,command";
 
 # get OAF files
 #
- path = split(':', $ENV{'PATH'});
-
-foreach $dir (@path) {
-	if (-f "$dir/oafd") {
-		$ins_dir  = `/usr/bin/dirname $dir`;
-		chomp $ins_dir;
-		$oaf_dir  = $ins_dir . "/share/oaf";
-		last;
+ oaf_dirs = ( "@prefix@/share/oaf" );
+foreach $dir (split(':', $ENV{'OAF_INFO_PATH'})) {
+	if (-d $dir) {
+		push @oaf_dirs, $dir;
+	}
+}
+foreach $dir (split(':', $ENV{'GNOME_PATH'})) {
+	if (-d "$dir/share/oaf") {
+		push @oaf_dirs, "$dir/share/oaf";
 	}
 }
 
-chdir($oaf_dir);
-opendir(DIR, $oaf_dir) || die "\nCan not open directory $oaf_dir\n\t$!\n\n";
- oaf_files = readdir(DIR);
-closedir DIR;
+foreach $dir (@oaf_dirs) {
+	opendir(DIR, $dir) || die "\nCan not open directory $dir\n\t$!\n\n";
+	while (readdir(DIR)) {
+		push @oaf_files, "$dir/$_";
+	}
+	closedir DIR;
+}
 
 # Initialize variables
 #
@@ -134,7 +139,7 @@
 				chomp $el;
 				if ($el =~m/$filep/ ) {
 					@ps_array = split(' ', $el);
-					$list_array[$index]=$ps_array[0]."\t".$ps_array[2]."\n";
+					$list_array[$index]=$ps_array[0]."\t".$ps_array[1]."\n";
 					$process_pids[$index]=$ps_array[0]."\n";
 					$index++;
 					}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]