-------------------- AmigaOS 3.1.4.(1) project -----------------------

Changes for list 45.4 (31.7.2017)

- Enlarged the buffers such that list no longer crashes on file names
  longer than 32 characters
  
- Made most string buffers static such that list no longer requires
  enormous amounts of stack

- Dynamically allocates the BSS space such that list remains pure
  but does not require passing arguments around.
  
Changes for list 45.5 (5.11.2017)

- List now also shows the targets of soft and hard links. The current
  lformat inidicator for the link target is %i. (lInktarget). This
  may change for the final release.
  
Changes for list 45.6 (9.11.2017)

- Changed the format for the link target to %r instead of %i to be
  in line with AmigaOs 4.0.
  
Changes for list 45.7 (18.11.2017)

- The new lformat code %Q prints the directory name without a trailing
  slash, though a colon is always included for devices.

Changes for list 45.8 (25.2.2018)

- The lformat option %s was not always treated correctly and did not
  expand alternatively to directory and file name.

Changes for list 45.9 (22.3.2018)

- Blocksize, disk key and number of blocks are now unsigned numbers, so
  they will be printed even for files larger than 2GB.

----------------------- AmigaOS 3.2 project --------------------------

List 47.7 (10.4.2020)

- Backport of List 51.20.

- This still needs to be checked against Thomas Richter's changes.

List 47.8 (11.4.2020)

- Cleaned up some more, removing remains of the AmigaOS4 conditional
  compilation.

- Added support for the %P LFORMAT option.

- Added support for the FLAT option.

- Updated the documentation to account for LFORMAT and FLAT
  integration.

- For now the workaround for MatchFirst() failing because Lock/Examine
  is not working for a file or directory is disabled.

- Adding escape characters to path and file/directory names containing
  wildcard characters when using the LFORMAT option is not implemented
  as designed by Thomas yet since the outcome may be unexpected by the
  user. This feature could make a return if enabled through a control
  switch.

list 47.9 (19.7.2020)

- Fixed typos in the "%U" substitution operator documentation.

- Allocating memory for the output format information now
  makes sure that the buffer is always NUL-terminated, and
  not just NUL-terminated by accident.

- Moved error checking for mutually exclusive DATES/NODATES
  switches to the earliest possible stage, so that no memory
  allocation or parsing work is being done first which would
  be pointless...

- Opening the output file (as requested through the "TO" option)
  is now postponed until after all the setup work is complete.
  Previously, the file would be opened, setup could fail and
  then leave the output file empty for no good reason.

- Unscrambled the LFORMAT substitution string setup code which
  now gets the same job done without repeatedly checking the
  length of the format string, format parameters, etc.
  Also, it no longer modifies the LFORMAT parameter string
  because it really doesn't need to. And, slightly more
  obscure, the total number of "%s" substitution operators
  counted does not have to be a global variable after all.

- Each directory and subdirectory list output begins with figuring
  out the full path name of the directory being listed through
  NameFromLock(). Up until now there was always a test missing to
  make sure that NameFromLock() had actually succeeded. Fixed.

- The string table which collects all the printf() style parameter
  strings was never actually declared as being a table of pointers
  to strings. Changing this revealed that the cast to (long) of
  the file name parameter only worked by accident.

- The SUB and PAT option code preprocesses wildcard patterns or
  names for later use. If these cannot be processed the state of
  the preprocessed buffers is basically undefined. The corresponding
  code which used them to detect matches on the file name or a
  substring of the file name did not check if the respective
  preprocessed buffer was set up correctly, or if a buffer
  overflow had occured. Fixed. Note that this code, by design, does
  not care if the setup fails anyway.

list 47.10 (20.7.2020)

- Pattern matching preprocessing for the PAT and SUB options needs
  to be done only once before directory scanning begins, and need
  not be repeated for every directory since the respective patterns
  are not changed by directory scanning.

- Reworked the names of the local variables and their respective
  scope for better readability and sense of purpose.

