* PChar -> PAnsiChar

This commit is contained in:
Michaël Van Canneyt 2023-01-14 14:54:04 +01:00
parent 62accca3a9
commit 414a55c3ce
2 changed files with 25 additions and 25 deletions

View File

@ -487,7 +487,7 @@ var
bversion, path: ansistring;
version: dword;
i: Integer;
s: string;
s: AnsiString;
begin
aspell_init := True;
libname := libn;

View File

@ -11,10 +11,10 @@ uses
SysUtils, Classes, Aspell;
type
TSuggestionArray = array of string;
TSuggestionArray = array of AnsiString;
TWordError = record
Word: string; // the word itself
Word: AnsiString; // the word itself
Pos: LongWord; // word position in line
Length: LongWord; // word length
Suggestions: TSuggestionArray; // suggestions for the given word
@ -27,21 +27,21 @@ type
TSpeller = class // abstract class, basis for all checkers
protected
FMode: string;
FEncoding: string;
FLanguage: string;
procedure SetEncoding(const AValue: string);
procedure SetLanguage(const AValue: string);
procedure SetMode(const AValue: string);
FMode: AnsiString;
FEncoding: AnsiString;
FLanguage: AnsiString;
procedure SetEncoding(const AValue: AnsiString);
procedure SetLanguage(const AValue: AnsiString);
procedure SetMode(const AValue: AnsiString);
procedure CreateSpeller; virtual; abstract;
procedure FreeSpeller; virtual; abstract;
public
constructor Create;
destructor Destroy; override;
public
property Mode: string read FMode write SetMode;
property Encoding: string read FEncoding write SetEncoding;
property Language: string read FLanguage write SetLanguage;
property Mode: AnsiString read FMode write SetMode;
property Encoding: AnsiString read FEncoding write SetEncoding;
property Language: AnsiString read FLanguage write SetLanguage;
end;
{ TWordSpeller }
@ -49,13 +49,13 @@ type
TWordSpeller = class(TSpeller) // class for simple per-word checking
private
FSpeller: PAspellSpeller;
FLastError: string;
FLastError: AnsiString;
function DoCreateSpeller(Lang, Enc, aMode: PAnsiChar): PAspellSpeller;
protected
procedure CreateSpeller; override;
procedure FreeSpeller; override;
public
function SpellCheck(const Word: string): TSuggestionArray; // use to check single words, parsed out by you
function SpellCheck(const Word: AnsiString): TSuggestionArray; // use to check single words, parsed out by you
end;
{ TDocumentSpeller }
@ -70,11 +70,11 @@ type
protected
procedure CreateSpeller; override;
procedure FreeSpeller; override;
procedure DoNameSuggestions(const Word: string; var aWordError: TWordError);
procedure DoNameSuggestions(const Word: AnsiString; var aWordError: TWordError);
public
constructor Create;
function CheckLine(const aLine: string): TLineErrors;
function CheckDocument(const FileName: string): Integer; // returns number of spelling errors found or -1 for error
function CheckLine(const aLine: AnsiString): TLineErrors;
function CheckDocument(const FileName: AnsiString): Integer; // returns number of spelling errors found or -1 for error
function CheckDocument(aStringList: TStringList): Integer; // returns number of spelling errors found or -1 for error
procedure Reset;
public
@ -90,7 +90,7 @@ const
DEFAULT_LANGUAGE = 'en';
DEFAULT_MODE = '';
function GetDefaultLanguage: string;
function GetDefaultLanguage: AnsiString;
begin
Result := GetEnvironmentVariable('LANG');
if Length(Result) = 0 then
@ -99,19 +99,19 @@ end;
{ TSpeller }
procedure TSpeller.SetEncoding(const AValue: string);
procedure TSpeller.SetEncoding(const AValue: AnsiString);
begin
FEncoding := aValue;
CreateSpeller;
end;
procedure TSpeller.SetLanguage(const AValue: string);
procedure TSpeller.SetLanguage(const AValue: AnsiString);
begin
FLanguage := aValue;
CreateSpeller;
end;
procedure TSpeller.SetMode(const AValue: string);
procedure TSpeller.SetMode(const AValue: AnsiString);
begin
FMode := aValue;
CreateSpeller;
@ -185,7 +185,7 @@ begin
end;
end;
function TWordSpeller.SpellCheck(const Word: string): TSuggestionArray;
function TWordSpeller.SpellCheck(const Word: AnsiString): TSuggestionArray;
var
sgs: Paspellwordlist;
elm: Paspellstringenumeration;
@ -252,7 +252,7 @@ begin
inherited FreeSpeller;
end;
procedure TDocumentSpeller.DoNameSuggestions(const Word: string;
procedure TDocumentSpeller.DoNameSuggestions(const Word: AnsiString;
var aWordError: TWordError);
begin
aWordError.Suggestions := SpellCheck(Word);
@ -265,7 +265,7 @@ begin
FNameSuggestions := True;
end;
function TDocumentSpeller.CheckLine(const aLine: string): TLineErrors;
function TDocumentSpeller.CheckLine(const aLine: AnsiString): TLineErrors;
const
CHUNK_SIZE = 10;
var
@ -300,7 +300,7 @@ begin
SetLength(Result, Count);
end;
function TDocumentSpeller.CheckDocument(const FileName: string): Integer;
function TDocumentSpeller.CheckDocument(const FileName: AnsiString): Integer;
var
s: TStringList;
begin