From e6d3f3b1da16269e6cb17b34d38ef7adc2691ae1 Mon Sep 17 00:00:00 2001 From: Steven Dake Date: Wed, 26 Jul 2006 06:57:52 +0000 Subject: [PATCH] Cleanup comparisons in lcr_ifact and use strtok_r instead of junky parser. git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1160 fd59a12c-fef9-0310-b244-a6a79926bd2f --- lcr/lcr_ifact.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/lcr/lcr_ifact.c b/lcr/lcr_ifact.c index eb3dd992..e4331f14 100644 --- a/lcr/lcr_ifact.c +++ b/lcr/lcr_ifact.c @@ -1,5 +1,6 @@ /* * Copyright (C) 2006 Steven Dake (sdake@mvista.com) + * Copyright (c) 2006 Sun Microsystems, Inc. * * This software licensed under BSD license, the text of which follows: * @@ -32,6 +33,7 @@ #include #include #include +#include #include #include #include "lcr_comp.h" @@ -177,28 +179,21 @@ static void ld_library_path_build (void) { char *ld_library_path; char *my_ld_library_path; - char *p_s; - unsigned int i; - unsigned int len; + char *p_s, *ptrptr; ld_library_path = getenv ("LD_LIBRARY_PATH"); if (ld_library_path == NULL) { return; } my_ld_library_path = strdup (ld_library_path); - if (my_ld_library_path == 0) { + if (my_ld_library_path == NULL) { return; } - len = strlen (my_ld_library_path) + 1; - - for (i = 0, p_s = my_ld_library_path, i = 0; i < len; i++) { - if (my_ld_library_path[i] == ':' || my_ld_library_path[i] == '\0') { - my_ld_library_path[i]='\0'; -//printf ("path list %x path list entries %d\n", path_list, path_list_entries); - path_list[path_list_entries++] = strdup (p_s); - p_s = &my_ld_library_path[i]; - } + p_s = strtok_r (my_ld_library_path, ":", &ptrptr); + while (p_s != NULL) { + path_list[path_list_entries++] = strdup (p_s); + p_s = strtok_r (NULL, ":", &ptrptr); } free (my_ld_library_path);