Procházet zdrojové kódy

Merged revisions 10213,10224,10226,10230 via svnmerge from
http://svn.freepascal.org/svn/fpc/trunk

........
r10213 | Almindor | 2008-02-04 22:14:11 +0100 (Po, 04 feb 2008) | 2 lines

* fix mis-type in one function return value

........
r10224 | Almindor | 2008-02-05 10:23:26 +0100 (Ut, 05 feb 2008) | 3 lines

* hopefully fix windows aspell compilation
* fix also darwin/macosx libaspell.15.dylib location

........
r10226 | Almindor | 2008-02-05 10:45:22 +0100 (Ut, 05 feb 2008) | 2 lines

* add additional path for libaspell on darwin

........
r10230 | Almindor | 2008-02-05 11:36:40 +0100 (Ut, 05 feb 2008) | 1 line

* fix windows compilation
........

git-svn-id: branches/fixes_2_2@10232 -

Almindor před 17 roky
rodič
revize
d5b42cc034
1 změnil soubory, kde provedl 41 přidání a 6 odebrání
  1. 41 6
      packages/aspell/src/aspell.pp

+ 41 - 6
packages/aspell/src/aspell.pp

@@ -24,7 +24,7 @@ uses
 {$ENDIF}
 
 {$IFDEF darwin}
- const libaspell = 'libaspell.dylib';
+ const libaspell = '/opt/local/lib/libaspell.15.dylib';
 {$ENDIF}
 
 {$IFDEF windows}
@@ -417,7 +417,7 @@ uses
      * misspelled words, then token.word will be
      * NULL and token.size will be 0  }
 
-    function aspell_document_checker_next_misspelling(ths:PAspellDocumentChecker):PAspellToken;cdecl;external libaspell name 'aspell_document_checker_next_misspelling';
+    function aspell_document_checker_next_misspelling(ths:PAspellDocumentChecker):AspellToken;cdecl;external libaspell name 'aspell_document_checker_next_misspelling';
 
     { Returns the underlying filter class.  }
 
@@ -822,7 +822,7 @@ var
        * misspelled words, then token.word will be
        * NULL and token.size will be 0  }
 
-  aspell_document_checker_next_misspelling: function(ths:PAspellDocumentChecker):PAspellToken;cdecl;
+  aspell_document_checker_next_misspelling: function(ths:PAspellDocumentChecker):AspellToken;cdecl;
 
       { Returns the underlying filter class.  }
 
@@ -997,7 +997,7 @@ end;
 
 uses
   {$IFDEF WINDOWS}
-  SysUtils,
+  Windows, SysUtils, Classes,
   {$ENDIF}
   dynlibs;
 
@@ -1005,6 +1005,35 @@ var
   LibHandle: TLibHandle = 0;
   AspellInited_: Boolean;
 
+{$IFDEF WINDOWS}
+function RegistryQueryValue (name,sub:shortstring):shortstring;
+const 
+  maxkeysize=255;
+var
+  buf:string [maxkeysize];
+  bufsize:longint;
+  buftype:longint;
+  res:longint;
+  key,rkey:hkey;
+  p,sp:pchar;
+
+begin
+  RegistryQueryValue:='';
+  name:=name+#0; p:=@name[1];
+  if sub='' then sp:=nil else begin sub:=sub+#0; sp:=@sub[1]; end;
+  bufsize:=maxkeysize;
+  buftype:=REG_SZ;
+  key:=HKEY_LOCAL_MACHINE;
+  res:=RegOpenKeyEx (key,p,0,KEY_QUERY_VALUE,rkey);
+  if res<>ERROR_SUCCESS then exit;
+  res:=RegQueryValueEx (rkey,sp,nil,@buftype,@buf[1],@bufsize);
+  if res<>ERROR_SUCCESS then exit;
+  buf[0]:=chr(bufsize-1);
+  RegCloseKey (rkey);
+  RegistryQueryValue:=buf;
+end;
+{$ENDIF}
+
 function aspell_init(const libn: ansistring): Boolean;
 var
   libname: ansistring;
@@ -1017,14 +1046,20 @@ begin
   libname := libn;
   
   {$IFDEF windows}
-  bversion := RegistryQueryValue(regLocalMachine,'SOFTWARE\Aspell','AspellVersion');
+  bversion := RegistryQueryValue('SOFTWARE\Aspell','AspellVersion');
   move(bversion[1], version, 4);
-  path := RegistryQueryValue(regLocalMachine,'SOFTWARE\Aspell','Path');
+  path := RegistryQueryValue('SOFTWARE\Aspell','Path');
   // will work if they passed %s, won't bork if they passed absolute
   libname := path + PathDelim + StringReplace(libn, '%s', IntToStr(Version), [rfReplaceAll]);
   {$ENDIF}
 
   LibHandle := LoadLibrary(libname);
+  {$ifdef darwin}
+  if LibHandle = 0 then begin
+    libname := '/sw/lib/libaspell.15.dylib';
+    LibHandle := LoadLibrary(libname);
+  end;
+  {$endif}
 
   if LibHandle = 0 then
     Exit(False);