adddocsref.pl 874 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/perl
  2. # pass files as argument(s)
  3. my $docroot="http://curl.haxx.se/libcurl/c";
  4. for $f (@ARGV) {
  5. open(NEW, ">$f.new");
  6. open(F, "<$f");
  7. while(<F>) {
  8. my $l = $_;
  9. if($l =~ /\/* $docroot/) {
  10. # just ignore preciously added refs
  11. }
  12. elsif($l =~ /^( *).*curl_easy_setopt\([^,]*, *([^ ,]*) *,/) {
  13. my ($prefix, $anc) = ($1, $2);
  14. $anc =~ s/_//g;
  15. print NEW "$prefix/* $docroot/curl_easy_setopt.html#$anc */\n";
  16. print NEW $l;
  17. }
  18. elsif($l =~ /^( *).*(curl_([^\(]*))\(/) {
  19. my ($prefix, $func) = ($1, $2);
  20. print NEW "$prefix/* $docroot/$func.html */\n";
  21. print NEW $l;
  22. }
  23. else {
  24. print NEW $l;
  25. }
  26. }
  27. close(F);
  28. close(NEW);
  29. system("mv $f $f.org");
  30. system("mv $f.new $f");
  31. }