From e03fd447770c1f8698d438f54fe09c9b756f5bd9 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Mon, 28 Mar 2016 21:56:44 +0200 Subject: [PATCH] update etc/fscl-json to 33310 --- etc/fcl-json/src/xfpjson.pp | 8 ++++++-- etc/fcl-json/src/xfpjsonrtti.pp | 2 +- etc/fcl-json/src/xjsonconf.pp | 20 ++++++++++++++++++-- src/ce_dubproject.pas | 1 + src/ce_optionseditor.pas | 2 +- 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/etc/fcl-json/src/xfpjson.pp b/etc/fcl-json/src/xfpjson.pp index e2eeb18e..14053d62 100644 --- a/etc/fcl-json/src/xfpjson.pp +++ b/etc/fcl-json/src/xfpjson.pp @@ -668,6 +668,7 @@ function StringToJSONString(const S: TJSONStringType): TJSONStringType; Var I,J,L : Integer; P : PJSONCharType; + C : AnsiChar; begin I:=1; @@ -677,10 +678,11 @@ begin P:=PJSONCharType(S); While I<=L do begin - if (AnsiChar(P^) in ['"','/','\',#8,#9,#10,#12,#13]) then + C:=AnsiChar(P^); + if (C in ['"','/','\',#0..#31]) then begin Result:=Result+Copy(S,J,I-J); - Case P^ of + Case C of '\' : Result:=Result+'\\'; '/' : Result:=Result+'\/'; '"' : Result:=Result+'\"'; @@ -689,6 +691,8 @@ begin #10 : Result:=Result+'\n'; #12 : Result:=Result+'\f'; #13 : Result:=Result+'\r'; + else + Result:=Result+'\u'+HexStr(Ord(C),4); end; J:=I+1; end; diff --git a/etc/fcl-json/src/xfpjsonrtti.pp b/etc/fcl-json/src/xfpjsonrtti.pp index 057143e4..5f0a5387 100644 --- a/etc/fcl-json/src/xfpjsonrtti.pp +++ b/etc/fcl-json/src/xfpjsonrtti.pp @@ -1,4 +1,4 @@ -unit fpjsonrtti; +unit xfpjsonrtti; {$mode objfpc} diff --git a/etc/fcl-json/src/xjsonconf.pp b/etc/fcl-json/src/xjsonconf.pp index 53f96066..748b8952 100644 --- a/etc/fcl-json/src/xjsonconf.pp +++ b/etc/fcl-json/src/xjsonconf.pp @@ -23,13 +23,15 @@ {$H+} {$ENDIF} -unit jsonConf; +unit xjsonConf; interface uses SysUtils, Classes, xfpjson, xjsonscanner, xjsonparser; +Const + DefaultJSONOptions = [joUTF8,joComments]; type EJSONConfigError = class(Exception); @@ -57,9 +59,11 @@ type FFormatIndentSize: Integer; FFormatoptions: TFormatOptions; FFormatted: Boolean; + FJSONOptions: TJSONOptions; FKey: TJSONObject; procedure DoSetFilename(const AFilename: String; ForceReload: Boolean); procedure SetFilename(const AFilename: String); + procedure SetJSONOptions(AValue: TJSONOptions); Function StripSlash(Const P : UnicodeString) : UnicodeString; protected FJSON: TJSONObject; @@ -109,6 +113,7 @@ type Property Formatted : Boolean Read FFormatted Write FFormatted; Property FormatOptions : TFormatOptions Read FFormatoptions Write FFormatOptions Default DefaultFormat; Property FormatIndentsize : Integer Read FFormatIndentSize Write FFormatIndentSize Default DefaultIndentSize; + Property JSONOptions : TJSONOptions Read FJSONOptions Write SetJSONOptions Default DefaultJSONOptions; end; @@ -127,6 +132,7 @@ begin FKey:=FJSON; FFormatOptions:=DefaultFormat; FFormatIndentsize:=DefaultIndentSize; + FJSONOptions:=DefaultJSONOptions; end; destructor TJSONConfig.Destroy; @@ -687,7 +693,7 @@ begin begin F:=TFileStream.Create(AFileName,fmopenRead); try - P:=TJSONParser.Create(F,[joUTF8,joComments]); + P:=TJSONParser.Create(F,FJSONOptions); try J:=P.Parse; If (J is TJSONObject) then @@ -712,6 +718,16 @@ begin DoSetFilename(AFilename, False); end; +procedure TJSONConfig.SetJSONOptions(AValue: TJSONOptions); +begin + if FJSONOptions=AValue then Exit; + FJSONOptions:=AValue; + if csLoading in ComponentState then + exit; + if (FFileName<>'') then + Reload; +end; + function TJSONConfig.StripSlash(const P: UnicodeString): UnicodeString; Var diff --git a/src/ce_dubproject.pas b/src/ce_dubproject.pas index babf203e..7d4fd52b 100644 --- a/src/ce_dubproject.pas +++ b/src/ce_dubproject.pas @@ -212,6 +212,7 @@ begin parser := TJSONParser.Create(loader, [joIgnoreTrailingComma, joUTF8]); //TODO-cfcl-json: remove etc/fcl-json the day they'll merge and rlz the version with 'Options' //TODO-cfcl-json: track possible changes and fixes at http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/packages/fcl-json/ + //latest in in etc = rev 33310. try try fJSON := parser.Parse as TJSONObject; diff --git a/src/ce_optionseditor.pas b/src/ce_optionseditor.pas index 412981b2..c33ae8f6 100644 --- a/src/ce_optionseditor.pas +++ b/src/ce_optionseditor.pas @@ -251,7 +251,7 @@ begin begin nme := aEditor.GetPropInfo^.Name; len := nme.length; - // TODO-cbugfix: filtering does not work on sub componenets 'e.g D2HL options) + // TODO-cbugfix: filtering does not work on sub components (see editor options, highlighterDlang) if (len > 2) and (nme[len - 2 .. len] = 'Tag') then aShow := false else if (len > 3) and (nme[len - 3 .. len] = 'Name') then