diff -ruN ../tcpspy-1.7a/rule.c ./rule.c
--- ../tcpspy-1.7a/rule.c	Fri Jun  1 22:22:54 2001
+++ ./rule.c	Sun Jan  6 17:57:47 2002
@@ -3,7 +3,7 @@
  *
  * This file is part of tcpspy, a TCP/IP connection monitor. 
  *
- * Copyright (c) 2000, 2001 Tim J. Robbins. 
+ * Copyright (c) 2000, 2001, 2002 Tim J. Robbins. 
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -40,6 +40,7 @@
 
 #include <assert.h>
 #include <fnmatch.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -494,6 +495,20 @@
 	rule_lexer_scan_string (r);
 	if (ruleparse () != 0)
 		abort ();
+}
+
+/*
+ * rule_parse_file ()
+ *
+ * Parse and compile the specified open file.
+ */
+void rule_parse_file (FILE *fp)
+{
+	extern void rulerestart (FILE *);
+	extern int ruleparse (void);
+
+	rulerestart (fp);
+	ruleparse ();
 }
 
 /*
diff -ruN ../tcpspy-1.7a/rule.h ./rule.h
--- ../tcpspy-1.7a/rule.h	Fri Jun  1 22:22:51 2001
+++ ./rule.h	Sun Jan  6 17:57:54 2002
@@ -3,7 +3,7 @@
  *
  * This file is part of tcpspy, a TCP/IP connection monitor. 
  *
- * Copyright (c) 2000, 2001 Tim J. Robbins. 
+ * Copyright (c) 2000, 2001, 2002 Tim J. Robbins. 
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -36,6 +36,7 @@
 
 #include <netinet/in.h>
 #include <sys/types.h>
+#include <stdio.h>
 #include <unistd.h>
 
 void rule_gen_user (uid_t uid);
@@ -50,6 +51,7 @@
 int rule_eval (uid_t muid, u_int32_t mladdr, u_int16_t mlport,
 		u_int32_t mraddr, u_int16_t mrport, const char *mexe);
 void rule_parse (const char *r);
+void rule_parse_file (FILE *fp);
 
 unsigned long st_store (const char *s);
 
diff -ruN ../tcpspy-1.7a/rule_grammar.y ./rule_grammar.y
--- ../tcpspy-1.7a/rule_grammar.y	Fri Jun  1 22:22:48 2001
+++ ./rule_grammar.y	Sun Jan  6 17:58:01 2002
@@ -4,7 +4,7 @@
  *
  * This file is part of tcpspy, a TCP/IP connection monitor.
  *
- * Copyright (c) 2000, 2001 Tim J. Robbins. 
+ * Copyright (c) 2000, 2001, 2002 Tim J. Robbins. 
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -44,6 +44,8 @@
 int yyerror ();
 extern int yylex ();
 
+extern int firstrule;
+
 %}
 
 %union {
@@ -76,8 +78,12 @@
 
 %%
 
-ruleset	:	/* empty */
-	|	rule ruleset
+ruleset	:	rule ruleset		{
+	if (!firstrule) rule_gen_or ();
+	firstrule = 0;
+}
+
+	|	/* empty */		{ } 
 	;
 
 rule	:	rule OR rule		{ rule_gen_or (); }
diff -ruN ../tcpspy-1.7a/rule_lexer.l ./rule_lexer.l
--- ../tcpspy-1.7a/rule_lexer.l	Fri Jun  1 22:22:48 2001
+++ ./rule_lexer.l	Sun Jan  6 17:58:08 2002
@@ -4,7 +4,7 @@
  *
  * This file is part of tcpspy, a TCP/IP connection monitor. 
  *
- * Copyright (c) 2000, 2001 Tim J. Robbins. 
+ * Copyright (c) 2000, 2001, 2002 Tim J. Robbins. 
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -179,6 +179,8 @@
 			rulelval.exe = st_store (yytext + 1);
 			return EXE_SPEC;
 			}
+
+<*>#.*\n		{ /* eat comments */ }
 
 <*>[ \n\t]		{ /* whitespace is ignored */ }
 
