2
0

adddocsref.pl 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. # pass files as argument(s)
  26. my $docroot="https://curl.se/libcurl/c";
  27. for $f (@ARGV) {
  28. open(NEW, ">$f.new");
  29. open(F, "<$f");
  30. while(<F>) {
  31. my $l = $_;
  32. if($l =~ /\/* $docroot/) {
  33. # just ignore preciously added refs
  34. }
  35. elsif($l =~ /^( *).*curl_easy_setopt\([^,]*, *([^ ,]*) *,/) {
  36. my ($prefix, $anc) = ($1, $2);
  37. $anc =~ s/_//g;
  38. print NEW "$prefix/* $docroot/curl_easy_setopt.html#$anc */\n";
  39. print NEW $l;
  40. }
  41. elsif($l =~ /^( *).*(curl_([^\(]*))\(/) {
  42. my ($prefix, $func) = ($1, $2);
  43. print NEW "$prefix/* $docroot/$func.html */\n";
  44. print NEW $l;
  45. }
  46. else {
  47. print NEW $l;
  48. }
  49. }
  50. close(F);
  51. close(NEW);
  52. system("mv $f $f.org");
  53. system("mv $f.new $f");
  54. }