You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2020/08/01 09:58:53 UTC

[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #1499: FAT Filesystem: UTF8 support for long filenames, bugfixes.

xiaoxiang781216 commented on a change in pull request #1499:
URL: https://github.com/apache/incubator-nuttx/pull/1499#discussion_r463945462



##########
File path: fs/fat/fs_fat32dirent.c
##########
@@ -2071,7 +2278,11 @@ static int fat_putlfname(FAR struct fat_mountpt_s *fs,
    * LDIR_MAXLFNCHARS (13).
    */
 
-  namelen = strlen((FAR char *)dirinfo->fd_lfname);
+  for (namelen = 0; dirinfo->fd_lfname[namelen] != '\0'; namelen++)

Review comment:
       Why not process like lnfchar?
   ```
   #ifdef CONFIG_FAT_LFN_UTF8
   #define lnflen(s) wcslen(s)
   #else
   #define lnflen(s) strlen(s)
   #endif

##########
File path: fs/fat/fs_fat32dirent.c
##########
@@ -564,19 +668,25 @@ static inline int fat_parselfname(FAR const char **path,
 #ifdef CONFIG_FAT_LFN
 static inline int fat_createalias(FAR struct fat_dirinfo_s *dirinfo)
 {
-  uint8_t ch;        /* Current character being processed */
-  char   *ext;       /* Pointer to the extension substring */
-  char   *src;       /* Pointer to the long file name source */
-  int     len;       /* Total length of the long file name */
-  int     namechars; /* Number of characters available in long name */
-  int     extchars;  /* Number of characters available in long name extension */
-  int     endndx;    /* Maximum index into the short name array */
-  int     ndx;       /* Index to store next character */
+  uint8_t  ch;        /* Current character being processed */
+  lfnchar *ext;       /* Pointer to the extension substring */
+  lfnchar *src;       /* Pointer to the long file name source */
+  int      len;       /* Total length of the long file name */
+  int      namechars; /* Number of characters available in long name */
+  int      extchars;  /* Number of characters available in long name extension */
+  int      endndx;    /* Maximum index into the short name array */
+  int      ndx;       /* Index to store next character */
 
   /* First, let's decide what is name and what is extension */
 
-  len = strlen((FAR char *)dirinfo->fd_lfname);
-  ext = strrchr((FAR char *)dirinfo->fd_lfname, '.');
+  for (len = 0, ext = NULL; dirinfo->fd_lfname[len] != '\0'; len++)

Review comment:
       #ifdef CONFIG_FAT_LFN_UTF8
   #define lnfchr(s,c) wcschr(s,c)
   #else
   #define lnflen(s,c) strchr(s,c)
   #endif
   Instead the manual loop

##########
File path: fs/fat/fs_fat32dirent.c
##########
@@ -143,10 +143,102 @@ static int fat_putsfdirentry(FAR struct fat_mountpt_s *fs,
                              FAR struct fat_dirinfo_s *dirinfo,
                              uint8_t attributes, uint32_t fattime);
 
+#if defined(CONFIG_FAT_LFN) && defined(CONFIG_FAT_LFN_UTF8)
+static int fat_utf8toucs(FAR const char **str, lfnchar *ucs);
+static int fat_ucstoutf8(FAR uint8_t *dest, uint8_t offset, lfnchar ucs);

Review comment:
       it's better to move the implementation to mbstowcs and wcsrtombs. and call mbstowcs/wcsrtombs instead. Then the conversion can be reused.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org