Commit Graph

57 Commits

Author SHA1 Message Date
paul
0be1f4d23d rtl: missing FPC_UNICODESTRING_TYPE_DEFINED define
git-svn-id: trunk@23600 -
2013-02-13 00:16:11 +00:00
Jonas Maebe
7c578c3541 * made the pascal name of the string range checking helpers match
their assembler name

git-svn-id: trunk@23324 -
2013-01-06 15:05:33 +00:00
Jonas Maebe
fe5a4baa15 - removed FPC 2.4 bootstrapping support
git-svn-id: trunk@23321 -
2013-01-06 15:05:20 +00:00
Jonas Maebe
e073bf3008 * set destination codepage in DefaultUnicode2AnsiMove
git-svn-id: trunk@22247 -
2012-08-26 14:51:26 +00:00
Jonas Maebe
504544e173 * fixed null-termination in StringToWideChar() if the buffer is larger than
the string (mantis #22669)

git-svn-id: trunk@22124 -
2012-08-19 13:48:02 +00:00
pierre
a311c53167 Replace HandleErrorFrame calls by HandleErrorAddrFrameInd where possible in common code (to allow correct backtrace for mips cpu)
git-svn-id: trunk@21900 -
2012-07-12 11:53:59 +00:00
Jonas Maebe
834026bfb5 * synchronised with trunk up to r21067
git-svn-id: branches/jvmbackend@21068 -
2012-04-26 21:24:20 +00:00
paul
19d1cf9470 rtl: reduce amount of warnings regards implicit string conversions + little formatting
git-svn-id: trunk@20925 -
2012-04-19 01:33:47 +00:00
Jonas Maebe
aee5380ae0 * merged trunk up to r20882
o support for the new codepage-aware ansistrings in the jvm branch
   o empty ansistrings are now always represented by a nil pointer rather than
     by an empty string, because an empty string also has a code page which
     can confuse code (although this will make ansistrings harder to use
     in Java code)
   o more string helpers code shared between the general and jvm rtl
   o support for indexbyte/word in the jvm rtl (warning: first parameter
     is an open array rather than an untyped parameter there, so
     indexchar(pcharvar^,10,0) will be equivalent to
     indexchar[pcharvar^],10,0) there, which is different from what is
     intended; changing it to an untyped parameter wouldn't help though)
   o default() support is not yet complete
   o calling fpcres is currently broken due to limitations in
     sysutils.executeprocess() regarding handling unix quoting and
     the compiler using the same command lines for scripts and directly
     calling external programs
   o compiling the Java compiler currently requires adding ALLOW_WARNINGS=1
     to the make command line

git-svn-id: branches/jvmbackend@20887 -
2012-04-15 15:54:10 +00:00
sergei
180686e429 * Removed 'first' field and 'packed' attribute from TAnsiRec and TUnicodeRec. Removing 'packed' should yield more efficient code on alignment-sensitive targets, while removing 'first' effectively makes two records identical to each other. Further cleanup is possible, but let's see the test suite results before proceeding.
git-svn-id: trunk@20275 -
2012-02-07 16:23:50 +00:00
sergei
a1cb87bcf8 * Improved ucs4 to utf16 conversions: removed function call on every character and multiple memory allocations, made as much code as possible shared between WideString and UnicodeString versions.
git-svn-id: trunk@20270 -
2012-02-06 19:55:56 +00:00
sergei
e94508d5eb * Improved utf16 to ucs4 conversion routines: removed function call on every character, allocate memory once and made as much as possible code shared between WideString and UnicodeString versions.
git-svn-id: trunk@20269 -
2012-02-06 17:55:06 +00:00
sergei
8dab34b31a * fpc_char_to_unicodestr: call widestringmanager directly instead of nested char_to_uchar conversion.
* UnicodeToUtf8: calculate UCS4 value without three (!) temp string variables. Also removed separate word-sized variable and unsigned subtractions.

git-svn-id: trunk@20268 -
2012-02-06 10:22:17 +00:00
sergei
f07d02b427 - Removed string conversion helpers that are not actually used by compiler code generation (duplicated pwidechar/punicodechar stuff).
- Removed one copy of duplicated utf8 encode/decode procedures.

git-svn-id: trunk@20262 -
2012-02-05 18:01:04 +00:00
sergei
8d26b3358f RTL, wide/unicode strings cleanup:
- Removed outdated debugging code
- Removed DefaultWide2AnsiMove, using DefaultUnicode2AnsiMove instead.
- Removed unnecessary operations like SetLength before widestringmanager conversion calls and null-termination afterwards.
- Removed setting pointer to nil after fpc_wide/unicodestr_decr_ref.

git-svn-id: trunk@20231 -
2012-02-03 11:12:25 +00:00
sergei
7ff76caa73 * Removed 'inline' attribute from 6 overloaded pos() functions which contain a managed typecast. Inlining it leads to noticeable increase in code size without any sensible speed improvement.
* Added 'const' modifier to the first argument of these functions in order to avoid creating a local copy.

git-svn-id: trunk@20207 -
2012-02-01 13:34:36 +00:00
sergei
06192a8137 Values of managed variables are never ever used after decrementing reference on the variable, so there is no point of having a 'decrement reference' as a separate operation. We can always do 'finalize', i.e. clear the contents after decref.
* Modified fpc_ansistr_decr_ref and fpc_widestr_decr_ref so they always zero the pointer passed by reference. Other _decr_ref helpers already do it.
- Removed tcg.g_decrrefcount, calling cg.g_finalize instead.
- finalize_data_node and tcg.g_finalize: removed code generation for zeroing locations, because it is now done by RTL helpers. This further reduces code size.

As a total result of this change and r20118, the size of Lazarus executable is reduced by about 12%.

git-svn-id: trunk@20119 -
2012-01-19 23:11:09 +00:00
sergei
009ee271ec - Cleaned out STR_CONCAT_PROCS define
- i386-specific fpc_shortstr_append_shortstr removed too, because a) it was anyway disabled with STR_CONCAT_PROCS, b) the generic implementation is smaller and probably faster due to optimized Move().

