[Pinfo-devel] r254 - pinfo/branches/cxx/src

Nathanael Nerode neroden-guest at costa.debian.org
Mon Sep 26 05:20:54 UTC 2005


Author: neroden-guest
Date: 2005-09-26 05:20:53 +0000 (Mon, 26 Sep 2005)
New Revision: 254

Modified:
   pinfo/branches/cxx/src/colors.h
   pinfo/branches/cxx/src/common_includes.h
   pinfo/branches/cxx/src/keyboard.h
   pinfo/branches/cxx/src/mainfunction.cxx
   pinfo/branches/cxx/src/manual.cxx
   pinfo/branches/cxx/src/parse_config.cxx
   pinfo/branches/cxx/src/parse_config.h
   pinfo/branches/cxx/src/pinfo.cxx
   pinfo/branches/cxx/src/video.cxx
Log:
Reorganize header material from parse_config.h (leaving it rather empty);
make most functions in parse_config.cxx static.
Continue removing includes from common_includes.h in favor of individual
includes.



Modified: pinfo/branches/cxx/src/colors.h
===================================================================
--- pinfo/branches/cxx/src/colors.h	2005-09-26 05:03:16 UTC (rev 253)
+++ pinfo/branches/cxx/src/colors.h	2005-09-26 05:20:53 UTC (rev 254)
@@ -55,9 +55,33 @@
 extern int searchhighlight;
 
 #ifndef NO_COLOR_CURSES
+typedef struct colours
+{
+	int normal_fore, normal_back, normal_bold, normal_blink;
+	int menuselected_fore, menuselected_back, menuselected_bold, menuselected_blink;
+	int menu_fore, menu_back, menu_bold, menu_blink;
+	int noteselected_fore, noteselected_back, noteselected_bold, noteselected_blink;
+	int note_fore, note_back, note_bold, note_blink;
+	int topline_fore, topline_back, topline_bold, topline_blink;
+	int bottomline_fore, bottomline_back, bottomline_bold, bottomline_blink;
+	int manualbold_fore, manualbold_back, manualbold_bold, manualbold_blink;
+	int manualitalic_fore, manualitalic_back, manualitalic_bold, manualitalic_blink;
+	int url_fore, url_back, url_bold, url_blink;
+	int urlselected_fore, urlselected_back, urlselected_bold, urlselected_blink;
+	int infohighlight_fore, infohighlight_back, infohighlight_bold, infohighlight_blink;
+	int searchhighlight_fore, searchhighlight_back, searchhighlight_bold,
+		searchhighlight_blink;
+} colours;
+
 extern struct colours cols;
-#endif
+#endif /* NO_COLOR_CURSES */
 
+/* Monochrome defines */
+#define BOLD 1
+#define NO_BOLD 0
+#define BLINK 1
+#define NO_BLINK 0
+
 /*
  * initialize color values/attributes/etc.  Either for color and monochrome
  * mode.

Modified: pinfo/branches/cxx/src/common_includes.h
===================================================================
--- pinfo/branches/cxx/src/common_includes.h	2005-09-26 05:03:16 UTC (rev 253)
+++ pinfo/branches/cxx/src/common_includes.h	2005-09-26 05:20:53 UTC (rev 254)
@@ -60,8 +60,6 @@
 #include "filehandling_functions.h"
 #include "mainfunction.h"
 #include "utils.h"
-#include "parse_config.h"
-#include "initializelinks.h"
 
 /* I hear voices, that it is needed by RH5.2 ;) */
 #define _REGEX_RE_COMP

Modified: pinfo/branches/cxx/src/keyboard.h
===================================================================
--- pinfo/branches/cxx/src/keyboard.h	2005-09-26 05:03:16 UTC (rev 253)
+++ pinfo/branches/cxx/src/keyboard.h	2005-09-26 05:20:53 UTC (rev 254)
@@ -35,6 +35,39 @@
 
 /***********************************/
 
+typedef struct keybindings
+{
+	int totalsearch_1, totalsearch_2;
+	int search_1, search_2;
+	int goto_1, goto_2;
+	int prevnode_1, prevnode_2;
+	int nextnode_1, nextnode_2;
+	int upnode_1, upnode_2;
+	int up_1, up_2;
+	int end_1, end_2;
+	int pgdn_1, pgdn_2;
+	int home_1, home_2;
+	int pgup_1, pgup_2;
+	int down_1, down_2;
+	int top_1, top_2;
+	int back_1, back_2;
+	int followlink_1, followlink_2;
+	int quit_1, quit_2;
+	int refresh_1, refresh_2;
+	int shellfeed_1, shellfeed_2;
+	int dirpage_1, dirpage_2;
+	int pgdn_auto_1, pgdn_auto_2;
+	int pgup_auto_1, pgup_auto_2;
+	int search_again_1, search_again_2;
+	int goline_1, goline_2;
+	int twoup_1, twoup_2;
+	int twodown_1, twodown_2;
+	int print_1, print_2;
+	int left_1, left_2;
+	int right_1, right_2;
+}
+keybindings;
+
 /* a structure, which holds the keybindings */
 extern struct keybindings keys;
 

