JCF2: Use String type + UTF-8 instead of WideString. Prevents conversions and compiler warnings. Also related to issue #27945.

git-svn-id: trunk@51043 -
This commit is contained in:
juha 2015-12-26 16:52:28 +00:00
parent b6a09af5dc
commit 32f2f78b28
57 changed files with 276 additions and 575 deletions

1
.gitattributes vendored
View File

@ -2239,7 +2239,6 @@ components/jcf2/Utils/JcfLog.pas svneol=native#text/pascal
components/jcf2/Utils/JcfMiscFunctions.pas svneol=native#text/pascal
components/jcf2/Utils/JcfStringUtils.pas svneol=native#text/pascal
components/jcf2/Utils/JcfSystemUtils.pas svneol=native#text/pascal
components/jcf2/Utils/JcfUnicode.pas svneol=native#text/pascal
components/jcf2/Utils/JcfUnicodeFiles.pas svneol=native#text/pascal
components/jcf2/readme.txt svneol=native#text/plain
components/lazcontrols/Makefile svneol=native#text/plain

View File

@ -55,7 +55,7 @@ const
FORMAT_CURRENT_NAME = 'jcfCurrentEditorWindow';
FORMAT_PROJECT_MENU_NAME = 'jcfAllFilesinProject';
FORMAT_OPEN_MENU_NAME = 'jcfAllOpenWindows';
FORMAT_REG_SETTINGS_MENU_NAME = 'jcfRegistrySettings';
//FORMAT_REG_SETTINGS_MENU_NAME = 'jcfRegistrySettings';
FORMAT_SETTINGS_MENU_NAME = 'jcfFormatSettings';
FORMAT_ABOUT_MENU_NAME = 'jcfAbout';
FORMAT_CATEGORY_IDECMD_NAME = 'jcfFormat';
@ -68,7 +68,7 @@ resourcestring
FORMAT_CURRENT_IDECMD = 'Format code in current editor window';
FORMAT_PROJECT_MENU = '&All Files in Project';
FORMAT_OPEN_MENU = 'All &Open Windows';
FORMAT_REG_SETTINGS_MENU = '&Registry Settings';
//FORMAT_REG_SETTINGS_MENU = '&Registry Settings';
FORMAT_SETTINGS_MENU = '&Format Settings';
FORMAT_ABOUT_MENU = '&About';
FORMAT_CATEGORY_IDECMD = 'JEDI Code Format';

View File

@ -202,7 +202,7 @@ end;
procedure TfmJCFNotepad.DoFileOpen(const psFileName: string);
var
lsFileContents: WideString;
lsFileContents: String;
begin
if psFileName = '' then
exit;

View File

@ -291,8 +291,7 @@ uses
{ delphi }
SysUtils, Forms,
{ local }
JcfStringUtils,
JcfUnicode;
JcfStringUtils;
const
UPDATE_INTERVAL = 512;
@ -2631,7 +2630,7 @@ begin
begin
lc2 := fcTokenList.SolidToken(2);
lbOldStyleCharEscape := (lc2 <> nil) and (Length(lc2.Sourcecode) = 1) and
not (WideCharIsAlpha(lc2.Sourcecode[1]));
not (CharIsAlpha(lc2.Sourcecode[1]));
end
else
lc2 := nil;
@ -5236,7 +5235,7 @@ end;
procedure TBuildParseTree.RecogniseAsmFactor;
var
lcNext: TSourceToken;
lcLastChar: WideChar;
lcLastChar: Char;
begin
if fcTokenList.FirstSolidTokenType = ttNot then
Recognise(ttNot);
@ -5590,7 +5589,6 @@ begin
Result := False;
lc := fcTokenList.FirstSolidToken;
if lc.TokenType in [ttProcedure, ttFunction] then
begin
lcNext := fcTokenList.SolidToken(2);
@ -5620,7 +5618,7 @@ begin
if fcTokenList.FirstTokenLength = 1 then
Recognise(fcTokenList.FirstTokenType)
else
raise TEParseError.Create('Unexpected token, expected single char after ^', fcTokenList.FirstSolidToken);
raise TEParseError.Create('Unexpected token, expected single char after ^', fcTokenList.FirstSolidToken);
end;
ttHash:
begin

View File

