Avoided to convert empty PVD components copyright_file_id, abstract_file_id, or
bibliographic_file_id to " " and then "_" during multi-session loading and writing. New util function iso_util_strcopy_untail().
This commit is contained in:
parent
6bc1395e15
commit
f88d8a76b0
@ -2133,9 +2133,12 @@ int read_pvm(_ImageFsData *data, uint32_t block)
|
||||
data->data_preparer_id = strcopy((char*)pvm->data_prep_id, 128);
|
||||
data->system_id = strcopy((char*)pvm->system_id, 32);
|
||||
data->application_id = strcopy((char*)pvm->application_id, 128);
|
||||
data->copyright_file_id = strcopy((char*)pvm->copyright_file_id, 37);
|
||||
data->abstract_file_id = strcopy((char*)pvm->abstract_file_id, 37);
|
||||
data->biblio_file_id = strcopy((char*)pvm->bibliographic_file_id, 37);
|
||||
data->copyright_file_id =
|
||||
iso_util_strcopy_untail((char*) pvm->copyright_file_id, 37);
|
||||
data->abstract_file_id =
|
||||
iso_util_strcopy_untail((char*) pvm->abstract_file_id, 37);
|
||||
data->biblio_file_id =
|
||||
iso_util_strcopy_untail((char*) pvm->bibliographic_file_id, 37);
|
||||
|
||||
data->nblocks = iso_read_bb(pvm->vol_space_size, 4, NULL);
|
||||
|
||||
|
@ -1392,13 +1392,36 @@ char *strcopy(const char *buf, size_t len)
|
||||
strncpy(str, buf, len);
|
||||
str[len] = '\0';
|
||||
|
||||
/* remove trailing spaces */
|
||||
/* remove trailing spaces
|
||||
(This leaves the space at str[0] existing. Bug or feature ?)
|
||||
*/
|
||||
for (len = len-1; str[len] == ' ' && len > 0; --len)
|
||||
str[len] = '\0';
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
char *iso_util_strcopy_untail(const char *buf, size_t len)
|
||||
{
|
||||
char *str;
|
||||
|
||||
str = malloc((len + 1) * sizeof(char));
|
||||
if (str == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
strncpy(str, buf, len);
|
||||
str[len] = 0;
|
||||
|
||||
/* remove trailing spaces */
|
||||
for (len = len-1; len >= 0; --len) {
|
||||
if (str[len] != ' ')
|
||||
break;
|
||||
str[len] = 0;
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy up to \p max characters from \p src to \p dest. If \p src has less than
|
||||
* \p max characters, we pad dest with " " characters.
|
||||
|
@ -249,9 +249,19 @@ int iso_eaccess(const char *path);
|
||||
/**
|
||||
* Copy up to \p len chars from \p buf and return this newly allocated
|
||||
* string. The new string is null-terminated.
|
||||
* Note:
|
||||
* Trailing blanks will be removed. But the first one of an all blank string
|
||||
* persists. It is unclear whether this is a bug or a feature.
|
||||
*/
|
||||
char *strcopy(const char *buf, size_t len);
|
||||
|
||||
/**
|
||||
* Copy up to \p len chars from \p buf and return this newly allocated
|
||||
* string. The new string is null-terminated.
|
||||
* Any trailing blanks will be removed.
|
||||
*/
|
||||
char *iso_util_strcopy_untail(const char *buf, size_t len);
|
||||
|
||||
/**
|
||||
* Copy up to \p max characters from \p src to \p dest. If \p src has less than
|
||||
* \p max characters, we pad dest with " " characters.
|
||||
|
Loading…
Reference in New Issue
Block a user