After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 312241 - .lang files in homedir take priority over $prefix
.lang files in homedir take priority over $prefix
Status: RESOLVED FIXED
Product: gtksourceview
Classification: Platform
Component: General
git master
Other Linux
: High normal
: ---
Assigned To: GTK Sourceview maintainers
GTK Sourceview maintainers
Depends on:
Blocks:
 
 
Reported: 2005-08-01 14:43 UTC by Guillaume Desmottes
Modified: 2006-01-15 22:47 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
First patch to do that (1.57 KB, patch)
2005-08-01 15:42 UTC, Guillaume Desmottes
none Details | Review
same patch as before but read $HOME before to override $prefix (2.15 KB, patch)
2005-08-06 09:46 UTC, Guillaume Desmottes
needs-work Details | Review
patch (2.28 KB, patch)
2005-12-30 19:04 UTC, Paolo Borelli
none Details | Review
patch (3.35 KB, patch)
2005-12-30 20:10 UTC, Paolo Borelli
none Details | Review

Description Guillaume Desmottes 2005-08-01 14:43:33 UTC
According to the TODO in gtksourceview/gtksourceview/gtksourcelanguagesmanager.c
duplicated languages should be removed.

I think we should keep the second file (the one from the user's home directory)
because if a user changed a lang files into his home it's for work with his own
version and not the system one.
It will be easier to exchange the order in which the system dir and home dir are
readed to have home first.

The trivial way to do it will be to check the entire list before each insertion.
The complexity of this is O(n²). Is it ok, or you want something more optimized?
Comment 1 Guillaume Desmottes 2005-08-01 15:42:14 UTC
Created attachment 50074 [details] [review]
First patch to do that
Comment 2 Jeroen Zwartepoorte 2005-08-05 10:03:06 UTC

*** This bug has been marked as a duplicate of 110978 ***
Comment 3 Paolo Maggi 2005-08-05 10:16:02 UTC
This is not a duplicated of 110978.
Bug 110978 requires to implement a simple way for extending existing languages.
For example a c_gtk.lang file that extends c.lang by adding support for the gtk+
functions and types.
Comment 4 Jeroen Zwartepoorte 2005-08-05 11:03:56 UTC
Changing title to be more clear and to differentiate it from #110978.

If you have 2 language files containing the same styles, one in $prefix and one
in ~/.gnome2, gtksourceview should use the one in ~/.gnome2 (user override).
Comment 5 Guillaume Desmottes 2005-08-06 09:46:00 UTC
Created attachment 50310 [details] [review]
same patch as before but read $HOME before to override $prefix
Comment 6 Guillaume Desmottes 2005-08-06 09:56:03 UTC
priority high due to the patch
Comment 7 Paolo Maggi 2005-08-29 18:22:28 UTC
Sorry for the very late reply.
I think $HOME was already read before (we are using g_slist_prepend)... am I wrong?

I'd like to include this patch in 1.4.1 (too late for 1.4.0, sorry).

Comment 8 Paolo Borelli 2005-11-14 18:39:35 UTC
the patch needs a bit of work because on head we changed the code to consider
XDG_DATA_DIRS. I also agree with paolo that ~ was already searched before
PREFIX/share.
Comment 9 Paolo Borelli 2005-12-30 19:04:14 UTC
Created attachment 56560 [details] [review]
patch

here is a different patch to achieve the same result. It uses an hashtable to avoid the dups without the inefficient list walking.

It also fixes the leak of the filenames list, this is rather important indipendentely of the the rest of the patch.


However note that I have not yet tested this patch well (just quickly started up gedit to see if it works), so handle with care.
Comment 10 Paolo Borelli 2005-12-30 20:10:50 UTC
Created attachment 56561 [details] [review]
patch

actually now that I tested it, it turns out that we owe Guillaume an apology :)

If the ~/.gnome2/gtksourceview dir is first in the list of dirs to scan, it means that the files in that dir are considered *last*, since also when we collect the files list we prepend.

This patch seems to work ok
Comment 11 Jeroen Zwartepoorte 2006-01-15 10:13:19 UTC
Looks good.

Minor comment below:

-	while (filenames != NULL)
+	lang_hash = g_hash_table_new (g_str_hash, g_str_equal);
+
+	for (l = filenames; l != NULL; l = l->next)

Why introduce a for loop here? Why not just 

l = filenames;
while (l != NULL)
etc.
Comment 12 Paolo Borelli 2006-01-15 14:03:06 UTC
the for loop is handy because we use 'continue'


for (l = filenames; l != NULL; l = l->next)
  if (!foo)
    continue;
  ...


with while you need l = l->next both at the end of the loop and before every 'continue' which is IMHO messy and error prone
Comment 13 Paolo Borelli 2006-01-15 22:47:17 UTC
committed (with a better comment and with the right for loop when adding xdg dirs)