# HG changeset patch # User Eugenio Gianniti # Date 1393611850 -3600 # Node ID d227178a0d404722274bcbc744b1f0a7730e3eef # Parent cd83730e5e38ba0d9ef0516c24c9a787371aa995 validatestring.m: Change error message to follow Octave guidelines (bug #41484). * validatestring.m: Adapted the error messages to not mention validatestring when not needed. Modified %!tests to comply with the new output. * contributors.in: Add Eugenio Gianniti to list of contributors. diff -r cd83730e5e38 -r d227178a0d40 doc/interpreter/contributors.in --- a/doc/interpreter/contributors.in Thu Mar 20 12:31:19 2014 -0400 +++ b/doc/interpreter/contributors.in Fri Feb 28 19:24:10 2014 +0100 @@ -80,6 +80,7 @@ Walter Gautschi Klaus Gebhardt Driss Ghaddab +Eugenio Gianniti Nicolo Giorgetti Arun Giridhar Michael D. Godfrey diff -r cd83730e5e38 -r d227178a0d40 scripts/strings/validatestring.m --- a/scripts/strings/validatestring.m Thu Mar 20 12:31:19 2014 -0400 +++ b/scripts/strings/validatestring.m Fri Feb 28 19:24:10 2014 +0100 @@ -100,22 +100,21 @@ ## Make static part of error string that uses funcname, varname, and position errstr = ""; if (! isempty (funcname)) - errstr = sprintf ("Function: %s ", funcname); + errstr = [funcname ": "]; endif if (! isempty (varname)) - errstr = sprintf ("%sVariable: %s ", errstr, varname); + errstr = [errstr varname " "]; + else + errstr = sprintf ("%s'%s' ", errstr, str); endif if (position > 0) - errstr = sprintf ("%sArgument position %d ", errstr, position); - endif - if (! isempty (errstr)) - errstr(end:end+1) = ":\n"; + errstr = sprintf ("%s(argument #%i) ", errstr, position); endif matches = strncmpi (str, strarray(:), length (str)); nmatches = sum (matches); if (nmatches == 0) - error ("validatestring: %s'%s' does not match any of\n%s", errstr, str, + error ("%sdoes not match any of\n%s", errstr, sprintf ("%s, ", strarray{:})(1:end-2)); elseif (nmatches == 1) str = strarray{matches}; @@ -130,8 +129,8 @@ if (all (submatch)) str = short_str; else - error ("validatestring: %smultiple unique matches were found for '%s':\n%s", - errstr, str, sprintf ("%s, ", strarray{match_idx})(1:end-2)); + error ("%sallows multiple unique matches:\n%s", + errstr, sprintf ("%s, ", strarray{match_idx})(1:end-2)); endif endif @@ -147,10 +146,10 @@ %!assert (validatestring ("d", strarray), "def") %!error <'xyz' does not match any> validatestring ("xyz", strarray) -%!error validatestring ("xyz", strarray, "DUMMY_TEST") -%!error validatestring ("xyz", strarray, "DUMMY_TEST", "DUMMY_VAR") -%!error validatestring ("xyz", strarray, "DUMMY_TEST", "DUMMY_VAR", 5) -%!error validatestring ("abc", strarray) +%!error validatestring ("xyz", strarray, "DUMMY_TEST") +%!error validatestring ("xyz", strarray, "DUMMY_TEST", "DUMMY_VAR") +%!error validatestring ("xyz", strarray, "DUMMY_TEST", "DUMMY_VAR", 5) +%!error <'abc' allows multiple unique matches> validatestring ("abc", strarray) %% Test input validation %!error validatestring ("xyz")