Patch: Elm ME+ 2.5 PLalpha47 -> Elm ME+ 2.5 PLalpha48 [2/2] (2/3)
From
Kari Hurtta@21:1/5 to
All on Fri Jun 1 20:14:57 2018
[continued from previous message]
! }
!
! } else if (subset->magic || newptr->magic)
! return 0;
!
! return subset->magic_count;
}
void change_mime_types_map(map,new)
struct mime_types_item **map;
struct mime_types_item *new;
{
! size_t count = 0;
struct mime_types_item *ptr;
! for (ptr = *map; ptr && ptr->type; ptr++)
count++;
!
for (ptr = new; ptr && ptr->type; ptr++)
count++;
***************
*** 740,775 ****
for (ptr = new; ptr && ptr->type; ptr++) {
struct mime_types_item *ptr2;
for (ptr2 = *map; ptr2->type; ptr2++) {
if (match_item(ptr,ptr2)) {
goto set_it;
}
}
if (ptr2 > (*map) + count)
panic("CHARSET PANIC",__FILE__,__LINE__,"change_mime_types_map",
"Overflow",0);
!
ptr2->extension = NULL;
if (ptr->extension)
ptr2->extension = safe_strdup(ptr->extension);
! ptr2->length = ptr->length;
! ptr2->offset = ptr->offset;
! ptr2->bytes = NULL;
! if (ptr->bytes) {
! ptr2->bytes = safe_malloc(ptr->length);
! memcpy(ptr2->bytes,ptr->bytes,ptr->length);
}
ptr2->params = NULL;
-
(ptr2+1)->type = NULL;
set_it:
! ptr2->type = ptr->type;
ptr2->params_cs = ptr->params_cs;
!
if (ptr->params) {
ptr2->params = strmcpy(ptr2->params,ptr->params);
--- 925,1001 ----
for (ptr = new; ptr && ptr->type; ptr++) {
struct mime_types_item *ptr2;
+ struct mime_types_item *found = NULL;
+ size_t found_len = 0;
+
+
+ if (!ptr->valid)
+ continue;
+
+
for (ptr2 = *map; ptr2->type; ptr2++) {
if (match_item(ptr,ptr2)) {
goto set_it;
}
}
+ for (ptr2 = *map; ptr2->type; ptr2++) {
+ size_t z = subset_match_item(ptr2,ptr);
+
+ if (z > found_len) {
+ found = ptr2;
+ found_len = z;
+ }
+ }
+
if (ptr2 > (*map) + count)
panic("CHARSET PANIC",__FILE__,__LINE__,"change_mime_types_map",
"Overflow",0);
!
! /* Remove subset from list */
! if (found && !found->changed)
! found->valid = 0;
!
! ptr2->valid = 0;
! ptr2->changed = 0;
ptr2->extension = NULL;
if (ptr->extension)
ptr2->extension = safe_strdup(ptr->extension);
! ptr2->magic_count = ptr->magic_count;
! ptr2->magic = NULL;
!
! if (ptr->