Newsgroups: comp.ai.genetic
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!news.duke.edu!convex!cs.utexas.edu!howland.reston.ans.net!news.sprintlink.net!EU.net!uknet!festival!leeds.ac.uk!news
From: een6njb@sun.leeds.ac.uk (N J Bailey)
Subject: Re: GENEsYs
Message-ID: <1994Oct31.145913.19966@leeds.ac.uk>
Sender: news@leeds.ac.uk
Reply-To: een6njb@sun.leeds.ac.uk
Organization: University of Leeds, U.K.
Date: Mon, 31 Oct 1994 14:59:12 +0000 (GMT)
References: <38hbn7$ovf@Germany.EU.net>
Lines: 56

In article ovf@Germany.EU.net, jh@Germany.EU.net (Jrg Heitktter) writes:

...

> strdup(3) returns a malloc()'ed space containg a copy of it's argument;
> it's ANSI C standard; just type "man 3 strdup" to get the manual for
> section 3 functions, i.e. library calls...
> 
> #define strdup (x)	strcpy (malloc (strlen (x) + 1), x)
> 
> should work if strcpy(), malloc() and strlen() are avail. on your system.
> 
> Nope that you either have to include <string.h> or <strings.h> depending
> on the favours of your unix system. The first is System V, the latter
> BSD (Berkeley style). Since GenesYs was written on SunOS, it's Sys V style,
> and includes <string.h> (cf define.h)
> 
> 
> -- 
> Have fun,	-joke
> 
>  ===    ____                          ===   Jrg Heitktter
>  ===   /      /   /   ___    ___  _/_ ===   Research & Development
>  ===  /----  /   /  /   /  /___/  /   ===   EUnet Deutschland GmbH
>  === /____  /___/  /   /  /___   /    ===   Emil-Figge-Str. 80
>  =====                              =====   D-44227 Dortmund
>  ===== Connecting Europe since 1982 =====   Vox/Fax +49 231 972 -00/-1111
>  <A HREF="http://www.Germany.EU.net/people/joke.html"> The Jester's FAQ  </A>


While Jrg's fix may well work for this application, it is a rather dangereous one;
the x appears twice in the macro, so things like

	strdup(a++)

expand to

	strcpy(malloc(strlen(a++)+1), a++);

producing erroneous results.  So use it if it works, but watch out if you do the
same #define for other programs!

Nick.


---
-------------------------------------------------------------------------------
Nick Bailey                             Telephone: +44 532 332057
Lecturer in Electronic Engineering      Facsimile: +44 532 332032     
University of Leeds
Woodhouse Lane
Leeds LS2 9JT
United Kingdom
===============================================================================


