GRegex

After the last post I was asked where to find GRegex and how to use it, GRegex is not yet in GLib, probably it will be included in GLib 2.14, and GLib 2.14 will be probably used by Gnome 2.20.

If you can’t wait for GLib 2.14 you can include a copy of EggRegex, as it’s done by the soc-2006 branch of GtkSourceView. EggRegex has the same API of GRegex except for the egg_ prefix instead of g_ for function names, so the update to GRegex should be easy. The Mercurial repository is at techn.ocracy.org/eggregex, if you are not a Mercurial user you can get the .tar.gz. Please, do not use the EggRegex version you can find in the libegg module at svn.gnome.org because it’s old, buggy and not API-compatible with GRegex.

If you want to read the GRegex documentation without downloading and compiling anything you can read it from barisione.org/gregex, the relevant pages are the API documentation, the regular expression syntax, and the build options.

gnome-format

Recently Emmanuele Bassi asked for help on reviving GFloppy as it’s old and mostly useless. Paul Betts and Riccardo Setti (giskard) accepted the invitation and are working on gnome-format, an utility that will be able to format any removable disk (USB pendrives, etc.) Here’s some screenshots but remember that gnome-format is in alpha stage!

gnome-format

gnome-format (volume selection)

gnome-format (options)

gnome-format (fs type selection)

I don’t like the filesystem selection menu, but it will be probably changed to contain something like “Compatible with XXX (FS-NAME)”, so it will be usable be geek and non-geek users.

Hello Planet GNOME!

This should be my first post on Planet GNOME (thanks jdub), so hello everybody!

So, who am I? I’m Marco Barisione, an Italian student of Computer Engineering at the Politecnico di Torino.

For my third-year dissertation I wrote a new syntax highlighting engine for GtkSourceView 2 with Emanuele Aina, now the code is in the soc-2006 branch of GtkSourceView and Yevgen Muntyan is working on it.

