diff --git a/compiler/ccharset.pas b/compiler/ccharset.pas index 77b6399e15..bb6073c8a6 100644 --- a/compiler/ccharset.pas +++ b/compiler/ccharset.pas @@ -13,9 +13,6 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. **********************************************************************} - -{ this unit is included temporarily for 2.2 bootstrapping and can be - removed after the next release after 2.2.2 } {$mode objfpc} unit ccharset; @@ -41,8 +38,8 @@ unit ccharset; punicodemap = ^tunicodemap; tunicodemap = record - cpname : string[20]; - cp : word; + cpname : string[20]; + cp : word; map : punicodecharmapping; lastchar : longint; next : punicodemap; @@ -52,11 +49,15 @@ unit ccharset; tcp2unicode = class(tcsconvert) end; + const + DefaultSystemCodePage = 437; + function loadunicodemapping(const cpname,f : string; cp :word) : punicodemap; procedure registermapping(p : punicodemap); - function getmap(const s : string) : punicodemap; - function getmap(cp : word) : punicodemap; + function getmap(const s : string) : punicodemap; + function getmap(cp : word) : punicodemap; function mappingavailable(const s : string) : boolean; + function mappingavailable(cp :word) : boolean; function getunicode(c : char;p : punicodemap) : tunicodechar; function getascii(c : tunicodechar;p : punicodemap) : string; @@ -84,9 +85,9 @@ unit ccharset; datasize:=256; getmem(data,sizeof(tunicodecharmapping)*datasize); assign(t,f); - {$push}{$I-} + {$I-} reset(t); - {$pop} + {$I+} if ioresult<>0 then begin freemem(data,sizeof(tunicodecharmapping)*datasize); @@ -202,7 +203,7 @@ unit ccharset; hp:=hp^.next; end; getmap:=nil; - end; + end;//////// function getmap(cp : word) : punicodemap; @@ -232,7 +233,7 @@ unit ccharset; hp:=hp^.next; end; getmap:=nil; - end; + end; function mappingavailable(const s : string) : boolean; @@ -240,6 +241,12 @@ unit ccharset; mappingavailable:=getmap(s)<>nil; end; + function mappingavailable(cp : word) : boolean; + + begin + mappingavailable:=getmap(cp)<>nil; + end; + function getunicode(c : char;p : punicodemap) : tunicodechar; begin @@ -255,8 +262,8 @@ unit ccharset; i : longint; begin - { at least map to space } - getascii:=#32; + { at least map to '?' } + getascii:=#63; for i:=0 to p^.lastchar do if p^.map[i].unicode=c then begin diff --git a/compiler/cp1251.pas b/compiler/cp1251.pas index 2474932e16..83beeabfbb 100644 --- a/compiler/cp1251.pas +++ b/compiler/cp1251.pas @@ -6,7 +6,7 @@ unit cp1251; implementation uses - {$ifdef VER2_2}ccharset{$else VER2_2}charset{$endif VER2_2}; + {$ifdef VER2_4}ccharset{$else VER2_4}charset{$endif VER2_4}; const map : array[0..255] of tunicodecharmapping = ( @@ -269,8 +269,8 @@ unit cp1251; ); unicodemap : tunicodemap = ( - cpname : 'cp1251'; - cp : 1251; + cpname : 'cp1251'; + cp : 1251; map : @map; lastchar : 255; next : nil; diff --git a/compiler/cp1252.pp b/compiler/cp1252.pp index 51d62974ac..2f661834ca 100644 --- a/compiler/cp1252.pp +++ b/compiler/cp1252.pp @@ -6,7 +6,7 @@ unit CP1252; implementation uses - charset; + {$ifdef VER2_4}ccharset{$else VER2_4}charset{$endif VER2_4}; const map : array[0..255] of tunicodecharmapping = ( diff --git a/compiler/cp437.pas b/compiler/cp437.pas index a7587d91c7..6a416833af 100644 --- a/compiler/cp437.pas +++ b/compiler/cp437.pas @@ -6,7 +6,7 @@ unit cp437; implementation uses - {$ifdef VER2_2}ccharset{$else VER2_2}charset{$endif VER2_2}; + {$ifdef VER2_4}ccharset{$else VER2_4}charset{$endif VER2_4}; const map : array[0..255] of tunicodecharmapping = ( @@ -270,7 +270,7 @@ unit cp437; unicodemap : tunicodemap = ( cpname : 'cp437'; - cp : 437; + cp : 437; map : @map[0]; lastchar : 255; next : nil; diff --git a/compiler/cp850.pas b/compiler/cp850.pas index 9ae14ff5a7..3eac682738 100644 --- a/compiler/cp850.pas +++ b/compiler/cp850.pas @@ -6,7 +6,7 @@ unit cp850; implementation uses - {$ifdef VER2_2}ccharset{$else VER2_2}charset{$endif VER2_2}; + {$ifdef VER2_4}ccharset{$else VER2_4}charset{$endif VER2_4}; const map : array[0..255] of tunicodecharmapping = ( @@ -269,8 +269,8 @@ unit cp850; ); unicodemap : tunicodemap = ( - cpname : 'cp850'; - cp : 850; + cpname : 'cp850'; + cp : 850; map : @map[0]; lastchar : 255; next : nil; diff --git a/compiler/cp866.pas b/compiler/cp866.pas index 7df9db7f4f..4990a73267 100644 --- a/compiler/cp866.pas +++ b/compiler/cp866.pas @@ -6,7 +6,7 @@ unit cp866; implementation uses - {$ifdef VER2_2}ccharset{$else VER2_2}charset{$endif VER2_2}; + {$ifdef VER2_4}ccharset{$else VER2_4}charset{$endif VER2_4}; const map : array[0..255] of tunicodecharmapping = ( @@ -269,8 +269,8 @@ unit cp866; ); unicodemap : tunicodemap = ( - cpname : 'cp866'; - cp : 866; + cpname : 'cp866'; + cp : 866; map : @map; lastchar : 255; next : nil; diff --git a/compiler/cp8859_1.pas b/compiler/cp8859_1.pas index ed8951fc06..88b6360261 100644 --- a/compiler/cp8859_1.pas +++ b/compiler/cp8859_1.pas @@ -6,7 +6,7 @@ unit cp8859_1; implementation uses - {$ifdef VER2_2}ccharset{$else VER2_2}charset{$endif VER2_2}; + {$ifdef VER2_4}ccharset{$else VER2_4}charset{$endif VER2_4}; const map : array[0..255] of tunicodecharmapping = ( @@ -269,9 +269,9 @@ unit cp8859_1; ); unicodemap : tunicodemap = ( - cpname : '8859-1'; - cp : 28591; - map : @map[0]; + cpname : '8859-1'; + cp : 28591; + map : @map[0]; lastchar : 255; next : nil; internalmap : true diff --git a/compiler/cp8859_5.pas b/compiler/cp8859_5.pas index 694d0c86cd..12ea9d6870 100644 --- a/compiler/cp8859_5.pas +++ b/compiler/cp8859_5.pas @@ -6,7 +6,7 @@ unit cp8859_5; implementation uses - {$ifdef VER2_2}ccharset{$else VER2_2}charset{$endif VER2_2}; + {$ifdef VER2_4}ccharset{$else VER2_4}charset{$endif VER2_4}; const map : array[0..255] of tunicodecharmapping = ( @@ -269,8 +269,8 @@ unit cp8859_5; ); unicodemap : tunicodemap = ( - cpname : '8859-5'; - cp : 28595; + cpname : '8859-5'; + cp : 28595; map : @map; lastchar : 255; next : nil; diff --git a/compiler/cresstr.pas b/compiler/cresstr.pas index 118a3828a9..4a12f223f0 100644 --- a/compiler/cresstr.pas +++ b/compiler/cresstr.pas @@ -37,7 +37,11 @@ uses symconst,symtype,symdef,symsym, verbose,fmodule,ppu, aasmbase,aasmtai,aasmdata, - aasmcpu,asmutils; + aasmcpu, +{$if FPC_FULLVERSION<20700} + ccharset, +{$endif } + asmutils; Type { These are used to form a singly-linked list, ordered by hash value } @@ -203,7 +207,7 @@ uses { Update: the Mac OS X 10.6 linker orders data that needs to be } { relocated before all other data, so make this data relocatable, } { otherwise the end label won't be moved with the rest } - if (target_info.system in systems_darwin) then + if (target_info.system in systems_darwin) then current_asmdata.asmlists[al_resourcestrings].concat(Tai_const.create_sym(endsymlab)); end; diff --git a/compiler/options.pas b/compiler/options.pas index 8e3696fbc4..ed24b442d3 100644 --- a/compiler/options.pas +++ b/compiler/options.pas @@ -78,7 +78,7 @@ implementation uses widestr, - {$ifdef VER2_2}ccharset{$else VER2_2}charset{$endif VER2_2}, + {$ifdef VER2_4}ccharset{$else VER2_4}charset{$endif VER2_4}, SysUtils, version, cutils,cmsgs, @@ -904,7 +904,7 @@ begin 'm' : begin s:=ExtractFileDir(more); - if TryStrToInt(ExtractFileName(more),j) then + if TryStrToInt(ExtractFileName(more),j) then begin unicodemapping:=loadunicodemapping(More,More+'.txt',j); if assigned(unicodemapping) then @@ -2313,7 +2313,7 @@ begin if (paratargetdbg in [dbg_dwarf2,dbg_dwarf3]) and not(target_info.system in systems_darwin) then begin - { smartlink creation does not yet work with DWARF + { smartlink creation does not yet work with DWARF debug info on most targets, but it works in internal assembler } if (cs_create_smart in init_settings.moduleswitches) and not (af_outputbinary in target_asm.flags) then diff --git a/compiler/scanner.pas b/compiler/scanner.pas index 52419b15b6..0d6a171e3e 100644 --- a/compiler/scanner.pas +++ b/compiler/scanner.pas @@ -268,7 +268,11 @@ implementation symbase,symtable,symtype,symsym,symconst,symdef,defutil, { This is needed for tcputype } cpuinfo, - fmodule; + fmodule +{$ifdef FPC_FULLVERSION<20700} + ,ccharset +{$endif} + ; var { dictionaries with the supported directives } diff --git a/compiler/widestr.pas b/compiler/widestr.pas index e02a03c717..18646424d5 100644 --- a/compiler/widestr.pas +++ b/compiler/widestr.pas @@ -28,7 +28,7 @@ unit widestr; interface uses - {$ifdef VER2_2}ccharset{$else VER2_2}charset{$endif VER2_2},globtype; + {$ifdef VER2_4}ccharset{$else VER2_4}charset{$endif VER2_4},globtype; type @@ -59,7 +59,7 @@ unit widestr; function cpavailable(const s : string) : boolean; function cpavailable(cp : word) : boolean; procedure changecodepage( - s : pchar; l : SizeInt; scp : tstringencoding; + s : pchar; l : SizeInt; scp : tstringencoding; d : pchar; dcp : tstringencoding ); function codepagebyname(const s : string) : tstringencoding; @@ -284,15 +284,15 @@ unit widestr; function cpavailable(const s : string) : boolean; begin cpavailable:=mappingavailable(lower(s)); - end; - + end; + function cpavailable(cp : word) : boolean; begin cpavailable:=mappingavailable(cp); - end; + end; procedure changecodepage( - s : pchar; l : SizeInt; scp : tstringencoding; + s : pchar; l : SizeInt; scp : tstringencoding; d : pchar; dcp : tstringencoding ); var @@ -311,7 +311,7 @@ unit widestr; inc(dest); inc(source); end; - end; + end; function codepagebyname(const s : string) : tstringencoding; var @@ -320,7 +320,7 @@ unit widestr; Result:=0; p:=getmap(s); if (p<>nil) then - Result:=p^.cp; + Result:=p^.cp; end; end.