Limit FatFs' ability to upper case paths
Only uppercase ASCII letters a-z. This saves ~900 bytes. Previously written files with other unicode letters will only be accessible from their upper cased path.
This commit is contained in:
parent
de5f58a61d
commit
1a3358d036
@ -278,6 +278,12 @@ typedef struct {
|
|||||||
|
|
||||||
|
|
||||||
/* SBCS up-case tables (\x80-\xFF) */
|
/* SBCS up-case tables (\x80-\xFF) */
|
||||||
|
// Optimize the 437-only case with a truncated lookup table.
|
||||||
|
#if FF_CODE_PAGE == 437
|
||||||
|
#define TBL_CT437 {0x80,0x9A,0x45,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F, \
|
||||||
|
0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
|
||||||
|
0x41,0x49,0x4F,0x55,0xA5}
|
||||||
|
#else
|
||||||
#define TBL_CT437 {0x80,0x9A,0x45,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F, \
|
#define TBL_CT437 {0x80,0x9A,0x45,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F, \
|
||||||
0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
|
0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
|
||||||
0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \
|
0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \
|
||||||
@ -286,6 +292,7 @@ typedef struct {
|
|||||||
0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
|
0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
|
||||||
0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \
|
0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \
|
||||||
0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
|
0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
|
||||||
|
#endif
|
||||||
#define TBL_CT720 {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \
|
#define TBL_CT720 {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \
|
||||||
0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
|
0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
|
||||||
0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \
|
0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \
|
||||||
@ -2887,7 +2894,12 @@ static FRESULT create_name ( /* FR_OK: successful, FR_INVALID_NAME: could not
|
|||||||
}
|
}
|
||||||
#elif FF_CODE_PAGE < 900 /* SBCS cfg */
|
#elif FF_CODE_PAGE < 900 /* SBCS cfg */
|
||||||
wc = ff_uni2oem(wc, CODEPAGE); /* Unicode ==> ANSI/OEM code */
|
wc = ff_uni2oem(wc, CODEPAGE); /* Unicode ==> ANSI/OEM code */
|
||||||
|
// Optimize the 437-only case with a truncated lookup table.
|
||||||
|
#if FF_CODE_PAGE == 437
|
||||||
|
if (wc & 0x80 && wc < (0xA5 - 0x80)) wc = ExCvt[wc & 0x7F]; /* Convert extended character to upper (SBCS) */
|
||||||
|
#else
|
||||||
if (wc & 0x80) wc = ExCvt[wc & 0x7F]; /* Convert extended character to upper (SBCS) */
|
if (wc & 0x80) wc = ExCvt[wc & 0x7F]; /* Convert extended character to upper (SBCS) */
|
||||||
|
#endif
|
||||||
#else /* DBCS cfg */
|
#else /* DBCS cfg */
|
||||||
wc = ff_uni2oem(ff_wtoupper(wc), CODEPAGE); /* Unicode ==> Upper convert ==> ANSI/OEM code */
|
wc = ff_uni2oem(ff_wtoupper(wc), CODEPAGE); /* Unicode ==> Upper convert ==> ANSI/OEM code */
|
||||||
#endif
|
#endif
|
||||||
|
@ -499,6 +499,13 @@ DWORD ff_wtoupper ( /* Returns up-converted code point */
|
|||||||
DWORD uni /* Unicode code point to be up-converted */
|
DWORD uni /* Unicode code point to be up-converted */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
#if FF_FS_ASCII_UPPER_ONLY
|
||||||
|
// Only uppercase ASCII characters. Everything else will require the user to
|
||||||
|
// pass in an uppercase version.
|
||||||
|
if ('a' <= uni && uni <= 'z') {
|
||||||
|
uni -= 32;
|
||||||
|
}
|
||||||
|
#else
|
||||||
const WORD *p;
|
const WORD *p;
|
||||||
WORD uc, bc, nc, cmd;
|
WORD uc, bc, nc, cmd;
|
||||||
static const WORD cvt1[] = { /* Compressed up conversion table for U+0000 - U+0FFF */
|
static const WORD cvt1[] = { /* Compressed up conversion table for U+0000 - U+0FFF */
|
||||||
@ -619,6 +626,7 @@ DWORD ff_wtoupper ( /* Returns up-converted code point */
|
|||||||
}
|
}
|
||||||
uni = uc;
|
uni = uc;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return uni;
|
return uni;
|
||||||
}
|
}
|
||||||
|
@ -594,6 +594,8 @@ void supervisor_run_background_tasks_if_tick(void);
|
|||||||
#define CIRCUITPY_DIGITALIO_HAVE_INVALID_DRIVE_MODE (0)
|
#define CIRCUITPY_DIGITALIO_HAVE_INVALID_DRIVE_MODE (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define FF_FS_ASCII_UPPER_ONLY (1)
|
||||||
|
|
||||||
#define FF_FS_MAKE_VOLID (1)
|
#define FF_FS_MAKE_VOLID (1)
|
||||||
|
|
||||||
#define MICROPY_PY_OPTIMIZE_PROPERTY_FLASH_SIZE (CIRCUITPY_OPTIMIZE_PROPERTY_FLASH_SIZE)
|
#define MICROPY_PY_OPTIMIZE_PROPERTY_FLASH_SIZE (CIRCUITPY_OPTIMIZE_PROPERTY_FLASH_SIZE)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user