#!/usr/bin/perl # # Copyright 2014 Chris Young # # This file is part of NetSurf, http://www.netsurf-browser.org/ # # NetSurf is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. # # NetSurf is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . use strict; use Getopt::Long (); use Fcntl qw( O_CREAT O_EXCL O_WRONLY O_APPEND O_RDONLY O_WRONLY ); use constant GETOPT_OPTS => qw( auto_abbrev no_getopt_compat bundling ); use constant GETOPT_SPEC => qw( output|o=s properties|p=s joining|j=s help|h|? ); # default option values: my %opt = qw(properties "idna-tables-properties.csv" joining "DerivedJoiningType.txt"); sub usage { my @fmt = map { s/::$//; $_ } keys(%{$::{'msgfmt::'}}); print(STDERR <; # discard header line while($line = <$properties>) { my @items = split(/\,/, $line); my @codepoints = split(/-/, $items[0]); if($#codepoints == 0) { $codepoints[1] = $codepoints[0]; } print { $output } "\t{ 0x" . $codepoints[0] . ", 0x" . $codepoints[1] . ", .p.property = IDNA_P_" . $items[1] . " },\n"; } close($properties); print { $output } <) { chop($line); if(substr($line, 0, 1) eq '#') {next;} if(length($line) == 0) {next;} my @items = split(/;/, $line); my @codepoints = split(/\./, $items[0]); if($#codepoints == 0) { $codepoints[2] = $codepoints[0]; } print { $output } "\t{ 0x" . $codepoints[0] . ", 0x" . $codepoints[2] . ", .p.jt = IDNA_UNICODE_JT_" . substr($items[1], 1, 1) . " },\n"; } close($joining); print { $output } <