Re: removal of duplicated code in gnome-vfs-uri



On 7 Feb 2003, Christophe Fergeau wrote:

> Hi,
> 
> The attached patch removes lots of duplicated code from
> gnome-vfs-utils.c and gnome-vfs-uri.c. It changes
> gnome_vfs_uri_make_full_from_relative,
> gnome_vfs_make_uri_full_from_relative and
> gnome_vfs_uri_resolve_relative.
> 
> gnome_vfs_make_uri_full_from_relative is deprecated and calls
> gnome_vfs_uri_make_full_from_relative (both contained the exact same
> code).
> I also noticed that gnome_vfs_uri_make_full_from_relative and
> gnome_vfs_uri_resolve_relative were doing mostly the same thing, the
> only difference being that gnome_vfs_uri_resolve_relative takes a
> GnomeVFSURI, and the other takes a string as parameter. Since they were
> duplicating code doing the same thing, I factored it in
> make_full_uri_from_relative. There is still a slight difference between
> the 2 functions: gnome_vfs_uri_resolve_relative will return NULL if the
> relative_uri argument is NULL, while
> gnome_vfs_uri_make_full_from_relative will return the base_uri arg. The
> gnome_vfs_uri_resolve_relative behaviour seems flawed in that case, I'd
> like to change it to behave the same as
> gnome_vfs_uri_make_full_from_relative (that would also allow to
> factorize some more code).
> 
> For now, the attached patch shouldn't modify at all the behaviour of
> these 3 functions. If something changed, that's unexpected and that's a
> bug. I'd prefer to commit this patch first, it only moves some code so
> it should be safe, but it's quite big, so I'm not really comfortable
> with it, a review would be nice if someone has some time :)

This looks fine to commit. The only change in behaviour is the replacement 
of g_return_val_if_fail() with normal comparisons in some edge cases (used 
to be in make_full_uri_from_relative). g_return_val_if_fail() prints out a 
warning if it fails and G_DISABLE_CHECKS is not defined. Maybe we should 
add that back?
 
> Then I'll change gnome_vfs_uri_resolve_relative behaviour if we agree
> that it's a bit buggy, and I'll try to fix #105094. One possibility to
> fix this bug is to remove the make_full_from_relative code from
> gnome-vfs and to use xmlBuildURI from libxml2 which implements section
> 5.2 of the RFC 2396 as does make_full_from_relative. However, that
> change would need to be carefully tested since gnome-vfs parsing code
> may not be 100% spec-compliant, and some apps may rely on that, so a
> less invasive fix would probably be better :)

Changes like this tend to affect apps like nautilus a great deal, so be 
very careful.

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
                   alexl redhat com    alla lysator liu se 
He's a maverick drug-addicted messiah living undercover at Ringling Bros. 
Circus. She's a cold-hearted paranoid snake charmer from the wrong side of the 
tracks. They fight crime! 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]