<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/glibc.git/posix/tst-getopt_long1.c, branch maskray/grte-old</title>
<subtitle>sourceware.org: git/glibc.git
</subtitle>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/glibc.git/'/>
<entry>
<title>getopt: merge from gnulib: alloca avoidance</title>
<updated>2017-04-07T11:51:52+00:00</updated>
<author>
<name>Zack Weinberg</name>
<email>zackw@panix.com</email>
</author>
<published>2017-04-01T21:13:45+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/glibc.git/commit/?id=aeacb9f9127cff0ed099026156ca35c025f343b7'/>
<id>aeacb9f9127cff0ed099026156ca35c025f343b7</id>
<content type='text'>
In one place, glibc's getopt uses alloca to construct a linked list of
possibilities for an "ambiguous" long option.  In gnulib, malloc
should be used instead.  Providing for both cases complicates things a
fair bit.  Instead of merging straight across, therefore, I have
chosen to rewrite it using a boolean vector instead of a linked list.
There is then only one allocation that might need freeing; in glibc it
can honor __libc_use_alloca as usual, and in gnulib we define
__libc_use_alloca to always be false, so we don't need ifdefs in the
middle of the function.  This should also be slightly more efficient
in the normal case of long options being fully spelled out -- I think
most people aren't even aware they _can_ sometimes abbreviate long
options.

One interesting consequence is that the list of possibilities is now
printed in exactly the order they appear in the list of long options,
instead of the first possibility being shuffled to the end.  This
shouldn't be a big deal but it did break one test that relied on the
exact text of this error message.

(The reason the previous patch was "in aid of" merging from gnulib is
I didn't want to have to make this change in two places.)

(The patch looks bigger than it really is because there's a fair bit
of reindentation and code rearrangement.)

	* posix/getopt.c: When used standalone, define __libc_use_alloca
	as always false and alloca to abort if called.
	(process_long_option): Rewrite handling of ambiguous long options
	to use a single boolean vector, not a linked list; use
	__libc_use_alloca to decide whether to allocate this using alloca.

	* posix/tst-getopt_long1.c: Adjust text of expected error message.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In one place, glibc's getopt uses alloca to construct a linked list of
possibilities for an "ambiguous" long option.  In gnulib, malloc
should be used instead.  Providing for both cases complicates things a
fair bit.  Instead of merging straight across, therefore, I have
chosen to rewrite it using a boolean vector instead of a linked list.
There is then only one allocation that might need freeing; in glibc it
can honor __libc_use_alloca as usual, and in gnulib we define
__libc_use_alloca to always be false, so we don't need ifdefs in the
middle of the function.  This should also be slightly more efficient
in the normal case of long options being fully spelled out -- I think
most people aren't even aware they _can_ sometimes abbreviate long
options.

One interesting consequence is that the list of possibilities is now
printed in exactly the order they appear in the list of long options,
instead of the first possibility being shuffled to the end.  This
shouldn't be a big deal but it did break one test that relied on the
exact text of this error message.

(The reason the previous patch was "in aid of" merging from gnulib is
I didn't want to have to make this change in two places.)

(The patch looks bigger than it really is because there's a fair bit
of reindentation and code rearrangement.)

	* posix/getopt.c: When used standalone, define __libc_use_alloca
	as always false and alloca to abort if called.
	(process_long_option): Rewrite handling of ambiguous long options
	to use a single boolean vector, not a linked list; use
	__libc_use_alloca to decide whether to allocate this using alloca.

	* posix/tst-getopt_long1.c: Adjust text of expected error message.
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix warning in posix/tst-getopt_long1.c.</title>
<updated>2014-12-02T22:03:59+00:00</updated>
<author>
<name>Joseph Myers</name>
<email>joseph@codesourcery.com</email>
</author>
<published>2014-12-02T22:03:59+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/glibc.git/commit/?id=b1aff6a41120c1d9cedc1ecedeafc79f161ce982'/>
<id>b1aff6a41120c1d9cedc1ecedeafc79f161ce982</id>
<content type='text'>
This patch fixes a "discards qualifiers" warning in
posix/tst-getopt_long1.c.  glibc is built with -Wwrite-strings,
meaning a char * cannot be initialized directly with a string
constant; the patch casts the string constants to char *.

Tested for x86_64.

	* posix/tst-getopt_long1.c (do_test): Cast elements of argv array
	to char *.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch fixes a "discards qualifiers" warning in
posix/tst-getopt_long1.c.  glibc is built with -Wwrite-strings,
meaning a char * cannot be initialized directly with a string
constant; the patch casts the string constants to char *.

Tested for x86_64.

	* posix/tst-getopt_long1.c (do_test): Cast elements of argv array
	to char *.
</pre>
</div>
</content>
</entry>
<entry>
<title>Provide more helpful error message in getopt</title>
<updated>2011-05-15T17:35:09+00:00</updated>
<author>
<name>Ulrich Drepper</name>
<email>drepper@gmail.com</email>
</author>
<published>2011-05-15T17:35:09+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/glibc.git/commit/?id=bd25564e1e98910ed69043ed6a6f884ce60e5780'/>
<id>bd25564e1e98910ed69043ed6a6f884ce60e5780</id>
<content type='text'>
If provide with an ambiguous long option we now show all the possibilities.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If provide with an ambiguous long option we now show all the possibilities.
</pre>
</div>
</content>
</entry>
</feed>
