In bc_strerror, move the return statement to the line below the case statement for each case. These are purely whitespace changes; there is no functional change. This change is being made in preparation for the next change, which will add to the existing error strings. It is preferable to keep these as separate changes so that it's easier to see which error strings are added to.
Add the Bit Inspector test bitstream, which is displayed in the instructions shown at the top of the Bit Inspector window, to the formats file. This allows users to see how the fields table in Bit Inspector works using the default test bitstream. Previously, it may not have been obvious to the user that a fields table existed unless they found another bitstream to use that was recognized by the formats file.
The implicit link command in GNU make places $(LDFLAGS) just after $(CC). This causes linking to fail on MinGW gcc 3.4.2 because of "undefined reference" errors for libpcre functions. Placing $(LDFLAGS) at the end of the link options fixes the problem.
When building, the Makefile now checks if ../pcre exists and uses it for the libpcre include and library files. It assumes that such a libpcre should be linked statically with libbitconvert. This option is useful on systems where a binary distributable that uses libbitconvert should contain both libbitconvert and libpcre, such as on Windows and Mac OS X.
Replace "ar" and "rm" with "$(AR)" and "$(RM)" so that the Makefile uses the correct ar and rm. Note that "$(RM)" expands to "rm -f" on GNU and Solaris systems (probably POSIX) so an explicit "-f" is unneeded. Replace explicit target and source with "$@" and "$<" to make the archive rule more versatile (easier to copy into new rules). These changes were suggested by Stephen Paul Weber.
The formats file is now located at "formats.txt" instead of "formats". This change was made to make it easier for Windows users to modify the formats file. Double-clicking on the formats file in Windows will now open it in Notepad. Developers on Windows should turn on the "core.autocrlf" option in git: git config --global core.autocrlf true This will cause the checked out files to use Windows-style newlines, which Notepad can read. Without this option, the newlines will be Unix-style and Notepad will not read them correctly. Although the formats file could have been stored in the repository with Windows-style newlines, that option is not feasible because the libbitconvert codebase cannot handle such a formats file when compiled on a Unix-like system. However, the libbitconvert codebase works with such a formats file when compiled with the MinGW compiler on Windows. As a result, storing the formats file with Unix-style newlines and having git deal with the newline conversion on Windows is the most feasible option.
The BCERR_INVALID_TRACK error code is no longer used. It was phased out when libbitconvert switched to accepting all tracks at once rather than accepting each track individually, in which case the track number was specified for each track. This change was made in commit 7d77d2d.
Prior to this fix, if the library user called bc_decode and then bc_decoded_free, the library would segfault because result->field_values was not initialized and the library tried to free it. This bug had been hidden because all library users so far have called bc_find_fields after bc_decode, which initializes result->field_values. This fix checks result->field_names before freeing other result->field_* values. This works because result->field_names is always initialized.
ovector, the vector passed into pcre_exec that holds the offsets of the captured substrings, is now dynamically allocated. It is grown until pcre_exec returns non-zero, indicating that ovector was large enough or an error occurred. This change eliminates MAX_CAPTURED_SUBSTRINGS, which is no longer needed now that ovector is dynamically-sized. This change is the last one needed to make libbitconvert completely free of static buffers. The test drivers (driver and combine) still have static buffers, but the library itself does not.
Added array growing code to bc_decode_track_fields and a fields_size parameter to the bc_decode_track_fields interface for passing the current allocated size of the fields lists. Added initial allocation of the fields lists in bc_decode_fields. Updated bc_decode to initialize field_names to NULL, which is the new correct way to denote empty fields lists. Added corresponding frees in bc_decoded_free. This change also removes BC_NUM_FIELDS, which is no longer needed because there are no statically-sized fields in struct bc_decoded anymore. There is still the statically-sized ovector to fix in bc_decode_track_fields, though.
The emptying of field_names has been removed because it is unneeded: when control reaches the bottom of the bc_decode_fields loop, field_names is guaranteed to be empty already because rc is BCINT_NO_MATCH, which means that no field data was added to the field lists because bc_decode_track_fields has not started adding field data when it returns BCINT_NO_MATCH.
Each field_name (one element of field_names) is now dynamically allocated. This allows the field name to be copied via strcpy directly into the field_name. The field_names array is now NULL-terminated. All lines of code that depended on the previous behavior (empty string-terminated list), including one in the test driver, have been updated with this new assumption. This change also removes BC_FIELD_SIZE, which is no longer needed because there are no more statically-sized string buffers, only statically-sized arrays that store strings.
Check the value of pcre_get_named_substring's return code to see if there were problems and return an error if there were. Previously, the return code of pcre_get_named_substring was ignored, which could have led to segfaults or other problems given a malformed formats file.