changeset 26446:db5c5e6c2371

maint: merge stable to default.
author Rik <rik@octave.org>
date Sat, 05 Jan 2019 06:33:32 -0800
parents 2d7615a07002 (current diff) 7fb7229d6c51 (diff)
children dd81b92ce489
files NEWS etc/NEWS.5 libgui/src/m-editor/file-editor-tab.cc libinterp/corefcn/variables.cc libinterp/octave-value/ov-range.h libinterp/parse-tree/oct-parse.yy libinterp/parse-tree/parse.h liboctave/numeric/oct-rand.cc
diffstat 28 files changed, 160 insertions(+), 117 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Thu Jan 03 17:25:36 2019 -0800
+++ b/NEWS	Sat Jan 05 06:33:32 2019 -0800
@@ -5,6 +5,11 @@
  ** Specifying legend position with a numeric argument is deprecated and
     will be removed in Octave 7.0.  Use a string argument instead.
 
+ ** The environment variable used by mkoctfile for linker flags is now
+    LDFLAGS rather than LFLAGS.  LFLAGS is deprecated, and a warning
+    is emitted if is used, but it will continue to work until eventual
+    removal in Octave 7.0.
+
 
 
 
--- a/etc/NEWS.5	Thu Jan 03 17:25:36 2019 -0800
+++ b/etc/NEWS.5	Sat Jan 05 06:33:32 2019 -0800
@@ -170,6 +170,11 @@
  ** It is now possible to use files and folders containing Unicode
     characters in Windows.
 
+ ** The environment variable used by mkoctfile for linker flags is now
+    LDFLAGS rather than LFLAGS.  LFLAGS is deprecated, and a warning
+    is emitted if is used, but it will continue to work until eventual
+    removal in Octave 7.0.
+
  ** The GUI requires Qt libraries.  The minimum Qt4 version supported is
     Qt4.8.  Qt5 of any version is preferred.
 
