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