Fixed relaxed constraints patch

This commit is contained in:
Mario Danic 2007-08-10 09:30:26 +00:00
parent 0b13d485fe
commit ca09f3948d

View File

@ -508,7 +508,7 @@ sort_tree(struct ecma119_tree_node *root)
* "HELLOTHE03.TXT" * "HELLOTHE03.TXT"
*/ */
static void static void
mangle_name(char **name, int num_change, int level, int seq_num) mangle_name(char **name, int num_change, int level, int relaxed, int seq_num)
{ {
char *dot = strrchr(*name, '.'); char *dot = strrchr(*name, '.');
char *semi = strrchr(*name, ';'); char *semi = strrchr(*name, ';');
@ -521,6 +521,24 @@ mangle_name(char **name, int num_change, int level, int seq_num)
return; return;
} }
strncpy(base, *name, len+1); strncpy(base, *name, len+1);
if (relaxed & ECMA119_RELAXED_FILENAMES) {
/* relaxed filenames, don't care about extension */
int maxlen = (relaxed & (1<<1)) ? 37 : 31;
base[maxlen - num_change] = '\0';
baselen = strlen(base);
if (relaxed & ECMA119_OMIT_VERSION_NUMBERS) {
sprintf(fmt, "%%s%%0%1dd", num_change);
*name = realloc(*name, baselen + num_change + 1);
} else {
sprintf(fmt, "%%s%%0%1dd;1", num_change);
*name = realloc(*name, baselen + num_change + 3);
}
sprintf(*name, fmt, base, seq_num);
return;
}
if (dot) { if (dot) {
base[dot - *name] = '\0'; base[dot - *name] = '\0';
strncpy(ext, dot+1, len+1); strncpy(ext, dot+1, len+1);
@ -533,14 +551,24 @@ mangle_name(char **name, int num_change, int level, int seq_num)
} }
baselen = strlen(base); baselen = strlen(base);
extlen = strlen(ext); extlen = strlen(ext);
if (level == 1 && baselen + num_change > 8) {
if (relaxed & (1<<1)) {
/* 37 char filenames */
base[36 - extlen - num_change] = '\0';
} else if (level == 1 && baselen + num_change > 8) {
base[8 - num_change] = '\0'; base[8 - num_change] = '\0';
} else if (level != 1 && baselen + extlen + num_change > 30) { } else if (level != 1 && baselen + extlen + num_change > 30) {
base[30 - extlen - num_change] = '\0'; base[30 - extlen - num_change] = '\0';
} }
sprintf(fmt, "%%s%%0%1dd.%%s;1", num_change); if (relaxed & ECMA119_OMIT_VERSION_NUMBERS) {
*name = realloc(*name, baselen + extlen + num_change + 4); sprintf(fmt, "%%s%%0%1dd.%%s", num_change);
*name = realloc(*name, baselen + extlen + num_change + 1);
} else {
sprintf(fmt, "%%s%%0%1dd.%%s;1", num_change);
*name = realloc(*name, baselen + extlen + num_change + 4);
}
sprintf(*name, fmt, base, seq_num, ext); sprintf(*name, fmt, base, seq_num, ext);
} }
@ -575,6 +603,7 @@ mangle_all(struct ecma119_tree_node *dir)
mangle_name(&(d.children[i+k]->iso_name), mangle_name(&(d.children[i+k]->iso_name),
n_change, n_change,
dir->target->iso_level, dir->target->iso_level,
dir->target->relaxed_constraints,
k); k);
d.children[i+k]->dirent_len = d.children[i+k]->dirent_len =
calc_dirent_len(d.children[i+k]); calc_dirent_len(d.children[i+k]);