[Pinfo-devel] r84 - pinfo/branches/cxx/src
Nathanael Nerode
neroden-guest at costa.debian.org
Tue Aug 30 09:23:07 UTC 2005
Author: neroden-guest
Date: 2005-08-30 09:23:07 +0000 (Tue, 30 Aug 2005)
New Revision: 84
Modified:
pinfo/branches/cxx/src/filehandling_functions.cxx
Log:
More conversion in initpaths.
Modified: pinfo/branches/cxx/src/filehandling_functions.cxx
===================================================================
--- pinfo/branches/cxx/src/filehandling_functions.cxx 2005-08-30 09:04:30 UTC (rev 83)
+++ pinfo/branches/cxx/src/filehandling_functions.cxx 2005-08-30 09:23:07 UTC (rev 84)
@@ -791,11 +791,10 @@
void
initpaths()
{
- char emptystr[1] = "";
char **paths = NULL;
char *langpath = NULL;
- char *c, *dir, *env;
char *rawlang = NULL, *lang = NULL, *langshort = NULL;
+ char* c;
int ret;
unsigned int i, j, maxpaths, numpaths = 0, langlen;
size_t len;
@@ -803,13 +802,12 @@
ino_t *inodes;
/* first concat the paths */
- env = getenv("INFOPATH");
- if (env == NULL)
+ string infopath;
+ char* env = getenv("INFOPATH");
+ if (env != NULL)
{
- env = emptystr;
+ infopath = env;
}
- string infopath;
- infopath = env;
infopath += ":"; /* FIXME: what if one of the two is blank? */
infopath += configuredinfopath;
@@ -818,17 +816,20 @@
paths = (char **) xmalloc( maxpaths * sizeof(char *) );
/* split at ':' and put the path components into paths[] */
- c = strdup(infopath.c_str());
- while ((dir = strsep(&c, ":")))
- {
+ string::size_type stop_idx;
+ string::size_type start_idx = 0;
+ do {
+ stop_idx = infopath.find(":");
+ string dir = infopath.substr(start_idx, stop_idx);
/* if this actually is a non-empty string, add it to paths[] */
- if ( dir && strlen(dir)>0 )
- {
- paths[numpaths++] = dir;
+ if (dir.length() > 0) {
+ paths[numpaths] = strdup(dir.c_str());
+ numpaths++;
}
- }
- xfree(c);
+ start_idx = stop_idx + 1;
+ } while (stop_idx != string::npos) ;
+
/* get the current $LANG, if any (to use for localized info pages) */
rawlang = getenv("LANG");
if (rawlang) {
@@ -849,6 +850,7 @@
}
}
}
+
/* if we have a LANG defined, add paths with this lang to the paths[] */
if (lang && strlen(lang)>0 )
{
More information about the Pinfo-devel
mailing list