uses strtok_r if avaliable. r=doug/cls, sr=rpotts, patch by drepper@cygnus.com. bug 99248

This commit is contained in:
dougt%netscape.com 2001-09-25 23:31:27 +00:00
Родитель 05abd17648
Коммит 65aec024ea
2 изменённых файлов: 28 добавлений и 2 удалений

Просмотреть файл

@ -1507,6 +1507,9 @@ PR_IMPLEMENT(int) NS_TraceMallocStartupArgs(int argc, char* argv[])
/* In child: set up stdin, parse args, and exec. */
int maxargc, nargc;
char **nargv, *token;
#if HAVE_STRTOK_R
char *newstr = nsnull;
#endif
if (pipefds[0] != 0) {
dup2(pipefds[0], 0);
@ -1514,13 +1517,23 @@ PR_IMPLEMENT(int) NS_TraceMallocStartupArgs(int argc, char* argv[])
}
close(pipefds[1]);
#ifdef HAVE_STRTOK_R
tmlogname = strtok_r(tmlogname + 1, " \t", &newstr);
#else
tmlogname = strtok(tmlogname + 1, " \t");
#endif
maxargc = 3;
nargv = (char **) malloc((maxargc+1) * sizeof(char *));
if (!nargv) exit(1);
nargc = 0;
nargv[nargc++] = tmlogname;
while ((token = strtok(NULL, " \t")) != NULL) {
while (
#ifdef HAVE_STRTOK_R
(token = strtok_r(newstr, " \t", &newstr))
#else
(token = strtok(NULL, " \t"))
#endif
!= NULL) {
if (nargc == maxargc) {
maxargc *= 2;
nargv = (char**)

Просмотреть файл

@ -1507,6 +1507,9 @@ PR_IMPLEMENT(int) NS_TraceMallocStartupArgs(int argc, char* argv[])
/* In child: set up stdin, parse args, and exec. */
int maxargc, nargc;
char **nargv, *token;
#if HAVE_STRTOK_R
char *newstr = nsnull;
#endif
if (pipefds[0] != 0) {
dup2(pipefds[0], 0);
@ -1514,13 +1517,23 @@ PR_IMPLEMENT(int) NS_TraceMallocStartupArgs(int argc, char* argv[])
}
close(pipefds[1]);
#ifdef HAVE_STRTOK_R
tmlogname = strtok_r(tmlogname + 1, " \t", &newstr);
#else
tmlogname = strtok(tmlogname + 1, " \t");
#endif
maxargc = 3;
nargv = (char **) malloc((maxargc+1) * sizeof(char *));
if (!nargv) exit(1);
nargc = 0;
nargv[nargc++] = tmlogname;
while ((token = strtok(NULL, " \t")) != NULL) {
while (
#ifdef HAVE_STRTOK_R
(token = strtok_r(newstr, " \t", &newstr))
#else
(token = strtok(NULL, " \t"))
#endif
!= NULL) {
if (nargc == maxargc) {
maxargc *= 2;
nargv = (char**)