9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* Re: [9fans] strdup()
@ 2002-04-09 12:23 forsyth
  2002-04-11  8:44 ` peter a. cejchan
  0 siblings, 1 reply; 9+ messages in thread
From: forsyth @ 2002-04-09 12:23 UTC (permalink / raw)
  To: 9fans

in the APE environment, strdup is in bsd.h (/sys/include/ape/bsd.h) as an extension.
the manual pages describe the library for the Plan 9 native environment.
			options.nucl = strdup(optarg) ;
strdup isn't declared and gets the default type of int, following C's B compatibility rules.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9fans] strdup()
  2002-04-09 12:23 [9fans] strdup() forsyth
@ 2002-04-11  8:44 ` peter a. cejchan
  0 siblings, 0 replies; 9+ messages in thread
From: peter a. cejchan @ 2002-04-11  8:44 UTC (permalink / raw)
  To: 9fans

forsyth@caldo.demon.co.uk wrote in message news:<20020409122715.8EAA7199BC@mail.cse.psu.edu>...
> in the APE environment, strdup is in bsd.h (/sys/include/ape/bsd.h) as an extension.
> the manual pages describe the library for the Plan 9 native environment.
> 			options.nucl = strdup(optarg) ;
> strdup isn't declared and gets the default type of int, following C's B compatibility rules.
Thanks! This helps much. Sorry disturbing with my idiotic questions
all the time. That's for a non-programmer (==me) decided to switch to
Plan 9 as a primary (and, later, hopefully, the only) environment.
Thus, I need to port some daily used programs and libs (link to the
ports is on the Wiki --> biology progs.)
To my shame, I still have a dual plan9/linux box...

Cheers,
keep helping ;-)

++pac.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9fans] strdup()
  2002-04-09 13:56 rob pike, esq.
@ 2002-04-10 15:19 ` AMSRL-CI-CN
  0 siblings, 0 replies; 9+ messages in thread
From: AMSRL-CI-CN @ 2002-04-10 15:19 UTC (permalink / raw)
  To: 9fans

"rob pike, esq." <rob@plan9.bell-labs.com> wrote...
> Yes.  For reasons I can't fathom, strdup is not in the ANSI C definition.
> I hope C9X fixes this oversight.

We tried to include it, but there was not consensus to do so,
the primary objection being to system libraries allocating
storage that the application would be responsible for later
deallocating.  I didn't think it was a good objection, and as
a widely-used extension with an easy portable definition it
certainly is in need of standardization, just as gets was in the
1980s.  At least C99 added snprintf.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9fans] strdup()
  2002-04-10  1:41 rob pike, esq.
@ 2002-04-10  8:55 ` Anthony Mandic
  0 siblings, 0 replies; 9+ messages in thread
From: Anthony Mandic @ 2002-04-10  8:55 UTC (permalink / raw)
  To: 9fans

"rob pike, esq." wrote:

> Bite your tongue.

	Ouch!

-am	© 2002


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9fans] strdup()
@ 2002-04-10  1:41 rob pike, esq.
  2002-04-10  8:55 ` Anthony Mandic
  0 siblings, 1 reply; 9+ messages in thread
From: rob pike, esq. @ 2002-04-10  1:41 UTC (permalink / raw)
  To: 9fans

> strdup is not in c99.  I have the feeling
> that the committees (pre '89 now and more lately)
> were reluctant to start down the path
> of putting externally visible malloc calls
> into the library.

Heavens, no.  Dynamic memory allocation?  In C???
Bite your tongue.

-rob



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9fans] strdup()
@ 2002-04-10  1:30 dmr
  0 siblings, 0 replies; 9+ messages in thread
From: dmr @ 2002-04-10  1:30 UTC (permalink / raw)
  To: 9fans

strdup is not in c99.  I have the feeling
that the committees (pre '89 now and more lately)
were reluctant to start down the path
of putting externally visible malloc calls
into the library.

	Dennis


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9fans] strdup()
@ 2002-04-09 13:56 rob pike, esq.
  2002-04-10 15:19 ` AMSRL-CI-CN
  0 siblings, 1 reply; 9+ messages in thread
From: rob pike, esq. @ 2002-04-09 13:56 UTC (permalink / raw)
  To: 9fans

> in the APE environment, strdup is in bsd.h (/sys/include/ape/bsd.h) as an extension.
> the manual pages describe the library for the Plan 9 native environment.
> 			options.nucl = strdup(optarg) ;
> strdup isn't declared and gets the default type of int, following C's B compatibility rules.

Yes.  For reasons I can't fathom, strdup is not in the ANSI C definition.
I hope C9X fixes this oversight.

-rob



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9fans] strdup()
  2002-04-09 10:45 pac7
@ 2002-04-09 11:22 ` Lucio De Re
  0 siblings, 0 replies; 9+ messages in thread
From: Lucio De Re @ 2002-04-09 11:22 UTC (permalink / raw)
  To: 9fans

On Tue, Apr 09, 2002 at 12:45:18PM +0200, pac7@post.cz wrote:
>
> typedef struct {
> 	FILE *in ;
> 	FILE *out ;
> 	char *nucl ;
> 	int search_degenerate ; } opt_s ;
>
> 			options.nucl = strdup(optarg) ;
>
opt_s or options?

++L


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [9fans] strdup()
@ 2002-04-09 10:45 pac7
  2002-04-09 11:22 ` Lucio De Re
  0 siblings, 1 reply; 9+ messages in thread
From: pac7 @ 2002-04-09 10:45 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 26 bytes --]

Hi,

I have a problem:

[-- Attachment #2: strdup --]
[-- Type: text/plain, Size: 643 bytes --]



typedef struct {
	FILE *in ;
	FILE *out ;
	char *nucl ;
	int search_degenerate ; } opt_s ;

			options.nucl = strdup(optarg) ;

  cc -O -DPLAN9 -o  select select.c genpak.c  -lm
$  cc -o  select select.c genpak.c
/usr/pac/Test/gp-0.26/src/select.c:67[stdin:653] incompatible types: "IND CHAR" and "INT" for op "AS"
cc: cpp: 8c 1252:error
$

man strdup

...
          Strdup returns a pointer to a distinct copy of the null-
          terminated string s in space obtained from malloc(2) or `0'
          if no space can be obtained.


#############

Any hint?
TIA,
++pac
<pac7@post.cz> for the time being :-(


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2002-04-11  8:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-09 12:23 [9fans] strdup() forsyth
2002-04-11  8:44 ` peter a. cejchan
  -- strict thread matches above, loose matches on Subject: below --
2002-04-10  1:41 rob pike, esq.
2002-04-10  8:55 ` Anthony Mandic
2002-04-10  1:30 dmr
2002-04-09 13:56 rob pike, esq.
2002-04-10 15:19 ` AMSRL-CI-CN
2002-04-09 10:45 pac7
2002-04-09 11:22 ` Lucio De Re

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).