2
0

verify-synopsis.pl 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. my @files = @ARGV;
  26. my $cfile = "test.c";
  27. if($files[0] eq "-h") {
  28. print "Usage: verify-synopsis [man pages]\n";
  29. exit;
  30. }
  31. sub testcompile {
  32. my $rc = system("gcc -c test.c -DCURL_DISABLE_TYPECHECK -DCURL_ALLOW_OLD_MULTI_SOCKET -I include") >> 8;
  33. return $rc;
  34. }
  35. sub extract {
  36. my($f) = @_;
  37. my $syn = 0;
  38. my $l = 0;
  39. my $iline = 0;
  40. open(F, "<$f");
  41. open(O, ">$cfile");
  42. while(<F>) {
  43. $iline++;
  44. if(/^.SH SYNOPSIS/) {
  45. $syn = 1
  46. }
  47. elsif($syn == 1) {
  48. if(/^.nf/) {
  49. $syn++;
  50. print O "#line $iline \"$f\"\n";
  51. }
  52. }
  53. elsif($syn == 2) {
  54. if(/^.fi/) {
  55. last;
  56. }
  57. # turn the vararg argument into vararg
  58. $_ =~ s/, parameter\)\;/, ...);/;
  59. print O $_;
  60. $l++;
  61. }
  62. }
  63. close(F);
  64. close(O);
  65. return 0;
  66. }
  67. my $error;
  68. for my $m (@files) {
  69. print "Verify $m\n";
  70. extract($m);
  71. $error |= testcompile($m);
  72. }
  73. exit $error;