git-svn-id: trunk@19867 -
2011-12-17 17:22:18 +00:00
sergei
724f41a9af - Cleaned out FPC_STRTOSHORTSTRPROC and FPC_STRTOCHARARRAYPROC defines. Somebody had to do it one day.
git-svn-id: trunk@19851 -
2011-12-14 22:40:08 +00:00
paul
270fb09e87 rtl: add WideStringManager.GetStandardCodePageProc method to retrieve system ansi and console code pages
git-svn-id: trunk@19539 -
2011-10-25 01:39:11 +00:00
paul
c1866d5c17 compiler:
- don't pass CP_NONE encoding to internal functions. They handled it as 0 encoding. This will optimize the generated code a bit.
  - convert all king of string/char/pchar constants to local ansistring def if they needs to be passed to rawbytestring type. They should not get a CP_NONE codepage (delphi compatible)
  - don't convert left and right arguments of string concatenation to ansistring type if they are already ansistrings but with different codepage - RTL already handles different codepages in concat routine
  - fix resultdef for ansistring concatenations inside assignments - return def of left assignment operand if it is already ansistring - this reduces amount of unneeded condepage conversions since concat functions can return result in any desired codepage
rtl: remove CP_NONE comparisions from most of RTL functions, replace 0 constant with CP_ACP
tests: add test to check various conversions to RawByteString type

git-svn-id: trunk@19519 -
2011-10-20 09:25:51 +00:00
sergei
018fdaf839 - Removed unnecessary operations: SetLength before widestringmanager calls (widestringmanager does the allocation) and zero-termination after SetLength (SetLength does zero-termination).
git-svn-id: trunk@19483 -
2011-10-13 17:10:12 +00:00
paul
836889fc64 rtl: move some CP_xxx constants from syswin into systemh for generic use, redeclare UTF8Sting, RawByteString using constant identifiers instead of pure numbers. replace comparison with $ffff codepage to CP_NONE
git-svn-id: trunk@19354 -
2011-10-04 05:05:14 +00:00
paul
6384fa2a19 rtl: revert r19330. We probably need to create a separate encoding<->codepage table.
git-svn-id: trunk@19332 -
2011-10-03 10:28:14 +00:00
paul
a0e7196ae9 rtl: move winiconv.inc into general inc directory and rename it to wincodepages.inc, also rename win2iconv, iconv2win to CodePageToCodePageName, CodePageNameToCodePage.
This change is required since CodePage to CodePage name conversions are required in other parts of RTL. Moreover those codepage identifiers are windows codepage identifiers and thus must be compatible with codepage identifiers used by delphi.

