2
$Id: system.pas,v 1.85 2005/05/03 22:17:26 hajny Exp $
3
2
****************************************************************************
5
4
This file is part of the Free Pascal run time library.
6
Copyright (c) 1999-2002 by Free Pascal development team
5
Copyright (c) 1999-2005 by Free Pascal development team
8
7
Free Pascal - OS/2 runtime library
490
492
oldargvlen:=argvlen;
491
493
argvlen:=(idx+8) and (not 7);
492
494
sysreallocmem(argv,argvlen*sizeof(pointer));
493
fillchar(argv[oldargvlen],(argvlen-oldargvlen)*sizeof(pointer),0);
495
{ fillchar(argv[oldargvlen],(argvlen-oldargvlen)*sizeof(pointer),0);}
495
497
{ use realloc to reuse already existing memory }
496
498
{ always allocate, even if length is zero, since }
497
499
{ the arg. is still present! }
498
{ sysreallocmem(argv[idx],len+1);}
499
500
ArgV [Idx] := SysAllocMem (Succ (Len));
512
until (pc[Arglen] = #0);
513
allocarg(count,arglen);
514
move(pc^,argv[count]^,arglen);
516
{ ReSetup cmdline variable }
519
until (pc[Arglen]=#0);
522
move(cmdline^, pc^, arglen);
526
until (pc[Arglen]=#0);
527
pc[Arglen]:=' '; // combine argv[0] and command line
504
CmdLine := SysAllocMem (MaxPathLen);
506
ArgV := SysAllocMem (8 * SizeOf (pointer));
508
ArgLen := StrLen (PChar (PIB^.Cmd));
511
if DosQueryModuleName (PIB^.Handle, MaxPathLen, CmdLine) = 0 then
512
ArgVLen := Succ (StrLen (CmdLine))
514
(* Error occurred - use program name from command line as fallback. *)
516
Move (PIB^.Cmd^, CmdLine, ArgLen);
521
ArgV [0] := SysAllocMem (ArgVLen);
522
Move (CmdLine^, ArgV [0]^, ArgVLen);
525
(* PC points to leading space after program name on command line *)
526
PC := PChar (PIB^.Cmd) + ArgLen;
528
(* ArgLen contains size of command line arguments including leading space. *)
529
ArgLen := Succ (StrLen (PC));
531
SysReallocMem (CmdLine, ArgVLen + ArgLen);
533
Move (PC^, CmdLine [ArgVLen], Succ (ArgLen));
535
(* ArgV has space for 8 parameters from the first allocation. *)
530
538
{ process arguments }
532
{$IfDef DEBUGARGUMENTS}
533
Writeln(stderr,'GetCommandLine is #',pc,'#');
537
541
{ skip leading spaces }
697
705
FileHandleCount := GetFileHandleCount;
698
706
DosGetInfoBlocks (@TIB, @PIB);
699
707
StackBottom := TIB^.Stack;
708
StackTop := PtrUInt (TIB^.StackLimit);
709
StackLength := CheckInitialStkLen (InitialStkLen);
701
711
{Set type of application}
702
712
ApplicationType := PIB^.ProcType;
765
777
Str (RC, ErrStr);
766
778
ErrStr := 'Error during heap initialization (DosAllocMem - ' + ErrStr + ')!!'#13#10;
767
DosWrite (2, @ErrStr [1], Length (ErrStr), RC);
780
DosWrite (2, @ErrStr [1], Length (ErrStr), RC);
768
781
HandleError (204);
776
Revision 1.85 2005/05/03 22:17:26 hajny
777
* SysAllocMem used for ArgV [Idx] allocation again
779
Revision 1.84 2005/05/01 13:01:03 peter
780
use fillchar after reallocmem, fix taken from win32
782
Revision 1.83 2005/04/03 21:10:59 hajny
783
* EOF_CTRLZ conditional define replaced with CtrlZMarksEOF, #26 handling made more consistent (fix for bug 2453)
785
Revision 1.82 2005/03/27 20:50:35 hajny
786
* correction of previous mistyping
788
Revision 1.81 2005/03/27 20:40:54 hajny
791
Revision 1.80 2005/03/01 21:59:14 hajny
794
Revision 1.79 2005/02/14 17:13:31 peter
797
Revision 1.78 2005/02/06 16:57:18 peter
798
* threads for go32v2,os,emx,netware