changeset 26202:368dc1142072

makeValidName.m, makeUniqueStrings.m: Clean up functions to use Octave conventions. * NEWS: Alphabetize list of newly added functions. * var.txi: Add matlab.lang.makeValidName, matlab.lang.makeUniqueStrings to manual. * makeUniqueStrings.m: Use standard copyright block for Octave. Rename input "str" from "x". Rename output "uniqstr" from "y". Rename "converttochar" to "convert2char". Set default for maxlength to Inf (disabling maxlength restriction). Drop periods from end of all error messages. Use variable names from documentation in error messages. Use isindex() to simplify input validation. Delete istruncated variable and re-use ismodified variable. Add FIXME note about calls to ismember being slow. Rename temporary variable 'z' to "tmp". Check that error messages are correct in input validation BIST tests. * makeValidName.m: Use standard copyright block for Octave. Rename input "str" from "x". Rename output "varname" from "y". Rename "converttochar" to "convert2char". Use @table to describe "ReplacementStyle" option. Drop periods from end of all error messages. Use variable names from documentation in error messages. Use strcmp() rather than ismember() for speed. Replace subfunction isvalidname() with built-in isvarname(). Check that error messages are correct in input validation BIST tests. * scripts/legacy/genvarname.m: Move m-file to legacy directory. Add note at top of docstring that this function should not be used in modern code. Add seealso references to makeUniqueStrings and makeValidName. * scripts/legacy/module.mk: Add genvarname.m to legacy directory. * scripts/miscellaneous/module.mk: Remove genvarname.m from miscellaneous dir.
author Rik <rik@octave.org>
date Tue, 11 Dec 2018 13:14:09 -0800
parents 750a6f9957ea
children 3c445cd7f1a4
files NEWS doc/interpreter/var.txi scripts/+matlab/+lang/makeUniqueStrings.m scripts/+matlab/+lang/makeValidName.m scripts/legacy/genvarname.m scripts/legacy/module.mk scripts/miscellaneous/genvarname.m scripts/miscellaneous/module.mk
diffstat 8 files changed, 469 insertions(+), 446 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Tue Dec 11 15:19:00 2018 +0100
+++ b/NEWS	Tue Dec 11 13:14:09 2018 -0800
@@ -161,13 +161,13 @@
       clearvars
       isfile
       isfolder
+      matlab.lang.makeUniqueStrings
+      matlab.lang.makeValidName
       movegui
       openfig
       ordeig
       savefig
       uitable
-      matlab.lang.makeValidName
-      matlab.lang.makeUniqueStrings
 
  ** Legacy functions.
 
--- a/doc/interpreter/var.txi	Tue Dec 11 15:19:00 2018 +0100
+++ b/doc/interpreter/var.txi	Tue Dec 11 13:14:09 2018 -0800
@@ -67,7 +67,9 @@
 
 @DOCSTRING(isvarname)
 
-@DOCSTRING(genvarname)
+@DOCSTRING(matlab.lang.makeValidName)
+
+@DOCSTRING(matlab.lang.makeUniqueStrings)
 
 @DOCSTRING(namelengthmax)
 
--- a/scripts/+matlab/+lang/makeUniqueStrings.m	Tue Dec 11 15:19:00 2018 +0100
+++ b/scripts/+matlab/+lang/makeUniqueStrings.m	Tue Dec 11 13:14:09 2018 -0800
@@ -2,9 +2,9 @@
 ##
 ## This file is part of Octave.
 ##
-## Octave is free software; you can redistribute it and/or modify it
+## 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
+## 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
@@ -14,207 +14,218 @@
 ##
 ## 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/>.
+## <https://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn  {} {@var{y} =} matlab.lang.makeUniqueStrings (@var{x})
-## @deftypefnx {} {@var{y} =} matlab.lang.makeUniqueStrings (@var{x}, @var{ex})
-## @deftypefnx {} {@var{y} =} matlab.lang.makeUniqueStrings (@var{x}, @var{ex}, @var{maxlength})
-## @deftypefnx {} {[@var{y}, @var{ismodified}] =} matlab.lang.makeUniqueStrings (@dots{})
+## @deftypefn  {} {@var{uniqstr} =} matlab.lang.makeUniqueStrings (@var{str})
+## @deftypefnx {} {@var{uniqstr} =} matlab.lang.makeUniqueStrings (@var{str}, @var{ex})
+## @deftypefnx {} {@var{uniqstr} =} matlab.lang.makeUniqueStrings (@var{str}, @var{ex}, @var{maxlength})
+## @deftypefnx {} {[@var{uniqstr}, @var{ismodified}] =} matlab.lang.makeUniqueStrings (@dots{})
 ##
 ## Construct a list of unique strings from a list of strings.
 ##
-## @var{x} has to be a string or a cell array of strings.  @var{y} will be of
-## the same type, and all of its elements will be unique.
+## The input @var{str} must be a string or a cell array of strings.
+## The output @var{uniqstr} will be of the same type.
 ##
-## If @var{ex} is a string or a cell array of strings, @var{y} will contain
-## elements that are unique between themselves and with respect to @var{ex}.
+## The algorithm makes two strings unique by appending an underscore
+## (@qcode{"_"} and a numeric count to the second string.
+##
+## If @var{ex} is a string or a cell array of strings, @var{uniqstr} will
+## contain elements that are unique between themselves and with respect to
+## @var{ex}.
 ##
-## If @var{ex} is an index array or a logical array for @var{x} then it selects
-## the subset of @var{x} that is made unique.  Unselected elements are not
-## modified.
+## If @var{ex} is an index array or a logical array for @var{str} then it
+## selects the subset of @var{str} that are made unique.  Unselected elements
+## are not modified.
 ##
-## @var{maxlength} is the maximal acceptable length of the strings in @var{y}.
-##
-## @var{ismodified} is a logical array indicating whether each element in
-## @var{x} was modified to make it unique.
+## The optional input @var{maxlength} specifies the maximum length of any
+## string in @var{uniqstr}.  If an input string cannot be made unique without
+## exceeding @var{maxlength} an error is emitted.
+## 
+## The optional output @var{ismodified} is a logical array indicating whether
+## each element in @var{str} was modified to make it unique.
 ##
 ## @seealso{unique, matlab.lang.makeValidName}
 ## @end deftypefn
 
-function [y, ismodified] = makeUniqueStrings (x, ex = {}, maxlength = namelengthmax ())
+function [uniqstr, ismodified] = makeUniqueStrings (str, ex = {}, maxlength = Inf)
 
   if (nargin == 0 || nargout > 3)
     print_usage ();
   endif
 
   ##  Validate first input
