--- lexer.l.orig	2002-10-09 22:16:35.000000000 -0700
+++ lexer.l	2002-10-19 08:58:31.000000000 -0700
@@ -51,6 +51,23 @@
 char *yylval;
 static char alt_text[MAXTOKENLEN];
 
+char *fgetsnull(char *buf, int max_size, FILE *s)
+{
+	int c;
+	char *cp = buf;
+
+	while ((c = fgetc(s)) >= '\0') {
+		if (c == '\0')
+			c = ' ';	/* NULL becomes space */
+		*cp++ = c;
+		if (c == '\n')
+			break;
+	}
+	*cp++ = '\0';
+	return(buf);
+}
+
+
 int yyinput(char *buf, int max_size)
 // input getter for the scanner
 {
@@ -60,12 +77,12 @@
     if (hdrlen==0)
 	hdrlen=strlen(SPAM_HEADER_NAME);
 
-    returned = fgets(buf, max_size, yyin);
+    returned = fgetsnull(buf, max_size, yyin);
 
     while (returned != NULL && memcmp(buf,SPAM_HEADER_NAME,hdrlen) == 0)
     {
 	do {
-	    returned = fgets(buf, max_size, yyin);
+	    returned = fgetsnull(buf, max_size, yyin);
 	    if (returned != NULL && *buf == '\n')
 		break;
 	} while (returned != NULL && isspace(*buf));
