Preprocessor directives and gettext - patch for pidgin-mtn/pidgin/gtkmain.c

Richard Laager rlaager at wiktel.com
Sun Jan 13 12:54:49 EST 2008


On Fri, 2007-09-21 at 08:36 -0600, David Mohr wrote:
> On 9/20/07, Ethan Blanton <elb at pidgin.im> wrote:
> > Etan Reisner spake unto us the following wisdom:
> > > Thinking about this again, if we simply set opterr to 0 (so getopt stops
> > > bailing on unknown arguments for us) and then check to see if anything is
> > > left in argv/argc after we call gtk_init_check I *think* we can only parse
> > > arguments once ourselves, let GTK+ options propagate to GTK+, and keep our
> > > current die-on-unrecognized-arguments behaviour. That is of course
> > > assuming that both getopt and GTK+ remove arguments that they have
> > > handled, which I know is the case for GTK+ but I am unsure about for
> > > getopt.
> >
> > getopt does not remove arguments it has handled, but it rearranges the
> > argument list so that they are at the beginning, and updates 'optind'
> > to point at the first unrecognized argument.  What we should be able
> > to do is parse our arguments, store optind, then let Gtk+ at its
> > arguments, and check that argv[optind] == NULL.
> 
> I wrote a little patch for what you suggested, and it seems to work
> fine for me.

Sorry for the massive delay. This patch got lost in the shuffle.

I just tested this patch (with changes to make it apply) with:
	pidgin --sync -nm

It doesn't work. getopt is setting optind to 1, which means that it's
pointing to --sync. Then gtk_init_check() removes that, so it's pointing
to -nm, which is != NULL. getopt() isn't moving --sync to the end.

What happens for you with pidgin --sync -nm?

I looked at moving gtk_init_check() up, but we need to call
gtk_rc_add_default_file() before that. That code depends on knowing the
user directory, which depends on parsing our command line arguments.
Thus, we're stuck with the current ordering.

Richard

P.S. For reference, I've attached my diff against MTN head.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: getopt.patch
Type: text/x-patch
Size: 2293 bytes
Desc: not available
URL: <http://pidgin.im/pipermail/devel/attachments/20080113/7c620fce/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://pidgin.im/pipermail/devel/attachments/20080113/7c620fce/attachment.sig>


More information about the Devel mailing list