[Pinfo-devel] r49 - pinfo/branches/cxx/src
Nathanael Nerode
neroden-guest at costa.debian.org
Fri Aug 26 11:15:38 UTC 2005
Author: neroden-guest
Date: 2005-08-26 11:15:34 +0000 (Fri, 26 Aug 2005)
New Revision: 49
Modified:
pinfo/branches/cxx/src/manual.cxx
pinfo/branches/cxx/src/manual.h
pinfo/branches/cxx/src/pinfo.cxx
pinfo/branches/cxx/src/video.cxx
Log:
Convert handle_manual to take a std::string argument.
Clean up getopts a little.
Remove now-unused info_addstr from video.cxx.
Modified: pinfo/branches/cxx/src/manual.cxx
===================================================================
--- pinfo/branches/cxx/src/manual.cxx 2005-08-26 10:53:45 UTC (rev 48)
+++ pinfo/branches/cxx/src/manual.cxx 2005-08-26 11:15:34 UTC (rev 49)
@@ -24,6 +24,8 @@
#include <ctype.h>
#include <sys/stat.h>
+#include <string>
+using std::string;
#define HTTPSECTION 100
#define FTPSECTION 101
@@ -151,7 +153,7 @@
/* initialize history variables for manual pages. */
void
-set_initial_history(char *name)
+set_initial_history(const char *name)
{
int len = strlen(name), i;
char *name1 = strdup(name);
@@ -243,7 +245,7 @@
/* this is something like main() function for the manual viewer code. */
int
-handlemanual(char * const name)
+handlemanual(string name)
{
int return_value = 0;
struct stat statbuf;
@@ -283,7 +285,7 @@
if (!plain_apropos)
snprintf(cmd, 255, "man %s %s %s > %s",
ManOptions,
- name,
+ name.c_str(),
StderrRedirection,
tmpfilename1);
if ((plain_apropos) ||(system(cmd) != 0))
@@ -298,7 +300,7 @@
{
printf(_("Calling apropos \n"));
apropos_tempfilename = tempnam("/tmp", NULL);
- snprintf(cmd, 255, "apropos %s > %s", name, apropos_tempfilename);
+ snprintf(cmd, 255, "apropos %s > %s", name.c_str(), apropos_tempfilename);
if (system(cmd) != 0)
{
printf(_("Nothing apropiate\n"));
@@ -315,7 +317,7 @@
init_curses();
- set_initial_history(name);
+ set_initial_history(name.c_str());
/* load manual to memory */
loadmanual(id);
fclose(id);
Modified: pinfo/branches/cxx/src/manual.h
===================================================================
--- pinfo/branches/cxx/src/manual.h 2005-08-26 10:53:45 UTC (rev 48)
+++ pinfo/branches/cxx/src/manual.h 2005-08-26 11:15:34 UTC (rev 49)
@@ -21,8 +21,9 @@
#ifndef __MANUAL_H
#define __MANUAL_H
+#include <string>
/* passes control to the manual code */
-int handlemanual (char *name);
+int handlemanual (std::string);
#endif
Modified: pinfo/branches/cxx/src/pinfo.cxx
===================================================================
--- pinfo/branches/cxx/src/pinfo.cxx 2005-08-26 10:53:45 UTC (rev 48)
+++ pinfo/branches/cxx/src/pinfo.cxx 2005-08-26 11:15:34 UTC (rev 49)
@@ -50,7 +50,7 @@
void checksu();
/* Get options. Split out of main() to shorten it. */
-int
+void
getopts(int argc, char *argv[], string& filename_string, FILE** id) {
#ifdef HAVE_GETOPT_LONG
static struct option long_options[] =
@@ -144,10 +144,7 @@
filename_string.append(argv[i]);
filename_string.append(" ");
}
- char filename[256];
- strncpy(filename, filename_string.c_str(), 200);
- exit(handlemanual(filename));
- /* This is weird in the extreme!!! Fixme. */
+ exit(handlemanual(filename_string));
}
case 'f':
case 'r':
@@ -177,11 +174,10 @@
break;
case 'p':
{
- char filename[256];
use_apropos = 1;
plain_apropos = 1;
- strncpy(filename, argv[argc - 1], 200);
- exit(handlemanual(filename));
+ string filename_string = argv[argc - 1];
+ exit(handlemanual(filename_string));
/* Again, really really weird. FIXME. */
}
break;
@@ -244,22 +240,24 @@
{
if (verbose)
printf(_("Looking for man page...\n"));
- strcpy(filename, "");
+ string filename_string;
/*
* pass all arguments to the `man' command(manhandler calls
* `man')
*/
for (int i = 1; i < argc; i++)
{
- strcat(filename, argv[i]);
- strcat(filename, " ");
+ filename_string.append(argv[i]);
+ filename_string.append(" ");
}
- exit(handlemanual(filename));
+ exit(handlemanual(filename_string));
}
+ /* Break out getopts to make main() smaller */
string filename_string;
FILE** idptr = &id;
getopts(argc, argv, filename_string, idptr);
+
if (filename_string != "") {
strncpy(filename, filename_string.c_str(), 200);
}
@@ -328,7 +326,8 @@
if (id == NULL)
{
printf(_("Error: could not open info file, trying manual\n"));
- exit(handlemanual(filename));
+ string filename_string = filename;
+ exit(handlemanual(filename_string));
}
/* search for indirect entries, if any */
if (seek_indirect(id))
@@ -369,7 +368,8 @@
if (TagTableEntries < 1)
{
printf(_("This doesn't look like info file...\n"));
- exit(handlemanual(filename));
+ string filename_string = filename;
+ exit(handlemanual(filename_string));
}
}
else
Modified: pinfo/branches/cxx/src/video.cxx
===================================================================
--- pinfo/branches/cxx/src/video.cxx 2005-08-26 10:53:45 UTC (rev 48)
+++ pinfo/branches/cxx/src/video.cxx 2005-08-26 11:15:34 UTC (rev 49)
@@ -131,16 +131,6 @@
refresh();
#endif /* __DEBUG__ */
}
-/*
- * Wrapper for the above for unconverted routines.
- */
-void
-info_addstr(int y, int x, char *txt, int column, int txtlen)
-{
- string newtxt;
- newtxt.assign(txt, txtlen);
- info_addstring(y, x, newtxt, column);
-}
void
info_add_highlights(int pos, int cursor, long lines, int column, char **message)
More information about the Pinfo-devel
mailing list