View Issue Details

IDProjectCategoryView StatusLast Update
0022596LazarusIDEpublic2012-08-08 10:57
ReporterBerndAssigned ToPaul Ishenin 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformWindowsOSWin98OS Version4.10.2222A
Product Version1.0.0RC1Product Build 
Target Version1.0.0Fixed in Version1.0.0RC1 
Summary0022596: [1.0RC1]Lazarus does not run on Win98 anymore.
DescriptionWhen I start lazarus.exe the "Configure Lazarus IDE" dialog complaints about an invalid version in ide\version.inc.

The problem seems to be UTF8 related, since the stringlist "sl" in initialsetupdlgs.pas (line 244 and following) is not loaded.

  sl:=TStringListUTF8.Create;
  try
    try
      sl.LoadFromFile(ADirectory+VersionIncFile);
      if (sl.Count=0) or (sl[0]='') or (sl[0][1]<>'''') then
      begin
         Note:=Format(lisInvalidVersionIn, [VersionIncFile]);
         exit;
      end;

sl.Count is zero in my case. I changed then the stringlist to a usual TStringList and sl gets properly loaded.

When I ignore all the error messages in the "Configure Lazarus IDE" dialog about package conflicts, the IDE finally starts, but does not show any Icons in the component bar. The IDE dialogs seem to work well.

Loading a project is not possible, since the IDE complaints about suspicious .lpi file. I think this is UTF8 related too. Lazarus compiles with no problems on Win98 with fpc 2.6.0.

Regards, Bernd.
TagsNo tags attached.
Fixed in Revision38199
LazTarget1.0
WidgetsetWin32/Win64
Attached Files
  • winfileutil.inc.diff (1,984 bytes)
    Index: components/lazutils/winfileutil.inc
    ===================================================================
    --- components/lazutils/winfileutil.inc	(revision 37266)
    +++ components/lazutils/winfileutil.inc	(working copy)
    @@ -604,21 +604,30 @@
                    FILE_SHARE_WRITE,
                    FILE_SHARE_READ or FILE_SHARE_WRITE);
     begin
    -  Result := CreateFileW(PWideChar(UTF8Decode(FileName)), dword(AccessMode[Mode and 3]),
    -                       dword(ShareMode[(Mode and $F0) shr 4]), nil, OPEN_EXISTING,
    -                       FILE_ATTRIBUTE_NORMAL, 0);
    +  if (Win32Platform = VER_PLATFORM_WIN32_WINDOWS) then
    +    Result := FileOpen(Utf8ToSys(FileName), Mode)
    +  else
    +    Result := CreateFileW(PWideChar(UTF8Decode(FileName)), dword(AccessMode[Mode and 3]),
    +                         dword(ShareMode[(Mode and $F0) shr 4]), nil, OPEN_EXISTING,
    +                         FILE_ATTRIBUTE_NORMAL, 0);
       //if fail api return feInvalidHandle (INVALIDE_HANDLE=feInvalidHandle=-1)
     end;
     
     function FileCreateUTF8(Const FileName : string) : THandle;
     begin
    -  Result := CreateFileW(PWideChar(UTF8Decode(FileName)), GENERIC_READ or GENERIC_WRITE,
    -                       0, nil, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
    +  if (Win32Platform = VER_PLATFORM_WIN32_WINDOWS) then
    +    Result := FileCreate(Utf8ToSys(FileName))
    +  else
    +    Result := CreateFileW(PWideChar(UTF8Decode(FileName)), GENERIC_READ or GENERIC_WRITE,
    +                          0, nil, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
     end;
     
     function FileCreateUTF8(Const FileName : string; Rights: Cardinal) : THandle;
     begin
    -  Result := CreateFileW(PWideChar(UTF8Decode(FileName)), GENERIC_READ or GENERIC_WRITE,
    +  if (Win32Platform = VER_PLATFORM_WIN32_WINDOWS) then
    +    Result := FileCreate(Utf8ToSys(FileName), Rights)
    +  else
    +    Result := CreateFileW(PWideChar(UTF8Decode(FileName)), GENERIC_READ or GENERIC_WRITE,
                            0, nil, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
     end;
     
    
    winfileutil.inc.diff (1,984 bytes)

Activities

Bart Broersma

2012-08-07 19:33

developer   ~0061487

Last edited: 2012-08-07 19:53

Confirmed on WinMe
Unpacked lazarus-1.0RC1-0-src.zip
Did make clean all
Build just fine.
Same error message as Bernd.

The setup dialog also rejects my 2.6.0 source directory (where my current Lazarus 1.1 accepts this just fine):
Directory: E:\Fpc\source\ (here reside the rtl and packages folder of fpc sources)
Warning: Found version .., expected 2.6.0
A correct (fpc) version.pas file is nevertheless there in E:\Fpc\source\compiler

Bart Broersma

2012-08-07 20:20

developer   ~0061490

Basically it seems that all UTF8 fileroutines in FileUtil.pas on Windows link to the Unicode variant of windows kernel routines.
These obviously fail on win98 and winme.
As a result TStringListUtf8.LoadfromFile will always return an empty stringlist on this platform.

Bart Broersma

2012-08-07 22:55

developer   ~0061492

Correction on my note above.
The FileOpenUtf8 and FileCreateUtf8 functions that bind to Unicode kernel routines.
I attached a possible fix (created against r37266, so not against RC1).

2012-08-07 22:56

 

winfileutil.inc.diff (1,984 bytes)
Index: components/lazutils/winfileutil.inc
===================================================================
--- components/lazutils/winfileutil.inc	(revision 37266)
+++ components/lazutils/winfileutil.inc	(working copy)
@@ -604,21 +604,30 @@
                FILE_SHARE_WRITE,
                FILE_SHARE_READ or FILE_SHARE_WRITE);
 begin
-  Result := CreateFileW(PWideChar(UTF8Decode(FileName)), dword(AccessMode[Mode and 3]),
-                       dword(ShareMode[(Mode and $F0) shr 4]), nil, OPEN_EXISTING,
-                       FILE_ATTRIBUTE_NORMAL, 0);
+  if (Win32Platform = VER_PLATFORM_WIN32_WINDOWS) then
+    Result := FileOpen(Utf8ToSys(FileName), Mode)
+  else
+    Result := CreateFileW(PWideChar(UTF8Decode(FileName)), dword(AccessMode[Mode and 3]),
+                         dword(ShareMode[(Mode and $F0) shr 4]), nil, OPEN_EXISTING,
+                         FILE_ATTRIBUTE_NORMAL, 0);
   //if fail api return feInvalidHandle (INVALIDE_HANDLE=feInvalidHandle=-1)
 end;
 
 function FileCreateUTF8(Const FileName : string) : THandle;
 begin
-  Result := CreateFileW(PWideChar(UTF8Decode(FileName)), GENERIC_READ or GENERIC_WRITE,
-                       0, nil, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
+  if (Win32Platform = VER_PLATFORM_WIN32_WINDOWS) then
+    Result := FileCreate(Utf8ToSys(FileName))
+  else
+    Result := CreateFileW(PWideChar(UTF8Decode(FileName)), GENERIC_READ or GENERIC_WRITE,
+                          0, nil, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
 end;
 
 function FileCreateUTF8(Const FileName : string; Rights: Cardinal) : THandle;
 begin
-  Result := CreateFileW(PWideChar(UTF8Decode(FileName)), GENERIC_READ or GENERIC_WRITE,
+  if (Win32Platform = VER_PLATFORM_WIN32_WINDOWS) then
+    Result := FileCreate(Utf8ToSys(FileName), Rights)
+  else
+    Result := CreateFileW(PWideChar(UTF8Decode(FileName)), GENERIC_READ or GENERIC_WRITE,
                        0, nil, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
 end;
 
winfileutil.inc.diff (1,984 bytes)

Bart Broersma

2012-08-07 22:58

developer   ~0061493

I set target to 1.0.0, since there is no 1.0RC2 target yet.

Paul Ishenin

2012-08-08 07:56

manager   ~0061498

please test and close if ok.

Bernd

2012-08-08 10:57

reporter   ~0061507

With the patch applied, Lazarus runs on Win98 now. Thanks.

Issue History

Date Modified Username Field Change
2012-08-07 18:20 Bernd New Issue
2012-08-07 18:20 Bernd Widgetset => Win32/Win64
2012-08-07 19:33 Bart Broersma LazTarget => -
2012-08-07 19:33 Bart Broersma Note Added: 0061487
2012-08-07 19:33 Bart Broersma Status new => confirmed
2012-08-07 19:53 Bart Broersma Note Edited: 0061487
2012-08-07 20:20 Bart Broersma Note Added: 0061490
2012-08-07 22:55 Bart Broersma Note Added: 0061492
2012-08-07 22:56 Bart Broersma File Added: winfileutil.inc.diff
2012-08-07 22:57 Bart Broersma Target Version => 1.0.0
2012-08-07 22:58 Bart Broersma Note Added: 0061493
2012-08-08 07:56 Paul Ishenin Fixed in Revision => 38199
2012-08-08 07:56 Paul Ishenin LazTarget - => 1.0
2012-08-08 07:56 Paul Ishenin Status confirmed => resolved
2012-08-08 07:56 Paul Ishenin Fixed in Version => 1.0.0RC1
2012-08-08 07:56 Paul Ishenin Resolution open => fixed
2012-08-08 07:56 Paul Ishenin Assigned To => Paul Ishenin
2012-08-08 07:56 Paul Ishenin Note Added: 0061498
2012-08-08 10:57 Bernd Status resolved => closed
2012-08-08 10:57 Bernd Note Added: 0061507