@ -45,18 +45,18 @@ type
TBuildTokenList = class(TObject)
private
{ property implementation }
fsSourceCode: WideString;
fsSourceCode: String;
fsFileName: string;
{ woker procs }
fiCurrentIndex: integer;
procedure SetSourceCode(const Value: WideString);
procedure SetSourceCode(const Value: String);
function Current: WideChar;
function CurrentChars(const piCount: integer): WideString;
function ForwardChar(const piOffset: integer): WideChar;
function ForwardChars(const piOffset, piCount: integer): WideString;
function Current: Char;
function CurrentChars(const piCount: integer): String;
function ForwardChar(const piOffset: integer): Char;
function ForwardChars(const piOffset, piCount: integer): String;
procedure Consume(const piCount: integer = 1);
function EndOfFile: boolean;
function EndOfFileAfter(const piChars: integer): boolean;
@ -70,7 +70,7 @@ type
function TryWhiteSpace(const pcToken: TSourceToken): boolean;
function TryLiteralString(const pcToken: TSourceToken;
const pcDelimiter: WideChar): boolean;
const pcDelimiter: Char): boolean;
function TryNumber(const pcToken: TSourceToken): boolean;
function TryHexNumber(const pcToken: TSourceToken): boolean;
@ -95,7 +95,7 @@ type
function BuildTokenList: TSourceTokenList;
property SourceCode: WideString read fsSourceCode write SetSourceCode;
property SourceCode: String read fsSourceCode write SetSourceCode;
property FileName: string read fsFileName write fsFileName;
end;
@ -106,14 +106,13 @@ uses
Forms, SysUtils,
{ local }
JcfStringUtils, JcfSystemUtils,
JcfUnicode,
JcfRegistrySettings;
const
CurlyLeft = widechar(123);
CurlyRight = widechar(125);
CurlyLeft = '{'; //widechar(123);
CurlyRight = '}'; //widechar(125);
function CheckMultiByte(const pcChar: widechar): boolean;
function CheckMultiByte(const pcChar: char): boolean;
begin
Result := False;
if GetRegSettings.CheckMultiByteChars then
@ -133,7 +132,7 @@ begin
inherited;
end;
procedure TBuildTokenList.SetSourceCode(const Value: WideString);
procedure TBuildTokenList.SetSourceCode(const Value: String);
begin
fsSourceCode := Value;
// reset the index
@ -267,7 +266,7 @@ var
lNestedDepth: integer;
procedure MoveToCommentEnd;
var
lForwardChar:widechar;
lForwardChar: char;
begin
{ comment is ended by (close-curly AND lNestedDepth=0) or by EOF (bad source) }
while True do
@ -333,7 +332,7 @@ var
continue;
end;
if WideCharIsReturn(ForwardChar(liCommentLength)) then
if CharIsReturn(ForwardChar(liCommentLength)) then
break;
inc(liCommentLength);
@ -364,10 +363,10 @@ end;
function TBuildTokenList.TryReturn(const pcToken: TSourceToken): boolean;
var
chNext: WideChar;
chNext: Char;
begin
Result := False;
if not WideCharIsReturn(Current) then
if not CharIsReturn(Current) then
exit;
Result := True;
@ -380,7 +379,7 @@ begin
{ concat the next return char if it is not the same
This will recognise <cr><lf> or <lf><cr>, but not <cr><cr> }
chNext := Current;
if WideCharIsReturn(chNext) and (chNext <> pcToken.SourceCode[1]) then
if CharIsReturn(chNext) and (chNext <> pcToken.SourceCode[1]) then
begin
pcToken.SourceCode := pcToken.SourceCode + chNext;
Consume;
@ -389,7 +388,7 @@ end;
{ complexities like 'Hello'#32'World' and #$12'Foo' are assemlbed in the parser }
function TBuildTokenList.TryLiteralString(const pcToken: TSourceToken;
const pcDelimiter: WideChar): boolean;
const pcDelimiter: Char): boolean;
begin
Result := False;
@ -404,7 +403,7 @@ begin
repeat
if Current = #0 then
break;
if WideCharIsReturn(Current) then
if CharIsReturn(Current) then
Raise Exception.Create('Unterminated string: ' + pcToken.SourceCode);
{ two quotes in a row are still part of the string }
@ -442,14 +441,14 @@ function TBuildTokenList.TryWord(const pcToken: TSourceToken): boolean;
begin
Result := False;
if not WideCharIsWordChar(Current) then
if not CharIsWordChar(Current) then
exit;
pcToken.SourceCode := Current;
Consume;
{ concat any subsequent word chars }
while WideCharIsWordChar(Current) or WideCharIsDigit(Current) do
while CharIsWordChar(Current) or CharIsDigit(Current) do
begin
pcToken.SourceCode := pcToken.SourceCode + Current;
Consume;
@ -466,7 +465,7 @@ end;
function TBuildTokenList.TryWhiteSpace(const pcToken: TSourceToken): boolean;
begin
Result := False;
if not WideCharIsWhiteSpaceNoReturn(Current) then
if not CharIsWhiteSpaceNoReturn(Current) then
exit;
pcToken.TokenType := ttWhiteSpace;
@ -474,7 +473,7 @@ begin
Consume;
{ concat any subsequent return chars }
while WideCharIsWhiteSpaceNoReturn(Current) do
while CharIsWhiteSpaceNoReturn(Current) do
begin
pcToken.SourceCode := pcToken.SourceCode + Current;
Consume;
@ -485,7 +484,7 @@ end;
function TBuildTokenList.TryAssign(const pcToken: TSourceToken): boolean;
var
TwoChars: WideString;
TwoChars: String;
begin
Result := False;
@ -532,7 +531,7 @@ begin
and -.3 is not legal at all }
{ first one must be a digit }
if not WideCharIsDigit(Current) then
if not CharIsDigit(Current) then
exit;
if (Current = '.') or (Current = '-') then
@ -551,7 +550,7 @@ begin
ie one dat = decimal
two dots = end of number
}
while WideCharIsDigit(Current) or (Current = '.') do
while CharIsDigit(Current) or (Current = '.') do
begin
// have we got to the dot?
if (Current = '.') then
@ -573,21 +572,21 @@ begin
{ scientific notation suffix, eg 3e2 = 30, 2.1e-3 = 0.0021 }
{ check for a trailing 'e' }
if WideCharInSet(Current, ['e', 'E']) then
if CharInSet(Current, ['e', 'E']) then
begin
// sci notation mode
pcToken.SourceCode := pcToken.SourceCode + Current;
Consume;
// can be a minus or plus here
if WideCharInSet(Current, ['-', '+']) then
if CharInSet(Current, ['-', '+']) then
begin
pcToken.SourceCode := pcToken.SourceCode + Current;
Consume;
end;
{ exponent must be integer }
while WideCharIsDigit(Current) do
while CharIsDigit(Current) do
begin
pcToken.SourceCode := pcToken.SourceCode + Current;
Consume;
@ -615,7 +614,7 @@ begin
lbHasDecimalSep := False;
{ concat any subsequent number chars }
while WideCharIsHexDigitDot(Current) do
while CharIsHexDigitDot(Current) do
begin
// have we got to the dot?
if (Current = '.') then
@ -651,7 +650,7 @@ begin
Consume;
{ concat any subsequent binary chars }
while WideCharIsBinDigit(Current) do
while CharIsBinDigit(Current) do
begin
pcToken.SourceCode := pcToken.SourceCode + Current;
Consume;
@ -688,7 +687,7 @@ end;
function TBuildTokenList.TryPunctuation(const pcToken: TSourceToken): boolean;
function FollowsPunctuation(const chLast, ch: WideChar): boolean;
function FollowsPunctuation(const chLast, ch: Char): boolean;
const
{ These have meanings on thier own and should not be recognised as part of the punc.
e.g '=(' is not a punctation symbol, but 2 of them ( for e.g. in const a=(3);
@ -709,16 +708,16 @@ function TBuildTokenList.TryPunctuation(const pcToken: TSourceToken): boolean;
begin
Result := False;
if WideCharInSet(chLast, UnitaryPunctuation) or WideCharInSet(ch, UnitaryPunctuation) then
if CharInSet(chLast, UnitaryPunctuation) or CharInSet(ch, UnitaryPunctuation) then
exit;
if WideCharInSet(chLast, SingleChars) then
if CharInSet(chLast, SingleChars) then
exit;
{ '<' or '<' can only be followed by '<', '>' or '='.
Beware of "if x<-1"
}
if WideCharInSet(chLast, ['<', '>']) and not WideCharInSet(ch, ['<', '>', '=']) then
if CharInSet(chLast, ['<', '>']) and not CharInSet(ch, ['<', '>', '=']) then
exit;
// ':' can be followed by '=' only
@ -738,17 +737,17 @@ function TBuildTokenList.TryPunctuation(const pcToken: TSourceToken): boolean;
exit;
Result := WideCharIsPuncChar(ch);
Result := CharIsPuncChar(ch);
end;
var
leWordType: TWordType;
leTokenType: TTokenType;
lcLast: WideChar;
lcLast: Char;
begin
Result := False;
if not WideCharIsPuncChar(Current) then
if not CharIsPuncChar(Current) then
exit;
pcToken.TokenType := ttPunctuation;
@ -819,22 +818,22 @@ begin
Result := lcList;
end;
function TBuildTokenList.Current: WideChar;
function TBuildTokenList.Current: Char;
begin
Result := fsSourceCode[fiCurrentIndex];
end;
function TBuildTokenList.CurrentChars(const piCount: integer): WideString;
function TBuildTokenList.CurrentChars(const piCount: integer): String;
begin
Result := Copy(fsSourceCode, fiCurrentIndex, piCount);
end;
function TBuildTokenList.ForwardChar(const piOffset: integer): WideChar;
function TBuildTokenList.ForwardChar(const piOffset: integer): Char;
begin
Result := fsSourceCode[fiCurrentIndex + piOffset];
end;
function TBuildTokenList.ForwardChars(const piOffset, piCount: integer): WideString;
function TBuildTokenList.ForwardChars(const piOffset, piCount: integer): String;
begin
Result := Copy(fsSourceCode, fiCurrentIndex + piOffset, piCount);
end;

View File

@ -41,7 +41,7 @@ type
TSourceToken = class(TParseTreeNode)
private
{ property implementation }
fsSourceCode: WideString;
fsSourceCode: String;
feTokenType: TTokenType;
feWordType: TWordType;
feCommentStyle: TCommentStyle;
@ -52,7 +52,7 @@ type
fbPreprocessedOut: boolean;
fePreprocessorSymbol: TPreProcessorSymbolType;
fsPreProcessorText: WideString;
fsPreProcessorText: String;
protected
public
@ -66,7 +66,7 @@ type
function HasChildNode(const peTokens: TTokenTypeSet): boolean; override;
function HasChildNode(const peTokens: TTokenTypeSet;
const piMaxDepth: integer): boolean; override;
const {%H-}piMaxDepth: integer): boolean; override;
function SolidChildCount: integer; override;
function FirstSolidLeaf: TParseTreeNode; override;
@ -85,7 +85,7 @@ type
property TokenType: TTokenType Read feTokenType Write feTokenType;
property WordType: TWordType Read feWordType Write feWordType;
property SourceCode: WideString Read fsSourceCode Write fsSourceCode;
property SourceCode: String Read fsSourceCode Write fsSourceCode;
property CommentStyle: TCommentStyle Read feCommentStyle Write feCommentStyle;
property FileName: string read fsFileName write fsFileName;
@ -95,7 +95,7 @@ type
Read fiSolidTokenOnLineIndex Write fiSolidTokenOnLineIndex;
property PreprocessorSymbol: TPreProcessorSymbolType Read fePreprocessorSymbol;
property PreProcessorText: WideString Read fsPreProcessorText;
property PreProcessorText: String Read fsPreProcessorText;
property PreprocessedOut: boolean Read fbPreprocessedOut Write fbPreprocessedOut;
end;
@ -265,7 +265,7 @@ begin
while (lcLineToken <> nil) and (lcLineToken.TokenType <> ttReturn) do
begin
Result := Result + lcLineToken.SourceCode;
lcLineToken := lcLineToken.NextToken;
lcLineToken := lcLineToken.NextToken;
end;
end;

View File

@ -176,7 +176,6 @@ uses
{$IFNDEF FPC}Windows,{$ENDIF} SysUtils,
{ local }
JcfSettings,
JcfUnicode,
JcfStringUtils,
ParseTreeNodeType, Tokens, Nesting,
AsmKeywords;
@ -186,7 +185,7 @@ function NewReturn: TSourceToken;
begin
Result := TSourceToken.Create;
Result.TokenType := ttReturn;
Result.SourceCode := WideLineBreak;
Result.SourceCode := NativeLineBreak;
end;
function NewSpace(const piLength: integer): TSourceToken;
@ -195,7 +194,7 @@ begin
Result := TSourceToken.Create;
Result.TokenType := ttWhiteSpace;
Result.SourceCode := WideStringRepeat(WideSpace, piLength);
Result.SourceCode := StringOfChar(' ', piLength);
end;
procedure InsertTokenAfter(const pt, ptNew: TSourceToken);
@ -552,7 +551,7 @@ begin
exit;
// otherwise, if it contains a return it's not single line
if (Pos(WideString(WideLineBreak), pcToken.SourceCode) <= 0) then
if (Pos(NativeLineBreak, pcToken.SourceCode) <= 0) then
exit;
Result := True;

View File

@ -477,8 +477,8 @@ type
const
PREPROC_BLOCK_END = [ppElseIf, ppElse, ppEndIf, ppIfEnd];
procedure GetPreprocessorSymbolData(const psSourceCode: WideString;
var peSymbolType: TPreProcessorSymbolType; var psText: WideString);
procedure GetPreprocessorSymbolData(const psSourceCode: String;
var peSymbolType: TPreProcessorSymbolType; var psText: String);
function PreProcSymbolTypeToString(const peSymbolType: TPreProcessorSymbolType): string;
function PreProcSymbolTypeSetToString(
@ -493,8 +493,7 @@ uses
{$ENDIF}
SysUtils,
{ local }
JcfStringUtils,
JcfUnicode;
JcfStringUtils;
{ the majority of these tokens have a fixed textual representation
e.g. ':=', 'if'.
@ -1077,8 +1076,8 @@ const
{ given a token, identify the preprocessor symbol and the text after it }
procedure GetPreprocessorSymbolData(const psSourceCode: WideString;
var peSymbolType: TPreProcessorSymbolType; var psText: WideString);
procedure GetPreprocessorSymbolData(const psSourceCode: String;
var peSymbolType: TPreProcessorSymbolType; var psText: String);
var
leLoop: TPreProcessorSymbolType;
liItemLen: integer;
@ -1093,7 +1092,7 @@ begin
liItemLen := Length(PreProcessorSymbolData[leLoop]);
if AnsiSameText(StrLeft(psSourceCode, liItemLen), PreProcessorSymbolData[leLoop]) and
( not WideCharIsAlpha(psSourceCode[liItemLen + 1])) then
( not CharIsAlpha(psSourceCode[liItemLen + 1])) then
begin
peSymbolType := leLoop;
break;

View File

@ -64,11 +64,10 @@ type
procedure cbShowWhiteSpaceClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure lvTokensClick(Sender: TObject);
procedure lvTokensSelectItem(Sender: TObject; Item: TListItem;
Selected: boolean);
procedure lvTokensSelectItem(Sender: TObject; {%H-}Item: TListItem; {%H-}Selected: boolean);
procedure lvTokensDblClick(Sender: TObject);
procedure tvParseTreeDblClick(Sender: TObject);
procedure FormKeyUp(Sender: TObject; var Key: word; Shift: TShiftState);
procedure FormKeyUp(Sender: TObject; var Key: word; {%H-}Shift: TShiftState);
procedure FormCreate(Sender: TObject);
private
fcRootNode: TParseTreeNode;

View File

@ -55,13 +55,13 @@ type
{ API for descendant classes }
function TokenIsAligned(const pt: TSourceToken): boolean; virtual; abstract;
function TokenEndsStatement(const pt: TSourceToken): boolean; virtual; abstract;
function IsTokenInContext(const pt: TSourceToken): boolean; virtual;
function TokenEndsAlignment(const pt: TSourceToken): boolean; virtual;
function IsTokenInContext(const {%H-}pt: TSourceToken): boolean; virtual;
function TokenEndsAlignment(const {%H-}pt: TSourceToken): boolean; virtual;
{ override this to let the child class see the tokens as they come
this is used by the align vars to detect the first non-white space token after the : }
procedure OnTokenRead(const pt: TSourceToken); virtual;
procedure OnTokenRead(const {%H-}pt: TSourceToken); virtual;
procedure ResetState; virtual;
function EnabledVisitSourceToken(const pcNode: TObject): boolean; override;
@ -278,8 +278,6 @@ begin
end;
end;
procedure TAlignBase.OnTokenRead(const pt: TSourceToken);
begin
// here for override

View File

@ -50,11 +50,11 @@ type
{ these are called when visiting interior nodes before and after thier children
Must return true if the visited node is deleted, or if nodes are inserted before it
ie if the curent node's index is not correct and the same after the visit}
procedure PreVisitParseTreeNode(const pcNode: TObject); virtual;
procedure PostVisitParseTreeNode(const pcNode: TObject); virtual;
procedure PreVisitParseTreeNode(const {%H-}pcNode: TObject); virtual;
procedure PostVisitParseTreeNode(const {%H-}pcNode: TObject); virtual;
{ this is called when visiting a leaf node (ie a source token) }
function VisitSourceToken(const pcToken: TObject): Boolean; virtual;
function VisitSourceToken(const {%H-}pcToken: TObject): Boolean; virtual;
function FinalSummary(out psMessage: string): boolean; virtual;
function IsIncludedInSettings: boolean; virtual;

View File

@ -136,7 +136,7 @@ begin
begin
Result := True;
if psMessage <> '' then
psMessage := psMessage + NativeLineBreak;
psMessage := psMessage + '. ';
psMessage := psMessage + 'Non-identifier caps: ';

View File

@ -50,8 +50,7 @@ type
implementation
uses
JcfUnicode,
SourceToken, Tokens, FormatFlags, TokenUtils, ParseTreeNodeType;
JcfStringUtils, SourceToken, Tokens, FormatFlags, TokenUtils, ParseTreeNodeType;
function CanBreakHere(const pt: TSourceToken): boolean;
var
@ -108,7 +107,7 @@ begin
lcNew := TSourceToken.Create;
lcNew.TokenType := ttReturn;
lcNew.SourceCode := WideLineBreak;
lcNew.SourceCode := NativeLineBreak;
XPos := 0;
InsertTokenAfter(lcToken, lcNew);

View File

@ -50,20 +50,19 @@ implementation
uses
{ local }
SourceToken, Tokens, ParseTreeNodeType,
JcfUnicode,
FormatFlags, TokenUtils;
JcfStringUtils, FormatFlags, TokenUtils;
function TextOrNumberString(const str: WideString): boolean;
function TextOrNumberString(const str: String): boolean;
var
liLoop: integer;
ch: WideChar;
ch: Char;
begin
Result := True;
for liLoop := 1 to Length(str) do
begin
ch := str[liLoop];
if not (WideCharIsAlphaNum(ch) or (ch = '_') or (ch = '.')) then
if not (CharIsAlphaNum(ch) or (ch = '_') or (ch = '.')) then
begin
Result := False;
break;

View File

@ -136,7 +136,7 @@ begin
lcToken := TSourceToken(pcToken);
if (lcToken.TokenType = ttComment) and (Pos(WideString(MozURL), lcToken.SourceCode) > 0) then
if (lcToken.TokenType = ttComment) and (Pos(MozURL, lcToken.SourceCode) > 0) then
begin
fbWorkIsDone := True;
exit;

View File

@ -95,7 +95,7 @@ const
PAST_END = 0;
ROOFSLOPE = 5; // the plateau slopes a bit up to a point /\
INCREASE_TO_RIGHT_FACTOR = 15; // and it also slopes to the right
WIDTH_SCORE_FACTOR = 5;
//WIDTH_SCORE_FACTOR = 5;
TO_FAR_SCORE_FACTOR = 10;
FAR_TO_FAR_SCORE_FACTOR = 0.3;
FIRST_TOKENS = 3;
@ -252,7 +252,7 @@ const
HALF_GOOD = 5;
GOOD1 = 10;
GOOD2 = 20;
//GOOD2 = 20;
GOOD3 = 30;
GOOD4 = 40;
GOOD5 = 50;
@ -540,7 +540,7 @@ begin
end;
ttComment:
begin
if Pos(WideString(NativeLineBreak), lt.SourceCode) <= 0 then
if Pos(NativeLineBreak, lt.SourceCode) <= 0 then
liPos := liPos + Length(lt.SourceCode)
else
liPos := LastLineLength(lt.SourceCode);

View File

@ -141,7 +141,7 @@ begin
end;
function NeedsBlankLine(const pt, ptNext: TSourceToken): boolean;
function NeedsBlankLine(const pt: TSourceToken): boolean;
var
lcNext: TSourceToken;
begin
@ -428,7 +428,7 @@ begin
liReturnsNeeded := 0;
if NeedsBlankLine(lcSourceToken, lcNext) then
if NeedsBlankLine(lcSourceToken) then
liReturnsNeeded := 2
else if NeedsReturn(lcSourceToken, lcNext) then
liReturnsNeeded := 1;

View File

@ -65,12 +65,9 @@ begin
end;
function TTabToSpace.EnabledVisitSourceToken(const pcNode: TObject): Boolean;
const
// this is needed in Delphi 2007
TabChar: WideChar = WideChar(NativeTab);
var
lcSourceToken, lcNextToken: TSourceToken;
ls: WideString;
ls: String;
begin
Result := False;
lcSourceToken := TSourceToken(pcNode);
@ -94,7 +91,7 @@ begin
end;
end;
ls := WideStringReplace(ls, TabChar, fsSpaces, [rfReplaceAll]);
ls := StringReplace(ls, NativeTab, fsSpaces, [rfReplaceAll]);
lcSourceToken.SourceCode := ls;
end;

View File

@ -50,9 +50,9 @@ type
procedure CheckEnabled(const pcToken: TObject); virtual;
// every token is inspected, even when the visitor is disabled
procedure InspectSourceToken(const pcToken: TObject); virtual;
procedure InspectSourceToken(const {%H-}pcToken: TObject); virtual;
// this is only called when the processor is enabled
function EnabledVisitSourceToken(const pcToken: TObject): Boolean; virtual;
function EnabledVisitSourceToken(const {%H-}pcToken: TObject): Boolean; virtual;
public
constructor Create; override;

View File

@ -47,7 +47,7 @@ type
TConverter = class(TObject)
private
{ the strings for the in and out code }
fsInputCode, fsOutputCode: WideString;
fsInputCode, fsOutputCode: String;
fsFileName: String;
{ classes to lex and parse the source }
@ -93,8 +93,8 @@ type
procedure CollectOutput(const pcRoot: TParseTreeNode);
property InputCode: WideString Read fsInputCode Write fsInputCode;
property OutputCode: WideString Read fsOutputCode Write fsOutputCode;
property InputCode: String Read fsInputCode Write fsInputCode;
property OutputCode: String Read fsOutputCode Write fsOutputCode;
property FileName: String Read fsFileName Write fsFileName;
property TokenCount: Integer Read fiTokenCount;
@ -111,8 +111,7 @@ implementation
uses
AllProcesses, fShowParseTree, JcfRegistrySettings,
JcfSettings, JcfStringUtils, JcfUnicode,
ParseError, PreProcessorParseTree,
JcfSettings, JcfStringUtils, ParseError, PreProcessorParseTree,
SourceToken, SourceTokenList, TreeWalker, VisitSetNesting, VisitSetXY;
function StrInsert(const psSub, psMain: String; const piPos: Integer): String;
@ -373,7 +372,7 @@ const
var
liRealInputStart, liRealInputEnd: Integer;
liOutputStart, liOutputEnd: Integer;
lsNewOutput: WideString;
lsNewOutput: String;
begin
Assert(piStartIndex >= 0);
Assert(piEndIndex >= piStartIndex);
@ -384,13 +383,13 @@ begin
liRealInputEnd := piEndIndex;
{ get to the start of the line }
while (liRealInputStart > 1) and (not WideCharIsReturn(InputCode[liRealInputStart - 1])) do
while (liRealInputStart > 1) and (not CharIsReturn(InputCode[liRealInputStart - 1])) do
Dec(liRealInputStart);
{ get to the start of the next line }
while (liRealInputEnd < Length(InputCode)) and (not WideCharIsReturn(InputCode[liRealInputEnd])) do
while (liRealInputEnd < Length(InputCode)) and (not CharIsReturn(InputCode[liRealInputEnd])) do
Inc(liRealInputEnd);
while (liRealInputEnd < Length(InputCode)) and (WideCharIsReturn(InputCode[liRealInputEnd])) do
while (liRealInputEnd < Length(InputCode)) and (CharIsReturn(InputCode[liRealInputEnd])) do
Inc(liRealInputEnd);
{ put markers into the input }
@ -401,8 +400,8 @@ begin
{ locate the markers in the output,
and replace before and after }
liOutputStart := Pos(WideString(FORMAT_START), fsOutputCode) + Length(FORMAT_START);
liOutputEnd := Pos(WideString(FORMAT_END), fsOutputCode);
liOutputStart := Pos(FORMAT_START, fsOutputCode) + Length(FORMAT_START);
liOutputEnd := Pos(FORMAT_END, fsOutputCode);
{ splice }

View File

@ -139,14 +139,14 @@ begin
end;
fsCurrentUnitName := pciUnit.FileName;
fcConverter.InputCode := UTF8ToUTF16(ReadFromIDE(pciUnit));
fcConverter.InputCode := ReadFromIDE(pciUnit);
// now convert
fcConverter.Convert;
fsCurrentUnitName := '';
if not ConvertError then
begin
WriteToIDE(pciUnit, UTF16ToUTF8(fcConverter.OutputCode));
WriteToIDE(pciUnit, fcConverter.OutputCode);
SendStatusMessage(pciUnit.FileName, 'Formatted unit', mtProgress, -1, -1);
Inc(fiConvertCount);
end;
@ -169,7 +169,7 @@ begin
exit;
lcSourceLines := TStringList.Create;
lcSourceLines.Text := UTF16ToUTF8(fcConverter.InputCode);
lcSourceLines.Text := fcConverter.InputCode;
lcDestLines := TStringList.Create;
lcDestLines.Text := psText;
lcSameStart := TStringList.Create;

View File

@ -190,7 +190,7 @@ var
wRes: word;
lbFileIsChanged: boolean;
lsOutType: string;
lsSourceCode: WideString;
lsSourceCode: String;
leContentType: TFileContentType;
begin
// do checks
@ -403,7 +403,7 @@ begin
{$ELSE}
lsSearch := psDir + '*.*';
{$ENDIF}
FillChar(rSearch, Sizeof(TSearchRec), 0);
FillChar(rSearch{%H-}, Sizeof(TSearchRec), 0);
bDone := (FindFirst(lsSearch, 0, rSearch) <> 0);
while not bDone do
@ -438,7 +438,7 @@ begin
lsSearch := psDir + '*.*';
{$ENDIF}
FillChar(rSearch, Sizeof(TSearchRec), 0);
FillChar(rSearch{%H-}, Sizeof(TSearchRec), 0);
bDone := (FindFirst(lsSearch, faDirectory, rSearch) <> 0);
while not bDone do

View File

@ -85,7 +85,7 @@ type
destructor Destroy; override;
class function GetGroupCaption: String; override;
class function GetInstance: TAbstractIDEOptions; override;
procedure DoAfterWrite(Restore: boolean); override;
procedure DoAfterWrite({%H-}Restore: boolean); override;
procedure Read;
procedure ReadFromFile(const psFileName: string; const pbMustExist: boolean);

View File

@ -70,7 +70,7 @@ uses
const
REG_CAPS = 'Caps';
REG_BREAKS_AFTER_LABEL = 'BreaksAfterLabel';
REG_INDENT_LEVEL = 'Indent_';
//REG_INDENT_LEVEL = 'Indent_';
REG_BREAKS_AFTER_LABEL_ENABLED = 'BreaksAfterLabelEnabled';
REG_STATEMENT_INDENT_ENABLED = 'StatementIndentEnabled';

View File

@ -164,7 +164,7 @@ const
REG_NUM_RETURNS_AFTER_FINAL_END = 'NumReturnsAfterFinalEnd';
REG_ALIGN_ASSIGN = 'AlignAssign';
//REG_ALIGN_ASSIGN = 'AlignAssign';
REG_REMOVE_BAD_RETURNS = 'RemoveBadReturns';
REG_ADD_GOOD_RETURNS = 'AddGoodReturns';

View File

@ -140,15 +140,15 @@ type
TSettingsInputDummy = class(TSettingsInput)
private
public
function ExtractSection(const psSection: string): TSettingsInput; override;
function HasTag(const psTag: string): boolean; override;
function ExtractSection(const {%H-}psSection: string): TSettingsInput; override;
function HasTag(const {%H-}psTag: string): boolean; override;
function Read(const psTag: string): string; override;
function Read(const psTag, psDefault: string): string; override;
function Read(const psTag: string; const piDefault: integer): integer; override;
function Read(const psTag: string; const pfDefault: double): double; override;
function Read(const psTag: string; const pbDefault: boolean): boolean; override;
function Read(const psTag: string; const pcStrings: TStrings): boolean; override;
function Read(const {%H-}psTag: string): string; override;
function Read(const {%H-}psTag, psDefault: string): string; override;
function Read(const {%H-}psTag: string; const piDefault: integer): integer; override;
function Read(const {%H-}psTag: string; const pfDefault: double): double; override;
function Read(const {%H-}psTag: string; const pbDefault: boolean): boolean; override;
function Read(const {%H-}psTag: string; const {%H-}pcStrings: TStrings): boolean; override;
end;
implementation

View File

@ -47,9 +47,9 @@ type
constructor Create(AOwner: TComponent); override;
function GetTitle: String; override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings({%H-}AOptions: TAbstractIDEOptions); override;
procedure WriteSettings({%H-}AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
end;

View File

@ -54,9 +54,9 @@ type
procedure FrameResize(Sender:TObject);
public
function GetTitle: String; override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings({%H-}AOptions: TAbstractIDEOptions); override;
procedure WriteSettings({%H-}AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
end;

View File

@ -55,9 +55,9 @@ type
constructor Create(AOwner: TComponent); override;
function GetTitle: String; override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings({%H-}AOptions: TAbstractIDEOptions); override;
procedure WriteSettings({%H-}AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
end;

View File

@ -45,9 +45,9 @@ type
constructor Create(AOwner: TComponent); override;
function GetTitle: String; override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings({%H-}AOptions: TAbstractIDEOptions); override;
procedure WriteSettings({%H-}AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
class function DefaultCollapseChildNodes: Boolean; override;
end;

View File

@ -65,9 +65,9 @@ type
constructor Create(AOwner: TComponent); override;
function GetTitle: String; override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings({%H-}AOptions: TAbstractIDEOptions); override;
procedure WriteSettings({%H-}AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
end;

View File

@ -49,9 +49,9 @@ type
constructor Create(AOwner: TComponent); override;
function GetTitle: String; override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings({%H-}AOptions: TAbstractIDEOptions); override;
procedure WriteSettings({%H-}AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
end;

View File

@ -50,9 +50,9 @@ type
constructor Create(AOwner: TComponent); override;
function GetTitle: String; override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings({%H-}AOptions: TAbstractIDEOptions); override;
procedure WriteSettings({%H-}AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
end;

View File

@ -61,9 +61,9 @@ type
constructor Create(AOwner: TComponent); override;
function GetTitle: String; override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings({%H-}AOptions: TAbstractIDEOptions); override;
procedure WriteSettings({%H-}AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
end;

View File

@ -46,9 +46,9 @@ type
constructor Create(AOwner: TComponent); override;
function GetTitle: String; override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings({%H-}AOptions: TAbstractIDEOptions); override;
procedure WriteSettings({%H-}AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
end;

View File

@ -54,9 +54,9 @@ type
constructor Create(AOwner: TComponent); override;
function GetTitle: String; override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings({%H-}AOptions: TAbstractIDEOptions); override;
procedure WriteSettings({%H-}AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
end;

View File

@ -85,9 +85,9 @@ type
constructor Create(AOwner: TComponent); override;
function GetTitle: String; override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings({%H-}AOptions: TAbstractIDEOptions); override;
procedure WriteSettings({%H-}AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
end;

View File

@ -44,9 +44,9 @@ type
constructor Create(AOwner: TComponent); override;
function GetTitle: String; override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings({%H-}AOptions: TAbstractIDEOptions); override;
procedure WriteSettings({%H-}AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
end;

View File

@ -51,9 +51,9 @@ type
constructor Create(AOwner: TComponent); override;
function GetTitle: String; override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings({%H-}AOptions: TAbstractIDEOptions); override;
procedure WriteSettings({%H-}AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
end;

View File

@ -49,9 +49,9 @@ type
procedure FrameResize(Sender: TObject);
public
function GetTitle: String; override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings({%H-}AOptions: TAbstractIDEOptions); override;
procedure WriteSettings({%H-}AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
end;
@ -96,7 +96,7 @@ begin
{ from the file, about itself}
lblDate.Caption := Format(lisFrFilesDateFileWritten,
[FormatDateTime(ShortDateFormat + ' ' + ShortTimeFormat,
[FormatDateTime(DefaultFormatSettings.ShortDateFormat + ' ' + DefaultFormatSettings.ShortTimeFormat,
FormatSettings.WriteDateTime)]);
lblVersion.Caption := Format(lisFrFilesVersionThatWroteThisFile, [FormatSettings.WriteVersion]);
mDescription.Text := FormatSettings.Description;

View File

@ -47,9 +47,9 @@ type
constructor Create(AOwner: TComponent); override;
function GetTitle: String; override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings({%H-}AOptions: TAbstractIDEOptions); override;
procedure WriteSettings({%H-}AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
end;

View File

@ -47,9 +47,9 @@ type
constructor Create(AOwner: TComponent); override;
function GetTitle: String; override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings({%H-}AOptions: TAbstractIDEOptions); override;
procedure WriteSettings({%H-}AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
end;

View File

@ -48,9 +48,9 @@ type
constructor Create(AOwner: TComponent); override;
function GetTitle: String; override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings({%H-}AOptions: TAbstractIDEOptions); override;
procedure WriteSettings({%H-}AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
end;

View File

@ -49,9 +49,9 @@ type
constructor Create(AOwner: TComponent); override;
function GetTitle: String; override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings({%H-}AOptions: TAbstractIDEOptions); override;
procedure WriteSettings({%H-}AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
end;

View File

@ -47,9 +47,9 @@ type
constructor Create(AOwner: TComponent); override;
function GetTitle: String; override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings({%H-}AOptions: TAbstractIDEOptions); override;
procedure WriteSettings({%H-}AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
end;

View File

@ -50,9 +50,9 @@ type
constructor Create(AOwner: TComponent); override;
function GetTitle: String; override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings({%H-}AOptions: TAbstractIDEOptions); override;
procedure WriteSettings({%H-}AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
end;

View File

@ -52,9 +52,9 @@ type
constructor Create(AOwner: TComponent); override;
function GetTitle: String; override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings({%H-}AOptions: TAbstractIDEOptions); override;
procedure WriteSettings({%H-}AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
end;

View File

@ -45,9 +45,9 @@ type
constructor Create(AOwner: TComponent); override;
function GetTitle: String; override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings({%H-}AOptions: TAbstractIDEOptions); override;
procedure WriteSettings({%H-}AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
end;
@ -77,7 +77,6 @@ end;
procedure TfrUnitNameCaps.ReadSettings(AOptions: TAbstractIDEOptions);
begin
inherited;
with FormatSettings.UnitNameCaps do
begin
cbEnableAnyWords.Checked := Enabled;
@ -88,7 +87,6 @@ end;
procedure TfrUnitNameCaps.WriteSettings(AOptions: TAbstractIDEOptions);
begin
inherited;
with FormatSettings.UnitNameCaps do
begin
Enabled := cbEnableAnyWords.Checked;

View File

@ -56,9 +56,9 @@ type
constructor Create(AOwner: TComponent); override;
function GetTitle: String; override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings({%H-}AOptions: TAbstractIDEOptions); override;
procedure WriteSettings({%H-}AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
end;

View File

@ -49,9 +49,9 @@ type
constructor Create(AOwner: TComponent); override;
function GetTitle: String; override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings({%H-}AOptions: TAbstractIDEOptions); override;
procedure WriteSettings({%H-}AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
end;

View File

@ -48,7 +48,7 @@ type
procedure FormCreate(Sender: TObject);
procedure imgOpenSourceClick(Sender: TObject);
procedure lblMPLClick(Sender: TObject);
procedure FormKeyUp(Sender: TObject; var Key: word; Shift: TShiftState);
procedure FormKeyUp(Sender: TObject; var {%H-}Key: word; {%H-}Shift: TShiftState);
procedure hlHomePageClick(Sender: TObject);
procedure lblMPLMouseEnter(Sender: TObject);
procedure lblMPLMouseLeave(Sender: TObject);
@ -65,30 +65,15 @@ implementation
{$endif}
uses
{ delphi }
{$ifndef fpc}
Windows, ShellAPI, URLMon,
{$else}
LCLIntf,
{$endif}
LCLIntf,
{ local }
JcfVersionConsts, JcfFontSetFunctions, JcfStringUtils, jcfuiconsts;
JcfVersionConsts, JcfStringUtils, jcfuiconsts;
{$ifdef fpc}
procedure ShowURL(const ps: string);
begin
// do it silent
// do it silently
OpenURL(ps);
end;
{$else}
procedure ShowURL(const ps: string);
var
lws: WideString;
begin
lws := ps;
HLinkNavigateString(nil, pWideChar(lws));
end;
{$endif}
procedure TfrmAboutBox.imgOpenSourceClick(Sender: TObject);
begin

View File

@ -65,7 +65,6 @@ type
constructor Create;
destructor Destroy; override;
function Count: integer;
function Add(const piValue: integer): integer;
@ -108,7 +107,7 @@ end;
function TIntList.Add(const piValue: integer): integer;
begin
Result := fcList.Add(Pointer(PtrInt(piValue)));
Result := fcList.Add({%H-}Pointer(PtrInt(piValue)));
end;
procedure TIntList.Clear;
@ -121,15 +120,14 @@ begin
Result := fcList.Count;
end;
function TIntList.GetItem(const piIndex: integer): integer;
begin
Result := integer(PtrInt(fcList.Items[piIndex]));
Result := integer({%H-}PtrInt(fcList.Items[piIndex]));
end;
procedure TIntList.SetItem(const piIndex, piValue: integer);
begin
fcList.Items[piIndex] := Pointer(PtrInt(piValue));
fcList.Items[piIndex] := {%H-}Pointer(PtrInt(piValue));
end;
procedure TIntList.ChangeValue(const liIndex, liDelta: integer);

View File

@ -60,7 +60,7 @@ function Float2Str(const d: double): string;
{not really a file fn - string file name manipulation}
function SetFileNameExtension(const psFileName, psExt: string): string;
procedure AdvanceTextPos(const AText: WideString; var ARow, ACol: integer);
procedure AdvanceTextPos(const AText: String; var ARow, ACol: integer);
function LastLineLength(const AString: string): integer;
{ split into lines at CrLf or Lf}
@ -104,9 +104,10 @@ var
code: integer;
begin
// de-localise the string if need be
if (DecimalSeparator <> '.') and (Pos(DecimalSeparator, s) > 0) then
if (DefaultFormatSettings.DecimalSeparator <> '.')
and (Pos(DefaultFormatSettings.DecimalSeparator, s) > 0) then
begin
StrReplace(s, DecimalSeparator, '.');
StrReplace(s, DefaultFormatSettings.DecimalSeparator, '.');
end;
Val(s, Result, Code);
@ -120,10 +121,10 @@ function Float2Str(const d: double): string;
var
OrgSep: char;
begin
OrgSep := DecimalSeparator;
DecimalSeparator := '.';
OrgSep := DefaultFormatSettings.DecimalSeparator;
DefaultFormatSettings.DecimalSeparator := '.';
Result := FloatToStr(d);
DecimalSeparator := OrgSep;
DefaultFormatSettings.DecimalSeparator := OrgSep;
end;
@ -214,11 +215,11 @@ begin
end;
end;
procedure PosLastAndCount(const ASubString, AString: WideString;
procedure PosLastAndCount(const ASubString, AString: String;
out ALastPos: integer; out ACount: integer);
var
{This gets the last occurrence and count in one go. It saves time}
LastChar1: WideChar;
LastChar1: Char;
Index1: integer;
Index2: integer;
Index3: integer;
@ -269,7 +270,7 @@ end;
- if the text contains newlines, then add on to the Y pos, and
set the X pos to the text length after the last newline }
{AdemBaba}
procedure AdvanceTextPos(const AText: WideString; var ARow, ACol: integer);
procedure AdvanceTextPos(const AText: String; var ARow, ACol: integer);
var
Length1: integer;
Count1: integer;
@ -303,7 +304,7 @@ begin
Inc(ARow, Length1);
end;
else
PosLastAndCount(WideChar(NativeLineBreak), AText, Pos1, Count1);
PosLastAndCount(NativeLineBreak, AText, Pos1, Count1);
if Pos1 <= 0 then
Inc(ARow, Length1)
else

View File

@ -97,20 +97,22 @@ const
function CharInSet(const C: Char; const testSet: TSysCharSet): Boolean;
{$ENDIF}
{$ENDIF}
function CharIsControl(const C: Char): Boolean;
function CharIsAlpha(const C: Char): Boolean;
function CharIsAlphaNum(const C: Char): Boolean;
function CharIsWordChar(const c: Char): Boolean;
function CharIsControl(const C: Char): Boolean;
function CharIsDigit(const C: Char): Boolean;
function CharIsReturn(const C: Char): Boolean;
function CharIsWhiteSpace(const C: Char): Boolean;
function CharUpper(const C: Char): Char;
function CharIsWhiteSpaceNoReturn(const c: Char): boolean;
function CharIsPuncChar(const c: Char): boolean;
function StrIsAlpha(const S: string): Boolean;
function StrIsAlphaNum(const S: string): Boolean;
function CharIsHexDigitDot(const c: Char): Boolean;
function CharIsBinDigit(const c: Char): Boolean;
function StrTrimQuotes(const S: string): string;
function StrAfter(const SubStr, S: string): string;
function StrBefore(const SubStr, S: string): string;
function StrChopRight(const S: string; N: Integer): string;
@ -145,7 +147,7 @@ function IntToStrZeroPad(Value, Count: Integer): String;
function StrPadLeft(const pcOriginal: string;
const piDesiredLength: integer; const pcPad: Char): string;
function WideStringReplace(const S, OldPattern, NewPattern: WideString; Flags: TReplaceFlags): WideString;
//function WideStringReplace(const S, OldPattern, NewPattern: WideString; Flags: TReplaceFlags): WideString;
function PathExtractFileNameNoExt(const Path: string): string;
@ -187,6 +189,11 @@ begin
Result := CharIsAlpha(C) or CharIsDigit(C);
end;
function CharIsWordChar(const c: Char): Boolean;
begin
Result := CharIsAlpha(c) or (c = '_');
end;
function CharIsControl(const C: Char): Boolean;
begin
Result := C <= #31;
@ -207,10 +214,22 @@ begin
Result := CharInSet(C, NativeWhiteSpace) ;
end;
function CharUpper(const C: Char): Char;
function CharIsWhiteSpaceNoReturn(const c: Char): boolean;
begin
// Paul: original code used char case table
Result := UpCase(C);
Result := False;
if (c = #0) or CharIsReturn(c) then exit;
// Result := CharIsWhiteSpace(c) and (c <> AnsiLineFeed) and (c <> AnsiCarriageReturn);
Result := (ord(c) <= Ord(NativeSpace));
end;
function CharIsPuncChar(const c: Char): boolean;
begin
Result := False;
if CharIsWhiteSpace(c) then exit;
if CharIsAlphaNum(c) then exit;
if CharIsReturn(c) then exit;
if CharIsControl(c) then exit;
Result := True;
end;
function StrIsAlpha(const S: string): Boolean;
@ -241,6 +260,23 @@ begin
end;
end;
function CharIsHexDigitDot(const c: Char): Boolean;
const
HexDigits: set of AnsiChar = [
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F',
'a', 'b', 'c', 'd', 'e', 'f'];
begin
Result := (c in HexDigits) or (c = '.');
end;
function CharIsBinDigit(const c: Char): Boolean;
const
BinDigits: set of AnsiChar = ['0','1'];
begin
Result := (c in BinDigits);
end;
function StrTrimQuotes(const S: string): string;
var
C1, C2: Char;
@ -508,7 +544,7 @@ begin
end;
// Based on FreePascal version of StringReplace
function WideStringReplace(const S, OldPattern, NewPattern: WideString; Flags: TReplaceFlags): WideString;
{function WideStringReplace(const S, OldPattern, NewPattern: WideString; Flags: TReplaceFlags): WideString;
var
Srch, OldP, RemS: WideString; // Srch and Oldp can contain uppercase versions of S,OldPattern
P: Integer;
@ -545,7 +581,7 @@ begin
end;
end;
end;
}
function PadNumber(const pi: integer): string;
begin
Result := IntToStrZeroPad(pi, 3);

View File

@ -43,7 +43,7 @@ function FileGetSize(const FileName: string): Int64;
procedure ShellExecEx(const FileName: string; const Parameters: string = '');
function GetTickCount: Cardinal;
function IsMultiByte(const pcChar: WideChar): Boolean;
function IsMultiByte(const {%H-}pcChar: Char): Boolean;
function IsWinServer2008R2: Boolean;
function IsWin7: Boolean;
@ -161,14 +161,10 @@ begin
{$endif}
end;
function IsMultiByte(const pcChar: WideChar): Boolean;
function IsMultiByte(const pcChar: Char): Boolean;
begin
{$ifdef MSWINDOWS}
Result := IsDBCSLeadByte(Byte(pcChar));
{$else}
//Result := IsDBCSLeadByte(Byte(pcChar));
Result := False;
// TODO: ?
{$endif}
end;
function IsWinServer2008R2: Boolean;

View File

@ -1,282 +0,0 @@
unit JcfUnicode;
{(*}
(*------------------------------------------------------------------------------
Delphi Code formatter source code
The Original Code is JcfUnicode, released March 2007.
The Initial Developer of the Original Code is Anthony Steele.
Portions created by Anthony Steele are Copyright (C) 2007 Anthony Steele.
All Rights Reserved.
Contributor(s): Anthony Steele.
The contents of this file are subject to the Mozilla Public License Version 1.1
(the "License"). you may not use this file except in compliance with the License.
You may obtain a copy of the License at http://www.mozilla.org/NPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied.
See the License for the specific language governing rights and limitations
under the License.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 or later (the "GPL")
See http://www.gnu.org/licenses/gpl.html
------------------------------------------------------------------------------*)
{*)}
{$I JcfGlobal.inc}
interface
type
AnsiCharSet = set of AnsiChar;
function WideCharIsReturn(const C: WideChar): Boolean;
function WideCharIsDigit(const wc: WideChar): Boolean;
function WideCharIsAlpha(const wc: WideChar): Boolean;
function WideCharIsAlphaNum(const wc: WideChar): Boolean;
function WideCharIsHexDigitDot(const wc: WideChar): Boolean;
function WideCharIsBinDigit(const wc: WideChar): Boolean; // ~bk 2014.11.01
function WideCharIsPuncChar(const wc: WideChar): boolean;
function WideCharIsWordChar(const wc: WideChar): Boolean;
function WideCharIsWhiteSpaceNoReturn(const wc: WideChar): boolean;
function WideCharInSet(const wc: WideChar; const charSet: AnsiCharSet): Boolean;
function WideStringRepeat(const ws: WideString; const count: integer): WideString;
const
WideNullChar = WideChar(#0);
WideLineFeed = WideChar(#10);
WideCarriageReturn = WideChar(#13);
WideSpace = WideChar(#32);
{$IFDEF MSWINDOWS}
{$IFDEF DELPHI7}
WideLineBreak = WideString(WideCarriageReturn) + WideString(WideLineFeed);
{$ELSE}
WideLineBreak = WideCarriageReturn + WideLineFeed;
{$ENDIF DELPHI7}
{$ENDIF MSWINDOWS}
{$IFDEF UNIX}
WideLineBreak = WideLineFeed;
{$ENDIF UNIX}
implementation
uses
{ Delphi }
Classes, SysUtils,
{ local }
JcfStringUtils;
const
MaxAnsiChar = 127;
// true when the char is not in the ansi char set
function WideCharIsHigh(const wc: WideChar): Boolean;
var
index: integer;
begin
index := integer(wc);
Result := (Index > MaxAnsiChar);
end;
function WideCharIsReturn(const C: WideChar): Boolean;
begin
Result := (C = WideLineFeed) or (C = WideCarriageReturn);
end;
function WideCharIsDigit(const wc: WideChar): Boolean;
var
ch: char;
begin
if WideCharIsHigh(wc) then
begin
Result := False;
exit;
end;
ch := char(wc);
Result := CharIsDigit(ch);
end;
function WideCharIsAlpha(const wc: WideChar): Boolean;
var
ch: char;
begin
if WideCharIsHigh(wc) then
begin
Result := False;
exit;
end;
ch := char(wc);
Result := CharIsAlpha(ch);
end;
function WideCharIsAlphaNum(const wc: WideChar): Boolean;
var
ch: char;
begin
if WideCharIsHigh(wc) then
begin
Result := False;
exit;
end;
ch := char(wc);
Result := CharIsAlpha(ch) or CharIsDigit(ch);
end;
function WideCharIsHexDigitDot(const wc: WideChar): Boolean;
const
HexDigits: set of AnsiChar = [
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F',
'a', 'b', 'c', 'd', 'e', 'f'];
var
ch: AnsiChar;
begin
if WideCharIsHigh(wc) then
begin
Result := False;
exit;
end;
ch := AnsiChar(wc);
Result := (ch in HexDigits) or (ch = '.');
end;
{ ~bk 2014.11.01 }
function WideCharIsBinDigit(const wc: WideChar): Boolean;
const
BinDigits: set of AnsiChar = ['0','1'];
var
ch: AnsiChar;
begin
if WideCharIsHigh(wc) then
begin
Result := False;
exit;
end;
ch := AnsiChar(wc);
Result := (ch in BinDigits);
end;
function WideCharIsWordChar(const wc: WideChar): Boolean;
var
ch: char;
begin
if WideCharIsHigh(wc) then
begin
Result := False;
exit;
end;
ch := char(wc);
Result := CharIsAlpha(ch) or (ch = '_');
end;
function WideCharIsPuncChar(const wc: WideChar): boolean;
var
ch: char;
begin
Result := False;
if WideCharIsHigh(wc) then
begin
exit;
end;
ch := char(wc);
if CharIsWhiteSpace(ch) then
exit;
if CharIsAlphaNum(ch) then
exit;
if CharIsReturn(ch) then
exit;
if CharIsControl(ch) then
exit;
Result := True;
end;
function WideCharIsWhiteSpaceNoReturn(const wc: WideChar): boolean;
var
ch: char;
begin
Result := False;
if WideCharIsHigh(wc) then
begin
exit;
end;
// null chars
if wc = WideNullChar then
exit;
if WideCharIsReturn(wc) then
exit;
ch := char(wc);
{ 7 April 2004 following sf snag 928460 and discussion in newsgroups
must accept all other chars < 32 as white space }
// Result := CharIsWhiteSpace(ch) and (ch <> AnsiLineFeed) and (ch <> AnsiCarriageReturn);
Result := (ord(ch) <= Ord(NativeSpace));
end;
{
Returnh true if the widechar is in the ansi char set
}
function WideCharInSet(const wc: WideChar; const charSet: AnsiCharSet): Boolean;
var
ch: AnsiChar;
begin
Result := False;
if WideCharIsHigh(wc) then
begin
exit;
end;
// null chars
if wc = WideNullChar then
exit;
ch := AnsiChar(wc);
Result := ch in charSet;
end;
function WideStringRepeat(const ws: WideString; const count: integer): WideString;
var
liLoop: integer;
begin
Result := '';
for liLoop := 0 to count - 1 do
begin
Result := Result + ws;
end;
end;
end.

View File

@ -36,10 +36,10 @@ type
function TypeOfTextFile(const psFileName: string): TFileContentType;
procedure ReadTextFile(const psFileName: string; out psContents: WideString;
procedure ReadTextFile(const psFileName: string; out psContents: String;
out peContentType: TFileContentType);
procedure WriteTextFile(const psFileName: string; const psContents: WideString;
procedure WriteTextFile(const psFileName: string; const psContents: String;
const peContentType: TFileContentType);
@ -70,7 +70,7 @@ const
Utf32BigEndianMarker1 = $0000;
Utf32BigEndianMarker2 = $FFFE;
MaxAnsiChar = 127;
//MaxAnsiChar = 127;
function ReadFileHeader(const pcFileStream: TFileStream): TFileContentType;
var
@ -88,6 +88,8 @@ begin
// read the first 4 bytes
pcFileStream.Seek(0, soFromBeginning);
word1:=0;
word2:=0;
pcFileStream.Read(word1, SizeOf(word));
pcFileStream.Read(word2, SizeOf(word));
@ -155,7 +157,7 @@ begin
end;
{ this is one of the few cases where 'AnsiString' must be used }
function Read8BitFile(const pcFileStream: TFileStream): WideString;
function Read8BitFile(const pcFileStream: TFileStream): String;
var
liBytesRemaining: integer;
lsContents8bit: AnsiString;
@ -167,13 +169,11 @@ begin
begin
pcFileStream.ReadBuffer(lsContents8bit[1], liBytesRemaining);
end;
// convert to wide string
Result := WideString(lsContents8bit);
Result := lsContents8bit;
end;
function ReadUtf8File(const pcFileStream: TFileStream): WideString;
function ReadUtf8File(const pcFileStream: TFileStream): String;
var
liBytesRemaining: integer;
lsContents: AnsiString;
@ -185,13 +185,7 @@ begin
begin
pcFileStream.ReadBuffer(lsContents[1], liBytesRemaining);
end;
// convert to wide string
{$IFDEF DELPHI12}
Result := UTF8ToWideString(lsContents);
{$ELSE}
Result := UTF8Decode(lsContents);
{$ENDIF}
Result := lsContents;
end;
@ -249,9 +243,7 @@ begin
begin
// swap the bytes
for liLoop := 0 to charsRemaining - 1 do
begin
ucs4Chars[liLoop] := SwapWords(ucs4Chars[liLoop]);
end;
end;
Result := UCS4StringToWideString(ucs4Chars);
@ -261,11 +253,11 @@ end;
the file can contain 8-bit or 16-bit chars
code is much adapted from a sample by Mike Shkolnik
in nntp://borland.public.delphi.rtl.general
Re: Read UNICODE/ANSI/ASCII Text File to WideString
Re: Read UNICODE/ANSI/ASCII Text File to String
at: Jan 23 2006, 12:17
found at http://delphi.newswhat.com/geoxml/forumhistorythread?groupname=borland.public.delphi.rtl.general&messageid=43d485bf$1@newsgroups.borland.com
}
procedure ReadTextFile(const psFileName: string; out psContents: WideString;
procedure ReadTextFile(const psFileName: string; out psContents: String;
out peContentType: TFileContentType);
var
fs: TFileStream;
@ -288,10 +280,10 @@ begin
psContents := ReadUtf8File(fs);
eUtf16LittleEndian, eUtf16BigEndian:
psContents := Read16BitFile(fs, peContentType = eUtf16BigEndian);
psContents := {%H-}Read16BitFile(fs, peContentType = eUtf16BigEndian);
eUtf32LittleEndian, eUtf32BigEndian:
psContents := Read32BitFile(fs, peContentType = eUtf32BigEndian);
psContents := {%H-}Read32BitFile(fs, peContentType = eUtf32BigEndian);
else
raise Exception.Create('Unknown file content type: ' + IntToStr(Ord(peContentType)));
@ -303,32 +295,26 @@ begin
end;
{ this is one of the few cases when "AnsiString" must be used }
procedure Write8BitFile(const pcFileStream: TFileStream; const psContents: WideString);
procedure Write8BitFile(const pcFileStream: TFileStream; const psContents: String);
var
Len: integer;
lsContents: AnsiString;
begin
lsContents := AnsiString(psContents);
lsContents := psContents;
Len := Length(lsContents);
if Len > 0 then
begin
pcFileStream.WriteBuffer(lsContents[1], Len);
end;
end;
{ this is one of the few cases when "AnsiString" must be used }
procedure WriteUtf8File(const pcFileStream: TFileStream; const psContents: WideString);
procedure WriteUtf8File(const pcFileStream: TFileStream; const psContents: String);
var
Len: integer;
lsContents: AnsiString;
utf8Header: array [0..2] of byte;
begin
lsContents := UTF8Encode(psContents);
lsContents := psContents;
Len := Length(lsContents);
// write the BOM
utf8Header[0] := Utf8Marker1;
utf8Header[1] := Utf8Marker2;
@ -336,9 +322,7 @@ begin
pcFileStream.WriteBuffer(utf8Header[0], 3);
if Len > 0 then
begin
pcFileStream.WriteBuffer(lsContents[1], Len);
end;
end;
procedure Write16BitFile(const pcFileStream: TFileStream;
@ -418,7 +402,7 @@ begin
end;
end;
procedure WriteTextFile(const psFileName: string; const psContents: WideString;
procedure WriteTextFile(const psFileName: string; const psContents: String;
const peContentType: TFileContentType);
var
fs: TFileStream;
@ -439,12 +423,12 @@ var
eUtf16LittleEndian, eUtf16BigEndian:
begin
Write16BitFile(fs, psContents, peContentType = eUtf16BigEndian);
Write16BitFile(fs, psContents{%H-}, peContentType = eUtf16BigEndian);
end;
eUtf32LittleEndian, eUtf32BigEndian:
begin
Write32BitFile(fs, psContents, peContentType = eUtf32BigEndian);
Write32BitFile(fs, psContents{%H-}, peContentType = eUtf32BigEndian);
end;
else