--- a/libgui/src/m-editor/file-editor-tab.cc	Thu Jan 03 17:25:36 2019 -0800
+++ b/libgui/src/m-editor/file-editor-tab.cc	Sat Jan 05 06:33:32 2019 -0800
@@ -2336,7 +2336,7 @@
         size_t length;
         char *res_str =
           octave_u32_conv_to_encoding_strict (_encoding.toStdString ().c_str (),
-                                              src, u32_str.length (), &length);
+                                              src, u32_str.size (), &length);
         if (! res_str)
           {
             if (errno == EILSEQ)
--- a/libgui/src/octave-dock-widget.cc	Thu Jan 03 17:25:36 2019 -0800
+++ b/libgui/src/octave-dock-widget.cc	Sat Jan 05 06:33:32 2019 -0800
@@ -1,7 +1,7 @@
 /*
 
 Copyright (C) 2012-2019 Richard Crozier
-Copyright (C) 2013-2019 Torsten <ttl@justmail.de>
+Copyright (C) 2013-2019 Torsten <mttl@mailbox.org>
 
 This file is part of Octave.
 
@@ -443,7 +443,7 @@
     else
       m_icon_color_active = "";
 
-    QRect available_size = QApplication::desktop ()->availableGeometry ();
+    QRect available_size = QApplication::desktop ()->availableGeometry (m_parent);
     int x1, y1, x2, y2;
     available_size.getCoords (&x1, &y1, &x2, &y2);
     QRect default_size = QRect (x1, y1, x2/3, y2/2);
@@ -452,7 +452,10 @@
                                            + "_floating_geometry",
                                            default_size).toRect ();
 
-    if (! available_size.contains (m_recent_float_geom, false))
+    QWidget dummy;
+    dummy.setGeometry (m_recent_float_geom);
+
+    if (QApplication::desktop ()->screenNumber (&dummy) == -1)
       m_recent_float_geom = default_size;
 
     m_recent_dock_geom = settings->value ("DockWidgets/" + objectName (),
--- a/libinterp/corefcn/bitfcns.cc	Thu Jan 03 17:25:36 2019 -0800
+++ b/libinterp/corefcn/bitfcns.cc	Sat Jan 05 06:33:32 2019 -0800
@@ -598,8 +598,6 @@
       int64_t mask = max_mantissa_value<double> ();
       if (nbits < bits_in_mantissa)
         mask = mask >> (bits_in_mantissa - nbits);
-      else if (nbits < 1)
-        mask = 0;
       int bits_in_type = sizeof (double)
                          * std::numeric_limits<unsigned char>::digits;
       NDArray m = m_arg.array_value ();
@@ -629,8 +627,6 @@
       int64_t mask = max_mantissa_value<float> ();
       if (nbits < bits_in_mantissa)
         mask = mask >> (bits_in_mantissa - nbits);
-      else if (nbits < 1)
-        mask = 0;
       int bits_in_type = sizeof (float)
                          * std::numeric_limits<unsigned char>::digits;
       FloatNDArray m = m_arg.float_array_value ();
--- a/libinterp/corefcn/dynamic-ld.cc	Thu Jan 03 17:25:36 2019 -0800
+++ b/libinterp/corefcn/dynamic-ld.cc	Sat Jan 05 06:33:32 2019 -0800
@@ -225,17 +225,14 @@
     if (! mex_file)
       error ("%s is not a valid shared library", file_name.c_str ());
 
-    void *function = nullptr;
-
     bool have_fmex = false;
 
-    function = mex_file.search (fcn_name, mex_mangler);
+    void *function = mex_file.search (fcn_name, mex_mangler);
 
     if (! function)
       {
-        // FIXME: can we determine this C mangling scheme
-        // automatically at run time or configure time?
-
+        // FIXME: Can we determine this C mangling scheme
+        //        automatically at run time or configure time?
         function = mex_file.search (fcn_name, mex_uscore_mangler);
 
         if (! function)
@@ -247,11 +244,11 @@
           }
       }
 
-    if (function)
-      retval = new octave_mex_function (function, have_fmex, mex_file, fcn_name);
-    else
+    if (! function)
       error ("failed to install .mex file function '%s'", fcn_name.c_str ());
 
+    retval = new octave_mex_function (function, have_fmex, mex_file, fcn_name);
+
     return retval;
   }
 
@@ -279,20 +276,8 @@
   dynamic_loader::remove_mex (const std::string& fcn_name,
                               dynamic_library& shl)
   {
-    bool retval = false;
-
-    // We don't need to do anything if this is called because we are in
-    // the process of reloading a .oct file that has changed.
-
-    if (! m_doing_load)
-      {
-        retval = shl.remove (fcn_name);
-
-        if (shl.number_of_functions_loaded () == 0)
-          m_loaded_shlibs.remove (shl);
-      }
-
-    return retval;
+    // Use the same procedure as for oct files.
+    return remove_oct (fcn_name, shl);
   }
 
   std::string
--- a/libinterp/corefcn/gl-render.cc	Thu Jan 03 17:25:36 2019 -0800
+++ b/libinterp/corefcn/gl-render.cc	Sat Jan 05 06:33:32 2019 -0800
@@ -1553,7 +1553,7 @@
           {
             y_axis_pos = math::max (math::min (0., y_max), y_min);
             m_glfcns.glBegin (GL_LINES);
-            set_color (props.get_ycolor_rgb ());
+            set_color (props.get_xcolor_rgb ());
             m_glfcns.glVertex3d (x_min, y_axis_pos, zpTick);
             m_glfcns.glVertex3d (x_max, y_axis_pos, zpTick);
             m_glfcns.glEnd ();
--- a/libinterp/corefcn/mex.cc	Thu Jan 03 17:25:36 2019 -0800
+++ b/libinterp/corefcn/mex.cc	Sat Jan 05 06:33:32 2019 -0800
@@ -2228,22 +2228,24 @@
 
     if (ptr)
       {
+        auto p_local = memlist.find (ptr);
+        auto p_global = global_memlist.find (ptr);
+
         v = std::realloc (ptr, n);
 
-        auto p = memlist.find (ptr);
-
-        if (v && p != memlist.end ())
+        if (v)
           {
-            memlist.erase (p);
-            memlist.insert (v);
-          }
-
-        p = global_memlist.find (ptr);
-
-        if (v && p != global_memlist.end ())
-          {
-            global_memlist.erase (p);
-            global_memlist.insert (v);
+            if (p_local != memlist.end ())
+              {
+                memlist.erase (p_local);
+                memlist.insert (v);
+              }
+
+            if (p_global != global_memlist.end ())
+              {
+                global_memlist.erase (p_global);
+                global_memlist.insert (v);
+              }
           }
       }
     else
--- a/libinterp/corefcn/syminfo.cc	Thu Jan 03 17:25:36 2019 -0800
+++ b/libinterp/corefcn/syminfo.cc	Sat Jan 05 06:33:32 2019 -0800
@@ -99,9 +99,6 @@
               default:
                 error ("whos_line_format: modifier '%c' unknown",
                        param.modifier);
-
-                os << std::setiosflags (std::ios::right)
-                   << std::setw (param.parameter_length);
               }
 
             switch (param.command)
@@ -280,25 +277,22 @@
 
             if (param.command == 's' && param.modifier == 'c')
               {
-                if (param.modifier == 'c')
-                  {
-                    int a = param.first_parameter_length - param.balance;
-                    a = (a < 0 ? 0 : a);
-                    int b = param.parameter_length - a - param.text.length ();
-                    b = (b < 0 ? 0 : b);
-                    os << std::setiosflags (std::ios::left) << std::setw (a)
-                       << "" << std::resetiosflags (std::ios::left) << param.text
-                       << std::setiosflags (std::ios::left)
-                       << std::setw (b) << ""
-                       << std::resetiosflags (std::ios::left);
-                    param_buf << std::setiosflags (std::ios::left)
-                              << std::setw (a)
-                              << "" << std::resetiosflags (std::ios::left)
-                              << param.line
-                              << std::setiosflags (std::ios::left)
-                              << std::setw (b) << ""
-                              << std::resetiosflags (std::ios::left);
-                  }
+                int a = param.first_parameter_length - param.balance;
+                a = (a < 0 ? 0 : a);
+                int b = param.parameter_length - a - param.text.length ();
+                b = (b < 0 ? 0 : b);
+                os << std::setiosflags (std::ios::left) << std::setw (a)
+                   << "" << std::resetiosflags (std::ios::left) << param.text
+                   << std::setiosflags (std::ios::left)
+                   << std::setw (b) << ""
+                   << std::resetiosflags (std::ios::left);
+                param_buf << std::setiosflags (std::ios::left)
+                          << std::setw (a)
+                          << "" << std::resetiosflags (std::ios::left)
+                          << param.line
+                          << std::setiosflags (std::ios::left)
+                          << std::setw (b) << ""
+                          << std::resetiosflags (std::ios::left);
               }
             else
               {
@@ -431,7 +425,6 @@
 
         if (format[idx] == '%')
           {
-            bool error_encountered = false;
             param.modifier = 'r';
             param.parameter_length = 0;
 
@@ -546,9 +539,7 @@
                                          ? param_length(pos_s)
                                          : param.parameter_length));
 
-            // Parameter will not be pushed into parameter list if ...
-            if (! error_encountered)
-              params.push_back (param);
+            params.push_back (param);
           }
         else
           {
--- a/libinterp/corefcn/text-renderer.h	Thu Jan 03 17:25:36 2019 -0800
+++ b/libinterp/corefcn/text-renderer.h	Sat Jan 05 06:33:32 2019 -0800
@@ -135,7 +135,7 @@
 
       string (const string& s)
         : str (s.str), family (s.family), fnt (s.fnt), x (s.x), y (s.y),
-          xdata (s.xdata), code (s.code), color (s.color)
+          z (s.z), xdata (s.xdata), code (s.code), color (s.color)
       { }
 
       ~string (void) = default;
@@ -149,6 +149,7 @@
             fnt = s.fnt;
             x = s.x;
             y = s.y;
+            z = s.z;
             xdata = s.xdata;
             code = s.code;
             color = s.color;
--- a/libinterp/corefcn/variables.cc	Thu Jan 03 17:25:36 2019 -0800
+++ b/libinterp/corefcn/variables.cc	Sat Jan 05 06:33:32 2019 -0800
@@ -122,9 +122,7 @@
                   const std::string& fname, const std::string& header,
                   const std::string& trailer)
 {
-  octave_function *retval = nullptr;
-
-  retval = is_valid_function (arg, warn_for, 0);
+  octave_function *retval = is_valid_function (arg, warn_for, 0);
 
   if (! retval)
     {
@@ -1272,7 +1270,7 @@
 
   if (argc == 1)
     {
-      do_clear_variables (symtab, argv, argc, true);
+      do_clear_variables (symtab, argv, argc, argc);
 
       octave_link::clear_workspace ();
     }
--- a/libinterp/octave-value/ov-builtin.h	Thu Jan 03 17:25:36 2019 -0800
+++ b/libinterp/octave-value/ov-builtin.h	Sat Jan 05 06:33:32 2019 -0800
@@ -50,8 +50,8 @@
 {
 public:
 
-  octave_builtin (void) : octave_function (), f (nullptr), file (),
-                          jtype (nullptr)
+  octave_builtin (void) : octave_function (), f (nullptr), m (nullptr),
+                          file (), jtype (nullptr)
   { }
 
   typedef octave_value_list (*meth) (octave::interpreter&,
--- a/libinterp/octave-value/ov-range.h	Thu Jan 03 17:25:36 2019 -0800
+++ b/libinterp/octave-value/ov-range.h	Sat Jan 05 06:33:32 2019 -0800
@@ -155,7 +155,7 @@
   { return Array<octave_idx_type> (dim_vector (1, 0)); }
 
   sortmode is_sorted_rows (sortmode mode = UNSORTED) const
-  { return mode ? mode : ASCENDING; }
+  { return (mode == UNSORTED) ? ASCENDING : mode; }
 
   builtin_type_t builtin_type (void) const { return btyp_double; }
 
--- a/libinterp/parse-tree/oct-parse.yy	Thu Jan 03 17:25:36 2019 -0800
+++ b/libinterp/parse-tree/oct-parse.yy	Sat Jan 05 06:33:32 2019 -0800
@@ -5399,6 +5399,23 @@
   }
 }
 
+octave_value_list
+eval_string (const std::string& str, bool silent, int& parse_status,
+             int nargout)
+{
+  octave::interpreter& interp = octave::__get_interpreter__ ("eval_string");
+
+  return interp.eval_string (str, silent, parse_status, nargout);
+}
+
+octave_value
+eval_string (const std::string& str, bool silent, int& parse_status)
+{
+  octave::interpreter& interp = octave::__get_interpreter__ ("eval_string");
+
+  return interp.eval_string (str, silent, parse_status);
+}
+
 DEFMETHOD (eval, interp, args, nargout,
            doc: /* -*- texinfo -*-
 @deftypefn  {} {} eval (@var{try})
--- a/libinterp/parse-tree/parse.h	Thu Jan 03 17:25:36 2019 -0800
+++ b/libinterp/parse-tree/parse.h	Sat Jan 05 06:33:32 2019 -0800
@@ -592,4 +592,13 @@
   cleanup_statement_list (tree_statement_list **lst);
 }
 
+OCTAVE_DEPRECATED (4.4, "use 'octave::interpreter::eval_string' instead")
+extern OCTINTERP_API octave_value_list
+eval_string (const std::string& str, bool silent, int& parse_status,
+             int nargout);
+
+OCTAVE_DEPRECATED (4.4, "use 'octave::interpreter::eval_string' instead")
+extern OCTINTERP_API octave_value
+eval_string (const std::string& str, bool silent, int& parse_status);
+
 #endif
--- a/libinterp/parse-tree/token.cc	Thu Jan 03 17:25:36 2019 -0800
+++ b/libinterp/parse-tree/token.cc	Sat Jan 05 06:33:32 2019 -0800
@@ -84,11 +84,9 @@
   {
     if (m_type_tag == string_token)
       delete m_tok_info.m_str;
-
-    if (m_type_tag == sym_rec_token)
+    else if (m_type_tag == sym_rec_token)
       delete m_tok_info.m_sr;
-
-    if (m_type_tag == scls_name_token)
+    else if (m_type_tag == scls_name_token)
       delete m_tok_info.m_superclass_info;
   }
 
--- a/liboctave/array/Array-d.cc	Thu Jan 03 17:25:36 2019 -0800
+++ b/liboctave/array/Array-d.cc	Sat Jan 05 06:33:32 2019 -0800
@@ -102,9 +102,9 @@
   const double *el = data ();
 
   if (n <= 1)
-    return mode ? mode : ASCENDING;
+    return (mode == UNSORTED) ? ASCENDING : mode;
 
-  if (! mode)
+  if (mode == UNSORTED)
     {
       // Auto-detect mode.
       if (el[n-1] < el[0] || octave::math::isnan (el[0]))
--- a/liboctave/array/Array-f.cc	Thu Jan 03 17:25:36 2019 -0800
+++ b/liboctave/array/Array-f.cc	Sat Jan 05 06:33:32 2019 -0800
@@ -102,9 +102,9 @@
   const float *el = data ();
 
   if (n <= 1)
-    return mode ? mode : ASCENDING;
+    return (mode == UNSORTED) ? ASCENDING : mode;
 
-  if (! mode)
+  if (mode == UNSORTED)
     {
       // Auto-detect mode.
       if (el[n-1] < el[0] || octave::math::isnan (el[0]))
--- a/liboctave/array/MatrixType.cc	Thu Jan 03 17:25:36 2019 -0800
+++ b/liboctave/array/MatrixType.cc	Sat Jan 05 06:33:32 2019 -0800
@@ -188,7 +188,7 @@
         typ = MatrixType::Lower;
       else if (hermitian)
         typ = MatrixType::Hermitian;
-      else if (ncols == nrows)
+      else
         typ = MatrixType::Full;
     }
   else
--- a/liboctave/array/Range.cc	Thu Jan 03 17:25:36 2019 -0800
+++ b/liboctave/array/Range.cc	Sat Jan 05 06:33:32 2019 -0800
@@ -339,7 +339,7 @@
   else if (rng_numel > 1 && rng_inc < 0)
     mode = (mode == ASCENDING) ? UNSORTED : DESCENDING;
   else
-    mode = (mode ? mode : ASCENDING);
+    mode = (mode == UNSORTED) ? ASCENDING : mode;
 
   return mode;
 }
--- a/liboctave/numeric/lo-specfun.cc	Thu Jan 03 17:25:36 2019 -0800
+++ b/liboctave/numeric/lo-specfun.cc	Sat Jan 05 06:33:32 2019 -0800
@@ -1594,7 +1594,7 @@
               return;
             }
           Nn = n;
-          for (ii = 1; n > 0; ii = ii*2, --n) ; // ii = pow(2,Nn)
+          for (ii = 1; n > 0; ii *= 2, --n) {}  // ii = pow(2,Nn)
           phi = ii*a[Nn]*u;
           for (n = Nn; n > 0; --n)
             {
--- a/liboctave/numeric/oct-rand.cc	Thu Jan 03 17:25:36 2019 -0800
+++ b/liboctave/numeric/oct-rand.cc	Sat Jan 05 06:33:32 2019 -0800
@@ -93,7 +93,7 @@
   static int32_t
   force_to_fit_range (int32_t i, int32_t lo, int32_t hi)
   {
-    assert (hi > lo && lo >= 0 && hi > lo);
+    assert (hi > lo && lo >= 0);
 
     i = (i > 0 ? i : -i);
 
--- a/liboctave/numeric/randgamma.cc	Thu Jan 03 17:25:36 2019 -0800
+++ b/liboctave/numeric/randgamma.cc	Sat Jan 05 06:33:32 2019 -0800
@@ -110,7 +110,7 @@
       restart:
         x = rand_normal<T> ();
         v = (1+c*x);
-        v *= v*v;
+        v *= (v*v);
         if (v <= 0)
           goto restart; /* rare, so don't bother moving up */
         u = rand_uniform<T> ();
--- a/liboctave/util/lo-ieee.cc	Thu Jan 03 17:25:36 2019 -0800
+++ b/liboctave/util/lo-ieee.cc	Sat Jan 05 06:33:32 2019 -0800
@@ -130,7 +130,7 @@
 void
 octave_ieee_init (void)
 {
-  bool initialized = false;
+  static bool initialized = false;
 
   if (! initialized)
     {
@@ -180,7 +180,7 @@
           // floating point should be capable of removing this check and
           // the configure test.
           //
-          // If the the error handler returns, then we'll abort.
+          // If the error handler returns, then we'll abort.
 
           (*current_liboctave_error_handler)
             ("lo_ieee_init: floating point format is not IEEE!  Maybe DLAMCH is miscompiled, or you are using some strange system without IEEE floating point math?");
--- a/liboctave/util/lo-utils.cc	Thu Jan 03 17:25:36 2019 -0800
+++ b/liboctave/util/lo-utils.cc	Sat Jan 05 06:33:32 2019 -0800
@@ -102,6 +102,9 @@
   int max_size = grow_size;
 
   char *buf = static_cast<char *> (std::malloc (max_size));
+  if (! buf)
+    (*current_liboctave_error_handler) ("octave_fgets: unable to malloc %d bytes", max_size);
+
   char *bufptr = buf;
   int len = 0;
 
@@ -116,7 +119,13 @@
               int tmp = bufptr - buf + grow_size - 1;
               grow_size *= 2;
               max_size += grow_size;
-              buf = static_cast<char *> (std::realloc (buf, max_size));
+              auto tmpbuf = static_cast<char *> (std::realloc (buf, max_size));
+              if (! tmpbuf)
+                {
+                  free (buf);
+                  (*current_liboctave_error_handler) ("octave_fgets: unable to realloc %d bytes", max_size);
+                }
+              buf = tmpbuf;
               bufptr = buf + tmp;
 
               if (*(bufptr-1) == '\n')
--- a/liboctave/wrappers/getopt-wrapper.c	Thu Jan 03 17:25:36 2019 -0800
+++ b/liboctave/wrappers/getopt-wrapper.c	Sat Jan 05 06:33:32 2019 -0800
@@ -50,6 +50,11 @@
 
   retval = (struct option *) malloc ((n+1) * sizeof (struct option));
 
+  // If we don't have enough memory even to start Octave
+  // then we might as well quit now.
+  if (! retval)
+    abort ();
+
   p = opts;
   q = retval;
   while (p->name)
--- a/src/mkoctfile.in.cc	Thu Jan 03 17:25:36 2019 -0800
+++ b/src/mkoctfile.in.cc	Sat Jan 05 06:33:32 2019 -0800
@@ -212,18 +212,17 @@
   if (vars["INCLUDEDIR"] != "/usr/include")
     DEFAULT_INCFLAGS += " -I" + quote_path (vars["INCLUDEDIR"]);
 
-  std::string DEFAULT_LFLAGS;
+  std::string DEFAULT_LDFLAGS;
 
 #if (defined (OCTAVE_USE_WINDOWS_API) || defined (CROSS)) || (defined __APPLE__ && defined __MACH__)
 
-  // We'll be linking the files we compile with -loctinterp and
-  // -loctave, so we need to know where to find them.
-
-  DEFAULT_LFLAGS += "-L" + quote_path (vars["OCTLIBDIR"]);
+  // We'll be linking the files we compile with -loctinterp and -loctave,
+  // so we need to know where to find them.
+  DEFAULT_LDFLAGS += "-L" + quote_path (vars["OCTLIBDIR"]);
 #endif
 
   if (vars["LIBDIR"] != "/usr/lib")
-    DEFAULT_LFLAGS += " -L" + quote_path (vars["LIBDIR"]);
+    DEFAULT_LDFLAGS += " -L" + quote_path (vars["LIBDIR"]);
 
   vars["CPPFLAGS"] = get_variable ("CPPFLAGS", %OCTAVE_CONF_CPPFLAGS%);
 
@@ -307,14 +306,15 @@
   vars["OCT_LINK_OPTS"] = get_variable ("OCT_LINK_OPTS",
                                         %OCTAVE_CONF_OCT_LINK_OPTS%);
 
-  vars["LD_CXX"] = get_variable ("LD_CXX", %OCTAVE_CONF_MKOCTFILE_LD_CXX%);
+  vars["LDFLAGS"] = get_variable ("LDFLAGS", DEFAULT_LDFLAGS);
 
-  vars["LDFLAGS"] = get_variable ("LDFLAGS", %OCTAVE_CONF_LDFLAGS%);
+  vars["LD_CXX"] = get_variable ("LD_CXX", %OCTAVE_CONF_MKOCTFILE_LD_CXX%);
 
   vars["LD_STATIC_FLAG"] = get_variable ("LD_STATIC_FLAG",
                                          %OCTAVE_CONF_LD_STATIC_FLAG%);
 
-  vars["LFLAGS"] = get_variable ("LFLAGS", DEFAULT_LFLAGS);
+  // FIXME: Remove LFLAGS in Octave 7.0
+  vars["LFLAGS"] = get_variable ("LFLAGS", DEFAULT_LDFLAGS);
 
   vars["F77_INTEGER8_FLAG"] = get_variable ("F77_INTEGER8_FLAG",
                                             %OCTAVE_CONF_F77_INTEGER_8_FLAG%);
@@ -387,11 +387,11 @@
 "                          override with environment variables.  These are\n"
 "                          used in commands that mkoctfile executes.\n"
 "\n"
-"                            ALL_CFLAGS                  LAPACK_LIBS\n"
-"                            ALL_CXXFLAGS                LDFLAGS\n"
-"                            ALL_FFLAGS                  LD_CXX\n"
-"                            ALL_LDFLAGS                 LD_STATIC_FLAG\n"
-"                            BLAS_LIBS                   LFLAGS\n"
+"                            ALL_CFLAGS                  INCLUDEDIR\n"
+"                            ALL_CXXFLAGS                LAPACK_LIBS\n"
+"                            ALL_FFLAGS                  LDFLAGS\n"
+"                            ALL_LDFLAGS                 LD_CXX\n"
+"                            BLAS_LIBS                   LD_STATIC_FLAG\n"
 "                            CC                          LIBDIR\n"
 "                            CFLAGS                      LIBOCTAVE\n"
 "                            CPICFLAG                    LIBOCTINTERP\n"
@@ -406,7 +406,6 @@
 "                            FFLAGS                      SPECIAL_MATH_LIB\n"
 "                            FPICFLAG                    XTRA_CFLAGS\n"
 "                            INCFLAGS                    XTRA_CXXFLAGS\n"
-"                            INCLUDEDIR\n"
 "\n"
 "                          Octave configuration variables as above, but\n"
 "                          currently unused by mkoctfile.\n"
@@ -721,7 +720,7 @@
         }
       else if (arg == "-largeArrayDims" || arg == "-compatibleArrayDims")
         {
-          std::cout << "warning: -largeArrayDims and -compatibleArrayDims are accepted for compatibility, but ignored" << std::endl;
+          std::cerr << "warning: -largeArrayDims and -compatibleArrayDims are accepted for compatibility, but ignored" << std::endl;
         }
       else if (starts_with (arg, "-Wl,") || starts_with (arg, "-l")
                || starts_with (arg, "-L") || starts_with (arg, "-R"))
@@ -759,6 +758,10 @@
           if (i < argc-1)
             {
               arg = argv[++i];
+              // FIXME: Remove LFLAGS checking in Octave 7.0
+              if (arg == "LFLAGS")
+                std::cerr << "warning: LFLAGS is deprecated and will be removed in a future version of Octave, use LDFLAGS instead" << std::endl;
+
               std::cout << vars[arg] << std::endl;
               return 0;
             }
@@ -1060,7 +1063,7 @@
         }
     }
 
