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 26sub showline { 27 my ($l) = @_; 28 $l =~ s/([^\x20-\x7f])/sprintf "%%%02x", ord $1/eg; 29 return $l; 30} 31 32my $root = $ARGV[0]; 33 34open(my $fh, "-|", "perl $root/lib/optiontable.pl < $root/include/curl/curl.h"); 35binmode $fh; 36my @gen=<$fh>; 37close($fh); 38 39open($fh, "<", "$root/lib/easyoptions.c"); 40binmode $fh; 41my @file=<$fh>; 42close($fh); 43 44if(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} 67