Modified: pinfo/branches/cxx/src/mainfunction.cxx
===================================================================
--- pinfo/branches/cxx/src/mainfunction.cxx	2005-09-26 05:03:16 UTC (rev 253)
+++ pinfo/branches/cxx/src/mainfunction.cxx	2005-09-26 05:20:53 UTC (rev 254)
@@ -31,6 +31,7 @@
 #include <ctype.h>
 
 #include "colors.h"
+#include "initializelinks.h"
 #include "keyboard.h"
 #include "printinfo.h"
 #include "regexp_search.h"

Modified: pinfo/branches/cxx/src/manual.cxx
===================================================================
--- pinfo/branches/cxx/src/manual.cxx	2005-09-26 05:03:16 UTC (rev 253)
+++ pinfo/branches/cxx/src/manual.cxx	2005-09-26 05:20:53 UTC (rev 254)
@@ -31,6 +31,7 @@
 #include <sys/stat.h>
 
 #include "colors.h"
+#include "initializelinks.h"
 #include "keyboard.h"
 #include "manual.h"
 #include "regexp_search.h"

Modified: pinfo/branches/cxx/src/parse_config.cxx
===================================================================
--- pinfo/branches/cxx/src/parse_config.cxx	2005-09-26 05:03:16 UTC (rev 253)
+++ pinfo/branches/cxx/src/parse_config.cxx	2005-09-26 05:20:53 UTC (rev 254)
@@ -31,6 +31,7 @@
 #include "colors.h"
 #include "datatypes.h"
 #include "keyboard.h"
+#include "parse_config.h"
 #include "regexp_search.h"
 
 #define COLOR_DEFAULT -1	/* mutt uses this was for transparency */
@@ -86,67 +87,31 @@
 	return str;
 }
 
-int
-parse_config(void)
+static char *
+skip_whitespace(char *str)
 {
-	string config_file_name;
-	string home;
-	FILE *f;
+	int i = 0;
 
-	if (rcfile != "") { /* User specified config file */
-		f = fopen(rcfile.c_str(), "r");
-		if (f == NULL) {
-			fprintf(stderr, _("Can't open config file!\n"));
-			exit(1);
-		}
-	} else { /* rcfile == "" */
-		char* rawhome = getenv("HOME");
-		if (rawhome != NULL)
-			home = rawhome;
-		if (home != "") {
-			config_file_name = home;
-			config_file_name += "/.pinforc";
-			f = fopen(config_file_name.c_str(), "r");
-			if (f == NULL) {
-				config_file_name = CONFIGDIR;
-				f = fopen(config_file_name.c_str(), "r");
-				if (f == NULL) {
-					return 0;	/* no config file available */
-				}
-			}
-		} else { /* home == "" */
-			config_file_name = CONFIGDIR;
-			f = fopen(config_file_name.c_str(), "r");
-			if (f == NULL) {
-				return 0; /* no config file available */
-			}
-		}
-	}
+	if (!str)
+		return NULL;
 
-	int line_number = 0;
-	while (!feof(f)) {
-		char line[256];
-		if (!(fgets(line, 255, f))) {
-			fclose(f);
-			return 0;
-		}
-		if (parse_line(line)) {
-			/* Line parse failure */
-			line_number++;
-			fclose(f);
-			fprintf(stderr, _("Parse error in config file on line %d\n"), line_number);
-			exit(1);
-		} else {
-			/* Line parsed successfully */
-			line_number++;
-		}
-	}
+	while (str[i] == ' ' || str[i] == '\t' || str[i] == '\n')
+		i++;
 
-	fclose(f);
-	return 0;
+	return str + i;
 }
 
-int
+static char *
+str_toupper(char *str)
+{
+	for (unsigned int i = 0; i < strlen(str); ++i)
+		if (islower(str[i]))
+			str[i] = toupper(str[i]);
+
+	return str;
+}
+
+static int
 parse_line(char *line)
 {
 	char *temp;
@@ -925,27 +890,63 @@
 	return 0;
 }
 
-char *
-str_toupper(char *str)
+int
+parse_config(void)
 {
-	for (unsigned int i = 0; i < strlen(str); ++i)
-		if (islower(str[i]))
-			str[i] = toupper(str[i]);
+	string config_file_name;
+	string home;
+	FILE *f;
 
-	return str;
-}
+	if (rcfile != "") { /* User specified config file */
+		f = fopen(rcfile.c_str(), "r");
+		if (f == NULL) {
+			fprintf(stderr, _("Can't open config file!\n"));
+			exit(1);
+		}
+	} else { /* rcfile == "" */
+		char* rawhome = getenv("HOME");
+		if (rawhome != NULL)
+			home = rawhome;
+		if (home != "") {
+			config_file_name = home;
+			config_file_name += "/.pinforc";
+			f = fopen(config_file_name.c_str(), "r");
+			if (f == NULL) {
+				config_file_name = CONFIGDIR;
+				f = fopen(config_file_name.c_str(), "r");
+				if (f == NULL) {
+					return 0;	/* no config file available */
+				}
+			}
+		} else { /* home == "" */
+			config_file_name = CONFIGDIR;
+			f = fopen(config_file_name.c_str(), "r");
+			if (f == NULL) {
+				return 0; /* no config file available */
+			}
+		}
+	}
 