-  if ((! ischar (x)) && (! iscellstr (x)))
-    error ("makeUniqueStrings: input must be a string.");
+  if (! ischar (str) && ! iscellstr (str))
+    error ("makeUniqueStrings: STR must be a string or cellstr");
   endif
-  converttochar = ischar (x);
-  y = cellstr (x);
-  sz = size (y);
-  y = y(:)';
+
+  convert2char = ischar (str);
+  uniqstr = cellstr (str);
+  sz = size (uniqstr);
+  uniqstr = uniqstr(:)';
 
   ## Initialize array of strings to exclude
   excludedstrings = {};
 
-  ## Validate first optional input
+  ## Validate optional exclusion list input
   if (nargin > 1)
     if (ischar (ex) || iscellstr (ex))
       excludedstrings = cellstr (ex);
     elseif (islogical (ex))
-      if (numel (ex) != numel (y))
-        error ("makeUniqueStrings: input and logical array must have same length.");
+      if (numel (ex) != numel (uniqstr))
+        error ("makeUniqueStrings: STR and EX logical array must have the same length");
       endif
-      excludedstrings = y(! ex);
-      y = y(ex);
+      excludedstrings = uniqstr(! ex);
+      uniqstr = uniqstr(ex);
     elseif (isnumeric (ex))
-      if (any (ex <= 0 | ex > numel (y) | round (ex) != ex)) # isindex
-        error ("makeUniqueStrings: invalid array of indices.");
+      if (! isindex (ex, numel (uniqstr)))
+        error ("makeUniqueStrings: invalid array of indices EX");
       endif
-      excludedstrings = y(setdiff (1:numel (y), ex));
-      y = y(ex);
+      excludedstrings = uniqstr(setdiff (1:numel (uniqstr), ex));
+      uniqstr = uniqstr(ex);
     else
-      error ("makeUniqueStrings: invalid input.");
+      error ("makeUniqueStrings: invalid input");
     endif
     excludedstrings = excludedstrings(:)';
   endif
 
-  ## Validate second optional input
+  ## Validate optional maxlength input
   if (nargin > 2)
-    if (! isnumeric (maxlength)
-      || ! isscalar (maxlength)
-      || ! isreal (maxlength)
-      || maxlength < 0
-      || round (maxlength) != maxlength)
-      error ("makeUniqueStrings: 'maxlength' must be a positive integer.");
+    if (! isindex (maxlength))
+      error ("makeUniqueStrings: MAXLENGTH must be a positive integer");
     endif
   endif
-
-  ## Initialize second output
-  ismodified = false (size (y));
+  chk_length = ! isinf (maxlength);
 
-  ## Truncate output strings
-  istruncated = false (size (y));
-  if (maxlength < namelengthmax ())
-    istruncated = cellfun (@(x) length (x) > maxlength, y);
-    for i=find (istruncated)
-      y{i} = y{i}(1:maxlength);
-    endfor
+  ismodified = false (size (uniqstr));
+  if (chk_length)
+    ## Truncate output strings
+    ismodified = (cellfun (@length, uniqstr) > maxlength);
+    uniqstr(ismodified) = cellindexmat (uniqstr(ismodified), 1:maxlength);
   endif
 
   ## Make unique strings
-  [~, I, J] = unique (y, "first");
-  for i=1: numel (I)
-    R = ! ismember (y{I(i)}, excludedstrings);
+  ## FIXME: lots of call to ismember are slow.
+  [~, I, J] = unique (uniqstr, "first");
+  for i = 1:numel (I)
+    R = ! ismember (uniqstr{I(i)}, excludedstrings);
     K = find (J == J(I(i)));
     n = 1 + ceil (log10 (numel (K)));
-    if (length (y{K(1)}) + n > maxlength)
-      if (n >= maxlength)
-        error ("makeUniqueStrings: cannot create unique elements within 'maxlength'.");
+
+    if (! chk_length)
+      sub = uniqstr{K(1)};
+    else
+      if (length (uniqstr{K(1)}) + n > maxlength)
+        if (n >= maxlength)
+          error ("makeUniqueStrings: cannot create unique elements within MAXLENGTH");
+        endif
+        sub = uniqstr{K(1)}(1:maxlength-n);
+      else
+        sub = uniqstr{K(1)};
       endif
-      sub = y{K(1)}(1:maxlength-n);
-    else
-      sub = y{K(1)};
     endif
+
     for k = (1 + R):numel (K)
-      while true
+      while (true)
         N = k - R;
         proposal = [sub sprintf("_%d", N)];
-        if (! ismember (proposal, [excludedstrings y(I(i+1:end))]))
-          y{K(k)} = proposal;
+        if (! ismember (proposal, [excludedstrings, uniqstr(I(i+1:end))]))
+          uniqstr{K(k)} = proposal;
           break;
         else
-          R--; # i.e. increments N
+          R--;  # i.e. increments N
         endif
       endwhile
-      ismodified(K(k)) = true;
+      ismodified(K(k)) |= true;
     endfor
   endfor
 
   ## Return outputs with correct type and size
-  ismodified = ismodified | istruncated;
-
-  if (converttochar)
-    y = char (y);
-    if (isempty (y))
-      y = char ();
+  if (convert2char)
+    uniqstr = char (uniqstr);
+    if (isempty (uniqstr))
+      uniqstr = char ();
     endif
   else
     if (isnumeric (ex) || islogical (ex))
-      z = y;
-      y = cell (1, prod (sz));
-      y(ex) = z;
+      tmp = uniqstr;
+      uniqstr = cell (1, prod (sz));
+      uniqstr(ex) = tmp;
       if (isnumeric (ex))
-        y(setdiff (1:prod (sz), ex)) = excludedstrings;
+        uniqstr(setdiff (1:prod (sz), ex)) = excludedstrings;
       else
-        y(! ex) = excludedstrings;
+        uniqstr(! ex) = excludedstrings;
       endif
-      z = ismodified;
+      tmp = ismodified;
       ismodified = false (sz);
-      ismodified(ex) = z;
+      ismodified(ex) = tmp;
     endif
-    y = reshape (y, sz);
+    uniqstr = reshape (uniqstr, sz);
   endif
 
 endfunction
 
+
 ## Test first input
 %!test
