Commit Graph

247 Commits

Author SHA1 Message Date
florian
3180c985ed * fix naming (no functional change) 2024-07-03 18:47:26 +02:00
Rika Ichinose
4c6abb38b1 Non-nil-aware fpc_ansistr_compare(|_equal). 2024-03-08 18:19:03 +00:00
florian
e7600ee245 * patch by Rika: Small improvements to (a|u)strings.inc, resolves #40364 2024-02-11 16:29:53 +01:00
Rika Ichinose
854d944cfa Faster string concatenations. 2023-11-05 14:59:42 +00:00
florian
ba78551c4f * patch by Rika: improve fpc_*_concat_multi, resolves #40251 2023-09-10 19:27:55 +02:00
Michael VAN CANNEYT
dafe77b954 * string -> shortstring, 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
84e7a17b67 * patch by Rika: optimize Pos(), resolves #40088 2023-01-23 22:51:40 +01:00
Sergey Larin
a8b0e0ed65 Added TranslatePlaceholderCP before Wide2AnsiMoveProc call.
In the fpc_setstring_ansistr_pwidechar procedure, before calling Wide2AnsiMoveProc, the translation cp = 0 to the DefaultSystemCodePage has been added.
Note: In all other places such translation is present.
2022-01-26 20:28:17 +00:00
florian
a7a689ca16 * fpc_AnsiStr_To_ShortStr: set length before moving, should result in better memory access pattern 2022-01-20 22:14:33 +01:00
florian
8e4e229a5f + DestSize parameter for fpc_Val_UInt functions 2022-01-11 22:10:26 +01:00
florian
ee10850a57 * patch by Sergey Larin: Reducing and aligning the size of TAnsiRec, TUnicodeRec for CPU64, resolves #38018:
For CPU64, the size of record TAnsiRec and TUnicodeRec is 16 bytes instead of 24.
    Which is very good also because of the alignment. when allocating memory, the address
    of the first character of the string will be aligned on the 16-byte boundary.
    At the same time, the useless Dummy field, which is needed in CPU64 for exactly alignment, has been removed.
    For CPU32 (and CPU16), the record size has not changed, so procedures such as
    fpc_AnsiStr_Decr_Ref, implemented in assembler (see i386, arm), remained working correctly.
  * tests adapted
2021-10-17 11:13:29 +02: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
florian
8b08079224 * fpc_AnsiStr_Concat: if one of the strings is empty and CP_NONE is passed, the code page
of the other string is taken, this is also like fpc_AnsiStr_Concat_multi works if length(sarr)=2

