3 # Copyright (C) 2002 Simon Josefsson
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 # I consider the output of this program to be unrestricted. Use it as
29 my ($starheader, $header);
30 my ($profile) = "generic";
31 my ($filename) = "stringprep_${profile}.c";
32 my ($line, $start, $end, @map);
34 open(FH
, ">$filename") or die "cannot open $filename for writing";
36 print FH
"#include <stringprep.h>\n";
41 die "already in table" if $intable && m
,^----- Start Table
(.*) -----,;
42 die "not in table" if !$intable && m
,^----- End Table
(.*) -----,;
44 if ($intable && m
,^----- End Table
(.*) -----,) {
45 die "table error" unless $1 eq $tablename ||
46 ($1 eq "C.1.2" && $tablename eq "C.1.1"); # Typo in draft
58 next unless ($intable || m
,^----- Start Table
(.*) -----,);
64 die "regexp failed on line: $line" unless
65 m
,^([0-9A
-F
]+)(-([0-9A
-F
]+))?
(; ([0-9A
-F
]+)( ([0-9A
-F
]+))?
( ([0-9A
-F
]+))?
( ([0-9A
-F
]+))?
;)?
,;
67 die "too many mapping targets on line: $line" if $12;
76 die "tables tried to map a range" if $end && $map[0];
79 printf FH
" { 0x%06s, 0, { 0x%06s,%*s/* %s */\n 0x%06s, 0x%06s, 0x%06s }},\n",
80 $start, $map[0], $tab-length($line)-13, " ", $line,
81 $map[1], $map[2], $map[3];
83 printf FH
" { 0x%06s, 0, { 0x%06s,%*s/* %s */\n 0x%06s, 0x%06s }},\n",
84 $start, $map[0], $tab-length($line)-14, " ", $line,
87 printf FH
" { 0x%06s, 0, { 0x%06s,%*s/* %s */\n 0x%06s }},\n",
88 $start, $map[0], $tab-length($line)-14, " ", $line,
91 printf FH
" { 0x%06s, 0, { 0x%06s }},%*s/* %s */\n",
92 $start, $map[0], $tab-length($line)-17, " ", $line;
94 printf FH
" { 0x%06s, 0x%06s },%*s/* %s */\n",
95 $start, $end, $tab-length($line)-11, " ", $line;
97 printf FH
" { 0x%06s },%*s/* %s */\n",
98 $start, $tab-length($line)-11, " ", $line;
101 $intable = 1 if !$intable;
104 ($varname = $tablename) =~ tr/./_/;
105 $header =~ s/\n/\n * /s;
107 print FH
"\n/*\n * $header */\n\n";
108 print FH
"Stringprep_table_element stringprep_${profile}_${varname}\[\] = {\n";
112 close FH
or die "cannot close $filename";