diff -ruN ../tcpspy-1.7a/tcpspy.8 ./tcpspy.8
--- ../tcpspy-1.7a/tcpspy.8	Fri Jun  1 22:24:06 2001
+++ ./tcpspy.8	Sun Jan  6 17:57:30 2002
@@ -1,6 +1,6 @@
 .\" This file is part of tcpspy, a TCP/IP connection monitor.
 .\"
-.\" Copyright (c) 2000, 2001 Tim J. Robbins. 
+.\" Copyright (c) 2000, 2001, 2002 Tim J. Robbins. 
 .\" All rights reserved.
 .\" 
 .\" Redistribution and use in source and binary forms, with or without
@@ -251,6 +251,11 @@
 .TP
 tcpspy -e 'exe "/usr/bin/irc"'
 Log connections made by /usr/bin/irc (probably ircII).
+
+.SH BUGS
+Empty rule files cause
+.B tcpspy
+to log no connections instead of all connections.
 
 .SH AUTHOR
 Tim J. Robbins <tim@robbins.dropbear.id.au>
diff -ruN ../tcpspy-1.7a/tcpspy.c ./tcpspy.c
--- ../tcpspy-1.7a/tcpspy.c	Sun Jan  6 16:04:14 2002
+++ ./tcpspy.c	Sun Jan  6 17:58:29 2002
@@ -3,7 +3,7 @@
  *
  * This file is part of tcpspy, a TCP/IP connection monitor.
  *
- * Copyright (c) 2000, 2001 Tim J. Robbins. 
+ * Copyright (c) 2000, 2001, 2002 Tim J. Robbins. 
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -458,10 +458,12 @@
 static void usage (void)
 {
 	fprintf (stderr, "usage: tcpspy [-dp] [-e rule]... [-f rulefile] [-I interval] "
-			"[-U user] [-G group]\n\t[-F facility] [-I interval]\n");
+			"[-U user]\n\t[-G group] [-F facility] [-I interval]\n");
 	exit (EXIT_FAILURE);
 }
 
+int firstrule = 1;
+
 int main (int argc, char *argv[])
 {
 	conntable_t old, new;
@@ -469,7 +471,7 @@
 	int ch;
 	uid_t dropuser = -1;
 	gid_t dropgroup = -1, defgroup = -1;
-	int debug = 0, firstrule = 1;
+	int debug = 0;
 
 	log_set_syslog ();
 
@@ -502,37 +504,15 @@
 			case 'f':
 			{
 				FILE *fp;
-				char fbuf[512];
-				unsigned lineno = 0;
-				char *c;
+
+				gotrule = 1; /* XXX */
 
 				if ((fp = fopen (optarg, "r")) == NULL) {
 					fprintf (stderr, "tcpspy: %s: %s\n", optarg, strerror (errno));
 					exit (EXIT_FAILURE);
 				}
 
-				while (fgets (fbuf, sizeof fbuf, fp) != NULL) {
-					lineno++;
-					if (fbuf[strlen (fbuf) - 1] != '\n') {
-						fprintf (stderr, "tcpspy: %s:%u: line too long or missing newline\n", optarg, lineno);
-						exit (EXIT_FAILURE);
-					}
-					/*
-					 * Remove newline, remove comments.
-					 */
-					fbuf[strlen (fbuf) - 1] = '\0';
-					if ((c = strchr (fbuf, '#')) != NULL)
-						*c = '\0';
-					/*
-					 * Skip blank lines or whole line comments.
-					 */
-					if (*fbuf == '\0') continue;
-
-					rule_parse (fbuf);
-					if (firstrule == 0) rule_gen_or ();
-					gotrule = 1;
-					firstrule = 0;
-				}
+				rule_parse_file (fp);
 
 				fclose (fp);
 			}
@@ -642,7 +622,7 @@
 					strerror (errno));
 			exit (EXIT_FAILURE);
 		} else if (p != 0) {
-			fprintf (stderr, "tcpspy 1.7 started (pid %d)\n", 
+			fprintf (stderr, "tcpspy 1.7b started (pid %d)\n", 
 					(int) p);
 			exit (EXIT_SUCCESS);
 		}