git-svn-id: trunk@19330 -
2011-10-03 03:35:45 +00:00
florian
d7f7a9bb76 * patch by Alexander Shishkin to clean up $ifopt usage by $push/$pop, resolves #20346
git-svn-id: trunk@19256 -
2011-09-27 20:22:40 +00:00
Jonas Maebe
fadf8bf2a5 * fixed fpc_UnicodeStr_CheckRange() now that apparently the length in
unicodestring record is stored as the number of widechars rather than
    the number of bytes

git-svn-id: trunk@19198 -
2011-09-23 21:17:51 +00:00
sergei
f2852137c8 * DisposeAnsiString doesn't need to exist as a separate procedure, because it is only called from a single place. Merging it into caller yields somewhat more efficient code.
* DisposeWideString,DisposeUnicodeString: likewise.

git-svn-id: trunk@19163 -
2011-09-20 18:53:29 +00:00
paul
fd5a15fda5 rtl: manual merge some cpstrnew changes which was impossible to merge using regular tools due to the merge conflicts
git-svn-id: trunk@19132 -
2011-09-17 15:39:46 +00:00
paul
631c545423 merge r19075 from cpstrnew branch by paul:
rtl: change UTF8Decode, UTF8Encode, AnsiToUTF8, UTF8ToAnsi to use RawByteString as arguments/result for compatibility with the old code and also with delphi

git-svn-id: trunk@19128 -
2011-09-17 14:30:17 +00:00
paul
5ac95bc27a merge r17607 from cpstrnew branch by inoussa:
Updated to take care of the code page : fpc_ansistr_to_chararray, fpc_ansistr_to_widechararray

git-svn-id: trunk@19124 -
2011-09-17 14:18:53 +00:00
paul
005795495d merge r17552 from cpstrnew branch by inoussa:
*In normal procedure "var" and "out" RawByteString parameters does not accept other string types. Procedures with
"compilerproc" directive or the newly added "rtlproc" directive accept that. Please note that it is up to the
procedure coder to ensure the correctness of the code page in that case. The new directive is needed to handle 
the RTL procedures/functions that are not marked as "compilerproc" such as "UniqueString", "Insert" and "Delete".

*Correct "fpc_ansistr_concat" to handle code page correctly.

*Default "ansitring" type is now created with code page set to "0" instead of "65535". Before that change it was 
impossible to distinguish a "RawByteString" with the default "ansistring". At runtime "ansistring" variable'code
page is set to DefaultSystemCodePage

*UniqueString flavor of "SetLength" has been updated to release memory when shrinked to at least 50%, like ansitring
does.

git-svn-id: trunk@19118 -
2011-09-17 13:52:09 +00:00
paul
f8b5920f31 merge r17438 from cpstrnew branch by michael:
* Applied patch from Inoussa to fix copy of unicode string

git-svn-id: trunk@19112 -
2011-09-17 13:27:26 +00:00
paul
1db610ecbd merge r17434 from cpstrnew branch by michael:
* Patch from Inoussa to fix constant strings with codepage

git-svn-id: trunk@19109 -
2011-09-17 13:19:59 +00:00
paul
7fd7eee1c9 merge r17330 from cpstrnew branch by michael:
* Patch from Inoussa, fixing tunistr1.pp and twide1.pp

git-svn-id: trunk@19107 -
2011-09-17 13:12:07 +00:00
paul
091627883f merge r14347 from cpstrnew branch by florian:
* fixed bootstrapping with 2.4.0
* patches by Graeme Geldenhuys, resolve #15251, #15252, #15253

git-svn-id: trunk@19102 -
2011-09-17 12:00:06 +00:00
paul
2162add8ac merge r14132 from cpstrnew branch by paul:
- a set of rtl changes from AnsiString to RawByteString to various conversion functions
- a test which proves output in cp1251 and cp866 codepages (standard for Russian windows)

