shithub: riscv

Download patch

ref: 4908ea43d7603c435038de6739dd4589585b071b
parent: cd3a742b324a1256d52b42b82a90d335903f68e7
parent: 9dfe587b27af607a5bcfb9b695c642b7521c2d0d
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Nov 8 00:23:59 EST 2014

merge

--- a/sys/src/cmd/upas/smtp/smtpd.y
+++ b/sys/src/cmd/upas/smtp/smtpd.y
@@ -102,7 +102,7 @@
 element		: name			={ $$ = cat(&$1, 0, 0, 0, 0 ,0, 0); }
 		| '#' number		={ $$ = cat(&$1, &$2, 0, 0, 0 ,0, 0); }
 		| '[' ']'		={ $$ = cat(&$1, &$2, 0, 0, 0 ,0, 0); }
-		| '[' dotnum ']'	={ $$ = cat(&$1, &$2, &$3, 0, 0 ,0, 0); }
+		| '[' ipaddr ']'	={ $$ = cat(&$1, &$2, &$3, 0, 0 ,0, 0); }
 		;
 mailbox		: local_part		={ $$ = cat(&$1, 0, 0, 0, 0 ,0, 0); }
 		| local_part '@' domain	={ $$ = cat(&$3, bang, &$1, 0, 0 ,0, 0); }
@@ -142,13 +142,31 @@
 char		: c
 		| '\\' x		={ $$ = $2; }
 		;
-dotnum		: snum '.' snum '.' snum '.' snum ={ $$ = cat(&$1, &$2, &$3, &$4, &$5, &$6, &$7); }
+ipaddr		: ipv4addr				={ $$ = cat(&$1, 0, 0, 0, 0, 0, 0); }
+		| 'i' 'p' 'v' '6' ':' ipv6addr		={ $$ = cat(&$6, 0, 0, 0, 0, 0, 0); }
 		;
-number		: d		={ $$ = cat(&$1, 0, 0, 0, 0 ,0, 0); }
-		| number d	={ $$ = cat(&$1, &$2, 0, 0, 0 ,0, 0); }
+ipv6addr	: ipv6addr_list				={ $$ = cat(&$1, 0, 0, 0, 0, 0, 0); }
+		| ipv6addr_list ':' ':' ipv6addr_list	={ $$ = cat(&$1, &$2, &$3, &$4, 0, 0, 0); }
+		| ':' ':' ipv6addr_list			={ $$ = cat(&$1, &$2, &$3, 0, 0, 0, 0); }
 		;
+ipv6addr_list	: ipv6addr_elem				={ $$ = cat(&$1, 0, 0, 0, 0, 0, 0); }
+		| ipv6addr_list ':' ipv6addr_elem	={ $$ = cat(&$1, &$2, &$3, 0, 0, 0, 0); }
+		;
+ipv6addr_elem	: hnum					={ $$ = cat(&$1, 0, 0, 0, 0, 0, 0); }
+		| ipv4addr				={ $$ = cat(&$1, 0, 0, 0, 0, 0, 0); }
+		;
+ipv4addr	: snum '.' snum '.' snum '.' snum	={ $$ = cat(&$1, &$2, &$3, &$4, &$5, &$6, &$7); }
+		;
+number		: d		={ $$ = cat(&$1, 0, 0, 0, 0, 0, 0); }
+		| number d	={ $$ = cat(&$1, &$2, 0, 0, 0, 0, 0); }
+		;
 snum		: number		={ if(atoi(s_to_c($1.s)) > 255) fprint(2, "bad snum\n"); }
 		;
+hnum		: h		={ $$ = cat(&$1, 0, 0, 0, 0, 0, 0); }
+		| h h		={ $$ = cat(&$1, &$2, 0, 0, 0, 0, 0); }
+		| h h h		={ $$ = cat(&$1, &$2, &$3, 0, 0, 0, 0); }
+		| h h h h	={ $$ = cat(&$1, &$2, &$3, &$4, 0, 0, 0); }
+		;
 spaces		: SPACE		={ $$ = $1; }
 		| SPACE	spaces	={ $$ = $1; }
 		;
@@ -171,6 +189,8 @@
 		| 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z'
 		;
 d		: '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
+		;
+h		: d | 'a' | 'b' | 'c' | 'd' | 'e' | 'f'
 		;
 c		: a | d | notspecial
 		;