-%! assert (matlab.lang.makeUniqueStrings ("a"), "a")
-%! assert (matlab.lang.makeUniqueStrings ({"a","b","c"}), {"a","b","c"})
+%! assert (matlab.lang.makeUniqueStrings ("a"), "a");
+%! assert (matlab.lang.makeUniqueStrings ({"a","b","c"}), {"a","b","c"});
 %! assert (matlab.lang.makeUniqueStrings (''), '');
 %! assert (matlab.lang.makeUniqueStrings ({}), {});
 
 ## Test exclusion list
 %!test
-%! x = {"jwe", "Marco", "Rik", "jwe", "Kai", "jwe", "Torsten"};
-%! y = matlab.lang.makeUniqueStrings (x);
-%! assert (y, {"jwe", "Marco", "Rik", "jwe_1", "Kai", "jwe_2", "Torsten"})
-%! y = matlab.lang.makeUniqueStrings (x, "Rik");
-%! assert (y, {"jwe", "Marco", "Rik_1", "jwe_1", "Kai", "jwe_2", "Torsten"})
-%! [y, m] = matlab.lang.makeUniqueStrings (x, {"Kai", "Rik"});
-%! assert (y, {"jwe", "Marco", "Rik_1", "jwe_1", "Kai_1", "jwe_2", "Torsten"})
+%! str = {"jwe", "Marco", "Rik", "jwe", "Kai", "jwe", "Torsten"};
+%! uniqstr = matlab.lang.makeUniqueStrings (str);
+%! assert (uniqstr,
+%!         {"jwe", "Marco", "Rik", "jwe_1", "Kai", "jwe_2", "Torsten"});
+%! uniqstr = matlab.lang.makeUniqueStrings (str, "Rik");
+%! assert (uniqstr,
+%!         {"jwe", "Marco", "Rik_1", "jwe_1", "Kai", "jwe_2", "Torsten"});
+%! [uniqstr, m] = matlab.lang.makeUniqueStrings (str, {"Kai", "Rik"});
+%! assert (uniqstr,
+%!         {"jwe", "Marco", "Rik_1", "jwe_1", "Kai_1", "jwe_2", "Torsten"});
 %! assert (m, logical ([0 0 1 1 1 1 0]));
 
 ## Test index array
 %!test
-%! x = {"a", "a", "a", "b", "a", "b"};
-%! y = matlab.lang.makeUniqueStrings (x, 1:4);
-%! assert (y, {"a_1", "a_2", "a_3", "b_1", "a", "b"});
-%! x(end+1) = "a";
-%! [y, m] = matlab.lang.makeUniqueStrings (x, 1:4);
-%! assert (y, {"a_1", "a_2", "a_3", "b_1", "a", "b", "a"});
+%! str = {"a", "a", "a", "b", "a", "b"};
+%! uniqstr = matlab.lang.makeUniqueStrings (str, 1:4);
+%! assert (uniqstr, {"a_1", "a_2", "a_3", "b_1", "a", "b"});
+%! str(end+1) = "a";
+%! [uniqstr, m] = matlab.lang.makeUniqueStrings (str, 1:4);
+%! assert (uniqstr, {"a_1", "a_2", "a_3", "b_1", "a", "b", "a"});
 %! assert (m ,logical ([1 1 1 1 0 0 0]));
 
 ## Test logical array
 %!test
-%! x = {"a", "a", "a", "b", "a", "b"};
-%! [y, m] = matlab.lang.makeUniqueStrings (x, logical ([1 1 1 1 0 0]));
-%! assert (y, {"a_1", "a_2", "a_3", "b_1", "a", "b"});
+%! str = {"a", "a", "a", "b", "a", "b"};
+%! [uniqstr, m] = matlab.lang.makeUniqueStrings (str, logical ([1 1 1 1 0 0]));
+%! assert (uniqstr, {"a_1", "a_2", "a_3", "b_1", "a", "b"});
 %! assert (m, logical ([1 1 1 1 0 0]));
 
 ## Test maxlength
 %!test
-%! x = {"maxlength", "maxlength", "maxlength", "maxlength"};
-%! [y, m] = matlab.lang.makeUniqueStrings (x, 1:3, 5);
-%! assert (y, {"maxle", "max_1", "max_2", "maxlength"});
+%! str = {"maxlength", "maxlength", "maxlength", "maxlength"};
+%! [uniqstr, m] = matlab.lang.makeUniqueStrings (str, 1:3, 5);
+%! assert (uniqstr, {"maxle", "max_1", "max_2", "maxlength"});
 %! assert (m, logical ([1 1 1 0]));
-%!error matlab.lang.makeUniqueStrings (repmat ({"a"}, 1, 10), {}, 2)
+%!error <cannot create unique elements within MAXLENGTH>
+%! matlab.lang.makeUniqueStrings (repmat ({"a"}, 1, 10), {}, 2);
 
 %!test
-%! assert (matlab.lang.makeUniqueStrings ("a", {"a"}), "a_1")
-%! assert (matlab.lang.makeUniqueStrings ("a", {"a","a_1"}), "a_2")
-%! y = matlab.lang.makeUniqueStrings ({"a","a","a","a_6","a"}, {"a","a_3"});
-%! assert (y, {"a_1","a_2","a_4","a_6","a_5"})
+%! assert (matlab.lang.makeUniqueStrings ("a", {"a"}), "a_1");
+%! assert (matlab.lang.makeUniqueStrings ("a", {"a","a_1"}), "a_2");
+%! uniqstr = matlab.lang.makeUniqueStrings ({"a","a","a","a_6","a"},
+%!                                          {"a","a_3"});
+%! assert (uniqstr, {"a_1","a_2","a_4","a_6","a_5"});
 
-%!test
-%!error matlab.lang.makeUniqueStrings ();
-%!error matlab.lang.makeUniqueStrings (1);
-%!error matlab.lang.makeUniqueStrings ("a", struct ());
-%!error matlab.lang.makeUniqueStrings ("a", 2);
-%!error matlab.lang.makeUniqueStrings ("a", [true false]);
-%!error matlab.lang.makeUniqueStrings ("a", {}, pi);
+## Test input validation
+%!error matlab.lang.makeUniqueStrings ()
 %!error [a, b, c] = matlab.lang.makeUniqueStrings ("a");
+%!error <STR must be a string or cellstr> matlab.lang.makeUniqueStrings (1)
+%!error <STR and EX logical array must have the same length>
+%! matlab.lang.makeUniqueStrings ("a", [true false]);
+%!error <invalid array of indices EX> matlab.lang.makeUniqueStrings ("a", 2)
+%!error <MAXLENGTH must be a positive integer>
+%! matlab.lang.makeUniqueStrings ("a", {}, pi);
--- a/scripts/+matlab/+lang/makeValidName.m	Tue Dec 11 15:19:00 2018 +0100
+++ b/scripts/+matlab/+lang/makeValidName.m	Tue Dec 11 13:14:09 2018 -0800
@@ -2,9 +2,9 @@
 ##
 ## This file is part of Octave.
 ##
