changeset 3505:5a2c5361dbf1

[project @ 2000-02-01 11:04:15 by jwe]
author jwe
date Tue, 01 Feb 2000 11:05:08 +0000
parents 5eef8a2294bd
children ed0e55953260
files liboctave/ChangeLog liboctave/Makefile.in liboctave/oct-getopt.c liboctave/oct-getopt.h liboctave/oct-kpse.c liboctave/oct-kpse.h liboctave/pathsearch.cc liboctave/prog-args.cc
diffstat 8 files changed, 284 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/ChangeLog	Tue Feb 01 10:07:26 2000 +0000
+++ b/liboctave/ChangeLog	Tue Feb 01 11:05:08 2000 +0000
@@ -1,5 +1,9 @@
 2000-02-01  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
+	* oct-getopt.h, oct-getopt.c: New files for interface to getopt.
+
+	* oct-kpse.h, oct-kpse.c: New files for interface to kpathsearch.
+
 	* dMatrix.cc (write_int, read_int): No longer declared static.
 
 	* CDiagMatrix.h: Delete decls for friend operators that are
--- a/liboctave/Makefile.in	Tue Feb 01 10:07:26 2000 +0000
+++ b/liboctave/Makefile.in	Tue Feb 01 11:05:08 2000 +0000
@@ -47,9 +47,10 @@
 	dir-ops.h file-ops.h file-stat.h getopt.h glob-match.h \
 	idx-vector.h lo-ieee.h lo-mappers.h lo-specfun.h lo-sysdep.h \
 	lo-utils.h mach-info.h oct-alloc.h oct-cmplx.h oct-env.h \
-	oct-group.h oct-passwd.h oct-shlib.h oct-syscalls.h oct-time.h \
-	pathlen.h pathsearch.h prog-args.h statdefs.h str-vec.h sun-utils.h \
-	sysdir.h systime.h syswait.h \
+	oct-getopt.h oct-group.h oct-kpse.h oct-passwd.h \
+	oct-shlib.h oct-syscalls.h oct-time.h pathlen.h pathsearch.h \
+	prog-args.h statdefs.h str-vec.h sun-utils.h sysdir.h systime.h \
+	syswait.h \
 	$(MATRIX_INC) \
 	$(MX_OP_INC)
 
@@ -80,9 +81,10 @@
 	file-stat.cc filemode.c getopt.c getopt1.c glob-match.cc \
 	idx-vector.cc lo-ieee.cc lo-mappers.cc lo-specfun.cc \
 	lo-sysdep.cc lo-utils.cc mach-info.cc mkdir.c oct-alloc.cc \
-	oct-env.cc oct-group.cc oct-passwd.cc oct-shlib.cc oct-syscalls.cc \
-	oct-time.cc pathsearch.cc prog-args.cc rename.c rmdir.c \
-	strftime.c strptime.c str-vec.cc tempname.c tempnam.c \
+	oct-env.cc oct-getopt.c oct-group.cc oct-kpse.c oct-passwd.cc \
+	oct-shlib.cc oct-syscalls.cc oct-time.cc \
+	pathsearch.cc prog-args.cc rename.c rmdir.c strftime.c \
+	strptime.c str-vec.cc tempname.c tempnam.c \
 	$(TEMPLATE_SRC) \
 	$(TI_SRC) \
 	$(MATRIX_SRC) \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/liboctave/oct-getopt.c	Tue Feb 01 11:05:08 2000 +0000
