Re: Removing libiberty (was Re: gnatsd problems with 4.0.1)

"Mike M. Volokhov" <[email protected]>
Newsgroups gmane.comp.bug-tracking.gnats.general
Organization Insakharprom-K, Ltd.
Message-ID <[email protected]>
On Mon, 7 Feb 2005 11:42:01 -0600
Chad Walstrom <[email protected]> wrote:

> Mike M. Volokhov wrote:
[snip]
> > So, only six functions are used by GNATS, when libiberty provides
> > about 40. Only two functions (asprintf and vasprintf) are nor POSIX
> > nor standard C relevant (but included in both GNU and BSD libc).
> 
> Actually, add one more: getopt(), which is the one that's currently
> giving us problems on the BSD platform.

What kind of troubles you have? Yes, there is a set of differences, but
I just wish to know a direction to handle them.

> > Three functions (xstrdup, xmalloc, xrealloc) are totally
> > libiberty-own, but can be easy replaced with their standard
> > equivalents.
> 
> Yes.  They're convenience functions documented in the glibc "standards"
> manual as well.  In fact, writing wrapper functions is well documented
> by the venerable Stevens in his Unix programming books, although I
> believe he would have named the wrapper "Malloc()".  ;-) As such,
> they're not bad little functions, but I agree that we shouldn't have to
> carry libiberty around just for these three.
> 
> > Thus, I propose to eliminate dependency on libiberty completely.
> 
> I support that proposal.  When only 7 of 42 are required, they should be
> relatively easy to move into misc.c or a utils.{c,h} file pair and
> support in autoconf.

Exactly. The utils.[ch] possible the best place for handling this small
piece of software. Altough, I have rewrite some functions from scratch
and thus it can be joined the misc.[ch] files.

Please take a look to my patch which eliminates "libiberty" and
"include" directories completely. To test it:

1) Please be sure you have yesterday's AnonCVS sources.
2) Save the attached compressed diff to gnats subdirectory.
3) Apply a patch saved:
	gunzip < gnats-wo-libiberty.diff.gz | patch
4) Rename or remove "libiberty" and "include" subdirectories.
5) Configure and install GNATS as usual.

The following files was changed:

	Makefile.in
	configure
	configure.in
	configure
	gnats/Makefile.in
	gnats/ansidecl.h (moved from include/ansidecl.h)
	gnats/configure
	gnats/configure.in
	gnats/gnats.h
	gnats/util.h (added)
	gnats/util.c (added)
	libiberty/* (all removed)
	include/* (all removed)

The following functions was rewritten from scratch and was based on
their respective standard equivalents:

	xmalloc()
	xrealloc()
	xstrdup()

The following functions should be shipped by 3rd-party vendors and thus
configure will rely on them (yes, I've dropped them from GNATS):

	basename()
	asprintf()
	vasprintf()

The xstrndup() function was changed to more fault-tolerant behaviour,
when passed length is less than 1. This fixes potential problems with
other functions which relies on xstrndup(), i.e.:

	strlen(xstrndup(string, 0))

I did some tests on my NetBSD 2.x and have not any visible troubles.

--
Mishka.

_______________________________________________
Help-gnats mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gnats
gnats-wo-libiberty.diff.gz (application/octet-stream, 8.8 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.