-## Octave is free software; you can redistribute it and/or modify it
+## 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
+## 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
@@ -14,194 +14,195 @@
 ##
 ## 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/>.
+## <https://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn  {} {@var{y} =} matlab.lang.makeValidName (@var{x})
-## @deftypefnx {} {@var{y} =} matlab.lang.makeValidName (@var{x}, @qcode{"ReplacementStyle"}, @var{rs})
-## @deftypefnx {} {@var{y} =} matlab.lang.makeValidName (@var{x}, @qcode{"Prefix"}, @var{p})
-## @deftypefnx {} {[@var{y}, @var{ismodified}] =} matlab.lang.makeValidName (@dots{})
+## @deftypefn  {} {@var{varname} =} matlab.lang.makeValidName (@var{str})
+## @deftypefnx {} {@var{varname} =} matlab.lang.makeValidName (@dots{}, @qcode{"ReplacementStyle"}, @var{rs})
+## @deftypefnx {} {@var{varname} =} matlab.lang.makeValidName (@dots{}, @qcode{"Prefix"}, @var{pfx})
+## @deftypefnx {} {[@var{varname}, @var{ismodified}] =} matlab.lang.makeValidName (@dots{})
+##
+## Create valid variable name @var{varname} from @var{str}.
 ##
-## Create valid variable name(s) @var{y} from @var{x}.
+## The input @var{str} must be a string or a cell array of strings.
+## The output @var{varname} will be of the same type.
 ##
-## @var{x} has to be a string or a cell array of strings.  @var{y} will be of
-## the same type.
+## A valid variable name is a sequence of letters, digits, and underscores that
+## does not begin with a digit.
 ##
-## A valid name is a string of alphanumerics and underscores, starting with a
-## letter.
+## The @qcode{"ReplacementStyle"} option specifies how invalid characters
+## are handled.  Acceptable values are
 ##
-## The @qcode{"ReplacementStyle"} option specifies how non valid characters have
-## to be handled.  Acceptable values are @qcode{"underscore"}, @qcode{"hex"} and
-## @qcode{"delete"}.  Default value, @qcode{"underscore"}, replaces all non
-## valid characters with a @qcode{"_"}.  @qcode{"hex"} replaces all non valid
-## characters with their hexadecimal representation, while @qcode{"delete"} will
-## simply remove any character that is not alphanumeric or underscore.
-## Whitespace characters are always removed prior to the application of the
-## @qcode{"ReplacementStyle"}.  Lowercase letters following a whitespace will be
-## changed to uppercase.
+## @table @asis
+## @item @qcode{"underscore"} (default)
+## Replace all invalid characters with an underscore (@qcode{"_"}).
+##
+## @item @qcode{"delete"}
+## Remove any invalid character.
+##
+## @item @qcode{"hex"}
+## Replace all invalid characters with their hexadecimal representation.
+## @end table
 ##
-## The @qcode{"Prefix"} option specifies the string @var{p} to add as a prefix
-## to the input if it does not start with a letter.  @var{p} has to be a valid
-## variable name itself. Its default is @qcode{"x"}.
+## Whitespace characters are always removed @strong{prior} to the application
+## of the @qcode{"ReplacementStyle"}.  Lowercase letters following a whitespace
+## will be changed to uppercase.
 ##
-## @var{ismodified} is a logical array indicating whether each element in
-## @var{x} is a valid name or not (and therefore is modified in @var{y}).
+## The @qcode{"Prefix"} option specifies the string @var{pfx} to add as a
+## prefix to the input if it begins with a digit.  @var{pfx} must be a valid
+## variable name itself.  The default prefix is @qcode{"x"}.
+##
+## The optional output @var{ismodified} is a logical array indicating whether
+## the respective element in @var{str} was a valid name or not.
 ##
 ## @seealso{iskeyword, isvarname, matlab.lang.makeUniqueStrings}
 ## @end deftypefn
 
-function [y, ismodified] = makeValidName (x, varargin)
+function [varname, ismodified] = makeValidName (str, varargin)
 
   if (nargin == 0 || nargout > 2)
     print_usage ();
   endif
 
-  if ((! ischar (x)) && (! iscellstr (x)))
-    error ("makeValidName: input must be a string.");
+  if (! ischar (str) && ! iscellstr (str))
+    error ("makeValidName: STR must be a string or cellstr");
+  endif
+
+  if (mod (nargin - 1, 2) != 0)
+    error ("makeValidName: property/value options must occur in pairs");
   endif
 
-  converttochar = ischar (x);
-  y = cellstr (x);
-
-  ismodified = false (size (y));
-
+  varname = cellstr (str);
+  ismodified = false (size (varname));
+  convert2char = ischar (str);
   opts = struct ("replacementstyle", "underscore", "prefix", "x");
 
-  for i = 1:2:numel(varargin)
+  for i = 1:2:numel (varargin)
     if (! ischar (varargin{i}))
-      error ("makeValidName: input argument must be a string.");
+      error ("makeValidName: option argument must be a string");
     endif
     parameter = tolower (varargin{i});
-    if (numel (varargin) < i+1)
-      error ("makeValidName: input value missing.");
-    endif
     value = varargin{i+1};
     switch (parameter)
       case "replacementstyle"
         if (! ischar (value))
-          error ('makeValidName: "ReplacementStyle" value must be a string.');
+          error ('makeValidName: "ReplacementStyle" value must be a string');
         endif
         value = tolower (value);
-        if (! ismember (value, {"underscore", "hex", "delete"}))
-          error ('makeValidName: invalid "ReplacementStyle" value.');
+        if (! any (strcmp (value, {"underscore", "delete", "hex"})))
+          error ('makeValidName: invalid "ReplacementStyle" value "%s"', value);
         endif
         opts.replacementstyle = value;
+
       case "prefix"
-        if (! isvalidname (value))
-          error ('makeValidName: invalid "Prefix" value.');
+        if (! isvarname (value))
+          error ('makeValidName: invalid "Prefix" value "%s"', value);
         endif
         opts.prefix = value;
+
       otherwise
-        error ("makeValidName: unknown input argument.");
+        error ('makeValidName: unknown property "%s"', parameter);
     endswitch
   endfor
 