git-svn-id: trunk@19093 -
2011-09-17 11:39:13 +00:00
paul
848ca6b0c0 merge r14130 from cpstrnew branch by paul:
pass unicodestring to rawbytestring arguments with converting to default system code page

git-svn-id: trunk@19091 -
2011-09-17 11:34:42 +00:00
paul
afa559ab2e merge r14123 from cpstrnew branch by paul:
fix string ref count for empty strings

git-svn-id: trunk@19089 -
2011-09-17 11:27:05 +00:00
paul
5e9ee14ee7 merge r 14122 from cpstrnew branch by paul:
fix StringCodePage for empty unicode and ansi strings

git-svn-id: trunk@19088 -
2011-09-17 11:24:49 +00:00
paul
203ded84ec merge r14121 from cpstrnew branch by paul:
make tcpstr1 work

git-svn-id: trunk@19087 -
2011-09-17 11:23:02 +00:00
paul
8cc22972a0 merge r13488 from cpstrnew branch by florian except ncgcon.pas which has a difficult merge conflict (code moved to another unit which is not at the branch during the revision):
* first batch of patches to make tcpstr1.pp work

git-svn-id: trunk@19085 -
2011-09-17 11:16:45 +00:00
paul
ae0d732c8f merge r13485 from cpstrnew branch by florian:
* fixed compilation of system unit after last changes

git-svn-id: trunk@19083 -
2011-09-17 11:01:42 +00:00
paul
28627482c5 merge r13483 from cpstrnew branch by florian:
+ Win32Unicode2AnsiMove and Win32Wide2AnsiMove support code page parameter
+ Win32Ansi2UnicodeMove and Win32Ansi2WideMove support code page parameter
+ code page parameter added for several compilerprocs
* unified more code between win32 and win64 (widestring conversion routines

git-svn-id: trunk@19082 -
2011-09-17 10:54:00 +00:00
paul
8a4634a7b1 merge r13481 from cpstrnew branch by florian
+ support parsing of strings with code page specification
+ added encoding and elementsize field to ansi- and unicodestring records
+ some basic rtl support routines for encoding aware strings
+ DefaultSystemCodePage
+ DefaultUnicodeCodePage
+ ppu writing/loading of code page aware strings

git-svn-id: trunk@19080 -
2011-09-17 10:37:36 +00:00
Jonas Maebe
3a423b331c * full implementation of all routines in rtl/inc/ustringh.inc (except for
val/str for enums for now) for the JVM target: insert/delete/pos/...
  * use generic unicodestring helper routines where possible for the JVM
    target (not that many as for shortstrings since unicodestring is
    handled using java.lang.String)
  + complete widestring manager implementation for the JVM target. It uses
    a class with virtual methods rather than a record with function pointers
    for speed reasons though (since no existing widestring manager will be
    compatible anyway, that shouldn't cause any problems)

git-svn-id: branches/jvmbackend@18882 -
2011-08-28 19:22:22 +00:00
Jonas Maebe
1403e3df29 * renamed fpc_WChar_To_ShortStr() compilerproc to fpc_UChar_To_ShortStr() for
consistency with other helpers
  + added lowercase(unicodechar) and lowercase(unicodestring) overloads (for some
    reason only upcase() existed for them)

git-svn-id: branches/jvmbackend@18881 -
2011-08-28 19:22:15 +00:00
sergei
829ee9828d * Added back pre-r17129 configuration of string range check helpers under {$ifdef ver2_4}. Without it, bootstrapping with 2.4.4 and -Cr is broken.
git-svn-id: trunk@17715 -
2011-06-11 01:14:01 +00:00
sergei
3e6ad5f5aa * tcgvecnode, simplified range checking for strings. Removed FPC_*STR_CHECKZERO helpers, and changed FPC_*STR_CHECKRANGE so they accept the original left node. Now strings are checked the same way as dynamic arrays, and the compiler part is considerably simpler.
git-svn-id: trunk@17129 -
2011-03-13 15:52:02 +00:00
florian
e99c4d1950 + support str(<boolean>,...), boolean is an enumeration type
* don't run pass_1 on str or val calls in generic method/procedure definitions, resolves #18420

git-svn-id: trunk@16849 -
2011-01-30 14:27:09 +00:00