No subject

Net.Noise owner news at
Fri Mar 26 01:35:16 EST 1993

Newsgroups: info.grass.user
From: shapiro at (Michael Shapiro)
Subject: Re: xgrass on DECstation? (strdup undefined)
Message-ID: <C4HGyp.LGq at>
Sender: news at (Net.Noise owner)
Organization: US Army Corps of Engineers Construction Engineering Research Labs
References: <Mailstrom.1.0.61886.11025.nsmith at> <9303241850.AA10605 at>
Date: Fri, 26 Mar 1993 06:35:13 GMT
Lines: 84

>> Seeing xgrass in Reston was enough to convince me it was
>> time to make it.  I made grass4.1beta without any problems,
>> but am stuck on xgrass at xgrass/display :  the loader
>> can't find strdup.  Sure enough, it's called in lex.c
>> (and declared twice!), and not defined in any of the code
>> in src/xgrass/display.
>> Have I missed a header file somewhere?
>> I'm compiling on a DECStation 5000, X with Motif;  the
>> X headers seem to be in order.

>strdup is one of the string functions defined under SunOS, among
>others.  But, it is not available for Ultrix, for reasons that are
>unclear to all but DEC.  

You could use G_store() from the GRASS $(GISLIB) which does
a strdup() (except ti calls exit() if malloc() fails). Or write
a strdup():

	char *strdup(s) char *s;
		char *b;
		char *malloc();

		if(b = malloc(strlen(s)+1))
			strcpy (b, s);
		return b;


>STRING(3)              C LIBRARY FUNCTIONS              STRING(3)

>     strcat,  strncat,  strdup,  strcmp,   strncmp,   strcasecmp,
>     strncasecmp,   strcpy,  strncpy,  strlen,  strchr,  strrchr,
>     strpbrk, strspn, strcspn, strstr, strtok,  index,  rindex  -
>     string operations

>     #include <string.h>


>     char *strdup(s1)
>     char *s1;


>     These functions operate on null-terminated strings.  They do
>     not check for overflow of any receiving string.


>     strdup() returns a pointer to a new string which is a dupli-
>     cate  of the string pointed to by s1.  The space for the new
>     string is obtained using malloc(3V).  If the new string can-
>     not be created, a NULL pointer is returned.



>I have fiddled around a bit, trying to get around this, but havn't had any 
>luck getting the resulting code to run.  I don't think this one will be too
>hard to fix.

>| Kenn Gardels                Tel +01 (510) 642-9205   Fax +01 (510) 643-5571  |
>| CEDR - 390 Wurster Hall     Internet  gardels at               |
>| University of California    Bitnet    gardels at UCBCED                         |
>| Berkeley, CA  94720         Calendar  gardels at         |

Michael Shapiro U.S. Army CERL
Environmental Division       

More information about the grass-user mailing list