-  for i = 1:numel (y)
-    if (! isvalidname (y{i}))
+  for i = 1:numel (varname)
+    if (! isvarname (varname{i}))
       ismodified(i) = true;
+
       ## Remove leading and trailing whitespace
-      y{i} = strtrim (y{i});
-      if (isempty (y{i}))
-        y{i} = opts.prefix;
+      varname{i} = strtrim (varname{i});
+      if (isempty (varname{i}))
+        varname{i} = opts.prefix;
       endif
 
-      ## Check if input is a reserved keyword
-      if (iskeyword (y{i}))
-        y{i} = [opts.prefix, toupper(y{i}(1)), y{i}(2:end)];
+      ## Add prefix if input is a reserved keyword
+      if (iskeyword (varname{i}))
+        varname{i} = [opts.prefix, toupper(varname{i}(1)), varname{i}(2:end)];
       endif
 
-      ## Change lowercase letter followed by whitespace to uppercase
-      idx = regexp (y{i},'[\s][a-z]');
-      y{i}(idx+1) = toupper (y{i}(idx+1));
+      ## Change whitespace followed by lowercase letter to uppercase
+      idx = regexp (varname{i}, '\s[a-z]');
+      varname{i}(idx+1) = toupper (varname{i}(idx+1));
 
       ## Remove any whitespace character
-      y{i}(isspace (y{i})) = "";
+      varname{i}(isspace (varname{i})) = "";
 
-      ## Add prefix if first character is not a letter
-      if (! isempty (regexp (y{i}(1),"[^a-zA-Z]")))
-        y{i} = [opts.prefix y{i}];
+      ## Add prefix if first character is not a letter or underscore
+      char1 = varname{i}(1);
+      if (! isalpha (char1) && char1 != "_")
+        varname{i} = [opts.prefix varname{i}];
       endif
 
       ## Replace non alphanumerics or underscores
-      idx = regexp (y{i},"[^0-9A-Za-z_]");
+      idx = regexp (varname{i}, '[^0-9a-zA-Z_]');
       switch (opts.replacementstyle)
         case "underscore"
-          y{i}(idx) = "_";
+          varname{i}(idx) = "_";
+
+        case "delete"
+          varname{i}(idx) = "";
+
         case "hex"
           for j = numel (idx):-1:1
-            y{i} = strrep (y{i}, y{i}(idx(j)), sprintf ("0x%02X",y{i}(idx(j))));
+            varname{i} = strrep (varname{i}, varname{i}(idx(j)),
+                                 sprintf ("0x%02X",varname{i}(idx(j))));
           endfor
-        case "delete"
-          y{i}(idx) = "";
       endswitch
     endif
   endfor
 
-  if (converttochar)
-    y = char (y);
+  if (convert2char)
+    varname = char (varname);
   endif
 
 endfunction
 
 
-function tf = isvalidname (x)
-  # use isvarname instead
-  tf = true;
-  if (! ischar (x)
-    || isempty (x)
-    || numel (x) > namelengthmax ()
-    || ! isempty (regexp (x,"[^0-9A-Za-z_]"))
-    || ! isempty (regexp (x(1),"[^a-zA-Z]"))
-    || iskeyword (x))
-    tf = false;
-  endif
-endfunction
-
 ## Test char vector input
 %!test
-%! y = matlab.lang.makeValidName ("octave");
-%! assert (y, "octave");
+%! varname = matlab.lang.makeValidName ("octave");
+%! assert (varname, "octave");
 
 ## Test cellstr input
 %!test
-%! y = matlab.lang.makeValidName ({"gnu", "octave"});
-%! assert (y, {"gnu", "octave"});
+%! varname = matlab.lang.makeValidName ({"gnu", "octave"});
+%! assert (varname, {"gnu", "octave"});
 
 ## Test default flags
 %!test
-%! x = {"Octave", "3d plot", "GNU/Octave", "laplace_*"};
-%! y = matlab.lang.makeValidName (x);
-%! assert (y, {"Octave", "x3dPlot", "GNU_Octave", "laplace__"});
+%! str = {"Octave", "3d plot", "GNU/Octave", "laplace_*"};
+%! varname = matlab.lang.makeValidName (str);
+%! assert (varname, {"Octave", "x3dPlot", "GNU_Octave", "laplace__"});
 
 ## Test ReplacementStyle flag
 %!test
-%! x = {"Octave", "3d plot", "GNU/Octave", "laplace_*"};
-%! y = matlab.lang.makeValidName (x, "ReplacementStyle", "underscore");
-%! assert (y, {"Octave", "x3dPlot", "GNU_Octave", "laplace__"});
-%! y = matlab.lang.makeValidName (x, "ReplacementStyle", "hex");
-%! assert (y, {"Octave", "x3dPlot", "GNU0x2FOctave", "laplace_0x2A"});
-%! y = matlab.lang.makeValidName (x, "ReplacementStyle", "delete");
-%! assert (y, {"Octave", "x3dPlot", "GNUOctave", "laplace_"});
+%! str = {"Octave", "3d plot", "GNU/Octave", "laplace_*"};
+%! varname = matlab.lang.makeValidName (str, "ReplacementStyle", "underscore");
+%! assert (varname, {"Octave", "x3dPlot", "GNU_Octave", "laplace__"});
+%! varname = matlab.lang.makeValidName (str, "ReplacementStyle", "hex");
+%! assert (varname, {"Octave", "x3dPlot", "GNU0x2FOctave", "laplace_0x2A"});
+%! varname = matlab.lang.makeValidName (str, "ReplacementStyle", "delete");
+%! assert (varname, {"Octave", "x3dPlot", "GNUOctave", "laplace_"});
 
 ## Test Prefix flag
 %!test
 %! assert (matlab.lang.makeValidName ({"", " "}), {"x", "x"});
-%! x = {"Octave", "3d plot", "GNU/Octave", "laplace_*"};
-%! y = matlab.lang.makeValidName (x, "prefix", "oct_");
-%! assert (y, {"Octave", "oct_3dPlot", "GNU_Octave", "laplace__"});
+%! str = {"Octave", "3d plot", "GNU/Octave", "laplace_*"};
+%! varname = matlab.lang.makeValidName (str, "prefix", "oct_");
+%! assert (varname, {"Octave", "oct_3dPlot", "GNU_Octave", "laplace__"});
 
 ## Test second output
 %!test