-char *
-skip_whitespace(char *str)
-{
-	int i = 0;
+	int line_number = 0;
+	while (!feof(f)) {
+		char line[256];
+		if (!(fgets(line, 255, f))) {
+			fclose(f);
+			return 0;
+		}
+		if (parse_line(line)) {
+			/* Line parse failure */
+			line_number++;
+			fclose(f);
+			fprintf(stderr, _("Parse error in config file on line %d\n"), line_number);
+			exit(1);
+		} else {
+			/* Line parsed successfully */
+			line_number++;
+		}
+	}
 
-	if (!str)
-		return NULL;
-
-	while (str[i] == ' ' || str[i] == '\t' || str[i] == '\n')
-		i++;
-
-	return str + i;
+	fclose(f);
+	return 0;
 }
 

Modified: pinfo/branches/cxx/src/parse_config.h
===================================================================
--- pinfo/branches/cxx/src/parse_config.h	2005-09-26 05:03:16 UTC (rev 253)
+++ pinfo/branches/cxx/src/parse_config.h	2005-09-26 05:20:53 UTC (rev 254)
@@ -23,70 +23,8 @@
 #ifndef __PARSE_CONFIG_H
 #define __PARSE_CONFIG_H
 
-#define BOLD 1
-#define NO_BOLD 0
-#define BLINK 1
-#define NO_BLINK 0
-
-typedef struct keybindings
-{
-	int totalsearch_1, totalsearch_2;
-	int search_1, search_2;
-	int goto_1, goto_2;
-	int prevnode_1, prevnode_2;
-	int nextnode_1, nextnode_2;
-	int upnode_1, upnode_2;
-	int up_1, up_2;
-	int end_1, end_2;
-	int pgdn_1, pgdn_2;
-	int home_1, home_2;
-	int pgup_1, pgup_2;
-	int down_1, down_2;
-	int top_1, top_2;
-	int back_1, back_2;
-	int followlink_1, followlink_2;
-	int quit_1, quit_2;
-	int refresh_1, refresh_2;
-	int shellfeed_1, shellfeed_2;
-	int dirpage_1, dirpage_2;
-	int pgdn_auto_1, pgdn_auto_2;
-	int pgup_auto_1, pgup_auto_2;
-	int search_again_1, search_again_2;
-	int goline_1, goline_2;
-	int twoup_1, twoup_2;
-	int twodown_1, twodown_2;
-	int print_1, print_2;
-	int left_1, left_2;
-	int right_1, right_2;
-}
-keybindings;
-
-#ifndef NO_COLOR_CURSES
-typedef struct colours
-{
-	int normal_fore, normal_back, normal_bold, normal_blink;
-	int menuselected_fore, menuselected_back, menuselected_bold, menuselected_blink;
-	int menu_fore, menu_back, menu_bold, menu_blink;
-	int noteselected_fore, noteselected_back, noteselected_bold, noteselected_blink;
-	int note_fore, note_back, note_bold, note_blink;
-	int topline_fore, topline_back, topline_bold, topline_blink;
-	int bottomline_fore, bottomline_back, bottomline_bold, bottomline_blink;
-	int manualbold_fore, manualbold_back, manualbold_bold, manualbold_blink;
-	int manualitalic_fore, manualitalic_back, manualitalic_bold, manualitalic_blink;
-	int url_fore, url_back, url_bold, url_blink;
-	int urlselected_fore, urlselected_back, urlselected_bold, urlselected_blink;
-	int infohighlight_fore, infohighlight_back, infohighlight_bold, infohighlight_blink;
-	int searchhighlight_fore, searchhighlight_back, searchhighlight_bold,
-		searchhighlight_blink;
-}
-colours;
-#endif /* NO_COLOR_CURSES */
-
 extern int use_manual;
 
 int parse_config (void);
-int parse_line (char *line);
-char *str_toupper (char *s);
-char *skip_whitespace (char *s);
 
 #endif

Modified: pinfo/branches/cxx/src/pinfo.cxx
===================================================================
--- pinfo/branches/cxx/src/pinfo.cxx	2005-09-26 05:03:16 UTC (rev 253)
+++ pinfo/branches/cxx/src/pinfo.cxx	2005-09-26 05:20:53 UTC (rev 254)
@@ -33,6 +33,7 @@
 
 #include "colors.h"
 #include "manual.h"
+#include "parse_config.h"
 #include "regexp_search.h"
 #include "signal_handler.h"
 #include "tmpfiles.h"

Modified: pinfo/branches/cxx/src/video.cxx
===================================================================
--- pinfo/branches/cxx/src/video.cxx	2005-09-26 05:03:16 UTC (rev 253)
+++ pinfo/branches/cxx/src/video.cxx	2005-09-26 05:20:53 UTC (rev 254)
@@ -28,6 +28,7 @@
 using std::vector;
 
 #include "colors.h"
+#include "initializelinks.h" // for bletchulous calculate_len
 #include "regexp_search.h"
 
 /*




More information about the Pinfo-devel mailing list