- Added macros to make the directory entry type value tests
  more readable. Now there are FIB_IS_FILE(), FIB_IS_DIR() and
  FIB_IS_LINK(). The local variable which carries the
  "FileInfoBlock.fib_DirEntryType" value is now named "dir_entry_type"
  for consistency rather than "entry_type". For historic reasons
  "FileInfoBlock.fib_DirEntryType" and "FileInfoBlock.fib_EntryType"
  always carry identical values but Commodore recommended that
  unless you write a file system or handler which supports the
  ACTION_EXAMINE packet, etc. you should always use the value
  stored in "FileInfoBlock.fib_DirEntryType".

- The number of entries in the list which contains the substitution
  operators remains unchanged after parsing has concluded. No need
  to check this for each directory entry all over again. And,
  actually, the substitution parameter list probably does not
  even need to be rebuilt for each directory entry.

- Found two memory leaks in the code which prints the sorted
  directory entry list. If you stopped the printing with [Ctrl+C]
  or the Break shell command, then the memory allocated for the
  the entry which would not get printed (because printing was
  stopped) would never get released.

list 47.11 (23.7.2020)

- No. 4711 Eau de Cologne

- Humble preparations for maybe getting Thomas Richter's changes
  to escape designated strings produced through the LFORMAT
  option. For starters, the case of the substitution operator
  characters will be preserved for later reference.

list 47.12 (23.7.2020)

- Brought back the option to have the LFORMAT specs take quoting
  of file names, etc. strings into account, as added by Thomas Richter.

  Why or when a string is quoted depends upon three factors. The
  first is that the new LFORMATQUOTE option enables the quoting
  mode. Quoting modes are "shell" and "wildcard" which can be
  enabled individually and together. The second is that the LFORMAT
  option is used and the format specs are written in upper case
  characters, e.g. "list lformat %S lformatquote shell". The
  third is that the formatted output contains characters which
  make the quoting necessary, e.g. a file name which contains blank
  spaces, line feeds or the escape character, or it contains AmigaDOS
  wildcard characters.

list 47.13 (24.7.2020)

- Lucky number 13!

- Added missing code documentation.

- Fixed memory leaks in the new code. Oops.

- The AmigaDOS wildcard pattern character escaping code did not
  check for a failed memory allocation attempt and would have
  returned a truncated string. Fixed.

- Replaced the many memory allocation failure error messages
  with what amounts to PrintFault(..., ERROR_NO_FREE_STORE, ...)

- This contents of the escaped string buffer list is now rotated
  so that the last used buffer will go to the end of the list. This
  has the effect of the next buffer to be used coming to the front
  of the list.

- User documentation still needs updating...

list 47.14 (24.7.2020)

- Updated the user documentation, with particular emphasis on the effects
  of the LFORMATQUOTE option and where it will produce problems instead
  of solving them, i.e. use %F instead of %S%S or %P%N because with %F
  the quoting will cover the entire path name, whereas %S%S and %P%N
  will cover the individual names.

- Fixed an undefined pointer value reference. Ouch.

- To make the LFORMATQUOTE option a bit easier to use, LFQ is now
  an alias for it.

list 47.15 (25.7.2020)

- Turns out that the replacement rules for the %s operator are a bigger
  problem after all. %F is not helpful, the entire path name has to be
  made quotable. This is the purpose of the new %o/%O substitution
  operator which will produce the relative path and the actual name of
  the file/directory/link. Documentation has been updated accordingly.

  The List command now preprocesses the LFORMAT string and will detect
  those cases in which %S%S are translated into %P%N. When found, %P%N
  will be replaced by %O.

  In effect, this now makes %S%S safe to use with the LFORMATQUOTE
  option.

list 47.16 (26.7.2020)

- Reduced memory usage, checking which global data structures are
  being used in the first place and what their minimum sizes are. Not
  everything has to be 1024 bytes in size, e.g. single file names and
  comments.

