[Pinfo-devel] r97 - pinfo/branches/cxx/src
Nathanael Nerode
neroden-guest at costa.debian.org
Tue Aug 30 13:35:34 UTC 2005
Author: neroden-guest
Date: 2005-08-30 13:35:33 +0000 (Tue, 30 Aug 2005)
New Revision: 97
Modified:
pinfo/branches/cxx/src/filehandling_functions.cxx
pinfo/branches/cxx/src/filehandling_functions.h
pinfo/branches/cxx/src/pinfo.cxx
Log:
Convert pinfo_start_node.
Modified: pinfo/branches/cxx/src/filehandling_functions.cxx
===================================================================
--- pinfo/branches/cxx/src/filehandling_functions.cxx 2005-08-30 13:30:00 UTC (rev 96)
+++ pinfo/branches/cxx/src/filehandling_functions.cxx 2005-08-30 13:35:33 UTC (rev 97)
@@ -142,7 +142,7 @@
FILE *
dirpage_lookup(char **type, char ***message, long *lines,
- const string filename, char **first_node)
+ const string filename, string& first_node)
{
#define Type (*type)
#define Message (*message)
@@ -192,8 +192,7 @@
string::size_type idx = 0;
while (isspace(name[idx]))
idx++;
- string trimmed = name.substr(idx);
- *first_node = strdup(trimmed.c_str());
+ first_node = name.substr(idx);
}
if (id)
fclose(id); /* we don't need dirfile/badly matched infofile open anymore */
Modified: pinfo/branches/cxx/src/filehandling_functions.h
===================================================================
--- pinfo/branches/cxx/src/filehandling_functions.h 2005-08-30 13:30:00 UTC (rev 96)
+++ pinfo/branches/cxx/src/filehandling_functions.h 2005-08-30 13:35:33 UTC (rev 97)
@@ -85,7 +85,7 @@
*/
FILE *
dirpage_lookup (char **type, char ***message, long *lines,
- const std::string filename, char **first_node);
+ const std::string filename, std::string& first_node);
/* removes trailing .gz, .bz2, etc. */
void strip_compression_suffix (std::string& filename);
Modified: pinfo/branches/cxx/src/pinfo.cxx
===================================================================
--- pinfo/branches/cxx/src/pinfo.cxx 2005-08-30 13:30:00 UTC (rev 96)
+++ pinfo/branches/cxx/src/pinfo.cxx 2005-08-30 13:35:33 UTC (rev 97)
@@ -40,7 +40,7 @@
string curfile;
/* node specified by --node option */
-char *pinfo_start_node = 0;
+string pinfo_start_node;
/* strip `.info' suffix from "file" */
void strip_info_suffix_from_file(string& file);
@@ -92,8 +92,7 @@
printf(_("--node option used without argument\n"));
exit(1);
}
- pinfo_start_node = (char*)malloc(strlen(optarg) + 1);
- strcpy(pinfo_start_node, optarg);
+ pinfo_start_node = optarg;
break;
/* rcfile */
case 1:
@@ -273,9 +272,8 @@
if (j != string::npos) {
/* Looks like filename and node. */
/* copy the node content to pinfo_start_node */
- if (!pinfo_start_node)
- {
- pinfo_start_node=strdup(filename_string.substr(j+1).c_str());
+ if (pinfo_start_node == "") {
+ pinfo_start_node = filename_string.substr(j+1);
}
/* leave the filename part in filename */
filename_string.resize(j);
@@ -310,7 +308,7 @@
if (id == NULL)
{
id = dirpage_lookup(&type, &message, &lines, filename_string,
- &pinfo_start_node);
+ pinfo_start_node);
}
/* if still nothing, try to use man page instead */
@@ -363,9 +361,9 @@
return 1;
}
- if (pinfo_start_node)
+ if (pinfo_start_node != "")
{
- tag_table_pos = gettagtablepos(pinfo_start_node);
+ tag_table_pos = gettagtablepos(pinfo_start_node.c_str());
if (tag_table_pos == -1)
{
printf(_("Specified node does not exist...\n"));
More information about the Pinfo-devel
mailing list