summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-03-16 07:37:20 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-03-21 16:15:09 +0100
commit49eb6061ec01f5ae0208b487f97ccb6dab910313 (patch)
treedc1da63169350b996133041f5b231f8c831c6108 /cpukit
parent5ed41a6d825c5dbb7c543c96b51442e10e654eb1 (diff)
downloadrtems-49eb6061ec01f5ae0208b487f97ccb6dab910313.tar.bz2
dosfs: msdos_filename_utf8_to_short_name_for_save
Simplify.
Diffstat (limited to 'cpukit')
-rw-r--r--cpukit/libfs/src/dosfs/msdos_conv.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/cpukit/libfs/src/dosfs/msdos_conv.c b/cpukit/libfs/src/dosfs/msdos_conv.c
index 98f2e9be81..d7ef97ad2a 100644
--- a/cpukit/libfs/src/dosfs/msdos_conv.c
+++ b/cpukit/libfs/src/dosfs/msdos_conv.c
@@ -288,7 +288,13 @@ msdos_get_valid_utf16_filename_character (const uint16_t utf16_character)
static char
msdos_get_valid_codepage_filename_character (const uint8_t character)
{
- return codepage_valid_char_map[(unsigned int)character];
+ char c = codepage_valid_char_map[character];
+
+ if (c == 0) {
+ c = '_';
+ }
+
+ return c;
}
static ssize_t
@@ -556,7 +562,6 @@ msdos_filename_utf8_to_short_name_for_save (
size_t name_size = utf8_name_size;
char *dest_ptr = (char*)short_name;
unsigned int i;
- char c;
size_t name_size_tmp;
char name_to_format_buf[MSDOS_SHORT_NAME_LEN +1];
@@ -606,10 +611,8 @@ msdos_filename_utf8_to_short_name_for_save (
dest_ptr[0] = '_';
else if ( 0xE5 == *name_ptr )
dest_ptr[0] = 0x05;
- else if (0 != (c = msdos_get_valid_codepage_filename_character( *name_ptr ) ) )
- dest_ptr[0] = c;
else
- dest_ptr[0] = '_';
+ dest_ptr[0] = msdos_get_valid_codepage_filename_character(*name_ptr);
++name_ptr;
++returned_size;
--name_size;
@@ -617,11 +620,7 @@ msdos_filename_utf8_to_short_name_for_save (
* Validate and assign all other characters of the name part
*/
for (i = 1; i <= 7 && name_size && *name_ptr != '.'; ++i) {
- c = msdos_get_valid_codepage_filename_character ( *name_ptr );
- if (c != 0)
- dest_ptr[i] = c;
- else
- dest_ptr[i] = '_';
+ dest_ptr[i] = msdos_get_valid_codepage_filename_character(*name_ptr);
++name_ptr;
++returned_size;
--name_size;
@@ -644,11 +643,7 @@ msdos_filename_utf8_to_short_name_for_save (
* Copy in the extension part of the name, if any.
*/
for (; i <= 10 && name_size ; i++) {
- c = msdos_get_valid_codepage_filename_character ( *name_ptr);
- if (c != 0)
- dest_ptr[i] = c;
- else
- dest_ptr[i] = '_';
+ dest_ptr[i] = msdos_get_valid_codepage_filename_character(*name_ptr);
++name_ptr;
++returned_size;
name_size--;