-  // If we are only compliling, we are done.
+  // If we are only compiling, we are done.
 
   if (compile_only)
     return 0;
@@ -1071,21 +1074,29 @@
       return 1;
     }
 
+  // FIXME: Remove LFLAGS in Octave 7.0
+  if (vars["LFLAGS"] != vars["LDFLAGS"])
+    {
+      std::cerr << "warning: LFLAGS is deprecated and will be removed in a future version of Octave, use LDFLAGS instead" << std::endl;
+      vars["LDFLAGS"] = vars["LFLAGS"];
+    }
+
   std::string octave_libs;
-#if defined (OCTAVE_USE_WINDOWS_API) || defined(CROSS)
-  octave_libs = "-loctinterp -loctave";
-#endif
 
   if (link_stand_alone)
     {
       if (! vars["LD_CXX"].empty ())
         {
+          octave_libs = vars["OCTAVE_LIBS"];
+
           std::string cmd
             = (vars["LD_CXX"] + ' ' + vars["CPPFLAGS"] + ' '
                + vars["ALL_CXXFLAGS"] + ' ' + vars["RDYNAMIC_FLAG"] + ' '
                + vars["ALL_LDFLAGS"] + ' ' + pass_on_options + ' '
                + output_option + ' ' + objfiles + ' ' + libfiles + ' '
-               + ldflags + ' ' + vars["LFLAGS"] + ' ' + octave_libs + ' '
+               + ldflags + ' ' + vars["LDFLAGS"]
+               + " -L" + quote_path (vars["OCTLIBDIR"])
+               + ' ' + octave_libs + ' '
                + vars["OCTAVE_LINK_OPTS"] + ' ' + vars["OCTAVE_LINK_DEPS"]);
 
           int status = run_command (cmd, printonly);
@@ -1105,11 +1116,15 @@
     }
   else
     {
+#if defined (OCTAVE_USE_WINDOWS_API) || defined(CROSS)
+      octave_libs = vars["OCTAVE_LIBS"];
+#endif
+
       std::string cmd
         = (vars["DL_LD"] + ' ' + vars["ALL_CXXFLAGS"] + ' '
            + vars["DL_LDFLAGS"] + ' ' + pass_on_options
            + " -o " + octfile + ' ' + objfiles + ' ' + libfiles + ' '
-           + ldflags + ' ' + vars["LFLAGS"] + ' ' + octave_libs + ' '
+           + ldflags + ' ' + vars["LDFLAGS"] + ' ' + octave_libs + ' '
            + vars["OCT_LINK_OPTS"] + ' ' + vars["OCT_LINK_DEPS"]);
 
       int status = run_command (cmd, printonly);
--- a/test/module.mk	Thu Jan 03 17:25:36 2019 -0800
+++ b/test/module.mk	Sat Jan 05 06:33:32 2019 -0800
@@ -58,6 +58,7 @@
 include %reldir%/bug-38691/module.mk
 include %reldir%/bug-41723/module.mk
 include %reldir%/bug-44940/module.mk
+include %reldir%/bug-45969/module.mk
 include %reldir%/bug-45972/module.mk
 include %reldir%/bug-46660/module.mk
 include %reldir%/bug-49379/module.mk
@@ -71,6 +72,9 @@
 include %reldir%/bug-52075/module.mk
 include %reldir%/bug-52722/module.mk
 include %reldir%/bug-53027/module.mk
+include %reldir%/bug-55308/module.mk
+include %reldir%/bug-55321/module.mk
+include %reldir%/bug-55322/module.mk
 include %reldir%/class-concat/module.mk
 include %reldir%/classdef/module.mk
 include %reldir%/classdef-multiple-inheritance/module.mk