-%! x = {"Octave", "3d plot", "GNU/Octave", "laplace_*"};
-%! [y, modified] = matlab.lang.makeValidName (x);
+%! str = {"Octave", "3d plot", "GNU/Octave", "laplace_*"};
+%! [varname, modified] = matlab.lang.makeValidName (str);
 %! assert (modified, [false, true, true, true]);
 
-## Test lowercase letter following a whitespace
+## Test whitespace followed by a lowercase letter
 %!test
-%! y = matlab.lang.makeValidName ("gnu octave");
-%! assert (y, "gnuOctave");
-%! y = matlab.lang.makeValidName (" octave  ");
-%! assert (y, "octave");
+%! varname = matlab.lang.makeValidName ("gnu octave");
+%! assert (varname, "gnuOctave");
+%! varname = matlab.lang.makeValidName (" octave  ");
+%! assert (varname, "octave");
 
 ## Check for keywords
 %!test
@@ -210,9 +211,16 @@
 %!error matlab.lang.makeValidName ("for", "Prefix", "for")
 
 ## Test input validation
-%!test
-%!error matlab.lang.makeValidName ();
-%!error matlab.lang.makeValidName (42);
-%!error matlab.lang.makeValidName ("octave", "unknown");
-%!error matlab.lang.makeValidName ("octave", "prefix");
-%!error matlab.lang.makeValidName ("octave", "prefix", "$");
+%!error matlab.lang.makeValidName ()
+%!error <STR must be a string or cellstr> matlab.lang.makeValidName (42)
+%!error <options must occur in pairs> matlab.lang.makeValidName ("a", "opt1")
+%!error <option argument must be a string>
+%! matlab.lang.makeValidName ("a", 1, 2)
+%!error <"ReplacementStyle" value must be a string>
+%! matlab.lang.makeValidName ("a", "ReplacementStyle", 1);
+%!error <invalid "ReplacementStyle" value "foobar">
+%! matlab.lang.makeValidName ("a", "ReplacementStyle", "foobar");
+%!error <invalid "Prefix" value "1_">
+%! matlab.lang.makeValidName ("a", "Prefix", "1_");
+%!error <unknown property "foobar">
+%! matlab.lang.makeValidName ("a", "foobar", 1);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/legacy/genvarname.m	Tue Dec 11 13:14:09 2018 -0800
@@ -0,0 +1,221 @@
+## Copyright (C) 2008-2018 Bill Denney, Robert Platt
+##
+## 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
+## <https://www.gnu.org/licenses/>.
+
+## -*- texinfo -*-
+## @deftypefn  {} {@var{varname} =} genvarname (@var{str})
+## @deftypefnx {} {@var{varname} =} genvarname (@var{str}, @var{exclusions})
+##
+## This function is obsolete.  Use @code{matlab.lang.makeValidName} or
+## @code{matlab.lang.makeUniqueStrings} instead.
+##
+## Create valid unique variable name(s) from @var{str}.
+##
+## If @var{str} is a cellstr, then a unique variable is created for each cell
+## in @var{str}.
+##
+## @example
+## @group
+## genvarname (@{"foo", "foo"@})
+##   @result{}
+##      @{
+##        [1,1] = foo
+##        [1,2] = foo1
+##      @}
+## @end group
+## @end example
+##
+## If @var{exclusions} is given, then the variable(s) will be unique to each
+## other and to @var{exclusions} (@var{exclusions} may be either a string or a
+## cellstr).
+##
+## @example
+## @group
+## x = 3.141;
+## genvarname ("x", who ())
+##   @result{} x1
+## @end group
+## @end example
+##
+## Note that the result is a char array or cell array of strings, not the
+## variables themselves.  To define a variable, @code{eval()} can be used.
+## The following trivial example sets @code{x} to 42.
+##
+## @example
+## @group
+## name = genvarname ("x");
+## eval ([name " = 42"]);
+##   @result{} x =  42
+## @end group
+## @end example
+##
+## This can be useful for creating unique struct field names.
+##
+## @example
+## @group
+## x = struct ();
+## for i = 1:3
+##   x.(genvarname ("a", fieldnames (x))) = i;
+## endfor
+##   @result{} x =
+##      @{
+##        a =  1
+##        a1 =  2
+##        a2 =  3
+##      @}
+## @end group
+## @end example
+##
+## Since variable names may only contain letters, digits, and underscores,
+## @code{genvarname} will replace any sequence of disallowed characters with
+## an underscore.  Also, variables may not begin with a digit; in this case
+## an @samp{x} is added before the variable name.
+##
+## Variable names beginning and ending with two underscores @qcode{"__"} are
+## valid, but they are used internally by Octave and should generally be
+## avoided; therefore, @code{genvarname} will not generate such names.
+##
+## @code{genvarname} will also ensure that returned names do not clash with
+## keywords such as @qcode{"for"} and @qcode{"if"}.  A number will be
+## appended if necessary.  Note, however, that this does @strong{not} include
+## function names such as @qcode{"sin"}.  Such names should be included in
+## @var{exclusions} if necessary.
+## @seealso{matlab.lang.makeValidName, matlab.lang.makeUniqueStrings,
+## namelengthmax, isvarname, iskeyword, exist, who, tempname, eval}
+## @end deftypefn
+
+function varname = genvarname (str, exclusions = {})
+
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+  endif
+
+  strinput = ischar (str);
+  ## Process the inputs
+  if (strinput)
+    if (rows (str) != 1)
+      error ("genvarname: if more than one STR is given, it must be a cellstr");
+    endif
+    str = {str};
+  elseif (! iscellstr (str))
+    error ("genvarname: STR must be a string or cellstr");
+  endif
+
+  if (ischar (exclusions))
+    if (rows (exclusions) != 1)
+      error ("genvarname: if more than one exclusion is given, it must be a cellstr");
+    endif
+    exclusions = {exclusions};
+  elseif (! iscellstr (exclusions))
+    error ("genvarname: EXCLUSIONS must be a string or cellstr");
+  else
+    exclusions = exclusions(:);
+  endif
+
+  varname = cell (size (str));
+  for i = 1:numel (str)
+    ## Perform any modifications to the varname to make sure that it is
+    ## a valid variable name.
+
+    ## remove invalid characters
+    str{i}(! (isalnum (str{i}) | str{i} == "_")) = "_";
+    ## do not use keywords
+    if (iskeyword (str{i}))
+      firstcharacter = toupper (str{i}(1));
+      str{i} = ["x", firstcharacter, str{i}(2:end)];
+    endif
+    ## The variable cannot be empty
+    if (isempty (str{i}))
+      str{i} = "x";
+    endif
+    ## Leading underscores are not Matlab compatible
+    if (str{i}(1) == "_")
+      str{i} = ["x", str{i}];
+    endif
+    ## it cannot start with a number
+    if (isdigit (str{i}(1)))
+      str{i} = ["x", str{i}];
+    endif
+
+    ## make sure that the variable is unique relative to other variables
+    ## and the exclusions list
+    excluded = any (strcmp (str{i}, exclusions));
+    if (excluded && isdigit (str{i}(end)))
+      ## if it is not unique and ends with a digit, add an underscore to
+      ## make the variable name more readable ("x1_1" instead of "x11")
+      str{i} = [str{i}, "_"];
+    endif
+    varname(i) = str(i);
+    idx = 0;
+    while (excluded)
+      idx += 1;
+      varname{i} = sprintf ("%s%d", str{i}, idx);
+      excluded = any (strcmp (varname{i}, exclusions));
+    endwhile
+    exclusions(end+1) = varname(i);
+  endfor
+
+  if (strinput)
+    varname = varname{1};
+  endif
+
+endfunction
+
+
+## a single argument
+%!assert (genvarname ("a"), "a")
+## a single argument with a non-conflicting exception
+%!assert (genvarname ("a", "b"), "a")
+## a single argument with a conflicting exception
+%!assert (genvarname ("a", "a"), "a1")
+## a single argument as a cell
+%!assert (genvarname ({"a"}), {"a"})
+%!assert (genvarname ({"a"}, "b"), {"a"})
+%!assert (genvarname ({"a"}, {"b"}), {"a"})
+%!assert (genvarname ({"a"}, "a"), {"a1"})
+%!assert (genvarname ({"a"}, {"a"}), {"a1"})
+## Test different arguments
+## orientation
+%!assert (genvarname ({"a" "b"}), {"a" "b"})
+%!assert (genvarname ({"a";"b"}), {"a";"b"})
+%!assert (genvarname ({"a" "a"}), {"a" "a1"})
+%!assert (genvarname ({"a" "b";"c" "d"}), {"a" "b";"c" "d"})
+%!assert (genvarname ({"a" "a" "a";"a" "a" "a"}), {"a" "a2" "a4";"a1" "a3" "a5"})
+## more than one repetition
+%!assert (genvarname ({"a" "a" "a"}), {"a" "a1" "a2"})
+%!assert (genvarname ({"a" "a" "a"}, {"a" "a1" "a2"}), {"a3" "a4" "a5"})
+## more than one repetition not in order
+%!assert (genvarname ({"a" "b" "a" "b" "a"}), {"a" "b" "a1" "b1" "a2"})
+## Variable name munging
+%!assert (genvarname ("__x__"), "x__x__")
+%!assert (genvarname ("123456789"), "x123456789")
+%!assert (genvarname ("_$1__"), "x__1__")
+%!assert (genvarname ("__foo__", "x__foo__"), "x__foo__1")
+%!assert (genvarname ("1million_and1", "x1million_and1"), "x1million_and1_1")
+%!assert (genvarname ({"", "", ""}), {"x", "x1", "x2"})
+%!assert (genvarname ("if"), "xIf")
+%!assert (genvarname ({"if", "if", "if"}), {"xIf", "xIf1", "xIf2"})
+## Exclusions in odd format
+%!assert (genvarname ("x", {"a", "b"; "x", "d"}), "x1")
+
+## Test input validation
+%!error genvarname ()
+%!error genvarname (1,2,3)
+%!error <more than one STR is given, it must be a cellstr> genvarname (char ("a", "b", "c"))
+%!error <STR must be a string or cellstr> genvarname (1)
+%!error <more than one exclusion is given, it must be a cellstr> genvarname ("x", char ("a", "b", "c"))
+%!error <EXCLUSIONS must be a string or cellstr> genvarname ("x", 1)
--- a/scripts/legacy/module.mk	Tue Dec 11 15:19:00 2018 +0100
+++ b/scripts/legacy/module.mk	Tue Dec 11 13:14:09 2018 -0800
@@ -3,6 +3,7 @@
 %canon_reldir%_FCN_FILES = \
   %reldir%/findstr.m \
   %reldir%/flipdim.m \
