Move libldap/strdup.c to string.c.

libldap/string.c will hold various string.h replacements.
Removed liblutil/strdup.c
Moved ldap_pvt_strtok to string.c.
Moved prototype of ldap_pvt_strtok to <ac/string.h>.
Added #define strtok_r ldap_pvt_strtok (if strtok_r doesn't exist).
This commit is contained in:
Kurt Zeilenga 1999-01-22 04:33:29 +00:00
parent 2a7794de09
commit ddb0752b8f
9 changed files with 57 additions and 155 deletions

63
configure vendored
View File

@ -3593,8 +3593,8 @@ fi
if test $ol_link_threads = no ; then
echo $ac_n "checking for pthread_create with -pthread""... $ac_c" 1>&6
echo "configure:3598: checking for pthread_create with -pthread" >&5
echo $ac_n "checking for pthread_create with -kthread""... $ac_c" 1>&6
echo "configure:3598: checking for pthread_create with -kthread" >&5
if eval "test \"`echo '$''{'ol_cv_kthread_flag'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -8419,6 +8419,7 @@ for ac_func in \
sigset \
snprintf \
socket \
strdup \
strerror \
strpbrk \
strrchr \
@ -8433,12 +8434,12 @@ for ac_func in \
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:8437: checking for $ac_func" >&5
echo "configure:8438: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 8442 "configure"
#line 8443 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@ -8461,7 +8462,7 @@ $ac_func();
; return 0; }
EOF
if { (eval echo configure:8465: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
if { (eval echo configure:8466: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@ -8495,12 +8496,12 @@ for ac_func in \
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:8499: checking for $ac_func" >&5
echo "configure:8500: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 8504 "configure"
#line 8505 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@ -8523,7 +8524,7 @@ $ac_func();
; return 0; }
EOF
if { (eval echo configure:8527: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
if { (eval echo configure:8528: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@ -8548,20 +8549,21 @@ fi
done
echo $ac_n "checking number of arguments of ctime_r""... $ac_c" 1>&6
echo "configure:8553: checking number of arguments of ctime_r" >&5
if test "$ac_cv_func_ctime_r" = yes ; then
echo $ac_n "checking number of arguments of ctime_r""... $ac_c" 1>&6
echo "configure:8555: checking number of arguments of ctime_r" >&5
if eval "test \"`echo '$''{'ol_cv_func_ctime_r_nargs'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 8558 "configure"
#line 8560 "configure"
#include "confdefs.h"
#include <time.h>
int main() {
time_t ti; char *buffer; ctime_r(&ti,buffer,32);
; return 0; }
EOF
if { (eval echo configure:8565: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:8567: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ol_cv_func_ctime_r_nargs=3
else
@ -8573,7 +8575,7 @@ fi
rm -f conftest*
if test $ol_cv_func_ctime_r_nargs = 0 ; then
cat > conftest.$ac_ext <<EOF
#line 8577 "configure"
#line 8579 "configure"
#include "confdefs.h"
#include <time.h>
int main() {
@ -8581,7 +8583,7 @@ time_t ti; char *buffer;
ctime_r(&ti,buffer);
; return 0; }
EOF
if { (eval echo configure:8585: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:8587: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ol_cv_func_ctime_r_nargs=2
else
@ -8603,12 +8605,15 @@ EOF
fi
else
ol_cv_func_ctime_r=0
fi
if test $ac_cv_func_strtok_r = yes \
-a $ac_cv_func_ctime_r = yes \
-a $ol_cv_func_ctime_r_nargs -ge 2 -a $ol_cv_func_ctime_r_nargs -le 3 \
-a $ac_cv_func_gethostbyaddr_r = yes \
-a $ac_cv_func_gethostbyname_r = yes \
if test "$ac_cv_func_strtok_r" = yes \
-a "$ac_cv_func_ctime_r" = yes \
-a "$ol_cv_func_ctime_r_nargs" -ge 2 -a "$ol_cv_func_ctime_r_nargs" -le 3 \
-a "$ac_cv_func_gethostbyaddr_r" = yes \
-a "$ac_cv_func_gethostbyname_r" = yes \
; then
cat >> confdefs.h <<\EOF
@ -8624,15 +8629,15 @@ EOF
fi
for ac_func in getopt strdup tempnam
for ac_func in getopt tempnam
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:8631: checking for $ac_func" >&5
echo "configure:8636: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 8636 "configure"
#line 8641 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@ -8655,7 +8660,7 @@ $ac_func();
; return 0; }
EOF
if { (eval echo configure:8659: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
if { (eval echo configure:8664: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@ -8685,13 +8690,13 @@ done
# Check Configuration
echo $ac_n "checking declaration of sys_errlist""... $ac_c" 1>&6
echo "configure:8689: checking declaration of sys_errlist" >&5
echo "configure:8694: checking declaration of sys_errlist" >&5
if eval "test \"`echo '$''{'ol_cv_dcl_sys_errlist'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 8695 "configure"
#line 8700 "configure"
#include "confdefs.h"
#include <stdio.h>
@ -8701,7 +8706,7 @@ int main() {
char *c = (char *) *sys_errlist
; return 0; }
EOF
if { (eval echo configure:8705: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:8710: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ol_cv_dcl_sys_errlist=yes
else
@ -8722,20 +8727,20 @@ if test $ol_cv_dcl_sys_errlist = no ; then
EOF
echo $ac_n "checking existence of sys_errlist""... $ac_c" 1>&6
echo "configure:8726: checking existence of sys_errlist" >&5
echo "configure:8731: checking existence of sys_errlist" >&5
if eval "test \"`echo '$''{'ol_cv_have_sys_errlist'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 8732 "configure"
#line 8737 "configure"
#include "confdefs.h"
#include <errno.h>
int main() {
char *c = (char *) *sys_errlist
; return 0; }
EOF
if { (eval echo configure:8739: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
if { (eval echo configure:8744: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
ol_cv_have_sys_errlist=yes
else

View File

@ -1298,6 +1298,7 @@ AC_CHECK_FUNCS( \
sigset \
snprintf \
socket \
strdup \
strerror \
strpbrk \
strrchr \
@ -1319,13 +1320,17 @@ AC_CHECK_FUNCS( \
gethostbyname_r \
)
OL_FUNC_CTIME_R_NARGS
if test "$ac_cv_func_ctime_r" = yes ; then
OL_FUNC_CTIME_R_NARGS
else
ol_cv_func_ctime_r=0
fi
if test $ac_cv_func_strtok_r = yes \
-a $ac_cv_func_ctime_r = yes \
-a $ol_cv_func_ctime_r_nargs -ge 2 -a $ol_cv_func_ctime_r_nargs -le 3 \
-a $ac_cv_func_gethostbyaddr_r = yes \
-a $ac_cv_func_gethostbyname_r = yes \
if test "$ac_cv_func_strtok_r" = yes \
-a "$ac_cv_func_ctime_r" = yes \
-a "$ol_cv_func_ctime_r_nargs" -ge 2 -a "$ol_cv_func_ctime_r_nargs" -le 3 \
-a "$ac_cv_func_gethostbyaddr_r" = yes \
-a "$ac_cv_func_gethostbyname_r" = yes \
; then
AC_DEFINE(LDAP_API_FEATURE_X_OPENLDAP_REENTRANT, 1)
@ -1336,7 +1341,7 @@ if test $ol_link_threads != no ; then
fi
dnl We actually may need to replace more than this.
AC_REPLACE_FUNCS(getopt strdup tempnam)
AC_REPLACE_FUNCS(getopt tempnam)
dnl ----------------------------------------------------------------
# Check Configuration

View File

@ -42,10 +42,15 @@
# endif
#endif
extern char *ldap_pvt_strtok( char *str, const char *delim, char **pos );
#ifndef HAVE_STRTOK_R
# define strtok_r(s, d, p) ldap_pvt_strtok((s),(d),(p))
#endif
extern char *ldap_pvt_strdup( const char * s );
#ifndef HAVE_STRDUP
/* strdup() is missing, declare our own version */
extern char *ldap_pvt_strdup( const char * s );
# define strdup ldap_pvt_strdup
# define strdup(s) ldap_pvt_strdup(s)
#else
/* some systems fail to declare strdup */
extern char *strdup();

View File

@ -17,7 +17,6 @@
struct hostent; /* avoid pulling in <netdb.h> */
extern char *ldap_pvt_strtok( char *str, const char *delim, char **pos );
extern char *ldap_pvt_ctime( const time_t *tp, char *buf );
extern int ldap_pvt_gethostbyname_a(
const char *name,

View File

@ -15,7 +15,7 @@ SRCS = bind.c open.c result.c error.c compare.c search.c \
free.c disptmpl.c srchpref.c dsparse.c tmplout.c sort.c \
getdn.c getentry.c getattr.c getvalues.c addentry.c \
request.c getdxbyname.c os-ip.c url.c charset.c \
init.c options.c strdup.c util-int.c
init.c options.c string.c util-int.c
OBJS = bind.lo open.lo result.lo error.lo compare.lo search.lo \
controls.lo messages.lo references.lo \
modify.lo add.lo modrdn.lo delete.lo abandon.lo ufn.lo cache.lo \
@ -23,7 +23,7 @@ OBJS = bind.lo open.lo result.lo error.lo compare.lo search.lo \
free.lo disptmpl.lo srchpref.lo dsparse.lo tmplout.lo sort.lo \
getdn.lo getentry.lo getattr.lo getvalues.lo addentry.lo \
request.lo getdxbyname.lo os-ip.lo url.lo charset.lo \
init.lo options.lo strdup.lo util-int.lo
init.lo options.lo string.lo util-int.lo
LDAP_INCDIR= ../../include
LDAP_LIBDIR= ../../libraries

View File

@ -1,26 +0,0 @@
/*
* Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
#include "portable.h"
#include <stdlib.h>
#include <ac/string.h>
#include <ac/time.h>
#include "ldap-int.h"
char *
(ldap_pvt_strdup)( const char *s )
{
char *p;
int len;
len = strlen( s ) + 1;
if ( (p = (char *) malloc( len )) == NULL )
return( (char *)0 );
memcpy( p, s, len );
return( p );
}

View File

@ -57,71 +57,6 @@ static ldap_pvt_thread_mutex_t ldap_int_gethostbyaddr_mutex;
#undef HAVE_REENTRANT_FUNCTIONS
#endif
#if defined ( HAVE_STRSPN )
#define int_strspn strspn
#else
static int int_strspn( const char *str, const char *delim )
{
int pos;
const char *p=delim;
for( pos=0; (*str) ; pos++,str++) {
if (*str!=*p)
for( p=delim; (*p) ; p++ ) {
if (*str==*p)
break;
}
if (*p=='\0')
return pos;
}
return pos;
}
#endif
#if defined( HAVE_STRPBRK )
#define int_strpbrk strpbrk
#else
static char *int_strpbrk( const char *str, const char *accept )
{
const char *p;
for( ; (*str) ; str++ ) {
for( p=accept; (*p) ; p++) {
if (*str==*p)
return str;
}
}
return NULL;
}
#endif
char *ldap_pvt_strtok( char *str, const char *delim, char **pos )
{
#if defined( HAVE_STRTOK_R ) || defined( HAVE_REENTRANT_FUNCTIONS )
return strtok_r(str, delim, pos);
#else
char *p;
if (pos==NULL)
return NULL;
if (str==NULL) {
if (*pos==NULL)
return NULL;
str=*pos;
}
/* skip any initial delimiters */
str += int_strspn( str, delim );
if (*str == '\0')
return NULL;
p = int_strpbrk( str, delim );
if (p==NULL) {
*pos = NULL;
} else {
*p ='\0';
*pos = p+1;
}
return str;
#endif
}
char *ldap_pvt_ctime( const time_t *tp, char *buf )
{
#if (defined( HAVE_CTIME_R ) || defined( HAVE_REENTRANT_FUNCTIONS)) \

View File

@ -14,7 +14,7 @@ XXSRCS = apitest.c test.c tmpltest.c \
free.c disptmpl.c srchpref.c dsparse.c tmplout.c sort.c \
getdn.c getentry.c getattr.c getvalues.c addentry.c \
request.c getdxbyname.c os-ip.c url.c charset.c \
init.c options.c strdup.c util-int.c
init.c options.c string.c util-int.c
SRCS = thr_posix.c thr_cthreads.c thr_thr.c thr_lwp.c thr_nt.c \
thr_stub.c rdwr.c
OBJS = bind.lo controls.lo open.lo result.lo error.lo compare.lo search.lo \
@ -23,7 +23,7 @@ OBJS = bind.lo controls.lo open.lo result.lo error.lo compare.lo search.lo \
free.lo disptmpl.lo srchpref.lo dsparse.lo tmplout.lo sort.lo \
getdn.lo getentry.lo getattr.lo getvalues.lo addentry.lo \
request.lo getdxbyname.lo os-ip.lo url.lo charset.lo \
init.lo options.lo strdup.lo util-int.lo \
init.lo options.lo string.lo util-int.lo \
thr_posix.lo thr_cthreads.lo thr_thr.lo thr_lwp.lo thr_nt.lo \
thr_stub.lo rdwr.lo

View File

@ -1,21 +0,0 @@
#include "portable.h"
#ifndef HAVE_STRDUP
#include <stdlib.h>
#include <ac/string.h>
#include "lutil.h"
char *(strdup)( const char *s )
{
char *p;
if ( (p = (char *) malloc( strlen( s ) + 1 )) == NULL )
return( (char *)0 );
strcpy( p, s );
return( p );
}
#endif /* !strdup */