View Issue Details

IDProjectCategoryView StatusLast Update
0038368FPCDocumentationpublic2021-01-24 21:40
ReporterTrevor Roydhouse Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformAppleOSmacOS 
Fixed in Version3.3.1 
Summary0038368: 12.2 Creating a library (text and code need some fixes)
Descriptionhttps://www.freepascal.org/docs-html/current/prog/progse55.html

"Compilation of this source will result in the creation of a library called libsubs.so on unix systems, or subs.dll on Windows or os/2."

The above statement is incorrect. macOS is a certified UNIX and the library name is libsubs.dylib. Perhaps reword as follows:

"Compilation of this source will result in the creation of a library called libsubs.dylib on macOS, libsubs.so on UNIX-like (eg FreeBSD, Linux) systems, or subs.dll on Windows or OS/2."

I believe the library code presented is also incorrect:

  begin
    if Length >= FromPos then
      SubStr := CString + FromPos - 1;
    if Length > ToPos then
    CString[ToPos] := #0;
  end;

should, I believe, be:
  begin
    if Length >= FromPos then
      SubStr := CString + FromPos; <<< remove minus 1
    if Length > ToPos + 1 then <<< add plus 1
    CString[ToPos + 1] := #0; <<< add plus 1
  end;

otherwise with a test string of "1234" the result of SubStr(s, 1, 3) is "12" and not "123" and the result of SubStr(s, 2, 4) is "1234" and not "234".
Steps To ReproduceUse the example library in a program.
TagsNo tags attached.
Fixed in Revision1797
FPCOldBugId
FPCTarget3.2.2
Attached Files

Activities

Michael Van Canneyt

2021-01-24 19:28

administrator   ~0128569

Corrected as suggested.

Trevor Roydhouse

2021-01-24 21:40

reporter   ~0128573

Thanks!

Issue History

Date Modified Username Field Change
2021-01-18 08:22 Trevor Roydhouse New Issue
2021-01-18 08:22 Trevor Roydhouse Status new => assigned
2021-01-18 08:22 Trevor Roydhouse Assigned To => Michael Van Canneyt
2021-01-24 19:28 Michael Van Canneyt Status assigned => resolved
2021-01-24 19:28 Michael Van Canneyt Resolution open => fixed
2021-01-24 19:28 Michael Van Canneyt Fixed in Version => 3.3.1
2021-01-24 19:28 Michael Van Canneyt Fixed in Revision => 1797
2021-01-24 19:28 Michael Van Canneyt FPCTarget => 3.2.2
2021-01-24 19:28 Michael Van Canneyt Note Added: 0128569
2021-01-24 21:40 Trevor Roydhouse Status resolved => closed
2021-01-24 21:40 Trevor Roydhouse Note Added: 0128573