[Pinfo-devel] r143 - pinfo/branches/cxx/src
Nathanael Nerode
neroden-guest at costa.debian.org
Fri Sep 2 08:23:50 UTC 2005
Author: neroden-guest
Date: 2005-09-02 08:23:50 +0000 (Fri, 02 Sep 2005)
New Revision: 143
Modified:
pinfo/branches/cxx/src/manual.cxx
Log:
Convert interior of set_initial_history
Modified: pinfo/branches/cxx/src/manual.cxx
===================================================================
--- pinfo/branches/cxx/src/manual.cxx 2005-09-02 08:03:17 UTC (rev 142)
+++ pinfo/branches/cxx/src/manual.cxx 2005-09-02 08:23:50 UTC (rev 143)
@@ -154,26 +154,25 @@
void
set_initial_history(const char *name)
{
- int len = strlen(name), i;
- char *name1 = strdup(name);
+ string name2 = name;
/* filter trailing spaces */
- while ((len > 1) &&(isspace(name1[len - 1])))
- {
- name1[len - 1] = 0;
- len--;
- }
- i = len;
+ string::size_type len;
+ for (len = name2.length(); (len > 0) && isspace(name2[len - 1]); len--);
+ name2.resize(len);
+
/* find the beginning of the last token */
- for (i = len - 1;(i > 0) &&(!isspace(name1[i])); i--);
+ string::size_type i;
+ for (i = len - 1; (i > 0) && !isspace(name2[i]); i--);
/* if we've found space, then we move to the first nonspace character */
- if (i > 0)
+ if ( (i > 0) || (i == 0 && isspace(name2[i])) ) {
i++;
+ }
manhistory my_hist;
/* filename->name */
- my_hist.name = name1[i];
+ my_hist.name = name2.substr(i);
/* section unknown */
my_hist.sect = "";
/* selected unknown */
@@ -181,7 +180,6 @@
/* pos=0 */
my_hist.pos = 0;
manualhistory.push_back(my_hist);
- free(name1);
}
/* construct man name; take care about carry */
More information about the Pinfo-devel
mailing list