CRLF as line terminator in zone file

Joe Abley jabley at patho.gen.nz
Tue Oct 5 11:59:49 UTC 1999


On Tue, Oct 05, 1999 at 11:24:43PM +1300, Joe Abley wrote:
> > Sure, perl could get the job done as well.
> 
> And I could write a nice short piece of C which would be quicker
> than sed or perl, but I still think the functionality is valuable
> for bind.

Here's a patch for the release 8.2.1 source. It introduces a new
boolean option "treat-cr-as-space" in named.conf which, when turned
on, causes any CR's found in zone files to be treated as spaces.
It is off by default, with this patch applied.

Feedback welcome.


Joe

diff -u src.orig/bin/named/db_load.c src/bin/named/db_load.c
--- src.orig/bin/named/db_load.c	Sat Feb 14 09:02:28 1998
+++ src/bin/named/db_load.c	Wed Oct  6 00:09:35 1999
@@ -1375,6 +1375,11 @@
 			lineno++;
 			continue;
 
+		case '\r':
+			if (NS_OPTION_P(OPTION_TREAT_CR_AS_SPACE) != 0)
+				return (CURRENT); /* like ' ' or '\t' */
+			/* else treat as default (fall through below) */
+
 		default:
 			(void) ungetc(c, fp);
 			return (DNAME);
diff -u src.orig/bin/named/ns_defs.h src/bin/named/ns_defs.h
--- src.orig/bin/named/ns_defs.h	Tue Apr 14 12:35:09 1998
+++ src/bin/named/ns_defs.h	Wed Oct  6 00:36:30 1999
@@ -144,6 +144,7 @@
 					 * CNAME RRs */
 #define OPTION_HOSTSTATS	0x0080	/* Maintain per-host statistics? */
 #define OPTION_DEALLOC_ON_EXIT	0x0100	/* Deallocate everything on exit? */
+#define OPTION_TREAT_CR_AS_SPACE 0x0200	/* Treat 0x0d as 0x20 in zone files */
 
 #define	DEFAULT_OPTION_FLAGS	0
 
diff -u src.orig/bin/named/ns_lexer.c src/bin/named/ns_lexer.c
--- src.orig/bin/named/ns_lexer.c	Thu Dec  4 21:11:52 1997
+++ src/bin/named/ns_lexer.c	Wed Oct  6 00:24:44 1999
@@ -292,6 +292,7 @@
 	{"transfers-in", T_TRANSFERS_IN}, 
 	{"transfers-out", T_TRANSFERS_OUT}, 
 	{"transfers-per-ns", T_TRANSFERS_PER_NS}, 
+	{"treat-cr-as-space", T_TREAT_CR_AS_SPACE},
 	{"true", T_TRUE}, 
 	{"type", T_TYPE},
 	{"unlimited", T_UNLIMITED},
diff -u src.orig/bin/named/ns_parser.y src/bin/named/ns_parser.y
--- src.orig/bin/named/ns_parser.y	Thu Dec  4 20:03:05 1997
+++ src/bin/named/ns_parser.y	Wed Oct  6 00:28:44 1999
@@ -137,6 +137,7 @@
 %type	<axfr_fmt>	transfer_format
 %token			T_NOTIFY T_AUTH_NXDOMAIN T_MULTIPLE_CNAMES
 %token			T_CLEAN_INTERVAL T_INTERFACE_INTERVAL T_STATS_INTERVAL
+%token			T_TREAT_CR_AS_SPACE
 
 /* Items used for the "logging" statement: */
 %token			T_LOGGING T_CATEGORY T_CHANNEL T_SEVERITY T_DYNAMIC
@@ -398,6 +399,11 @@
 	| T_STATS_INTERVAL L_NUMBER
 	{
 		current_options->stats_interval = $2 * 60;
+	}
+	| T_TREAT_CR_AS_SPACE yea_or_nay
+        {
+                set_boolean_option(current_options, OPTION_TREAT_CR_AS_SPACE, $2);
+
 	}
 	| error
 	;


More information about the bind-users mailing list