[Pinfo-devel] r166 - pinfo/branches/cxx/src
Nathanael Nerode
neroden-guest at costa.debian.org
Sun Sep 4 07:27:12 UTC 2005
Author: neroden-guest
Date: 2005-09-04 07:27:11 +0000 (Sun, 04 Sep 2005)
New Revision: 166
Modified:
pinfo/branches/cxx/src/datatypes.cxx
pinfo/branches/cxx/src/datatypes.h
pinfo/branches/cxx/src/manual.cxx
pinfo/branches/cxx/src/pinfo.cxx
Log:
Some "easy" string conversions and const-ifications.
Modified: pinfo/branches/cxx/src/datatypes.cxx
===================================================================
--- pinfo/branches/cxx/src/datatypes.cxx 2005-09-04 07:10:55 UTC (rev 165)
+++ pinfo/branches/cxx/src/datatypes.cxx 2005-09-04 07:27:11 UTC (rev 166)
@@ -90,7 +90,7 @@
* Add history entry
*/
void
-addinfohistory(const char *file, const char *node, int cursor, int menu, int pos)
+addinfohistory(string file, string node, int cursor, int menu, int pos)
{
InfoHistory my_hist;
my_hist.node = node;
Modified: pinfo/branches/cxx/src/datatypes.h
===================================================================
--- pinfo/branches/cxx/src/datatypes.h 2005-09-04 07:10:55 UTC (rev 165)
+++ pinfo/branches/cxx/src/datatypes.h 2005-09-04 07:27:11 UTC (rev 166)
@@ -186,7 +186,8 @@
/* initialize history (see struct above) * variables for `lastread' history */
void inithistory ();
/* adds a history entry to the info file `lastread' history */
-void addinfohistory (const char *file, const char *node, int cursor, int menu, int pos);
+void addinfohistory (std::string file, std::string node,
+ int cursor, int menu, int pos);
/* deletes last history entry */
void dellastinfohistory ();
Modified: pinfo/branches/cxx/src/manual.cxx
===================================================================
--- pinfo/branches/cxx/src/manual.cxx 2005-09-04 07:10:55 UTC (rev 165)
+++ pinfo/branches/cxx/src/manual.cxx 2005-09-04 07:27:11 UTC (rev 166)
@@ -598,14 +598,12 @@
/* look for the closing bracket */
if ((temp = strchr(link, ')')))
{
- char *p_t1, *p_t;
- p_t = p_t1 = (char*)xmalloc((strlen(link) + 10) * sizeof(char));
- for (++link; link != temp; *p_t++ = *link++);
- *p_t = '\0';
- link -=(strlen(p_t1) + sizeof(char));
+ string p_t_str;
+ p_t_str.assign(link + 1, temp - (link + 1));
- if ( !strchr(p_t1, '(') && is_in_manlinks(manlinks, string(p_t1)) )
- {
+ if ( (p_t_str.find('(') == string::npos)
+ && is_in_manlinks(manlinks, p_t_str)
+ ) {
int breakpos;
int i = link - tmp - 1;
if (i < 0)
@@ -649,7 +647,9 @@
if ( (!strcasecmp(chosen_name.c_str(),
manualhistory[manualhistory.size() - 1].name.c_str())
)
- && ( (!strcasecmp(p_t1, manualhistory[manualhistory.size() - 1].sect.c_str()))
+ && ( (!strcasecmp(p_t_str.c_str(),
+ manualhistory[manualhistory.size() - 1].sect.c_str())
+ )
|| (manualhistory[manualhistory.size() - 1].sect == "")
|| (manualhistory[manualhistory.size() - 1].sect == " ")
)
@@ -690,7 +690,6 @@
/* increase the number of entries */
manuallinks.push_back(my_link);
} /*... if (in man links) */
- xfree((void *) p_t1);
}
}
if (link)
Modified: pinfo/branches/cxx/src/pinfo.cxx
===================================================================
--- pinfo/branches/cxx/src/pinfo.cxx 2005-09-04 07:10:55 UTC (rev 165)
+++ pinfo/branches/cxx/src/pinfo.cxx 2005-09-04 07:27:11 UTC (rev 166)
@@ -32,7 +32,7 @@
#include <getopt.h>
#endif
-char *version = VERSION;
+const char * const version = VERSION;
int DontHandleWithoutTagTable = 0;
/* currently viewed filename */
@@ -395,7 +395,7 @@
/* handle goto/link where no file was found -- see bellow */
if (!filenotfound)
- addinfohistory(curfile.c_str(), tag_table[tag_table_pos].nodename.c_str(), -1, -1, -1);
+ addinfohistory(curfile, tag_table[tag_table_pos].nodename, -1, -1, -1);
else
filenotfound = 0;
work_return_value = work(&message, &type, &lines, id, tag_table_pos);
More information about the Pinfo-devel
mailing list