2 #***************************************************************************
4 # Project ___| | | | _ \| |
6 # | (__| |_| | _ <| |___
7 # \___|\___/|_| \_\_____|
9 # Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
11 # This software is licensed as described in the file COPYING, which
12 # you should have received as part of this distribution. The terms
13 # are also available at https://curl.se/docs/copyright.html.
15 # You may opt to use, copy, modify, merge, publish, distribute and/or sell
16 # copies of the Software, and permit persons to whom the Software is
17 # furnished to do so, under the terms of the COPYING file.
19 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 # KIND, either express or implied.
22 # SPDX-License-Identifier: curl
25 ###########################################################################
27 # Check the OS/400 translating wrapper properly handles all translatable
33 my $root=$ARGV[0] || ".";
34 my $incdir = "$root/include/curl";
35 my $os400dir = "$root/packages/OS400";
38 # Scan header file for string option definitions.
45 open(my $h, "<", "$f");
47 s/^\s*(.*?)\s*$/$1/; # Trim.
48 # Remove multi-line comment trail.
50 if($_ !~ /.*?\*\/\s*(.*)$/) {
61 if($_ =~ /^(.*)\\$/) {
66 while($_ =~ /^(.*?)\/\*.*?\*\/(.*)$/) {
69 if($_ =~ /^(.*)\/\*/) {
73 s/^\s*(.*?)\s*$/$1/; # Trim again.
74 # Ignore preprocessor directives and blank lines.
75 if($_ =~ /^(?:#|$)/) {
78 # Handle lines that may be continued as if they were folded.
79 if($_ !~ /[;,{}]$/ || $_ =~ /[^)],$/) {
84 # Keep string options only.
85 if($_ =~ /CURLOPT(?:DEPRECATED)?\s*\(\s*([^, \t]+)\s*,\s*CURLOPTTYPE_STRINGPOINT/) {
86 push(@stringopts, $1);
93 # Scan packages/OS400/ccsidcurl.c for translatable string option cases.
94 sub scan_wrapper_for_strings {
99 open(my $h, "<", "$f");
101 if($_ =~ /(BEGIN|END) TRANSLATABLE STRING OPTIONS/) {
102 $inarmor = $1 eq "BEGIN";
104 elsif($inarmor && $_ =~ /case\s+([^:]+):/) {
105 push(@stringopts, $1);
112 # Get translatable string options from header file.
113 my @stringdefs = scan_header("$incdir/curl.h");
115 # Get translated string options.
116 my @stringrefs = scan_wrapper_for_strings("$os400dir/ccsidcurl.c");
118 # Lists should be equal: check differences.
120 @diff{@stringdefs} = 0..$#stringdefs;
121 delete @diff{@stringrefs};
123 foreach(keys %diff) {
124 print "$_ is not translated\n";
129 @diff{@stringrefs} = 0..$#stringrefs;
130 delete @diff{@stringdefs};
132 foreach(keys %diff) {
133 print "translated option $_ does not exist\n";
137 # Check translated string option cases are sorted alphanumerically.
138 foreach(my $i = 1; $i < $#stringrefs; $i++) {
139 if($stringrefs[$i] lt $stringrefs[$i - 1]) {
140 print("Translated string options are not sorted (" . $stringrefs[$i - 1] .
141 "/" . $stringrefs[$i] . ")\n");