@@ -0,0 +1,47 @@
+/*
+
+Copyright (C) 2000 John W. Eaton
+
+This file is part of Octave.
+
+Octave 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, or (at your option) any
+later version.
+
+Octave 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 Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "getopt.h"
+
+int
+octave_getopt (int argc, char *const *argv, const char *optstring)
+{
+  return getopt (argc, argv, optstring);
+}
+
+int
+octave_getopt_long (int argc, char *const *argv, const char *options,
+		    const struct option *long_options, int *opt_index)
+{
+  return getopt_long (argc, argv, options, long_options, opt_index);
+}
+
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/liboctave/oct-getopt.h	Tue Feb 01 11:05:08 2000 +0000
@@ -0,0 +1,43 @@
+/*
+
+Copyright (C) 2000 John W. Eaton
+
+This file is part of Octave.
+
+Octave 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, or (at your option) any
+later version.
+
+Octave 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 Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#if !defined (octave_getopt_h)
+#define octave_getopt_h 1
+
+extern int
+octave_getopt (int, char *const *, const char *);
+
+extern int
+octave_getopt_long (int, char *const *, const char *,
+		    const struct option *, int *);
+
+extern char *optarg;
+
+extern int optind;
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/liboctave/oct-kpse.c	Tue Feb 01 11:05:08 2000 +0000
@@ -0,0 +1,88 @@
+/*
+
+Copyright (C) 2000 John W. Eaton
+
+This file is part of Octave.
+
+Octave 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, or (at your option) any
+later version.
+
+Octave 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 Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <kpathsea/default.h>
+#include <kpathsea/expand.h>
+#include <kpathsea/pathsearch.h>
+#include <kpathsea/progname.h>
+
+#define OCTAVE_KPSE_SKIP_STRUCT_DECLS
+#include "oct-kpse.h"
+#undef OCTAVE_KPSE_SKIP_STRUCT_DECLS
+
+str_llist_type *
+octave_kpse_element_dirs (const char *elt)
+{
+  return kpse_element_dirs (elt);
+}
+
+char *
+octave_kpse_path_search (const char *path, const char *name, int must_exist)
+{
+  return kpse_path_search (path, name, must_exist);
+}
+
+char **
+octave_kpse_all_path_search (const char *path, const char *name)
+{
+  return kpse_all_path_search (path, name);
+}
+
+void
+octave_kpse_set_progname (const char *name)
+{
+  octave_kpse_set_progname (name);
+}
+
+void
+octave_kpse_clear_dir_cache (void)
+{
+  kpse_clear_dir_cache ();
+}
+
+char *
+octave_kpse_expand_default (const char *path, const char *dflt)
+{
+  return kpse_expand_default (path, dflt);
+}
+
+char *
+octave_kpse_path_expand (const char *path)
+{
+  return kpse_path_expand (path);
+}
+
+char *
+octave_kpse_path_element (const char *path)
+{
+  return kpse_path_element (path);
+}
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/liboctave/oct-kpse.h	Tue Feb 01 11:05:08 2000 +0000
@@ -0,0 +1,74 @@
+/*
+
+Copyright (C) 2000 John W. Eaton
+
+This file is part of Octave.
+
+Octave 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, or (at your option) any
+later version.
+
+Octave 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 Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#if !defined (octave_kpse_h)
+#define octave_kpse_h 1
+
+#if !defined (OCTAVE_KPSE_SKIP_STRUCT_DECLS)
+struct str_llist_elt
+{
+  char *str;
+  int moved;
+  struct str_llist_elt *next;
+};
+typedef struct str_llist_elt str_llist_elt_type;
+typedef struct str_llist_elt *str_llist_type;
+
+#define STR_LLIST(sl) ((sl).str)
+#define STR_LLIST_MOVED(sl) ((sl).moved)
+#define STR_LLIST_NEXT(sl) ((sl).next)
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+extern unsigned int kpathsea_debug;
+
+extern str_llist_type *octave_kpse_element_dirs (const char *);
+
+extern char *octave_kpse_path_search (const char *, const char *, int);
+
+extern char **octave_kpse_all_path_search (const char *, const char *);
+
+extern void octave_kpse_set_progname (const char *);
+
+extern void octave_kpse_clear_dir_cache (void);
+
+extern char *octave_kpse_expand_default (const char *, const char *);
+
+extern char *octave_kpse_path_expand (const char *);
+
+extern char *octave_kpse_path_element (const char *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
--- a/liboctave/pathsearch.cc	Tue Feb 01 10:07:26 2000 +0000
+++ b/liboctave/pathsearch.cc	Tue Feb 01 11:05:08 2000 +0000
@@ -29,26 +29,11 @@
 #include <string>
 
 #include "lo-utils.h"
+#include "oct-kpse.h"
 #include "pathsearch.h"
 #include "str-vec.h"
 #include "str-vec.h"
 
-extern "C"
-{
-// Have to redefine these because they conflict with new C++ keywords
-// or otherwise cause trouble...
-#define string kpse_string
-
-#include <kpathsea/default.h>
-#include <kpathsea/expand.h>
-#include <kpathsea/pathsearch.h>
-#include <kpathsea/progname.h>
-
-extern unsigned int kpathsea_debug;
-
-#undef string
-}
-
 static bool octave_kpathsea_initialized = false;
 
 string_vector
@@ -73,7 +58,8 @@
 
       for (int i = 0; i < len; i++)
 	{
-	  str_llist_type *elt_dirs = kpse_element_dirs (pv[i].c_str ());
+	  str_llist_type *elt_dirs
+	    = ::octave_kpse_element_dirs (pv[i].c_str ());
 
 	  if (elt_dirs)
 	    {
@@ -109,7 +95,7 @@
 
   if (initialized)
     {
-      char *tmp = kpse_path_search (p.c_str (), nm.c_str (), true);
+      char *tmp = ::octave_kpse_path_search (p.c_str (), nm.c_str (), true);
       if (tmp)
 	{
 	  retval = tmp;
@@ -127,12 +113,12 @@
 
   if (initialized)
     {
-      kpse_string *tmp = kpse_all_path_search (p.c_str (), nm.c_str ());
+      char **tmp = ::octave_kpse_all_path_search (p.c_str (), nm.c_str ());
 
       if (tmp)
 	{
 	  int count = 0;
-	  kpse_string *ptr = tmp;
+	  char **ptr = tmp;
 	  while (*ptr++)
 	    count++;
 
@@ -149,7 +135,7 @@
 void
 dir_path::set_program_name (const std::string& nm)
 {
-  kpse_set_progname (nm.c_str ());
+  ::octave_kpse_set_progname (nm.c_str ());
 }
 
 void
@@ -165,17 +151,18 @@
       octave_kpathsea_initialized = true;
     }
 
-  kpse_clear_dir_cache ();
+  ::octave_kpse_clear_dir_cache ();
 
   char *t1 = 0;
 
   if (p_default.empty ())
-    t1 = kpse_path_expand (p_orig.c_str ());
+    t1 = ::octave_kpse_path_expand (p_orig.c_str ());
   else
     {
-      char *t2 = kpse_expand_default (p_orig.c_str (), p_default.c_str ());
+      char *t2
+	= ::octave_kpse_expand_default (p_orig.c_str (), p_default.c_str ());
 
-      t1 = kpse_path_expand (t2);
+      t1 = ::octave_kpse_path_expand (t2);
 
       if (t2)
 	free (t2);
@@ -190,21 +177,21 @@
     p = std::string ();
 
   int count = 0;
-  char *path_elt = kpse_path_element (p.c_str ());
+  char *path_elt = ::octave_kpse_path_element (p.c_str ());
   while (path_elt)
     {
-      path_elt = kpse_path_element (0);
+      path_elt = ::octave_kpse_path_element (0);
       count++;
     }
 
   pv.resize (count);
 
-  path_elt = kpse_path_element (p.c_str ());
+  path_elt = ::octave_kpse_path_element (p.c_str ());
 
   for (int i = 0; i < count; i++)
     {
       pv[i] = path_elt;
-      path_elt = kpse_path_element (0);
+      path_elt = ::octave_kpse_path_element (0);
     }
 
   initialized = true;
--- a/liboctave/prog-args.cc	Tue Feb 01 10:07:26 2000 +0000
+++ b/liboctave/prog-args.cc	Tue Feb 01 11:05:08 2000 +0000
@@ -24,7 +24,7 @@
 #include <config.h>
 #endif
 
-#include "getopt.h"
+#include "oct-getopt.h"
 
 #include "prog-args.h"
 
@@ -32,10 +32,10 @@
 prog_args::getopt (void)
 {
   if (long_opts)
-    return ::getopt_long (xargc, xargv, short_opts,
-			  X_CAST (const struct option *, long_opts), 0);
+    return ::octave_getopt_long (xargc, xargv, short_opts,
+				 X_CAST (const struct option *, long_opts), 0);
   else
-    return ::getopt (xargc, xargv, short_opts);
+    return ::octave_getopt (xargc, xargv, short_opts);
 }
 
 const char *