- Replaced the roll-your-own singly-linked list of path names which is
  used if the "ALL" switch is used. This is now a standard Exec
  MinList/MinNode combo. Individual nodes are no longer all 1024 bytes
  in size and only use as much memory as is needed.

- Changed the names of the global data structures and in particular
  the names of the many different string buffers to better reflect
  their actual purpose.

- The buffers needed for the PAT and SUB options are now all allocated
  dynamically as needed and no longer prone to buffer overflows. Also,
  it saves at least 8K of memory if these options are not used.

- String constants are now really string constants and not necessarily
  provided as preprocessor definitions.

- String buffers are no longer reused for different purposes, e.g.
  for capturing the LFORMAT sprintf() style format specs for padding.

- When building the LFORMAT data structures, the code now checks
  for buffer overflows. Should one occur, the code now exits with
  an appropriate error message.

- Counting the number of %S string substitutions in the LFORMAT
  string never ever worked with sprintf() style format specs, such
  as "%-25s". Fixed. This bug is at least 30 years old.

- An unsupported string substitution operation would always produce
  a "%", e.g. "%x" would come out as "%x". However, if there were
  sprintf() style format specs present then these would be discarded,
  e.g. "%08x" would produce "%x" instead of "%08x" (preserving what
  the user had entered). Fixed. This bug is also at least 30
  years old.

list 47.17 (26.7.2020)

- The temporary memory allocated in order to prepare the wildcard
  match buffer for the SUB option is now released as soon as it
  no longer needed.

- If the date/time information provided to the SINCE and UPTO
  options is unsuitable, the warning message now specifically names
  the respective SINCE or UPTO option instead of suggesting that
  the user guesses which ones was at fault. Also, the date/time
  spec in question is printed, too.

- Turns out that if the SINCE or UPTO date/time was unsuitable, the
  warning message was incorrect: the invalid date/time information
  would not be ignored at all, and the contents of a date stamp
  with undefined state would be used instead. Fixed. This bug is
  also at least 30 years old.

- Added mitigations for a possible integer overflow in the
  code which checks if it has to print the number of files,
  directories, links, etc.

- Removed scores of unnecessary casts to the exact type which
  the respective variable/string/structure already was.

- Updated the code documentation.

list 47.18 (27.7.2020)

- Reworked how the directory scanning function handles errors
  and interruption through Ctrl+C. Previously, it would reuse
  the rc variable to hold status information on whether or not
  MatchFirst()/MatchNext() had failed, then later called IoErr()
  if such failure was detected storing the error code in the
  local temprc variable. Then there was the global rc variable
  which would be set to RETURN_WARN or RETURN_OK as needed.
  Status changes could then in turn require IoErr() to be called
  which had to be primed with SetIoErr() first.

  The new code now stores the result of the MatchFirst() and
  MatchNext() function calls as an error and will update that
  error variable as needed such as when CheckSignal() indicates
  an interruption. The local rc variable is gone, as is the
  local temprc variable and all error checking now refers to
  the error variable alone.

list 47.19 (28.7.2020)

- Turns out that the minimum buffer size used with the default
  output format string (if LFORMAT was not used) was far too
  short. It used to be 32 characters, but 40 were needed. This
  was never updated after the Envoy changes had been added
  around 1992. With all possible options present, the format
  spec would have been truncated. Fixed.

- More "double negative" semantic fixes for opts[OPT_NOHEAD]
  parameter checks. These have been converted from
  "NO opts[OPT_NOHEAD]" to "opts[OPT_NOHEAD] == FALSE" for
  better readability.

- uid_to_name() and gid_to_name() now reset the name string
  buffer to be filled to an empty string. That makes them
  safer to use.

- The statistics printed for the number of files, directories,
  links, blocks, etc. now use the singular only for cases
  in which there is 1 item. All others use the plural form.
  Up until now this was never done consistently.

- Updated the code documentation.