As a spin-off project of the highlighting engine I resurrected EggRegex (originally written by Scott Wimer and then modified by Matthias Clasen), as it was buggy, incomplete and abandoned in libegg. EggRegex, now called GRegex, should be included in glib 2.14 (bug #50075.)

Now I’m working on GSpell, a GObject-based version of Enchant, to add spell checking support into the Gtk+ stack (bug #383706.)

I maintain and host on my server Planet GNOME Italia.

I also wrote some Windows programs, such as WinCalendarTime, a replacement for the standard Windows XP clock, and HotKeyBind, a program that lets you use shortcut key combinations to do common tasks.

One of my hobbies is cooking, so I have a cooking blog in Italian at TarteTatin.it.

Vista miracles

A month ago my desktop computer died, Windows XP (both the installed version and the installer) was crashing while booting and using Linux live CDs I was only able to get kernel panics.

As a student of the Politecnico di Torino I can have a free copy of Windows Vista Business and other Microsoft products (see the MSDNAA web page of my university.)

Today I tried to install Vista on my dead computer without any hope to finish the setup, but wow, Vista was installed correctly and now the computer is working. This mean that now I have to use Vista, I’m sad :(.

Small things that matter / 2

After the post on the “Empty Trash” button in the trash folder, I’m looking for other small changes in GNOME 2.17, i.e. the development version for GNOME 2.18. These are not the big changes everyone can see like the new Control Center, but those small things that are improving GNOME version after version.

In the following screenshots you can see Glossy, a new theme included in 2.18 (to tell the truth it’s not a real theme, but just an option to the ClearLooks theme.)

GNOME 2.18

We will have a UI for configuring theme colors, see this post by Tim Retout.

Theme selection

GNOME Screenshot has a new dialog displayed when you pass --interactive to the program, the default if you launch the utility from the menu. Thanks Emmanuele!

gnome-screenshot

The UI of GNOME Power Manager was cleaned up, now the menu is much more readable and the ugly “Power History” window with lots of tabs has been improved too.

gnome-power-manager

Some minor changes were done to the “Startup Programs” tab in gnome-session-properties, spot the differences!

gnome-session-properties

The last small improvement I found is the new “System” tab in GNOME System Monitor, see this, this, and this.

gnome-system-monitor

Arrays of strings and relocation

While working on GRegex (Perl-style regular expressions for GLib) I discovered that arrays of string pointers can cause lots of relocations.

Relocation is the process of adjusting the pointers whose value is unknown at link-time, such as the pointer to a function is a dynamically loaded library.

In PCRE (the library used by GRegex) there is a table used to associate the name of a script, such as Latin or Arabic, to its properties:

const ucp_type_table _pcre_utt[] = {
  { "Any",      PT_ANY, 0 },
  { "Arabic",   PT_SC,  ucp_Arabic },
  { "Armenian", PT_SC,  ucp_Armenian },
  ...
  { "Zs",       PT_PC,  ucp_Zs }
};

The strings (they are more than 100!) are placed in read-only memory, while the _pcre_utt array will be placed in writeable memory, so the dynamic loader has to do a relocation for each string. The number of relocations in libglib with GRegex was:

libglib-2.0.so: 290 relocations, 263 relative (90%), 131 PLT entries, 1 for local syms (0%), 0 userstable

Without GRegex:

libglib-2.0.so: 90 relocations, 63 relative (70%), 131 PLT entries, 1 for local syms (0%), 0 users

A possible solution is to replace the strings in the table by offsets into one big string constant.

const char _pcre_ucp_names[] =
  "Any\0"
  "Arabic\0"
  "Armenian\0"
  ...
  "Zs";

const ucp_type_table _pcre_utt[] = {
  { 0,   PT_ANY, 0 },
  { 4,   PT_SC,  ucp_Arabic },
  { 11,  PT_SC,  ucp_Armenian },
  ...
  { 653, PT_PC,  ucp_Zs }
};

The result after this operation is:

libglib-2.0.so.0.1300.0: 187 relocations, 160 relative (85%), 131 PLT entries, 1 for local syms (0%), 0 users

Using the same technique on the other arrays in PCRE and GRegex, we reduced the number of relocations, now the results are similar to the ones obtained without GRegex:

libglib-2.0.so.0.1300.0: 102 relocations, 75 relative (73%), 131 PLT entries, 1 for local syms (0%), 0 users

The number of relocations was obtained using the relinfo.pl script by Ulrich Drepper. If you want to know something more about dynamic libraries, you can read How To Write Shared Libraries by the same author.

UPDATE: Declare _pcre_ucp_names as a char [] instead of char *, as suggested by Ulrich Drepper.

Internet Explorer on Linux

When developing my web sites I need to test them with Internet Explorer, after all it’s the most used browser. As my home computer (running Windows) died, I tried IEs4Linux.

Internet Explorer 6 on Linux

The stable version of IEs4Linux can run Internet Explorer 5, 5.5 and 6. If you want to run IE 7 (or better the GUI of IE 6 with the engine of IE 7) you need the 2.5 beta version. To run all these versions of Internet Explorer under Debian unstable, install wine and cabextract, then follow these instructions:

wget http://www.tatanka.com.br/ies4linux/downloads/ies4linux-2.5beta2.tar.gz
tar xzf ies4linux-2.5beta2.tar.gz
cd ies4linux-2.5beta5/
./ies4linux --install-ie5 --install-ie55 --beta-install-ie7

DNS problems

In these days using the Internet is a real pain for lots of Italians. The former TLC monopolist claims that the problems are due to viruses, but this does not explain why the service with the biggest problems is DNS, host name resolution requires at least 10 seconds! This is why I have been using OpenDNS for some days. Note that I don’t care about phishing protection and the other stuff offered by OpenDNS, but it’s fast and reliable.

BTW, merry Christmas!