annotate contrib/unicode2nginx/unicode-to-nginx.pl @ 8153:fcb2333c9982

Gzip: compatibility with recent zlib-ng versions. It now uses custom alloc_aligned() wrapper for all allocations, therefore all allocations are larger than expected by (64 + sizeof(void*)). Further, they are seen as allocations of 1 element. Relevant calculations were adjusted to reflect this, and state allocation is now protected with a flag to avoid misinterpreting other allocations as the zlib deflate_state allocation. Further, it no longer forces window bits to 13 on compression level 1, so the comment was adjusted to reflect this.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 27 Mar 2023 21:25:05 +0300
parents 8752257e883f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
667
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1 #!/usr/bin/perl -w
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
2
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
3 # Convert unicode mappings to nginx configuration file format.
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
4
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
5 # You may find useful mappings in various places, including
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
6 # unicode.org official site:
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
7 #
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
8 # http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1251.TXT
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
9 # http://www.unicode.org/Public/MAPPINGS/VENDORS/MISC/KOI8-R.TXT
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
10
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
11 # Needs perl 5.6 or later.
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
12
6665
8752257e883f Contrib: unicode2nginx compatibility with recent Perl versions.
Maxim Dounin <mdounin@mdounin.ru>
parents: 667
diff changeset
13 # Written by Maxim Dounin, mdounin@mdounin.ru
667
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
14
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
15 ###############################################################################
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
16
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
17 require 5.006;
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
18
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
19 while (<>) {
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
20 # Skip comments and empty lines
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
21
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
22 next if /^#/;
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
23 next if /^\s*$/;
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
24 chomp;
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
25
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
26 # Convert mappings
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
27
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
28 if (/^\s*0x(..)\s*0x(....)\s*(#.*)/) {
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
29 # Mapping <from-code> <unicode-code> "#" <unicode-name>
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
30 my $cs_code = $1;
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
31 my $un_code = $2;
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
32 my $un_name = $3;
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
33
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
34 # Produce UTF-8 sequence from character code;
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
35
6665
8752257e883f Contrib: unicode2nginx compatibility with recent Perl versions.
Maxim Dounin <mdounin@mdounin.ru>
parents: 667
diff changeset
36 my $un_utf8 = join('',
8752257e883f Contrib: unicode2nginx compatibility with recent Perl versions.
Maxim Dounin <mdounin@mdounin.ru>
parents: 667
diff changeset
37 map { sprintf("%02X", $_) }
8752257e883f Contrib: unicode2nginx compatibility with recent Perl versions.
Maxim Dounin <mdounin@mdounin.ru>
parents: 667
diff changeset
38 unpack("U0C*", pack("U", hex($un_code)))
8752257e883f Contrib: unicode2nginx compatibility with recent Perl versions.
Maxim Dounin <mdounin@mdounin.ru>
parents: 667
diff changeset
39 );
667
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
40
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
41 print " $cs_code $un_utf8 ; $un_name\n";
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
42
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
43 } else {
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
44 warn "Unrecognized line: '$_'";
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
45 }
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
46 }
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
47
63a820b0bc6c nginx-0.3.55-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
48 ###############################################################################