[Pinfo-devel] r248 - pinfo/branches/cxx/src
Nathanael Nerode
neroden-guest at costa.debian.org
Mon Sep 26 04:03:00 UTC 2005
Author: neroden-guest
Date: 2005-09-26 04:02:59 +0000 (Mon, 26 Sep 2005)
New Revision: 248
Modified:
pinfo/branches/cxx/src/datatypes.h
pinfo/branches/cxx/src/filehandling_functions.cxx
pinfo/branches/cxx/src/filehandling_functions.h
pinfo/branches/cxx/src/mainfunction.cxx
pinfo/branches/cxx/src/manual.cxx
pinfo/branches/cxx/src/pinfo.cxx
Log:
Miscellaneous cleanups, hopefully with no user-visible behavior.
Modified: pinfo/branches/cxx/src/datatypes.h
===================================================================
--- pinfo/branches/cxx/src/datatypes.h 2005-09-26 03:46:41 UTC (rev 247)
+++ pinfo/branches/cxx/src/datatypes.h 2005-09-26 04:02:59 UTC (rev 248)
@@ -26,9 +26,6 @@
#include <string>
#include <vector>
-#define FREE 0
-#define LOCKED 1
-
#define KEEP_HISTORY 1
#define KILL_HISTORY 2
@@ -37,27 +34,24 @@
#define HIGHLIGHT 1000
-typedef struct
+typedef struct SearchAgain
{
std::string lastsearch; /* last searched regexp */
char type; /* type of the last search (global/local) */
int search; /* if true -- search again */
-}
-SearchAgain;
+} SearchAgain;
typedef struct Indirect
{
long offset; /* offset of the node */
std::string filename; /* name of file, wherein the given offset is */
-}
-Indirect;
+} Indirect;
typedef struct TagTable
{
long offset; /* offset of the node */
std::string nodename; /* name of the node */
-}
-TagTable;
+} TagTable;
typedef struct InfoHistory
{
@@ -66,8 +60,7 @@
int pos; /* pos offset in viewed nodes */
int cursor; /* cursor offsets in viewed nodes */
int menu; /* menu position (in sequential reading) in viewed node */
-}
-InfoHistory;
+} InfoHistory;
typedef struct HyperObject
{
@@ -84,8 +77,7 @@
std::string node; /* name of the referenced node */
std::string file; /* name of the referenced file -- empty=this file */
int tagtableoffset; /* offset in tag table */
-}
-HyperObject;
+} HyperObject;
extern int verbose;
Modified: pinfo/branches/cxx/src/filehandling_functions.cxx
===================================================================
--- pinfo/branches/cxx/src/filehandling_functions.cxx 2005-09-26 03:46:41 UTC (rev 247)
+++ pinfo/branches/cxx/src/filehandling_functions.cxx 2005-09-26 04:02:59 UTC (rev 248)
@@ -1001,10 +1001,9 @@
}
void
-seeknode(int tag_table_pos, FILE ** Id)
+seeknode(int tag_table_pos, FILE * & id)
{
int i;
-#define id (*Id)
/*
* Indirect nodes are seeked using a formula:
* file-offset = tagtable_offset - indirect_offset +
@@ -1041,6 +1040,5 @@
else
fseek(id, off, SEEK_SET);
}
-#undef id
}
Modified: pinfo/branches/cxx/src/filehandling_functions.h
===================================================================
--- pinfo/branches/cxx/src/filehandling_functions.h 2005-09-26 03:46:41 UTC (rev 247)
+++ pinfo/branches/cxx/src/filehandling_functions.h 2005-09-26 04:02:59 UTC (rev 248)
@@ -38,7 +38,7 @@
void addrawpath (const std::string filename);
/* seek to a node in certain info file */
-void seeknode (int tag_table_pos, FILE ** Id);
+void seeknode (int tag_table_pos, FILE * & id);
/*
* Reads a node from 'id' to 'buf', and the header of node to 'type'.
Modified: pinfo/branches/cxx/src/mainfunction.cxx
===================================================================
--- pinfo/branches/cxx/src/mainfunction.cxx 2005-09-26 03:46:41 UTC (rev 247)
+++ pinfo/branches/cxx/src/mainfunction.cxx 2005-09-26 04:02:59 UTC (rev 248)
@@ -411,12 +411,11 @@
work(const vector<string>& my_message, string type_str, FILE * id, int tag_table_pos)
{
static WorkRVal rval;
- FILE *pipe;
- int cursorchanged = 0;
int key = 0;
int return_value;
- int statusline = FREE;
- /* if the static variable was allocated, free it */
+ bool statusline_locked = false;
+
+ /* reset the static return value variable */
rval.file = "";
rval.node = "";
rval.keep_going = false; /* Important */
@@ -479,14 +478,14 @@
key = pinfo_getch();
if (key == ERR)
{
- if (statusline == FREE) {
+ if (!statusline_locked) {
showscreen(my_message, pos, cursor, infocolumn);
}
waitforgetch();
key = pinfo_getch();
}
nodelay(stdscr, FALSE);
- statusline = FREE;
+ statusline_locked = false;
if (winchanged) /* SIGWINCH */
{
handlewinch();
@@ -587,6 +586,7 @@
if ((key == keys.shellfeed_1) ||
(key == keys.shellfeed_2))
{
+ FILE * pipe;
/* get command name */
attrset(bottomline);
move(maxy - 1, 0);
@@ -644,7 +644,7 @@
if (found_line == -1) {
attrset(bottomline);
mvaddstr(maxy - 1, 0, _("Search string not found..."));
- statusline = LOCKED;
+ statusline_locked = true;
}
if (return_value != -1) {
@@ -720,7 +720,7 @@
{
attrset(bottomline);
mvaddstr(maxy - 1, 0, _("Search string not found..."));
- statusline = LOCKED;
+ statusline_locked = true;
}
rescan_cursor(); /* rescan cursor position in the new place */
}
@@ -807,7 +807,7 @@
move(0, 0);
}
}
- statusline = LOCKED;
+ statusline_locked = true;
}
/*==========================================================================*/
if ((key == keys.prevnode_1) || /* goto previous node */
@@ -878,7 +878,7 @@
if ((key == keys.up_1) ||
(key == keys.up_2))
{
- cursorchanged = 0;
+ bool cursorchanged = false;
if (cursor != (typeof(hyperobjects.size()))-1) {
/* if we must handle cursor... */
if ((cursor > 0) && (hyperobjects.size()))
@@ -896,7 +896,7 @@
if (hyperobjects[i].type < HIGHLIGHT)
{
cursor = i;
- cursorchanged = 1;
+ cursorchanged = true;
break;
}
}
@@ -983,7 +983,7 @@
if ((key == keys.down_1) ||
(key == keys.down_2)) /* top+bottom line \|/ */
{
- cursorchanged = 0; /* works similar to keys.up */
+ bool cursorchanged = false; /* works similar to keys.up */
if (cursor < hyperobjects.size())
for (typeof(hyperobjects.size()) i = cursor + 1;
i < hyperobjects.size(); i++) {
@@ -993,7 +993,7 @@
if (hyperobjects[i].type < HIGHLIGHT)
{
cursor = i;
- cursorchanged = 1;
+ cursorchanged = true;
break;
}
}
@@ -1012,7 +1012,7 @@
if (hyperobjects[i].type < HIGHLIGHT)
{
cursor = i;
- cursorchanged = 1;
+ cursorchanged = true;
break;
}
}
Modified: pinfo/branches/cxx/src/manual.cxx
===================================================================
--- pinfo/branches/cxx/src/manual.cxx 2005-09-26 03:46:41 UTC (rev 247)
+++ pinfo/branches/cxx/src/manual.cxx 2005-09-26 04:02:59 UTC (rev 248)
@@ -89,7 +89,7 @@
vector<manuallink> manuallinks;
/* Debugging routine */
-void
+static void
dumplink(manuallink a) {
printf("LINK x%sx (x%sx %d) at %d %d (%d)\n\r", (a.name).c_str(),
(a.section).c_str(), a.section_mark,
@@ -853,14 +853,11 @@
static int
manualwork()
{
- /* for user's shell commands */
- FILE *pipe;
/* key, which contains the value entered by user */
int key = 0;
- /* tmp values */
- int selectedchanged;
- int statusline = FREE;
+ bool statusline_locked = false;
+
getmaxyx(stdscr, maxy, maxx);
check_manwidth();
@@ -886,14 +883,15 @@
if (key == ERR)
{
/* then show screen */
- if (statusline == FREE)
+ if (!statusline_locked) {
showmanualscreen();
+ }
wrefresh(stdscr);
waitforgetch();
key = pinfo_getch();
}
nodelay(stdscr, FALSE);
- statusline = FREE;
+ statusline_locked = false;
if (winchanged)
{
handlewinch();
@@ -992,6 +990,9 @@
if ((key == keys.shellfeed_1) ||
(key == keys.shellfeed_2))
{
+ /* for user's shell commands */
+ FILE *pipe;
+
/* get command name */
curs_set(1);
attrset(bottomline);
@@ -1122,7 +1123,7 @@
{
attrset(bottomline);
mvaddstr(maxy - 1, 0, _("Search string not found..."));
- statusline = LOCKED;
+ statusline_locked = true;
}
regex_is_current = true;
}
@@ -1150,7 +1151,7 @@
if ((key == keys.up_1) ||
(key == keys.up_2))
{
- selectedchanged = 0;
+ bool selectedchanged = false;
/* if there are links at all */
if (selected != -1)
{
@@ -1166,7 +1167,7 @@
(manuallinks[i].line < manualpos +(maxy - 1)))
{
selected = i;
- selectedchanged = 1;
+ selectedchanged = true;
break;
}
}
@@ -1275,7 +1276,7 @@
/* see keys.up for comments */
if ((key == keys.down_1) || (key == keys.down_2))
{
- selectedchanged = 0;
+ bool selectedchanged = false;
/* signed/unsigned issues with selected FIXME */
if (selected < manuallinks.size()) {
for (typeof(manuallinks.size()) i = selected + 1;
@@ -1283,7 +1284,7 @@
if ((manuallinks[i].line >= manualpos) &&
(manuallinks[i].line < manualpos +(lines_visible))) {
selected = i;
- selectedchanged = 1;
+ selectedchanged = true;
break;
}
}
@@ -1298,7 +1299,7 @@
if ((manuallinks[i].line >= manualpos) &&
(manuallinks[i].line < manualpos +(lines_visible))) {
selected = i;
- selectedchanged = 1;
+ selectedchanged = true;
break;
}
}
Modified: pinfo/branches/cxx/src/pinfo.cxx
===================================================================
--- pinfo/branches/cxx/src/pinfo.cxx 2005-09-26 03:46:41 UTC (rev 247)
+++ pinfo/branches/cxx/src/pinfo.cxx 2005-09-26 04:02:59 UTC (rev 248)
@@ -393,7 +393,7 @@
do
{
/* set seek offset for given node */
- seeknode(tag_table_pos, &id);
+ seeknode(tag_table_pos, id);
/* read the node */
read_item(id, type, message);
More information about the Pinfo-devel
mailing list