changeset 14467:ec7ab7e37731

maint: Remove redundant private functions from pkg/private. * pkg/private/rstrip.m: remove file * pkg/private/strip.m: remove file * pkg/private/split_by.m: remove file * pkg/private/get_description.m: replace rstrip with deblank and strip with strtrim * pkg/private/fix_depends.m: replace rstrip with deblanak, strip with strtrim and split_by with strstrip (strsplit ()) * pkg/private/generate_llokfor_cache.m: replace split_by with strsplit (strtrim ())
author Carlo de Falco <kingcrimson@tiscali.it>
date Thu, 15 Mar 2012 19:44:13 +0100
parents cfb0173fe1ca
children d16638f73691
files scripts/pkg/module.mk scripts/pkg/private/fix_depends.m scripts/pkg/private/generate_lookfor_cache.m scripts/pkg/private/get_description.m scripts/pkg/private/rstrip.m scripts/pkg/private/split_by.m scripts/pkg/private/strip.m
diffstat 7 files changed, 7 insertions(+), 113 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/pkg/module.mk	Thu Mar 15 19:41:24 2012 +0100
+++ b/scripts/pkg/module.mk	Thu Mar 15 19:44:13 2012 +0100
@@ -36,11 +36,8 @@
   pkg/private/rebuild.m \
   pkg/private/repackage.m \
   pkg/private/rm_rf.m \
-  pkg/private/rstrip.m \
   pkg/private/save_order.m \
   pkg/private/shell.m \
-  pkg/private/split_by.m \
-  pkg/private/strip.m \
   pkg/private/uninstall.m \
   pkg/private/unload_packages.m \
   pkg/private/verify_directory.m \
--- a/scripts/pkg/private/fix_depends.m	Thu Mar 15 19:41:24 2012 +0100
+++ b/scripts/pkg/private/fix_depends.m	Thu Mar 15 19:44:13 2012 +0100
@@ -26,7 +26,7 @@
 ## This function returns a cell of structures with the following fields:
 ##   package, version, operator
 function deps_cell = fix_depends (depends)
-  deps = split_by (tolower (depends), ",");
+  deps = strtrim (strsplit (tolower (depends), ","));
   deps_cell = cell (1, length (deps));
 
   ## For each dependency.
@@ -37,7 +37,7 @@
     ## Does the dependency specify a version
     ## Example: package(>= version).
     if (length (lpar) == 1 && length (rpar) == 1)
-      package = tolower (strip (dep(1:lpar-1)));
+      package = tolower (strtrim (dep(1:lpar-1)));
       sub = dep(lpar(1)+1:rpar(1)-1);
       parts = strsplit (sub, " ", true);
       if (length (parts) != 2)
@@ -54,7 +54,7 @@
   ## we say that the version should be greater than
   ## or equal to "0.0.0".
   else
-    package = tolower (strip (dep));
+    package = tolower (strtrim (dep));
     operator = ">=";
     version  = "0.0.0";
   endif
--- a/scripts/pkg/private/generate_lookfor_cache.m	Thu Mar 15 19:41:24 2012 +0100
+++ b/scripts/pkg/private/generate_lookfor_cache.m	Thu Mar 15 19:44:13 2012 +0100
@@ -23,7 +23,7 @@
 ## @end deftypefn
 
 function generate_lookfor_cache (desc)
-  dirs = split_by (genpath (desc.dir), pathsep ());
+  dirs = strtrim (strsplit (genpath (desc.dir), pathsep ()));
   for i = 1 : length (dirs)
     gen_doc_cache (fullfile (dirs{i}, "doc-cache"), dirs{i});
   endfor
--- a/scripts/pkg/private/get_description.m	Thu Mar 15 19:41:24 2012 +0100
+++ b/scripts/pkg/private/get_description.m	Thu Mar 15 19:44:13 2012 +0100
@@ -38,7 +38,7 @@
     elseif (isspace(line(1)))
       ## Continuation lines
       if (exist ("keyword", "var") && isfield (desc, keyword))
-        desc.(keyword) = cstrcat (desc.(keyword), " ", rstrip(line));
+        desc.(keyword) = cstrcat (desc.(keyword), " ", deblank (line));
       endif
     else
       ## Keyword/value pair
@@ -47,8 +47,8 @@
         disp ("skipping line");
       else
         colon = colon(1);
-        keyword = tolower (strip (line(1:colon-1)));
-        value = strip (line (colon+1:end));
+        keyword = tolower (strtrim (line(1:colon-1)));
+        value = strtrim (line (colon+1:end));
         if (length (value) == 0)
             fclose (fid);
             error ("The keyword `%s' of the package `%s' has an empty value",
--- a/scripts/pkg/private/rstrip.m	Thu Mar 15 19:41:24 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-## Copyright (C) 2005-2012 S�ren Hauberg
-## Copyright (C) 2010 VZLU Prague, a.s.
-##
-## 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
-## <http://www.gnu.org/licenses/>.
-
-## -*- texinfo -*-
-## @deftypefn  {Function File} {@var{text} =} rstrip (@var{text})
-## Undocumented internal function.
-## @end deftypefn
-
-## Strip the text of spaces from the right
-## Example: "  hello world  " => "  hello world"
-## FIXME -- is this the same as deblank?
-function text = rstrip (text)
-  chars = find (! isspace (text));
-  if (length (chars) > 0)
-    ## FIXME: shouldn't it be text = text(1:chars(end));
-    text = text (chars(1):end);
-  else
-    text = "";
-  endif
-endfunction
-
--- a/scripts/pkg/private/split_by.m	Thu Mar 15 19:41:24 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-## Copyright (C) 2005-2012 S�ren Hauberg
-## Copyright (C) 2010 VZLU Prague, a.s.
-##
-## 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
-## <http://www.gnu.org/licenses/>.
-
-## -*- texinfo -*-
-## @deftypefn  {Function File} {@var{text} =} split_by (@var{text}, @var{sep})
-## Undocumented internal function.
-## @end deftypefn
-
-## Split the text into a cell array of strings by sep.
-## Example: "A, B" => {"A", "B"} (with sep = ",")
-function out = split_by (text, sep)
-  out = strtrim (strsplit (text, sep));
-endfunction
-
--- a/scripts/pkg/private/strip.m	Thu Mar 15 19:41:24 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-## Copyright (C) 2005-2012 S�ren Hauberg
-## Copyright (C) 2010 VZLU Prague, a.s.
-##
-## 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
-## <http://www.gnu.org/licenses/>.
-
-## -*- texinfo -*-
-## @deftypefn  {Function File} {text =} strip (@var{text})
-## Undocumented internal function.
-## @end deftypefn
-
-
-## Strip the text of spaces from the left and the right.
-## Example: "  hello world  " => "hello world"
-function text = strip (text)
-  chars = find (! isspace (text));
-  if (length (chars) > 0)
-    text = text(chars(1):chars(end));
-  else
-    text = "";
-  endif
-endfunction
-