Fix:Core:Better prototype for getline/getdelim and check for requirement
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Fri, 2 Sep 2011 11:39:05 +0000 (11:39 +0000)
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Fri, 2 Sep 2011 11:39:05 +0000 (11:39 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@4747 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/CMakeLists.txt
navit/config.h.cmake
navit/navit/util.c

index 55b6462..0c7eed4 100644 (file)
@@ -118,8 +118,10 @@ CHECK_INCLUDE_FILES(string.h HAVE_STRING_H)
 CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY)
 CHECK_SYMBOL_EXISTS(system stdlib.h HAVE_SYSTEM)
 CHECK_SYMBOL_EXISTS(CreateProcess windows.h HAVE_CREATEPROCESS)
-CHECK_FUNCTION_EXISTS(stpcpy HAVE_STPCPY)
+CHECK_SYMBOL_EXISTS(stpcpy string.h HAVE_STPCPY)
 CHECK_FUNCTION_EXISTS(sbrk HAVE_SBRK)
+CHECK_FUNCTION_EXISTS(getdelim HAVE_GETDELIM)
+CHECK_FUNCTION_EXISTS(getline HAVE_GETLINE)
 
 
 ### Configure build
index 374f37e..984195e 100644 (file)
@@ -73,3 +73,7 @@
 #cmakedefine HAVE_SBRK 1
 
 #cmakedefine HAVE_PRAGMA_PACK 1
+
+#cmakedefine HAVE_GETDELIM 1
+
+#cmakedefine HAVE_GETLINE 1
index cbb42f1..6046747 100644 (file)
@@ -32,6 +32,7 @@
 #endif
 #include "util.h"
 #include "debug.h"
+#include "config.h"
 
 void
 strtoupper(char *dest, const char *src)
@@ -165,6 +166,7 @@ char *stristr(const char *String, const char *Pattern)
 #endif
 
 
+#ifndef HAVE_GETDELIM
 /**
  * Read the part of a file up to a delimiter to a string.
  * <p> 
@@ -178,7 +180,7 @@ char *stristr(const char *String, const char *Pattern)
  * @return Number of characters read (not including
    the null terminator), or -1 on error or EOF.
 */
-int
+ssize_t
 getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
 {
   int result;
@@ -252,12 +254,15 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
 
   return result;
 }
+#endif
 
-int
+#ifndef HAVE_GETLINE
+ssize_t
 getline (char **lineptr, size_t *n, FILE *stream)
 {
   return getdelim (lineptr, n, '\n', stream);
 }
+#endif
 
 #if defined(_UNICODE)
 wchar_t* newSysString(const char *toconvert)