New -find test -name_limit_blocker. Made -file_name_limit ready for loaded ISOs
This commit is contained in:
@ -937,3 +937,43 @@ decode:;
|
||||
}
|
||||
|
||||
|
||||
/* From libisofs:
|
||||
Find backward from idx the start byte of a possible UTF-8 character.
|
||||
https://en.wikipedia.org/wiki/UTF-8#Description
|
||||
*/
|
||||
static
|
||||
int find_utf8_start(char *name, int idx, int flag)
|
||||
{
|
||||
unsigned char *uname, uch;
|
||||
int i;
|
||||
|
||||
uname= (unsigned char *) name;
|
||||
if ((uname[idx] & 0xc0) != 0x80)
|
||||
return idx; /* not an UTF-8 tail byte */
|
||||
for (i = 0; i < 5 && idx - 1 - i >= 0; i++) {
|
||||
/* up to deprecated 6-byte codes */
|
||||
uch = uname[idx - 1 - i];
|
||||
if ((uch & 0xe0) == 0xc0 || (uch & 0xf0) == 0xe0 ||
|
||||
(uch & 0xf8) == 0xf0 || (uch & 0xfc) == 0xf8 ||
|
||||
(uch & 0xfe) == 0xfc)
|
||||
return (idx - 1 - i); /* UTF-8 start byte found */
|
||||
if ((uch & 0xc0) != 0x80)
|
||||
return idx; /* not an UTF-8 tail byte, so no UTF-8 */
|
||||
}
|
||||
return idx; /* no UTF-8 start found */
|
||||
}
|
||||
|
||||
|
||||
int Sfile_flatten_utf8_heads(char *name, int idx, int flag)
|
||||
{
|
||||
int neck;
|
||||
|
||||
neck = find_utf8_start(name, idx, 0);
|
||||
if(neck >= idx)
|
||||
return(2);
|
||||
for(; neck < idx; neck++)
|
||||
name[neck] = '_';
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user