test1276.pl (2057B)
1 #!/usr/bin/env perl 2 #*************************************************************************** 3 # _ _ ____ _ 4 # Project ___| | | | _ \| | 5 # / __| | | | |_) | | 6 # | (__| |_| | _ <| |___ 7 # \___|\___/|_| \_\_____| 8 # 9 # Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 10 # 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. 14 # 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. 18 # 19 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 20 # KIND, either express or implied. 21 # 22 # SPDX-License-Identifier: curl 23 # 24 ########################################################################### 25 26 sub showline { 27 my ($l) = @_; 28 $l =~ s/([^\x20-\x7f])/sprintf "%%%02x", ord $1/eg; 29 return $l; 30 } 31 32 my $root = $ARGV[0]; 33 34 open(my $fh, "-|", "perl $root/lib/optiontable.pl < $root/include/curl/curl.h"); 35 binmode $fh; 36 my @gen=<$fh>; 37 close($fh); 38 39 open($fh, "<", "$root/lib/easyoptions.c"); 40 binmode $fh; 41 my @file=<$fh>; 42 close($fh); 43 44 if(join("", @gen) ne join("", @file)) { 45 print "easyoptions.c need to be regenerated!\n"; 46 47 printf "easyoptions.c is %u lines\n", scalar(@file); 48 printf "generated file is %u lines\n", scalar(@gen); 49 my $e = 0; 50 for my $i (0 .. $#gen) { 51 # strip CRLFs to unify 52 $gen[$i] =~ s/[\r\n]//g; 53 $file[$i] =~ s/[\r\n]//g; 54 if($gen[$i] ne $file[$i]) { 55 printf "File: %u:%s\nGen: %u:%s\n", 56 $i+1, showline($file[$i]), 57 $i+1, showline($gen[$i]); 58 $e++; 59 if($e > 10) { 60 # only show 10 lines diff 61 last; 62 } 63 } 64 } 65 exit 1 if($e); 66 }