2
0

adddocsref.pl 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/usr/bin/env perl
  2. #***************************************************************************
  3. # _ _ ____ _
  4. # Project ___| | | | _ \| |
  5. # / __| | | | |_) | |
  6. # | (__| |_| | _ <| |___
  7. # \___|\___/|_| \_\_____|
  8. #
  9. # Copyright (C) 2004 - 2020, 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.haxx.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. ###########################################################################
  23. # pass files as argument(s)
  24. my $docroot="https://curl.haxx.se/libcurl/c";
  25. for $f (@ARGV) {
  26. open(NEW, ">$f.new");
  27. open(F, "<$f");
  28. while(<F>) {
  29. my $l = $_;
  30. if($l =~ /\/* $docroot/) {
  31. # just ignore preciously added refs
  32. }
  33. elsif($l =~ /^( *).*curl_easy_setopt\([^,]*, *([^ ,]*) *,/) {
  34. my ($prefix, $anc) = ($1, $2);
  35. $anc =~ s/_//g;
  36. print NEW "$prefix/* $docroot/curl_easy_setopt.html#$anc */\n";
  37. print NEW $l;
  38. }
  39. elsif($l =~ /^( *).*(curl_([^\(]*))\(/) {
  40. my ($prefix, $func) = ($1, $2);
  41. print NEW "$prefix/* $docroot/$func.html */\n";
  42. print NEW $l;
  43. }
  44. else {
  45. print NEW $l;
  46. }
  47. }
  48. close(F);
  49. close(NEW);
  50. system("mv $f $f.org");
  51. system("mv $f.new $f");
  52. }