Skip to Content.
Sympa Menu

sm-sorcery - [SM-Sorcery] liburl repeats itself??

sm-sorcery AT lists.ibiblio.org

Subject: Discussion of Sorcery related topics

List archive

Chronological Thread  
  • From: Casey Harkins <charkins AT upl.cs.wisc.edu>
  • To: sm-sorcery AT lists.ibiblio.org
  • Subject: [SM-Sorcery] liburl repeats itself??
  • Date: Sun, 10 Aug 2003 19:56:50 -0500 (CDT)


I was having trouble getting file urls to work, which I eventually traced
to a misformatted sed command in url_handlers/url_file (someone already
reported as bug #3872).

However, while adding debug statements throughout liburl to isolate the
problem, I realized that url_download basically repeats itself. Here is
the for loop from liburl::url_download():

for URL in $URL_LIST; do
if url_is_valid $URL &&
url_change_base &&
URL_PREFIX=`url_get_prefix $URL` &&
url_is_function "url_${URL_PREFIX}_download" &&
url_${URL_PREFIX}_download $URL; then
SUCCESS=true
break;
fi
done


The first call is to liburl::url_is_valid() which looks like this:

url_is_valid() {
[ "$1" == " " ] && return 1 #If it's only a space, it's not valid
local URL_PREFIX=`echo $1 | sed "s/[\:\/\/].*$//"`
[ -n "$URL_PREFIX" ] &&
url_is_function "url_${URL_PREFIX}_download"
}


url_is_valid sets the URL_PREFIX (locally) and calls url_is_function to
ensure that the url_*_download function exists. Then this is repeated in
url_download, this time using url_get_prefix() to get the URL_PREFIX and
leaving it global. The intent of this is probably to re-validate the url
after BASE_URL is applied, but why not just do:

if url_change_base &&
url_is_valid $URL &&
url_${URL_PREFIX}_download $URL; then
SUCCESS=true
break;
fi

and probably update url_is_valid() to use url_get_prefix()? Just curious.

-casey





  • [SM-Sorcery] liburl repeats itself??, Casey Harkins, 08/10/2003

Archive powered by MHonArc 2.6.24.

Top of Page