diff -ur grep-dctrl-2.6.7.base/grep-dctrl.c grep-dctrl-2.6.7.hacked/grep-dctrl.c
--- grep-dctrl-2.6.7.base/grep-dctrl.c	2006-02-12 20:25:15.000000000 -0500
+++ grep-dctrl-2.6.7.hacked/grep-dctrl.c	2006-02-12 20:37:09.000000000 -0500
@@ -859,8 +859,10 @@
 
 		if (fname.mode == m_error) break;
 
+		debug_message("opening file", fname.s);
 		fd = open_ifile(fname);
 		if (fd == -1) break;
+		int lineno = 1;
 
 		{
 			struct stat stat;
@@ -889,9 +891,9 @@
 
 		FSAF * fp = fsaf_fdopen(fd);
 		para_t para;
-		for (para_init(&para, fp, &args.p.trie);
+		for (para_init(&para, fp, &args.p.trie, fname.s, &lineno);
 		     !para_eof(&para);
-		     para_parse_next(&para)) {
+		     para_parse_next(&para, fname.s, &lineno)) {
 			if ((args.invert_match || !does_para_satisfy(&args.p, &para))
 			    && (!args.invert_match || does_para_satisfy(&args.p, &para))) {
 				continue;
diff -ur grep-dctrl-2.6.7.base/paragraph.c grep-dctrl-2.6.7.hacked/paragraph.c
--- grep-dctrl-2.6.7.base/paragraph.c	2005-06-08 12:31:24.000000000 -0400
+++ grep-dctrl-2.6.7.hacked/paragraph.c	2006-02-12 21:02:28.000000000 -0500
@@ -21,17 +21,17 @@
 #include "paragraph.h"
 #include "strutil.h"
 
-void para_init(para_t * para, FSAF * fp, fieldtrie_t * trie)
+void para_init(para_t * para, FSAF * fp, fieldtrie_t * trie, const char * filename, int * lineno)
 {
 	para->fp = fp;
 	para->trie = trie;
 	para->start = 0;
 	para->end = 0;
 	para->eof = false;
-	para_parse_next(para);
+	para_parse_next(para, filename, lineno);
 }
 
-void para_parse_next(para_t * para)
+void para_parse_next(para_t * para, const char * filename, int * lineno)
 {
 	debug_message("para_parse_next", 0);
 	para->start = para->end;
@@ -63,6 +63,7 @@
 				break;
 			case '\n':
 				para->start++;
+				(*lineno)++;
 				break;
 			default:
 				field_start = --pos;
@@ -72,7 +73,7 @@
 		case FIELD_NAME:
 			switch (c) {
 			case -1:
-				message(L_FATAL, _("unexpected end of file"), 0);
+				line_message(L_FATAL, _("unexpected end of file"), filename, *lineno);
 				fail();
 			case ':': {
 				size_t len = (pos-1) - field_start;
@@ -91,16 +92,18 @@
 			}
 				break;
 			case '\n':
-				message(L_FATAL, _("unexpected end of line"), 0);
+				(*lineno)++;
+				line_message(L_FATAL, _("unexpected end of line"), filename, *lineno);
 				fail();
 			}
 			break;
 		case BODY:
 			switch (c) {
 			case -1:
-				message(L_FATAL, _("unexpected end of file"), 0);
+				line_message(L_FATAL, _("unexpected end of file"), filename, *lineno);
 				fail();
 			case '\n':
+				(*lineno)++;
 				if (field_data != 0) {
 					field_data->end = pos-1;
 					while (field_data->start < field_data->end
@@ -118,6 +121,8 @@
 				//para->eof = true;
 				/* pass through */
 			case '\n':
+				/* Don't count this newline: it'll be (re)counted when we enter
+				   START state for next paragraph */
 				state = END;
 				break;
 			case ' ': case '\t':
@@ -133,6 +138,7 @@
 			case -1:
 				/* pass through */
 			case '\n':
+				(*lineno)++;
 				state = END;
 				break;
 			case ' ': case '\t':
diff -ur grep-dctrl-2.6.7.base/paragraph.h grep-dctrl-2.6.7.hacked/paragraph.h
--- grep-dctrl-2.6.7.base/paragraph.h	2005-06-08 12:31:24.000000000 -0400
+++ grep-dctrl-2.6.7.hacked/paragraph.h	2006-02-12 20:37:14.000000000 -0500
@@ -44,9 +44,9 @@
 
 /* Initialize the given para_t, associating with it the given
  * FSAF and the field trie.  */
-void para_init(para_t *, FSAF *, fieldtrie_t *);
+void para_init(para_t *, FSAF *, fieldtrie_t *, const char *, int *);
 
-void para_parse_next(para_t *);
+void para_parse_next(para_t *, const char *, int *);
 
 static inline
 bool para_eof(para_t * para) { return para->eof; }

