mirror of https://github.com/inolen/redream.git
trim any whitespace in strncpy_trim_space
This commit is contained in:
parent
6288e825a2
commit
781553ee3f
|
@ -42,14 +42,14 @@ void strncpy_pad_spaces(char *dst, const char *src, int size) {
|
|||
}
|
||||
}
|
||||
|
||||
void strncpy_trim_spaces(char *dst, const char *src, int size) {
|
||||
void strncpy_trim_space(char *dst, const char *src, int size) {
|
||||
char mask = 0x0;
|
||||
src += size - 1;
|
||||
dst += size - 1;
|
||||
*(dst + 1) = 0;
|
||||
while (size--) {
|
||||
/* mask off until a valid letter is hit */
|
||||
if (*src != ' ') {
|
||||
if (!isspace(*src)) {
|
||||
mask = 0xff;
|
||||
}
|
||||
*(dst--) = *(src--) & mask;
|
||||
|
|
|
@ -26,7 +26,7 @@ char *strnstr(const char *s1, const char *s2, size_t n);
|
|||
#endif
|
||||
|
||||
void strncpy_pad_spaces(char *dst, const char *str, int size);
|
||||
void strncpy_trim_spaces(char *dst, const char *str, int size);
|
||||
void strncpy_trim_space(char *dst, const char *str, int size);
|
||||
|
||||
int strnrep(char *dst, size_t dst_size, const char *token, size_t token_len,
|
||||
const char *value, size_t value_len);
|
||||
|
|
|
@ -217,17 +217,19 @@ struct disc *disc_create(const char *filename) {
|
|||
char bootname[17];
|
||||
char name[129];
|
||||
|
||||
strncpy_trim_spaces(device_info, meta.device_info, sizeof(meta.device_info));
|
||||
strncpy_trim_spaces(product_number, meta.product_number,
|
||||
sizeof(meta.product_number));
|
||||
strncpy_trim_spaces(product_version, meta.product_version,
|
||||
sizeof(meta.product_version));
|
||||
strncpy_trim_spaces(bootname, meta.bootname, sizeof(meta.bootname));
|
||||
strncpy_trim_spaces(name, meta.name, sizeof(meta.name));
|
||||
strncpy_trim_space(device_info, meta.device_info, sizeof(meta.device_info));
|
||||
strncpy_trim_space(product_number, meta.product_number,
|
||||
sizeof(meta.product_number));
|
||||
strncpy_trim_space(product_version, meta.product_version,
|
||||
sizeof(meta.product_version));
|
||||
strncpy_trim_space(bootname, meta.bootname, sizeof(meta.bootname));
|
||||
strncpy_trim_space(name, meta.name, sizeof(meta.name));
|
||||
|
||||
snprintf(disc->id, sizeof(disc->id), "%s %s %s %s", name, product_number,
|
||||
product_version, device_info);
|
||||
|
||||
LOG_INFO("disc_create looking for bootfile %s", bootname);
|
||||
|
||||
int found = disc_find_file(disc, bootname, &disc->bootfad, &disc->bootlen);
|
||||
CHECK(found);
|
||||
|
||||
|
|
Loading…
Reference in New Issue