diff libinterp/corefcn/dirfns.cc @ 20817:3d551b2ae928

Use variable name nargin consistently in C++ code. * debug.cc (do_dbstack): Rename variable len to nargin. Change type to int from octave_idx_type. * dirfns.cc (Fcd): Rename variable argc to nargin and update code. Add nargin checking and print_usage. Replace make_argv call with xstring_value() call. Use !empty() rather than length > 0 for clarity. * error.cc (Flasterr, Flastwarn): Rename variable argc to nargin and update code. * filter.cc (Ffilter): Remove extra space in nargin declaration. * input.cc (Fecho): Rename variable argc to nargin and update code. * load-path.cc (Fpath): Rename variable argc to nargin and update code. Eliminate unnecessary declaration of "octave_value retval;". Add more calling forms to docstring. * pager.cc (Fdiary): Rename variable argc to nargin and update code. Replace make_argv call with xstring_value() call. Eliminate unnecessary declaration of "octave_value retval;".
author Rik <rik@octave.org>
date Mon, 07 Dec 2015 09:32:33 -0800
parents a6eaedd8bd75
children 1142cf6abc0d
line wrap: on
line diff
--- a/libinterp/corefcn/dirfns.cc	Mon Dec 07 08:30:51 2015 -0800
+++ b/libinterp/corefcn/dirfns.cc	Mon Dec 07 09:32:33 2015 -0800
@@ -122,20 +122,21 @@
 @seealso{pwd, mkdir, rmdir, dir, ls}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
+  int nargin = args.length ();
+ 
+  if (nargin > 1)
+    print_usage ();
 
-  int argc = args.length () + 1;
-
-  string_vector argv = args.make_argv ("cd");
+  octave_value_list retval;
 
   if (nargout > 0)
     retval = octave_value (octave_env::get_current_directory ());
 
-  if (argc > 1)
+  if (nargin == 1)
     {
-      std::string dirname = argv[1];
+      std::string dirname = args(0).xstring_value ("cd: DIR must be a string");
 
-      if (dirname.length () > 0)
+      if (! dirname.empty ())
         octave_change_to_directory (dirname);
     }
   else