Bug 1874684 - Part 28: Return DateDuration from DifferenceISODateTime. r=mgaudet
[gecko.git] / gfx / thebes / genLanguageTagList.pl
blob0fa6c65f82fe5681451f1ec43408acc9a3365e52
1 #!/usr/bin/env perl
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 # This tool is used to prepare a list of valid language subtags from the
8 # IANA registry (http://www.iana.org/assignments/language-subtag-registry).
10 # Run as
12 # perl genLanguageTagList.pl language-subtag-registry > gfxLanguageTagList.cpp
14 # where language-subtag-registry is a copy of the IANA registry file.
16 use strict;
18 my $timestamp = gmtime();
19 print <<__END;
20 /* This Source Code Form is subject to the terms of the Mozilla Public
21 * License, v. 2.0. If a copy of the MPL was not distributed with this
22 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
25 * Derived from the IANA language subtag registry by genLanguageTagList.pl.
27 * Created on $timestamp.
29 * * * * * This file contains MACHINE-GENERATED DATA, do not edit! * * * * *
32 __END
34 my $isLanguage = 0;
36 while (<>) {
37 # strip leading/trailing whitespace, if any
38 chomp;
39 s/^\s+//;
40 s/\s+$//;
42 # assume File-Date precedes the actual list;
43 # record the date, and begin assignment to an array of valid tags
44 if (m/^File-Date:\s*(.+)$/) {
45 print "// Based on IANA registry dated $1\n\n";
46 print "static const uint32_t sLanguageTagList[] = {";
47 next;
50 if (m/^%%/) {
51 $isLanguage = 0;
52 next;
55 # we only care about records of type 'language'
56 if (m/^Type:\s*(.+)$/) {
57 $isLanguage = ($1 eq 'language');
58 next;
61 # append the tag to our string, with ";" as a delimiter
62 if ($isLanguage && m/^Subtag:\s*([a-z]{2,3})\s*$/) {
63 my $tagstr = $1;
64 print "\n TRUETYPE_TAG(",
65 join(",", map { $_ eq " " ? " 0 " : "'" . $_ . "'" } split(//, substr($tagstr . " ", 0, 4))),
66 "), // ", $tagstr;
67 next;
70 if ($isLanguage && m/^Description:\s*(.+)$/) {
71 print " = $1";
72 $isLanguage = 0; # only print first Description field
73 next;
77 # at end of file, terminate our assignment to the array of tags
78 print <<__END;
80 0x0 // end of language code list
84 * * * * * This file contains MACHINE-GENERATED DATA, do not edit! * * * * *
86 __END