On Mon, Feb 28, 2000 at 11:29:41PM +0000, Tom Gilbert wrote:
> * Cameron Simpson ([EMAIL PROTECTED]) wrote:
> > On Mon, Feb 28, 2000 at 04:26:56PM +0000, Tom Gilbert wrote:
> > | * David Filion ([EMAIL PROTECTED]) wrote:
> > | > I'm trying to compile a C program that I wrote on a Sun system
> > | > but it won't work. The code compiles and runs fine on the
> > | > Sun server. However, [...]
> > |
> > | Well, this isn't really the forum for it.
<snippage>
> > Well... Linux/Solaris differences _can_ be addressed here.
> >
> Seen it now. The offending line was:
>
> #define PATH_VARIABLE_NAME "TTSDATA"
> [...]
> strcpy(task_filename, getenv(PATH_VARIABLE_NAME));
>
> On his Sun system, the environment variable TTSDATA is defined, on his
> linux box, it is not :)
>
> That's where it segfaults. getenv returns NULL and the first strlen()
> in strcpy() dumps core.
>
> So it's not a Sun/Linux thing, it's an environment thing :)
Well, actually it's a non-robust-code-thing. You should _always_ check
the return value from routines that provide a meaningful diagnostic.
Given that some string implementations tolerate null pointers could
be viewed as transforming it into a portability-thing, but I'd go, myself,
for the robustiness-thing. It's not a good idea to lean on such checking
merely because some implementations provide it.
Fred
--
---- Fred Smith -- [EMAIL PROTECTED] ----------------------------
I can do all things through Christ
who strengthens me.
------------------------------ Philippians 4:13 -------------------------------
--
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.