PackageVersion:([\\d.]*) | ";
+ t = regexp (html, pat, "tokens");
+ if (isempty (t) || isempty(t{1}))
+ error ("get_forge_pkg: could not read version number from package's page");
+ else
+ ver = t{1}{1};
+ if (nargout > 1)
+ # Build download string.
+ urlbase = "http://downloads.sourceforge.net/octave/%s-%s.tar.gz?download";
+ url = sprintf (urlbase, name, ver);
+ ## Verify that the string exists on the page.
+ if (isempty (strfind (html, url)))
+ warning ("get_forge_pkg: download URL not verified");
+ endif
+ endif
+ endif
+ else
+ ## Try get the list of all packages.
+ [html, succ] = urlread ("http://octave.sourceforge.net/packages.php");
+ if (succ)
+ t = regexp (html, "", "tokens");
+ t = horzcat (t{:});
+ if (any (strcmp (t, name)))
+ error ("get_forge_pkg: package NAME exists, but index page not available");
+ else
+ ## Try a simplistic method to determine close names.
+ dist = cellfun (@(n) length (setdiff (name, n)), t);
+ [~, i] = min (dist);
+ error ("get_forge_pkg: package not found: ""%s"". Maybe you meant ""%s?""", name, t{i});
+ endif
+ else
+ error ("get_forge_pkg: could not read URL, please verify internet connection");
+ endif
+ endif
+
+endfunction