+  %reldir%/genvarname.m \
   %reldir%/isdir.m \
   %reldir%/isequalwithequalnans.m \
   %reldir%/isstr.m \
--- a/scripts/miscellaneous/genvarname.m	Tue Dec 11 15:19:00 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,219 +0,0 @@
-## Copyright (C) 2008-2018 Bill Denney, Robert Platt
-##
-## 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
-## <https://www.gnu.org/licenses/>.
-
-## -*- texinfo -*-
-## @deftypefn  {} {@var{varname} =} genvarname (@var{str})
-## @deftypefnx {} {@var{varname} =} genvarname (@var{str}, @var{exclusions})
-## Create valid unique variable name(s) from @var{str}.
-##
-## If @var{str} is a cellstr, then a unique variable is created for each cell
-## in @var{str}.
-##
-## @example
-## @group
-## genvarname (@{"foo", "foo"@})
-##   @result{}
-##      @{
-##        [1,1] = foo
-##        [1,2] = foo1
-##      @}
-## @end group
-## @end example
-##
-## If @var{exclusions} is given, then the variable(s) will be unique to each
-## other and to @var{exclusions} (@var{exclusions} may be either a string or a
-## cellstr).
-##
-## @example
-## @group
-## x = 3.141;
-## genvarname ("x", who ())
-##   @result{} x1
-## @end group
-## @end example
-##
-## Note that the result is a char array or cell array of strings, not the
-## variables themselves.  To define a variable, @code{eval()} can be used.
-## The following trivial example sets @code{x} to 42.
-##
-## @example
-## @group
-## name = genvarname ("x");
-## eval ([name " = 42"]);
-##   @result{} x =  42
-## @end group
-## @end example
-##
-## This can be useful for creating unique struct field names.
-##
-## @example
-## @group
-## x = struct ();
-## for i = 1:3
-##   x.(genvarname ("a", fieldnames (x))) = i;
-## endfor
-##   @result{} x =
-##      @{
-##        a =  1
-##        a1 =  2
-##        a2 =  3
-##      @}
-## @end group
-## @end example
-##
-## Since variable names may only contain letters, digits, and underscores,
-## @code{genvarname} will replace any sequence of disallowed characters with
-## an underscore.  Also, variables may not begin with a digit; in this case
-## an @samp{x} is added before the variable name.
-##
-## Variable names beginning and ending with two underscores @qcode{"__"} are
-## valid, but they are used internally by Octave and should generally be
-## avoided; therefore, @code{genvarname} will not generate such names.
-##
-## @code{genvarname} will also ensure that returned names do not clash with
-## keywords such as @qcode{"for"} and @qcode{"if"}.  A number will be
-## appended if necessary.  Note, however, that this does @strong{not} include
-## function names such as @qcode{"sin"}.  Such names should be included in
-## @var{exclusions} if necessary.
-## @seealso{isvarname, iskeyword, exist, who, tempname, eval}
-## @end deftypefn
-
-## Authors: Rob Platt <robert.platt@postgrad.manchester.ac.uk>
-##          Bill Denney <bill@denney.ws>
-
-function varname = genvarname (str, exclusions = {})
-
-  if (nargin < 1 || nargin > 2)
-    print_usage ();
-  endif
-
-  strinput = ischar (str);
-  ## Process the inputs
-  if (strinput)
-    if (rows (str) != 1)
-      error ("genvarname: if more than one STR is given, it must be a cellstr");
-    endif
-    str = {str};
-  elseif (! iscellstr (str))
-    error ("genvarname: STR must be a string or cellstr");
-  endif
-
-  if (ischar (exclusions))
-    if (rows (exclusions) != 1)
-      error ("genvarname: if more than one exclusion is given, it must be a cellstr");
-    endif
-    exclusions = {exclusions};
-  elseif (! iscellstr (exclusions))
-    error ("genvarname: EXCLUSIONS must be a string or cellstr");
-  else
-    exclusions = exclusions(:);
-  endif
-
-  varname = cell (size (str));
-  for i = 1:numel (str)
-    ## Perform any modifications to the varname to make sure that it is
-    ## a valid variable name.
-
-    ## remove invalid characters
-    str{i}(! (isalnum (str{i}) | str{i} == "_")) = "_";
-    ## do not use keywords
-    if (iskeyword (str{i}))
-      firstcharacter = toupper (str{i}(1));
-      str{i} = ["x", firstcharacter, str{i}(2:end)];
-    endif
-    ## The variable cannot be empty
-    if (isempty (str{i}))
-      str{i} = "x";
-    endif
-    ## Leading underscores are not Matlab compatible
-    if (str{i}(1) == "_")
-      str{i} = ["x", str{i}];
-    endif
-    ## it cannot start with a number
-    if (isdigit (str{i}(1)))
-      str{i} = ["x", str{i}];
-    endif
-
-    ## make sure that the variable is unique relative to other variables
-    ## and the exclusions list
-    excluded = any (strcmp (str{i}, exclusions));
-    if (excluded && isdigit (str{i}(end)))
-      ## if it is not unique and ends with a digit, add an underscore to
-      ## make the variable name more readable ("x1_1" instead of "x11")
-      str{i} = [str{i}, "_"];
-    endif
-    varname(i) = str(i);
-    idx = 0;
-    while (excluded)
-      idx += 1;
-      varname{i} = sprintf ("%s%d", str{i}, idx);
-      excluded = any (strcmp (varname{i}, exclusions));
-    endwhile
-    exclusions(end+1) = varname(i);
-  endfor
-
-  if (strinput)
-    varname = varname{1};
-  endif
-
-endfunction
-
-
-## a single argument
-%!assert (genvarname ("a"), "a")
-## a single argument with a non-conflicting exception
-%!assert (genvarname ("a", "b"), "a")
-## a single argument with a conflicting exception
-%!assert (genvarname ("a", "a"), "a1")
-## a single argument as a cell
-%!assert (genvarname ({"a"}), {"a"})
-%!assert (genvarname ({"a"}, "b"), {"a"})
-%!assert (genvarname ({"a"}, {"b"}), {"a"})
-%!assert (genvarname ({"a"}, "a"), {"a1"})
-%!assert (genvarname ({"a"}, {"a"}), {"a1"})
-## Test different arguments
-## orientation
-%!assert (genvarname ({"a" "b"}), {"a" "b"})
-%!assert (genvarname ({"a";"b"}), {"a";"b"})
-%!assert (genvarname ({"a" "a"}), {"a" "a1"})
-%!assert (genvarname ({"a" "b";"c" "d"}), {"a" "b";"c" "d"})
-%!assert (genvarname ({"a" "a" "a";"a" "a" "a"}), {"a" "a2" "a4";"a1" "a3" "a5"})
-## more than one repetition
-%!assert (genvarname ({"a" "a" "a"}), {"a" "a1" "a2"})
-%!assert (genvarname ({"a" "a" "a"}, {"a" "a1" "a2"}), {"a3" "a4" "a5"})
-## more than one repetition not in order
-%!assert (genvarname ({"a" "b" "a" "b" "a"}), {"a" "b" "a1" "b1" "a2"})
-## Variable name munging
-%!assert (genvarname ("__x__"), "x__x__")
-%!assert (genvarname ("123456789"), "x123456789")
-%!assert (genvarname ("_$1__"), "x__1__")
-%!assert (genvarname ("__foo__", "x__foo__"), "x__foo__1")
-%!assert (genvarname ("1million_and1", "x1million_and1"), "x1million_and1_1")
-%!assert (genvarname ({"", "", ""}), {"x", "x1", "x2"})
-%!assert (genvarname ("if"), "xIf")
-%!assert (genvarname ({"if", "if", "if"}), {"xIf", "xIf1", "xIf2"})
-## Exclusions in odd format
-%!assert (genvarname ("x", {"a", "b"; "x", "d"}), "x1")
-
-## Test input validation
-%!error genvarname ()
-%!error genvarname (1,2,3)
-%!error <more than one STR is given, it must be a cellstr> genvarname (char ("a", "b", "c"))
-%!error <STR must be a string or cellstr> genvarname (1)
-%!error <more than one exclusion is given, it must be a cellstr> genvarname ("x", char ("a", "b", "c"))
-%!error <EXCLUSIONS must be a string or cellstr> genvarname ("x", 1)
--- a/scripts/miscellaneous/module.mk	Tue Dec 11 15:19:00 2018 +0100
+++ b/scripts/miscellaneous/module.mk	Tue Dec 11 13:14:09 2018 -0800
@@ -26,7 +26,6 @@
   %reldir%/fileattrib.m \
   %reldir%/fileparts.m \
   %reldir%/fullfile.m \
-  %reldir%/genvarname.m \
   %reldir%/getfield.m \
   %reldir%/grabcode.m \
   %reldir%/gunzip.m \