[vlc-commits] Inline path_sanitize()
Rémi Denis-Courmont
git at videolan.org
Sun Nov 29 15:09:46 CET 2015
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Nov 29 15:48:41 2015 +0200| [9826be044cd79753ec1fa47845dde4bf1925dec4] | committer: Rémi Denis-Courmont
Inline path_sanitize()
Also optimize it away where applicable.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9826be044cd79753ec1fa47845dde4bf1925dec4
---
include/vlc_strings.h | 32 +++++++++++++++++++++++++++++++-
src/libvlccore.sym | 1 -
src/text/strings.c | 26 --------------------------
3 files changed, 31 insertions(+), 28 deletions(-)
diff --git a/include/vlc_strings.h b/include/vlc_strings.h
index 5339944..1705e4d 100644
--- a/include/vlc_strings.h
+++ b/include/vlc_strings.h
@@ -135,7 +135,37 @@ static inline char *str_format( input_thread_t *input, const char *fmt )
}
void filename_sanitize(char *);
-VLC_API void path_sanitize( char * );
+
+/**
+ * Remove forbidden characters from full paths (leaves slashes)
+ */
+static inline void path_sanitize(char *str)
+{
+#if defined( _WIN32 ) || defined( __OS2__ )
+ /* check drive prefix if path is absolute */
+ if ((((unsigned char)(str[0] - 'A') < 26)
+ || ((unsigned char)(str[0] - 'a') < 26)) && (str[1] == ':'))
+ str += 2;
+
+ while (*str != '\0')
+ {
+ if (strchr("*\"?:|<>", *str) != NULL)
+ *str = '_';
+ if (*str == '/')
+ *str = DIR_SEP_CHAR;
+ str++;
+ }
+#elif defined( __APPLE__ )
+ while (*str != '\0')
+ {
+ if (*str == ':')
+ *str = '_';
+ str++;
+ }
+#else
+ (void) str;
+#endif
+}
/**
* @}
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 3270dad..95152e8 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -285,7 +285,6 @@ net_SetCSCov
net_vaPrintf
net_Write
NTPtime64
-path_sanitize
picture_BlendSubpicture
picture_CopyPixels
picture_Hold
diff --git a/src/text/strings.c b/src/text/strings.c
index d2fb608..e1a3f80 100644
--- a/src/text/strings.c
+++ b/src/text/strings.c
@@ -887,29 +887,3 @@ void filename_sanitize( char *str )
*str = '_';
}
}
-
-/**
- * Remove forbidden characters from full paths (leaves slashes)
- */
-void path_sanitize( char *str )
-{
-#if defined( _WIN32 ) || defined( __OS2__ )
- /* check drive prefix if path is absolute */
- if( (((unsigned char)(str[0] - 'A') < 26)
- || ((unsigned char)(str[0] - 'a') < 26)) && (':' == str[1]) )
- str += 2;
-#endif
- while( *str )
- {
-#if defined( __APPLE__ )
- if( *str == ':' )
- *str = '_';
-#elif defined( _WIN32 ) || defined( __OS2__ )
- if( strchr( "*\"?:|<>", *str ) )
- *str = '_';
- if( *str == '/' )
- *str = DIR_SEP_CHAR;
-#endif
- str++;
- }
-}
More information about the vlc-commits
mailing list