changeset 21182:82a44483dbff

move octave_config_features function out of header file * oct-conf-features.h: New file. * module.mk: Generate octave-conf-features.cc instead of oct-conf-features.h. * toplev.cc (Foctave_config_info): Call octave::config::features. * config-features.sh: Adapt to use of namespace. Make internal data static and initialized only once.
author John W. Eaton <jwe@octave.org>
date Wed, 03 Feb 2016 15:10:15 -0500
parents a65b906e25bc
children e7fda94aec6b
files libinterp/config-features.sh libinterp/corefcn/toplev.cc libinterp/module.mk libinterp/oct-conf-features.h
diffstat 4 files changed, 73 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/config-features.sh	Wed Feb 03 14:37:13 2016 -0500
+++ b/libinterp/config-features.sh	Wed Feb 03 15:10:15 2016 -0500
@@ -1,5 +1,9 @@
 #! /bin/sh
 
+## Attempt to get traditional sort behavior based on byte values.
+LC_ALL="C"
+export LC_ALL
+
 set -e
 AWK=${AWK:-awk}
 
@@ -8,29 +12,46 @@
 cat << EOF
 // DO NOT EDIT!  Generated automatically from $conffile by Make."
 
-#include "oct-map.h"
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "oct-conf-features.h"
 #include "ov.h"
 
-octave_scalar_map
-octave_config_features (void)
+namespace octave
 {
-  octave_scalar_map m;
+  namespace config
+  {
+    octave_scalar_map
+    features (void)
+    {
+      static bool initialized = false;
 
+      static octave_scalar_map m;
+
+      if (! initialized)
+        {
 EOF
 
 $AWK \
   '/#define (HAVE|ENABLE)_/ {
-     sub (/(HAVE|ENABLE)_/, "", $2);
-     printf ("  m.assign (\"%s\", octave_value (true));\n", $2);
+     sub (/HAVE_/, "", $2);
+     printf ("          m.assign (\"%s\", octave_value (true));\n", $2);
    }
    /\/\* #undef (HAVE|ENABLE)_/ {
-     sub (/(HAVE|ENABLE)_/, "", $3);
-     printf ("  m.assign (\"%s\", octave_value (false));\n", $3);
+     sub (/HAVE_/, "", $3);
+     printf ("          m.assign (\"%s\", octave_value (false));\n", $3);
    } {
-   }' $conffile
+   }' $conffile | sort
 
 cat << EOF
 
-  return m;
-}
+          initialized = true;
+        }
+
+      return m;
+    }
+  };
+};
 EOF
--- a/libinterp/corefcn/toplev.cc	Wed Feb 03 14:37:13 2016 -0500
+++ b/libinterp/corefcn/toplev.cc	Wed Feb 03 15:10:15 2016 -0500
@@ -1456,7 +1456,7 @@
       m.assign ("words_little_endian",
                 octave_value (oct_mach_info::words_little_endian ()));
 
-      m.assign ("features", octave_value (octave_config_features ()));
+      m.assign ("features", octave_value (octave::config::features ()));
 
       int i = 0;
 
--- a/libinterp/module.mk	Wed Feb 03 14:37:13 2016 -0500
+++ b/libinterp/module.mk	Wed Feb 03 15:10:15 2016 -0500
@@ -36,7 +36,6 @@
   libinterp/corefcn/graphics-props.cc \
   libinterp/corefcn/graphics.h \
   libinterp/corefcn/mxarray.h \
-  libinterp/oct-conf-features.h \
   libinterp/parse-tree/oct-gperf.h \
   libinterp/parse-tree/oct-parse.h \
   libinterp/version.h
@@ -81,7 +80,7 @@
   libinterp/builtin-defun-decls.h \
   libinterp/operators/ops.cc \
   libinterp/oct-conf.cc \
-  libinterp/oct-conf-features.h \
+  libinterp/oct-conf-features.cc \
   libinterp/version.h \
   $(OPT_HANDLERS) \
   $(ALL_DEF_FILES) \
@@ -107,6 +106,7 @@
   libinterp/builtins.h \
   libinterp/builtin-defun-decls.h \
   libinterp/oct-conf.h \
+  libinterp/oct-conf-features.h \
   libinterp/octave.h \
   libinterp/options-usage.h \
   $(OCTAVE_VALUE_INC) \
@@ -161,7 +161,7 @@
   libinterp/builtin-defun-decls.h \
   libinterp/builtins.cc \
   libinterp/oct-conf.cc \
-  libinterp/oct-conf-features.h \
+  libinterp/oct-conf-features.cc \
   libinterp/version.h
 
 libinterp_liboctinterp_la_LIBADD = \
@@ -252,7 +252,7 @@
 libinterp/oct-conf.cc: libinterp/oct-conf.in.cc Makefile
 	$(AM_V_GEN)$(do_subst_config_vals)
 
-libinterp/oct-conf-features.h: $(top_builddir)/config.h libinterp/config-features.sh
+libinterp/oct-conf-features.cc: $(top_builddir)/config.h libinterp/config-features.sh
 	$(AM_V_GEN)rm -f $@-t && \
 	$(srcdir)/libinterp/config-features.sh $< > $@-t && \
 	$(simple_move_if_change_rule)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libinterp/oct-conf-features.h	Wed Feb 03 15:10:15 2016 -0500
@@ -0,0 +1,36 @@
+/*
+
+Copyright (C) 2016 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 3 of the License, 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, see
+<http://www.gnu.org/licenses/>.
+
+*/
+
+#if ! defined (octave_conf_features_h)
+#define octave_conf_features_h 1
+
+#include "oct-map.h"
+
+namespace octave
+{
+  namespace config
+  {
+    extern OCTAVE_API octave_scalar_map features (void);
+  };
+};
+
+#endif