# HG changeset patch # User Michael Goffioul # Date 1226493116 0 # Node ID 135c0e7d78020fc0f5eb3344f5e12c4168b2ea83 # Parent 830ad84d26547dded1b027577e08b7326ecdfacb Extend filesep functionality by allowing to return all valid file separators diff -r 830ad84d2654 -r 135c0e7d7802 src/ChangeLog --- a/src/ChangeLog Wed Nov 12 12:25:19 2008 +0100 +++ b/src/ChangeLog Wed Nov 12 12:31:56 2008 +0000 @@ -1,3 +1,8 @@ +2008-11-12 Michael Goffioul + + * dirfcn.cc (Ffilesep): Make it return all file separators when 'all' + is given as argument. + 2008-11-11 Jaroslav Hajek * pt-assign.cc: Fix handling of empty cs-lists in assignment LHS. diff -r 830ad84d2654 -r 135c0e7d7802 src/dirfns.cc --- a/src/dirfns.cc Wed Nov 12 12:25:19 2008 +0100 +++ b/src/dirfns.cc Wed Nov 12 12:31:56 2008 +0000 @@ -637,7 +637,13 @@ DEFUN (filesep, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} filesep ()\n\ +@deftypefnx {Built-in Function} {} filesep ('all')\n\ Return the system-dependent character used to separate directory names.\n\ +\n\ +If 'all' is given, the function return all valid file separators in\n\ +the form of a string. The list of file separators is system-dependent.\n\ +It is / (forward slash) under UNIX or Mac OS X, / and \\ (forward and\n\ +backward slashes) under Windows.\n\ @seealso{pathsep, dir, ls}\n\ @end deftypefn") { @@ -645,6 +651,20 @@ if (args.length () == 0) retval = file_ops::dir_sep_str (); + else if (args.length () == 1) + { + std::string s = args(0).string_value (); + + if (! error_state) + { + if (s == "all") + retval = file_ops::dir_sep_chars (); + else + gripe_wrong_type_arg ("filesep", args(0)); + } + else + gripe_wrong_type_arg ("filesep", args(0)); + } else print_usage ();