Develop and Download Open Source Software

Browse CVS Repository

Diff of /gikonavigoeson/gikonavi/GikoSystem.pas

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.184.2.7 by h677, Wed May 18 14:36:10 2005 UTC revision 1.184.2.8 by h677, Sat May 21 04:12:08 2005 UTC
# Line 526  var Line 526  var
526          ini: TMemIniFile;          ini: TMemIniFile;
527          ResRec: TResRec;          ResRec: TResRec;
528  //      RoundItem: TRoundItem;  //      RoundItem: TRoundItem;
529          idx: Integer;  //      idx: Integer;
530          usePlugIn : Boolean;          usePlugIn : Boolean;
531          tmpStr: string;          tmpStr: string;
532          BoardPath : String;          BoardPath : String;
# Line 1778  const Line 1778  const
1778                                                                           + '#$%&()*+,-./:;=?@[]^_`{|}~!''\';                                                                           + '#$%&()*+,-./:;=?@[]^_`{|}~!''\';
1779          ANCHOR_REF      = 'href=';          ANCHOR_REF      = 'href=';
1780          RES_REF                 = '>>';          RES_REF                 = '>>';
1781            REF_MARK: array[0..9] of string = ('http://', 'ttp://', 'tp://',
1782                                                                             'ms-help://','p://', 'https://',
1783                                                                             'www.', 'ftp://','news://','rtsp://');
1784    
1785  var  var
1786          wkIdx: array[0..9] of Integer;          wkIdx: array[0..9] of Integer;
1787          url: string;          url: string;
1788          href: string;          href: string;
1789          i, b: Integer;          i, j, b: Integer;
1790          idx: Integer;          tmp: Integer;
1791            idx, idx2: Integer;
1792          anchorLen : Integer;          anchorLen : Integer;
1793            pp, pe : PChar;
1794            pURLCHARs : PChar;
1795            pURLCHARe : PChar;
1796  begin  begin
1797          Result := '';          Result := '';
1798          // + 3 は 'href="' ('"'つき)などのバリエーションに余裕を持たせるため          // + 3 は 'href="' ('"'つき)などのバリエーションに余裕を持たせるため
1799          anchorLen := Length( ANCHOR_REF ) + 3;          anchorLen := Length( ANCHOR_REF ) + 3;
1800            pURLCHARs := PChar(URL_CHAR);
1801            pURLCHARe := pURLCHARs + Length(URL_CHAR);
1802          while True do begin          while True do begin
                 wkIdx[0] := AnsiPos('http://', s);  
                 wkIdx[1] := AnsiPos('ttp://', s);  
                 wkIdx[2] := AnsiPos('tp://', s);  
                 wkIdx[3] := AnsiPos('ms-help://', s);  
                 wkIdx[4] := AnsiPos('p://', s);  
                 wkIdx[5] := AnsiPos('https://', s);  
                 wkIdx[6] := AnsiPos('www.', s);  
                 wkIdx[7] := AnsiPos('ftp://', s);  
                 wkIdx[8] := AnsiPos('news://', s);  
                 wkIdx[9] := AnsiPos('rtsp://', s);  
   
1803                  idx := MaxInt;                  idx := MaxInt;
1804                  for i := 0 to 9 do                  for j := 0 to 9 do begin
1805                          if wkIdx[i] <> 0 then idx := Min(wkIdx[i], idx);                          tmp :=  AnsiPos(REF_MARK[j], s);
1806                            if tmp <> 0 then idx := Min(tmp, idx);
1807                            if idx = tmp then idx2 := j;   //どのマークで引っかかったかを保存
1808                    end;
1809                  if idx = MaxInt then begin                  if idx = MaxInt then begin
1810                          //リンクが無いよ。                          //リンクが無いよ。
1811                          Result := Result + s;                          Result := Result + s;
# Line 1823  begin Line 1823  begin
1823                          Continue;                          Continue;
1824                  end;                  end;
1825    
1826                  Result := Result + Copy(s, 0, idx - 1);                  Result := Result + Copy(s, 1, idx - 1);
   
                 s := Copy(s, idx, length(s));  
1827    
1828                    Delete(s, 1, idx - 1);
1829                  b := Length( s ) + 1;                  b := Length( s ) + 1;
1830                    pp      := PChar(s);
1831                  for i := 1 to b do begin                  for i := 1 to b do begin
1832                          if i = b then                          pe := AnsiStrPosEx(pURLCHARs, pURLCHARe, pp, pp + 1);
         idx := 0  
       else  
                                 idx := AnsiPos(s[i], URL_CHAR);  
                         if idx = 0 then begin  
                                 //URLじゃない文字発見!とか、文字がなくなった。  
                                 url := Copy(s, 0, i - 1);  
1833    
1834                                  if AnsiPos('ttp://', url) = 1 then                          if pe = nil then begin
1835                                          href := 'h' + url                                  //URLじゃない文字発見!とか、文字がなくなった。
1836                                  else if AnsiPos('tp://', url) = 1 then                                  url := Copy(s, 1, i - 1);
1837                                          href := 'ht' + url                                  case idx2 of
1838                                  else if AnsiPos('p://', url) = 1 then                                          1 : href := 'h' + url;
1839                                          href := 'htt' + url                                          2 : href := 'ht' + url;
1840                                  else if AnsiPos('www.', url) = 1 then                                          4 : href := 'htt' + url;
1841                                          href := 'http://' + url                                          6 : href := 'http://' + url;
1842                                  else                                  else
1843                                          href := url;                                          href := url;
1844                    end;
1845    
1846                                  Result := Result + '<a href="' + href + '" target="_blank">' + url + '</a>';                                  Result := Result + '<a href="' + href + '" target="_blank">' + url + '</a>';
1847                                  s := Copy(s, i, MaxInt);                                  Delete(s, 1, i - 1);
1848                                  Break;                                  Break;
1849                          end;                          end;
1850                //一文字進める。
1851                            Inc(pp);
1852                  end;                  end;
1853          end;          end;
1854  end;  end;
# Line 3660  end; Line 3658  end;
3658   *************************************************************************)   *************************************************************************)
3659  procedure TGikoSys.ReadBoardFile( bbs : TBBS );  procedure TGikoSys.ReadBoardFile( bbs : TBBS );
3660  var  var
3661          idx                                             : Integer;  //      idx                                             : Integer;
3662          ini                                             : TMemIniFile;          ini                                             : TMemIniFile;
3663          p : Integer;          p : Integer;
3664          boardFile                       : TStringList;          boardFile                       : TStringList;

Legend:
Removed from v.1.184.2.7  
changed lines
  Added in v.1.184.2.8

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26