Permalink
Browse files

Use AC_CHECK_FUNCS for strtok_r

  • Loading branch information...
1 parent 21a8e2c commit 1236d39f8af8e898cfcbb08f2cdae4ae6c7f54d2 @czchen czchen committed Nov 8, 2012
Showing with 25 additions and 22 deletions.
  1. +1 −0 configure.ac
  2. +24 −22 src/porting_layer/src/plat_path.c
View
@@ -58,6 +58,7 @@ AC_LANG(C)
# Checks for library functions.
AC_FUNC_MALLOC
+AC_CHECK_FUNCS([strtok_r])
# plat_mmap_posix
AC_FUNC_MMAP
@@ -46,6 +46,30 @@ int get_search_path( char * path, size_t path_len )
#elif defined(_WIN32) || defined(_WIN64) || defined(_WIN32_WCE)
#define SEARCH_PATH_SEP ";"
+int get_search_path( char * path, size_t path_len )
+{
+ char *chewing_path;
+ char *appdata;
+
+ chewing_path = getenv( "CHEWING_PATH" );
+ if ( chewing_path ) {
+ strncpy( path, chewing_path, path_len );
+ } else {
+ appdata = getenv( "APPDATA" );
+ if ( appdata ) {
+ snprintf( path, path_len, "%s", appdata );
+ } else {
+ return -1;
+ }
+ }
+
+ return 0;
+}
+#else
+#error please implement get_search_path
+#endif
+
+#if !HAVE_STRTOK_R
static char * strtok_r (char *s, const char *delim, char **save_ptr)
{
char *token;
@@ -73,28 +97,6 @@ static char * strtok_r (char *s, const char *delim, char **save_ptr)
}
return token;
}
-
-int get_search_path( char * path, size_t path_len )
-{
- char *chewing_path;
- char *appdata;
-
- chewing_path = getenv( "CHEWING_PATH" );
- if ( chewing_path ) {
- strncpy( path, chewing_path, path_len );
- } else {
- appdata = getenv( "APPDATA" );
- if ( appdata ) {
- snprintf( path, path_len, "%s", appdata );
- } else {
- return -1;
- }
- }
-
- return 0;
-}
-#else
-#error please implement get_search_path
#endif
static int are_all_files_readable(

0 comments on commit 1236d39

Please sign in to comment.