cleanspell.pl 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/usr/bin/perl
  2. # Copyright (C) 2022 Daniel Stenberg, <daniel@haxx.se>, et al.
  3. #
  4. # SPDX-License-Identifier: curl
  5. #
  6. # Input: a libcurl nroff man page
  7. # Output: the same file, minus the SYNOPSIS and the EXAMPLE sections
  8. #
  9. my $f = $ARGV[0];
  10. my $o = $ARGV[1];
  11. open(F, "<$f") or die;
  12. open(O, ">$o") or die;
  13. my $ignore = 0;
  14. while(<F>) {
  15. if($_ =~ /^.SH (SYNOPSIS|EXAMPLE|\"SEE ALSO\"|SEE ALSO)/) {
  16. $ignore = 1;
  17. }
  18. elsif($ignore && ($_ =~ /^.SH/)) {
  19. $ignore = 0;
  20. }
  21. elsif(!$ignore) {
  22. # filter out mentioned CURLE_ names
  23. $_ =~ s/CURL(M|SH|U|H)code//g;
  24. $_ =~ s/CURL_(READ|WRITE)FUNC_[A-Z0-9_]*//g;
  25. $_ =~ s/CURL_CSELECT_[A-Z0-9_]*//g;
  26. $_ =~ s/CURL_DISABLE_[A-Z0-9_]*//g;
  27. $_ =~ s/CURL_FORMADD_[A-Z0-9_]*//g;
  28. $_ =~ s/CURL_HET_DEFAULT//g;
  29. $_ =~ s/CURL_IPRESOLVE_[A-Z0-9_]*//g;
  30. $_ =~ s/CURL_PROGRESSFUNC_CONTINUE//g;
  31. $_ =~ s/CURL_REDIR_[A-Z0-9_]*//g;
  32. $_ =~ s/CURL_RTSPREQ_[A-Z0-9_]*//g;
  33. $_ =~ s/CURL_TIMECOND_[A-Z0-9_]*//g;
  34. $_ =~ s/CURL_VERSION_[A-Z0-9_]*//g;
  35. $_ =~ s/CURLALTSVC_[A-Z0-9_]*//g;
  36. $_ =~ s/CURLAUTH_[A-Z0-9_]*//g;
  37. $_ =~ s/CURLE_[A-Z0-9_]*//g;
  38. $_ =~ s/CURLFORM_[A-Z0-9_]*//g;
  39. $_ =~ s/CURLFTP_[A-Z0-9_]*//g;
  40. $_ =~ s/CURLFTPAUTH_[A-Z0-9_]*//g;
  41. $_ =~ s/CURLFTPMETHOD_[A-Z0-9_]*//g;
  42. $_ =~ s/CURLFTPSSL_[A-Z0-9_]*//g;
  43. $_ =~ s/CURLGSSAPI_[A-Z0-9_]*//g;
  44. $_ =~ s/CURLHEADER_[A-Z0-9_]*//g;
  45. $_ =~ s/CURLINFO_[A-Z0-9_]*//g;
  46. $_ =~ s/CURLM_[A-Z0-9_]*//g;
  47. $_ =~ s/CURLMIMEOPT_[A-Z0-9_]*//g;
  48. $_ =~ s/CURLMOPT_[A-Z0-9_]*//g;
  49. $_ =~ s/CURLOPT_[A-Z0-9_]*//g;
  50. $_ =~ s/CURLPIPE_[A-Z0-9_]*//g;
  51. $_ =~ s/CURLPROTO_[A-Z0-9_]*//g;
  52. $_ =~ s/CURLPROXY_[A-Z0-9_]*//g;
  53. $_ =~ s/CURLPX_[A-Z0-9_]*//g;
  54. $_ =~ s/CURLSHE_[A-Z0-9_]*//g;
  55. $_ =~ s/CURLSHOPT_[A-Z0-9_]*//g;
  56. $_ =~ s/CURLSSH_[A-Z0-9_]*//g;
  57. $_ =~ s/CURLSSLBACKEND_[A-Z0-9_]*//g;
  58. $_ =~ s/CURLU_[A-Z0-9_]*//g;
  59. $_ =~ s/CURLUE_[A-Z0-9_]*//g;
  60. $_ =~ s/CURLUPART_[A-Z0-9_]*//g;
  61. $_ =~ s/CURLUSESSL_[A-Z0-9_]*//g;
  62. $_ =~ s/curl_global_(init_mem|sslset|cleanup)//g;
  63. $_ =~ s/curl_(strequal|strnequal|formadd|waitfd|formget|getdate|formfree)//g;
  64. $_ =~ s/curl_easy_(nextheader|duphandle)//g;
  65. $_ =~ s/curl_multi_fdset//g;
  66. $_ =~ s/curl_mime_(subparts|addpart|filedata|data_cb)//g;
  67. $_ =~ s/curl_ws_(send|recv|meta)//g;
  68. $_ =~ s/curl_url_(dup)//g;
  69. $_ =~ s/libcurl-env//g;
  70. $_ =~ s/(^|\W)((tftp|https|http|ftp):\/\/[a-z0-9\-._~%:\/?\#\[\]\@!\$&'()*+,;=]+)//gi;
  71. print O $_;
  72. }
  73. }
  74. close(F);
  75. close(O);