> Maximiano Cruz Francisco writes:
>
> We are getting segmentation faults on strtok.
>
The implementation of strtok(3) on Suns is apparently broken. Look:
This is an SGI:
@Poptart 181->uname -a
IRIX Poptart 5.2 04091117 IP22
@Poptart 177->cat > sasa.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void main(void)
{
printf ("%s\n", strtok("The first words Adam said to Eve?", " "));
}
^D
@Poptart 178->gcc -g sasa.c -o sasa
@Poptart 179->sasa
The
So it works just fine. Now on a Sun
@Athena 51->uname -a
SunOS Athena.McRCIM.McGill.EDU 4.1.3 7 sun4m
@Athena 52->gcc -g sasa.c -o sasa
@Athena 53->sasa
Segmentation fault
Let's see where
@Athena 54->gdb sasa
GDB is free software and you are welcome to distribute copies of it
under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.13 (sparc-sun-sunos4.1.2),
Copyright 1994 Free Software Foundation, Inc...
(gdb) r
Starting program: /amnt/jerome-4/home/vision/franco/tmp/sasa
Program received signal SIGSEGV, Segmentation fault.
0xef79dc18 in strtok ()
Ok, you are right. Maybe it doesn't like the const char * in the first
argument? (The manpage says it should, but anyway...)
@Athena 177->cat > sasa.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void main(void)
{
char s[]="The first words Adam said to Eve?";
printf ("%s\n", strtok(s, " "));
}
^D
@Athena 178->gcc sasa.c -o sasa
@Athena 179->sasa
The
That's it
Ciao
Franco