Commit Graph

41008 Commits

Author SHA1 Message Date
Jonas Maebe
cde2d1b8ee o merged cpstrrtl branch (includes unicode branch). In general, this adds
support for arbitrarily encoded ansistrings to many routines related to
    file system access (and some others).
    
  WARNING: while the parameters of many routines have been changed from
    "ansistring" to "rawbytestring" to avoid data loss due to conversions,
    this is not a panacea. If you pass a string concatenation to such a
    parameter and not all strings in this concatenation have the same
    code page, all strings and the result will be converted to
    DefaultSystemCodePage (= ansi code page by default). In particular,
    concatenating e.g. an Utf8String with a constant string and passing
    the result to a RawByteString parameter will convert the result into
    the DefaultSystemCodePage (unless the source code is compiler with
    {$modeswitch systemcodepage} or {$mode delphiunicode} *and* the ansi
    code page on the system you are compiling *on* happens to be UTF-8)
    
    You can define and use alternative routines that explicitly accept
    Utf8String parameters to avoid this pitfall. Internally, all of these
    routines ensure that they never trigger this condition and ensure that
    not unnecessary/unwanted code page conversions occur.

  + 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
  + ToSingleByteFileSystemEncodedFileName() function to convert a string to to
    DefaultFileSystemCodePage (does *not* take care of OS-specific quirks like
    Darwin always returning file names in decomposed UTF-8)
  + support for CP_OEMCP
  * textrec/filerec now store the filename by default using widechar. It is
    possible to switch back to ansichars using the FPC_ANSI_TEXTFILEREC define.
    In that case, from now on the filename will always be stored in
    DefaultFileSystemEncoding
  * fixed potential buffer overflows and non-null-terminated file names in
    textrec/filerec

  * 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
  * never change the code page of a non-empty string when calling setlength on
    it

  * handle the fact that GetEnvironmentStringsA returns the environment in the
    OEM instead of in the Ansi code page (mantis #22524, #15233)
  * don't truncate environment variable strings in GetEnvironmentString(),
    its result is now ansistring/unicodestring depending on whether the
    RTL was compiled with FPC_RTL_UNICODE

  * unix:
   o made the ansistring parameters of the fp*() file system routine overloads
     constant, changed them to rawbytestring and added
     DefaultFileSystemCodePage conversions
   o unicodestring support for POpen(), and DefaultFileSystemCodePage support
     for POpen(RawByteString)

  + DefaultFileSystemCodePage support for dynlibs unit

  + rawbytestring/unicodestring overloads for:
   o system: fexpand, lowercase, uppercase, getdir, mkdir, chdir, rmdir,
     assign, erase, rename
   o objpas: AssignFile, 
   o sysutils: FileCreate, FileOpen, FileExists, DirectoryExists, FileSetDate,
     FileGetAttr, FileSetAttr, DeleteFile, RenameFile, FileSearch, ExeSearch,
     FindFirst, FindNext, FindClose, FileIsReadOnly, GetCurrentDir,
     SetCurrentDir, ChangeFileExt, ExtractFilePath, ExtractFileDrive,
     ExtractFileName, ExtractFileExt, ExtractFileDir, ExtractShortPathName,
     ExpandFileName, ExpandFileNameCase, ExpandUNCFileName,
     ExtractRelativepath, IncludeTrailingPathDelimiter,
     IncludeTrailingBackslash, ExcludeTrailingBackslash,
     ExcludeTrailingPathDelimiter, IncludeLeadingPathDelimiter,
     ExcludeLeadingPathDelimiter, IsPathDelimiter, DoDirSeparators,
     SetDirSeparators, GetDirs, ConcatPaths, GetEnvironmentVariable

    -- the default string type used by FindFirst/Next depends on whether the
      RTL was compiled with FPC_RTL_UNICODE. To force the RawByteString
      version pass a TRawByteSearchRec, for the UnicodeString version pass
      a TUnicodeSearchRec.

  + paramstr(longint):unicodestring available for {$modeswitch unicodestrings}

  + pwidechar versions in sysutils of strecopy, strend, strcat, strcomp,
    strlcomp, stricomp, strlcat, strrscan,strlower, strupper, strlicomp,
    strpos, WideStrAlloc, StrBufSize, StrDispose + tests
    

git-svn-id: trunk@25432 -
2013-09-06 11:04:32 +00:00
Jonas Maebe
de56f909d5 * synchronized with trunk up to and including r25430
git-svn-id: branches/cpstrrtl@25431 -
2013-09-06 10:09:26 +00:00
Jonas Maebe
f539e9158a * small change to r24997: also use the {$modeswitch unicodestrings} state to
determine whether (wide)char->pchar will be preferred over (wide)char ->
    p(wide)char or not (always convert to pchar if mode switch is not active,
    otherwise always to pwidechar). Delphi-compatible + consistent with the
    behaviour added for constant strings in that revision + tests

git-svn-id: branches/cpstrrtl@25430 -
2013-09-06 08:02:59 +00:00
Jonas Maebe
b3b404db4b * handle any char constant -> p(wide)char conversions via cunicodestringtype
because the compiler cannot convert arbitrary unicodechar constants at
  compile time to a shortstring (since it doesn't know the code page to use)
  (test part of next commit)

git-svn-id: branches/cpstrrtl@25429 -
2013-09-06 08:02:52 +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
florian
e0f48b9f02 * calculate stack correction on exit correctly if stack parameters are passed
git-svn-id: trunk@25427 -
2013-09-05 21:40:33 +00:00
florian
36e6f99843 * fix tthumbcgarm.g_flags2reg, mov reg,#imm for thumb updates the flags
git-svn-id: trunk@25426 -
2013-09-05 21:40:30 +00:00
sergei
5039ddc4a7 * Changed definition of XMM register save area from array to record, removes compilation warnings about reference size mismatch. The cause of warnings is rautils.getrecordoffsetsize function which, for array types, returns size of element and not size of array itself.
git-svn-id: trunk@25425 -
2013-09-05 12:39:16 +00:00
sergei
7e6a7f20cc - Removed unused variables and dead assignments.
git-svn-id: trunk@25424 -
2013-09-05 09:05:56 +00:00
paul
8d526e9b07 compiler: add a check for srsym <> nil since try_consume_unitsym may change srsym to nil, better error message
git-svn-id: trunk@25423 -
2013-09-05 08:39:10 +00:00
paul
3f2e62874b compiler: handle unit, namespace and class/record/object prefixes before identifiers while parsing {$IF ...} expressions (fixes mantis #0020996)
git-svn-id: trunk@25422 -
2013-09-05 07:05:19 +00:00
paul
4fd0245120 compiler: fix indentation
git-svn-id: trunk@25421 -
2013-09-05 06:29:06 +00:00
paul
1b81afcd42 compiler: allow to hide parent function identifier inside them (by a nested function with the same name or by a local variable). Fixes mantis #0024129.
git-svn-id: trunk@25420 -
2013-09-05 01:10:04 +00:00
paul
d25ae84113 compiler: don't output an error twice in 'on Exception do' block if Exception is not a valid type
git-svn-id: trunk@25419 -
2013-09-05 00:46:26 +00:00
florian
e2ec3bbcb0 * do shifts for sign/zero extensions correctly
git-svn-id: trunk@25418 -
2013-09-04 21:00:46 +00:00
florian
a240e74591 * check cputhumb/cputhumb2 to detect instruction set
git-svn-id: trunk@25417 -
2013-09-04 21:00:44 +00:00
florian
6f11e3f316 * clz is only available on thumb2/arm
git-svn-id: trunk@25416 -
2013-09-04 21:00:01 +00:00
Jonas Maebe
d2bad665fa * fixed a_op_*_reg() for OP_NOT/OP_NEG (due to the register allocation the
generated code often was still valid though)

git-svn-id: trunk@25415 -
2013-09-04 19:16:59 +00:00
sergei
da2887a4ec * x86_64-win64: SEH finalization procedures have frame pointer set to RBP but since r25389 they save registers relative to RSP. Fixed offsets for .seh_savereg/.seh_savexmm directives.
* In epilogue, deallocate current_procinfo.framepointer, not RBP.

git-svn-id: trunk@25414 -
2013-09-04 15:31:55 +00:00
Károly Balogh
2c49af3191 added missing closing parentheses
git-svn-id: trunk@25413 -
2013-09-04 14:56:53 +00:00
paul
115ddf4364 compiler: modernize exception class parse:
- use specially implemented type search routine in case of declaration with colon (on E: Exception do)
  - parse nested types in case of declaration without colon (on Exception do)
  + test

fixes issue #0022225

git-svn-id: trunk@25412 -
2013-09-04 14:09:09 +00:00
lacak
f24d30105e fcl-db: base: improve Blob handling. When writting empty blob set null on. raise data event FieldChange after data are written, not before.
git-svn-id: trunk@25411 -
2013-09-04 13:13:50 +00:00
svenbarth
d03507671d Fix for Mantis #24953.
pgenutil.pas, parse_generic_parameters:
  * set the typesym of the newly created def so that inline specializations in pexpr.pas, sub_expr can check it correctly

git-svn-id: trunk@25410 -
2013-09-04 12:56:08 +00:00
lacak
f11b8b5da4 fcl-db: base: fix streaming of NULL values in XMLDatapacketReader (like in Delphi null values are skiped and are not saved into <ROW ... />)
git-svn-id: trunk@25409 -
2013-09-04 07:43:32 +00:00
florian
333e84202f * fixed a_load_reg_reg for thumb
git-svn-id: trunk@25408 -
2013-09-03 21:11:02 +00:00
florian
7ef37b5d2a * PLD is not supported by thumb
git-svn-id: trunk@25407 -
2013-09-03 21:09:41 +00:00
florian
cb1f38b0af * strd/ldrd are not supported by thumb
git-svn-id: trunk@25406 -
2013-09-03 21:09:13 +00:00
florian
0e7a7c68b0 * the -CI switch is now handled correctly
git-svn-id: trunk@25405 -
2013-09-03 19:24:01 +00:00
michael
bda396906d * Forgot to commit
git-svn-id: trunk@25404 -
2013-09-03 12:51:39 +00:00
michael
3c7881ef04 * Fixed AV when setting capacity to something smaller than count but larger than 0 (bug ID 24943)
git-svn-id: trunk@25403 -
2013-09-03 07:10:53 +00:00
Jeppe Johansen
9acfd929f5 Added ARMv6M to cpu types where the default instruction set is Thumb
git-svn-id: trunk@25402 -
2013-09-03 06:57:24 +00:00
Jonas Maebe
1a78ec1f11 * workaround for bug in Apple's assembler regarding movq/vmovq and integer
registers

git-svn-id: trunk@25396 -
2013-09-02 14:39:26 +00:00
florian
0b30b0913d * fix building of go32v2 rtl with make 3.82
git-svn-id: trunk@25394 -
2013-09-01 20:29:02 +00:00
svenbarth
7babce23da Fix compilation of arm-wince on Linux(?).
rtl/arm/arm.inc & setjump.inc:
  * don't use BX if the current CPU (default for arm-wince is ARMv3)  does not support it

git-svn-id: trunk@25393 -
2013-09-01 14:05:48 +00:00
svenbarth
b288179d56 Fix for Mantis #24929.
rtl/sysutils/datih.inc:
  + add StrToDate overload which allows passing of specific TFormatSettings parameter
rtl/sysutils/dati.inc:
  * implement new StrToDate overload by calling IntStrToDate similar to StrToTime

git-svn-id: trunk@25392 -
2013-09-01 12:46:54 +00:00
Tomas Hajny
38ae8c7250 * changed from import by name (not working correctly) to import by index (as used everywhere else in OS/2 RTL)
git-svn-id: trunk@25391 -
2013-09-01 10:10:59 +00:00
sergei
e41149a7ec * x86_64: reworked register saving/restoring to use PUSH/POP instructions for procedures with RSP-based frame and SEH finalization procedures. XMM registers are also saved/restored without involving tempgen in mentioned cases. This prevents SEH finalization procedures from saving registers in stack frame of their parent procedures, fixing incorrect unwind bytecode (Mantis #24791). It also reduces executable size (for compiler itself, by about 100Kb).
git-svn-id: trunk@25389 -
2013-08-30 07:54:02 +00:00
Jonas Maebe
fcaad5baf2 * perform -CTlowercaseprocstart conversion it tprocsym.create rather than
when building the mangled name, because the latter can also be performed
    when compiler another unit (and therefore if that other unit's setting
    is different from that of the original unit, a wrong mangled name was
    generated) + test for this case

git-svn-id: trunk@25388 -
2013-08-29 22:43:06 +00:00
Jonas Maebe
a14ceba791 + -CTinitlocals switch for the JVM that initialises all local variables
that may trigger JVM bytecode verification errors if they are used
    before they are initialised (this includes passing them as a "var"
    parameter) + test
  * sorted -CT parameters alphabetically and alligned them

git-svn-id: trunk@25387 -
2013-08-29 22:21:23 +00:00
Jonas Maebe
10bb07a665 * brackets around and/or combination
git-svn-id: trunk@25386 -
2013-08-29 22:21:19 +00:00
Jonas Maebe
6013606a97 + -CTlowercaseprocstart switch to lowercase the first character of routines
so that code written according to Delphi coding standards can be compiled
    into JVM bytecode with routine names conforming to JVM coding standards

git-svn-id: trunk@25385 -
2013-08-29 22:21:15 +00:00
sergei
690995fa12 * RTL: fixed some warnings when compiling for x86_64:
* x86_64/x86_64.inc: IsMultithread is a LongBool, not Boolean -> fixed assembler instruction suffixes
  * inc/generic.inc: cast Sizeof() to unsigned, so that combining it with unsigned operands does not cause promotion to larger signed type.
  + win64/seh64.inc: explicit typecast and missing function result assignment.
  + inc/genmath.inc: explicit typecasts.

git-svn-id: trunk@25384 -
2013-08-29 07:52:38 +00:00
Károly Balogh
86cb4d0c12 use a TSuperRegister instead of an aint
git-svn-id: trunk@25383 -
2013-08-28 12:58:29 +00:00
Károly Balogh
c677f1fd69 trying harder to follow the code style (no functional changes)
git-svn-id: trunk@25382 -
2013-08-28 11:25:15 +00:00
sergei
5dda96bdfe - Tcgx86_64.init_register_allocators: removed 'preserved_by_proc' parameter, because it isn't used by RA in any way.
* tcgx86_64.g_intf_wrapper: jump directly to reference without loading its content into RAX, this saves an instruction.

git-svn-id: trunk@25381 -
2013-08-28 09:10:57 +00:00
Károly Balogh
25619d4991 removed the const-in-the-left internalerror
git-svn-id: trunk@25380 -
2013-08-27 16:18:53 +00:00
Károly Balogh
cb4d01627f save an extra reg if it's required to keep 64bit stack alignment on ARM
git-svn-id: trunk@25379 -
2013-08-27 12:49:50 +00:00
michael
901f5742b8 * Remove redundant if
git-svn-id: trunk@25378 -
2013-08-27 10:02:03 +00:00
lacak
c42890ed75 fcl-db: tests: test that RowsAffected is specific per query not per connection (if more queries are executed over same connection)
git-svn-id: trunk@25377 -
2013-08-27 09:54:01 +00:00
lacak
4817a0e670 fcl-db: tests: it seems, that Sybase ASE does not have NTEXT data type; so comment it for now; update for rev.25372
git-svn-id: trunk@25376 -
2013-08-27 05:57:17 +00:00