Commit Graph

76 Commits

Author SHA1 Message Date
Jonas Maebe
cec82a1540 * translate placeholder code page numbers into actual code pages in
fpc_ansistr_to_widechararray(), so that CP_ACP/CP_OEM etc are properly
    handled (fixes assign/assignfile with non-ansi characters in source files
    that don't explicitly specify the code page)

git-svn-id: trunk@29218 -
2014-12-08 12:11:33 +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
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
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
sergei
0914bb7944 - Removed empty include file wustrings.inc
git-svn-id: trunk@25551 -
2013-09-24 16:35:04 +00:00
Jonas Maebe
3c3ad705f1 * changed fpc_(u)char_to_shortstr() from a procedure into a function, like
the other fpc_(u)char_to_*str() routines (exception dates back to the
    time calls to these routines were still inserted "manually" in the
    compiler). Fixes the compilation of "shortstr:=widecharconstant" after
    r23613 and simplifies other code calling this helper + test

git-svn-id: branches/cpstrrtl@25428 -
2013-09-06 08:02:46 +00:00
Jonas Maebe
d1c36c464a * fixed r22247 so it does in fact set the destination code page properly
(and use the generic helper so no pointer errors can happen)

git-svn-id: branches/cpstrrtl@25141 -
2013-07-19 16:32:29 +00:00
Jonas Maebe
aaa5bb48de + ToSingleByteFileSystemEncodedFileName(array of widechar) overload for more
efficient operation in certain platform's dos units (avoid
    array-of-widechar -> unicodestring conversion)

git-svn-id: branches/cpstrrtl@25138 -
2013-07-19 16:31:21 +00:00
Jonas Maebe
e132a77709 - reverted optimisation from r24962, it's already performed in SetCodePage()
git-svn-id: branches/cpstrrtl@25132 -
2013-07-19 16:28:27 +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
8a4b092ab9 * made ToSingleByteFileSystemEncodedFileName(unicodestring) overridable by
target-specific code and implemented a JVM-compatible version

git-svn-id: branches/cpstrrtl@25001 -
2013-06-27 21:38:17 +00:00
Jonas Maebe
e65d01a717 * small optimisation for ToSingleByteFileSystemEncodedFileName(rawbytestring):
don't call SetCodePage() if the input already has the correct code page
    (SetCodePage would always make the string unique, which is not necessary)

git-svn-id: branches/cpstrrtl@24962 -
2013-06-24 09:40:06 +00:00
Jonas Maebe
980975ff85 * fixed fpc_UnicodeStr_SetLength for 2.6.x bootstrapping
git-svn-id: branches/cpstrrtl@24961 -
2013-06-24 09:40:03 +00:00
Jonas Maebe
3694b4f003 * moved ToSingleByteFileSystemEncodedFileName() to the system unit and
export it so it can be used in all rtl units

git-svn-id: branches/cpstrrtl@24960 -
2013-06-24 09:40:00 +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
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
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
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