4343 ' Draft' => ' ' ,
4444 ' Accepted' => ' A' ,
4545 ' Rejected' => ' R' ,
46- ' Withdrawn ' => ' W ' ,
46+ ' Replaced ' => ' P ' ,
4747 ' Deferred' => ' D' ,
4848 ' Final' => ' F' ,
4949 );
@@ -164,7 +164,7 @@ sub set_author {
164164}
165165
166166sub set_status {
167- m | ^ ([^/]*) (/? [^\s ]*) \s * (. *)| x ;
167+ m | ^ ([^/]*) (/? [^\s ]*) \s * ([^;] *)| x ;
168168 my ($status , $tag , $desc ) = ($1 , $2 , $3 );
169169 my $s = $status_map {lc $status };
170170 unless (defined $s ) {
@@ -196,7 +196,7 @@ sub set_type {
196196}
197197
198198# Mapping of EEP header tag to handler set_* function
199- my %key =
199+ my %set =
200200 (' eep' => \&set_eep,
201201 ' title' => \&set_title,
202202 ' version' => 0,
@@ -214,14 +214,43 @@ sub set_type {
214214 ' replaced-by' => 0,
215215 );
216216
217+ sub check_erlang_version {
218+ my $version = $_ ;
219+ if (defined ($version )) {
220+ push @warnings , " File $file : 'version: $version ' illegal!"
221+ unless $version =~ / OTP_R[0-9]+[AB]([-][0-9])?/ || $version =~ / OTP-([0-9]+)[.]/ ;
222+ } elsif ($status {$file } =~ / ^F\/ / ) {
223+ push @warnings , " File $file : 'version: EEPs in status Final must have an Erlang-Version!" ;
224+ }
225+ }
226+
227+ # Mapping of EEP header tag to handler check_* function
228+ my %check =
229+ (' eep' => 0,
230+ ' title' => 0,
231+ ' version' => 0,
232+ ' last-modified' => 0,
233+ ' author' => 0,
234+ ' discussions-to' => 0,
235+ ' status' => 0,
236+ ' type' => 0,
237+ ' content-type' => 0,
238+ ' requires' => 0,
239+ ' created' => 0,
240+ ' erlang-version' => \&check_erlang_version,
241+ ' post-history' => 0,
242+ ' replaces' => 0,
243+ ' replaced-by' => 0,
244+ );
245+
217246sub store_key {
218247 my ($hash , $key , $value ) = @_ ;
219- unless (defined $key {$key }) {
248+ unless (defined $set {$key }) {
220249 push
221250 @warnings ,
222251 " File $file : '$key :' unknown header - file skipped!" ;
223252 }
224- if ($key {$key }) {
253+ if ($set { $ key} || $check {$key }) {
225254 if (defined $$hash {$key }) {
226255 push
227256 @warnings ,
@@ -286,8 +315,8 @@ sub store_key {
286315 } elsif ($line =~ m | ^\s *$ | ) { # blank line
287316 # end of headers - process them all
288317 next LINE unless defined ($hdr {' eep' }); # still missing?
289- foreach (keys %key ) {
290- if ($key {$_ } and !(defined $hdr {$_ })) {
318+ foreach (keys %set ) {
319+ if ($set {$_ } and !(defined $hdr {$_ })) {
291320 push
292321 @warnings ,
293322 " File $file : '$_ :' missing header - file skipped!" ;
@@ -296,8 +325,14 @@ sub store_key {
296325 }
297326 # call handler for all headers
298327 while (($key , $_ ) = each %hdr ) {
299- &{$key {$key }};
328+ &{$set {$key }} if $set { $key };
300329 }
330+
331+ # call checks for all headers
332+ while (($key , $_ ) = each %hdr ) {
333+ &{$check {$key }} if $check {$key };
334+ }
335+
301336 last LINE;
302337 } else {
303338 push
@@ -369,7 +404,7 @@ sub table {
369404#
370405if (@warnings ) {
371406 print " ${lf}${lf}${lf} ----${lf} Warnings${lf} --------${lf} " ;
372- foreach (@warnings ) {
407+ foreach (sort @warnings ) {
373408 print " $_ " ;
374409 }
375410}
0 commit comments