Commit Graph

177 Commits

Author SHA1 Message Date
Michael VAN CANNEYT
3aefada11a * check zero length instead of comparing to empty string 2023-07-14 17:26:11 +02:00
Michael VAN CANNEYT
d2d3fe6bc3 * Char -> AnsiChar 2023-07-14 17:26:10 +02:00
florian
8e4e229a5f + DestSize parameter for fpc_Val_UInt functions 2022-01-11 22:10:26 +01:00
florian
a5f6505edc * fix range checking for zero based strings, resolves #39323 2021-09-05 21:03:31 +02:00
nickysn
800bb3adc2 * instead of using discardresult, wrap the uniquestring functions in procedures,
that are declared as inline

git-svn-id: trunk@49016 -
2021-03-19 21:13:20 +00:00
svenbarth
a2c9c75e97 Convert Insert() and Delete() to intrinsics in preparation for dynamic array support for these two procedures.
Since overloading compilerprocs does not work each procedure got its own unique name, but they are using the new compilerproc extension to map them to the Insert and Delete symbol so that error messages can be shown with the respective name for the procedure declarations instead of fpc_shortstr_delete for example.

git-svn-id: trunk@33895 -
2016-06-03 21:25:49 +00:00
michael
1bdae1edc8 * Correct comments about sizes/offsets in invisible string header record
git-svn-id: trunk@33247 -
2016-03-13 19:03:40 +00:00
michael
463c9f6e42 * Apply patch to improve pos() for widestring (mimicking unicodestring), bug ID #29790
git-svn-id: trunk@33210 -
2016-03-09 20:42:23 +00:00
svenbarth
77cb13c38c Revert r33057. MaxLen is the maximum value that Pos can return and does not need to be adjusted by (Offset - 1). Also there's no buffer that could be overrun as i is not used to access the string's buffer. Fixes failure of tests/test/units/system/tstring.pp
git-svn-id: trunk@33089 -
2016-02-12 16:07:26 +00:00
michael
e2733c9a50 * Small correction in POS (prevent moving out of buffer if offset<>1)
git-svn-id: trunk@33057 -
2016-02-06 12:17:13 +00:00
Jonas Maebe
2afd8eb802 - removed FPC_HAS_STR_CURRENCY-related code, FPC 2.6.4 has it
git-svn-id: trunk@31692 -
2015-09-15 11:51:48 +00:00
michael
a8978361dd * Fix signatures on all platforms
git-svn-id: trunk@31468 -
2015-08-31 19:36:15 +00:00
michael
8161c1135c * Add offset to Pos functions, Delphi XE 8 compatible.
git-svn-id: trunk@31464 -
2015-08-31 13:05:37 +00:00
sergei
ae68a4962f - RTL: merged functionality of InitWideStringManager into InitUnicodeStringManager and removed the former.
git-svn-id: trunk@29130 -
2014-11-23 21:09:00 +00:00
Jonas Maebe
ff583bde6c * made setstring() a compiler intrinsic so it can set the compile-time
code page of ansistrings (mantis #26735)

git-svn-id: trunk@28813 -
2014-10-12 20:27:06 +00:00
sergei
531c2d79e0 - RTL: removed 'unimplementedwidestring' procedure and use 'unimplementedunicodestring' instead. Reduces bloat. Furthermore, a separate message about missing widestring manager is misleading, because there is only one wide/unicodestring manager that can be set.
git-svn-id: trunk@27233 -
2014-03-23 02:16:03 +00:00
sergei
54e561dfa4 * Assign CharLengthPCharProc and CodePointLengthProc always in initunicodestringmanager, doing it in initwidestringmanager only complicates things.
git-svn-id: trunk@27086 -
2014-03-10 20:18:30 +00:00
Jonas Maebe
a5273abc9c + support for CP_OEMCP
* changed all mappings from CP_ACP to DefaultSystemCodePage to calls to the
    new TranslatePlaceholderCP() routine (which also handles CP_OEMCP)
  * removed unnecessary CP_ACP adaptations in fpc_AnsiStr_Concat_multi()
    for JVM target (now handled in the ansistring to unicodestring conversion
    routine)

git-svn-id: branches/cpstrrtl@25091 -
2013-07-12 17:18:24 +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
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
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
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
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
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
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
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
florian
f238c9161b + declaration of missing BufLen
git-svn-id: trunk@19130 -
2011-09-17 15:34:36 +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
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
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
99dae8b97e merge r16256 from cpstrnew branch by marco:
* fix for cycling with 2.4.x

git-svn-id: trunk@19103 -
2011-09-17 12:53:58 +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
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
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
Jonas Maebe
8c9d0f1f78 * fixed Windows compilation after r16533
git-svn-id: trunk@16539 -
2010-12-10 17:27:25 +00:00
sergei
1e11244ddf * Fix overflow in Delete procedure for Wide- and UnicodeStrings when its Size argument is MaxInt. Now using the same code as in AnsiString version. Mantis #17514.
git-svn-id: trunk@16092 -
2010-10-06 17:31:08 +00:00
florian
7a82669942 * forgotten part of r14432
git-svn-id: trunk@14433 -
2009-12-13 11:18:49 +00:00
Jonas Maebe
be39c47d02 * don't stop at #0 characters for setstring with pchar either
git-svn-id: trunk@13828 -
2009-10-09 19:47:46 +00:00
Jonas Maebe
6a0755e897 * fixed setstring for unicode/widestring: don't stop at embedded #0
characters, don't expect that buffer is null-terminated (mantis #14740)

git-svn-id: trunk@13826 -
2009-10-09 16:12:03 +00:00