git-svn-id: trunk@47976 -
2021-01-02 16:39:39 +00:00
yury
c3954a0cee * Fixed r44960. Also copy a trailing implicit #0 of the original string to the new larger string.
git-svn-id: trunk@44970 -
2020-04-21 18:55:24 +00:00
yury
1e32b96bc2 * Minor improvement. No need to move the terminating null char, since it is written later anyway. Remove a local var.
git-svn-id: trunk@44960 -
2020-04-21 14:18:35 +00:00
michael
68bb9bef2c * Optimize fpc_AnsiStr_Compare to not use exception frame unless codepages differ
git-svn-id: trunk@35620 -
2017-03-18 14:38:50 +00:00
michael
2714a06e77 * Small optimization for comparing nil strings.
git-svn-id: trunk@35619 -
2017-03-18 14:22:57 +00:00
michael
ae6b9652fc * Avoid exception frame in ansistring compare for cases where codepage is equal
git-svn-id: trunk@35603 -
2017-03-15 22:02:29 +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
Jonas Maebe
1294dc1ede * when inserting a non-empty ansistring into an empty ansistring, the
destination must get the code page of the source (mantis #28850)

git-svn-id: trunk@32066 -
2015-10-16 19:15:40 +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
Jonas Maebe
2b551d0241 * don't do anything in SetCodePage() if the requested code page is the same
as the current one, even if there are multiple references to the string

git-svn-id: trunk@31488 -
2015-09-03 13:35:55 +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
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
nickysn
ec9a57f854 * local variables in fpc_AnsiStr_Concat_multi changed from nativeint to objpasint
git-svn-id: trunk@27235 -
2014-03-23 12:43:52 +00:00
Jeppe Johansen
9b79f2f68d Added support for 8-bit CPU's in RTL. Mostly for missing implementations of int<->string conversion and console/text output.
git-svn-id: trunk@26958 -
2014-03-04 20:00:03 +00:00
nickysn
ad45bc17ec * local variables in fpc_AnsiStr_Concat_multi changed from longint to nativeint
git-svn-id: trunk@26926 -
2014-03-02 19:24:24 +00:00
Jonas Maebe
951727f453 * fixed crash when concatenating more than 2 ansistrings that are all empty
(mantis #25349, patch by C Western)

git-svn-id: trunk@26119 -
2013-11-22 12:57:41 +00:00
Jonas Maebe
14d62028ff * don't convert ansistrings when calling setcodepage() with a code page
number that means the same as the existing one but is nevertheless
    different (e.g. CP_ACP and the actual value of DefaultSystemCodePage)

git-svn-id: branches/cpstrrtl@25299 -
2013-08-19 22:04:11 +00:00
Jonas Maebe
b115231ea4 * never change the code page of a non-empty string when calling setlength on
it

git-svn-id: branches/cpstrrtl@25298 -
2013-08-19 22:04:07 +00:00
Jonas Maebe
29132f45b7 * synchronised with trunk up to r25167 (fixes glib compilation via r25164,
and occasional crashes in executeprocess on libc platforms via r25167)

git-svn-id: branches/cpstrrtl@25169 -
2013-07-24 14:24:49 +00:00
Jonas Maebe
1a560e9875 * when concatenating ansistrings, do not map CP_NONE (rawbytestring) to
CP_ACP (defaultsystemcodepage), because if all input strings have the
    same code page then the result should also have that code page if it's
    assigned to a rawbytestring rather than getting defaultsystemcodepage
  * do not consider empty strings to determine the code page of the result
    in fpc_AnsiStr_Concat_multi(), because that will cause a different
    result than when using a sequence of fpc_AnsiStr_Concat() calls (it
    ignores empty strings to determine the result code page) and it's also
    slower
  * do not consider the run time code page of the destination string in
    fpc_AnsiStr_Concat(_multi)() because Delphi does not do so either. This
    was introduced in r19118, probably to hide another bug
  + test

git-svn-id: branches/cpstrrtl@25143 -
2013-07-19 16:33:14 +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
44f4bdfb2e - removed stray stringcodepage assignment in fpc_AnsiStr_Concat_multi()
git-svn-id: branches/cpstrrtl@25090 -
2013-07-12 17:18:20 +00:00
Jonas Maebe
345ca6f187 * prevent going through (the expensive) InternalSetCodePage when changing
the code page of a string with refcount=1 and without conversion (happens
    a lot in internal RTL routines)

git-svn-id: trunk@24985 -
2013-06-27 13:11:57 +00:00
marco
eebfeca41d * removed all ver2_* defines older than 2_4. 2_4 can probably also get removed from trunk, but better in a separate commit.
git-svn-id: trunk@24971 -
2013-06-25 12:46:30 +00:00
florian
00b03de7f0 * split SetCodePage into a wrapper and a function doing the real work to get rid of exception frames in the simple case
git-svn-id: trunk@24942 -
2013-06-22 18:19:50 +00:00
Jonas Maebe
ecd3cba02b * synchronised with trunk up to r24912
o resolved conflict in updated morphos sysutils unit
   o moved code that had been added to the now deleted  sysunix.inc to the
     unix-specific block of the fpwidestring unit's init code

git-svn-id: branches/cpstrrtl@24913 -
2013-06-17 20:50:02 +00:00
nickysn
cac6ac38d0 + added RTL helpers for Val() for longint/dword on 16/8-bit CPUs
git-svn-id: branches/i8086@24048 -
2013-03-29 01:19:14 +00:00
nickysn
4dfbf148f2 + added Str() helpers for 32-bit ints for 16/8-bit CPUs
git-svn-id: branches/i8086@24008 -
2013-03-25 23:55:47 +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
michael
3367a29831 * Update ansistring header record explanation
git-svn-id: trunk@23249 -
2012-12-29 10:23:16 +00:00
Jonas Maebe
598d2feeb6 + rtldefs.inc file for every target that contains defines shared by multiple
RTL units. Comes with a FPCRTL_FILESYSTEM_UTF8 define that can be
    activated for targets whose single byte filesystem interface enforces
    UTF-8; included in inc/systemh.inc and unix/cwstring.pp until now
  + DefaultFileSystemCodePage variable that holds the code page used for
    communicating with the OS single byte file system APIs, and for the
    strings returned by those same APIs. Initialized with
   o the result of GetACP in the system unit of Windows platforms, except for
     WinCE which uses UTF-8 since its file system OS API calls already use
     the UTF-16 versions
   o CP_UTF8 on Unix platforms with FPCRTL_FILESYSTEM_UTF8 defined, and with
     DefaultSystemCodePage on other Unix platforms
   o DefaultSystemCodePage on Java/Android JVM targets
  + DefaultRTLFileSystemCodePage variable that holds the code page used to
    encode strings returned by RTL routines that return filenames obtained
    from OS API calls. By default the same as DefaultFileSystemCodePage on
    all platforms. Separate from DefaultFileSystemCodePage for clarity on
    platforms that may use either utf-16 or single byte OS API calls to
    send/receive file names (such as most Windows platforms)
  + new scpFileSystemSingleByte enum that can be passed to
    GetStandardCodePage() to get the default code page for OS single byte file
    system APIs, with implementations for Unix and Windows
  + SetMultiByteFileSystemCodePage() procedure to override the value of
    DefaultFileSystemCodePage

  In principle, in the long run unchanged programs only using generic
  ansistrings and unicodestrings should (mostly) behave the same as in
  FPC 2.6.0 as far as RTL-level file system APIs are concerned if
  they set DefaultFileSystemCodePage and DefaultRTLFileSystemCodePage
  to DefaultSystemCodePage at the start of their execution

git-svn-id: branches/cpstrrtl@22466 -
2012-09-27 07:54:06 +00:00
Jonas Maebe
8799d9d204 * don't create temporary ansistrings with codepage DefaultSystemCodePage
when concatenating or comparing CP_ACP strings, because the ansistring
    conversion helpers also check for CP_ACP and do the right thing in
    that case
  * don't convert code pages when comparing CP_ACP strings with
    DefaultSystemCodePage strings (mantis #22906)

git-svn-id: trunk@22415 -
2012-09-17 19:41:44 +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