test1276.pl 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. sub showline {
  26. my ($l) = @_;
  27. $l =~ s/([^\x20-\x7f])/sprintf "%%%02x", ord $1/eg;
  28. return $l;
  29. }
  30. my $root = $ARGV[0];
  31. open(my $fh, "-|", "perl $root/lib/optiontable.pl < $root/include/curl/curl.h");
  32. binmode $fh;
  33. my @gen=<$fh>;
  34. close($fh);
  35. open($fh, "<", "$root/lib/easyoptions.c");
  36. binmode $fh;
  37. my @file=<$fh>;
  38. close($fh);
  39. if(join("", @gen) ne join("", @file)) {
  40. print "easyoptions.c need to be regenerated!\n";
  41. printf "easyoptions.c is %u lines\n", scalar(@file);
  42. printf "generated file is %u lines\n", scalar(@gen);
  43. my $e = 0;
  44. for my $i (0 .. $#gen) {
  45. # strip CRLFs to unify
  46. $gen[$i] =~ s/[\r\n]//g;
  47. $file[$i] =~ s/[\r\n]//g;
  48. if($gen[$i] ne $file[$i]) {
  49. printf "File: %u:%s\nGen: %u:%s\n",
  50. $i+1, showline($file[$i]),
  51. $i+1, showline($gen[$i]);
  52. $e++;
  53. if($e > 10) {
  54. # only show 10 lines diff
  55. last;
  56. }
  57. }
  58. }
  59. exit 1 if($e);
  60. }