ObjFW  Check-in [a6c1870058]

Overview
Comment:Don't compile asprintf.c if not needed.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: a6c1870058e5d62cb6d6db5bc7a1b8420603609e94adce4e2058858534c91f06
User & Date: js on 2008-12-13 22:58:18
Other Links: manifest | tags
Context
2008-12-13
23:11
Fix two more FIXMEs in OFTCPSocket; new exception. check-in: ec3c199d1a user: js tags: trunk
22:58
Don't compile asprintf.c if not needed. check-in: a6c1870058 user: js tags: trunk
22:16
Properly clear line in tests on failure. check-in: 81c57d9f39 user: js tags: trunk
Changes

Modified configure.ac from [b75bd90040] to [6bc92d283b].

30
31
32
33
34
35
36

37

38
39
40
41
42
43
44
	AC_DEFINE(HAVE_SEL_GET_NAME, 1, [Whether we have sel_get_name])])
AC_CHECK_LIB(objc, sel_getName, [
	have_sel_getName="yes"
	AC_DEFINE(HAVE_SEL_GETNAME, 1, [Whether we have sel_getName])])
test x"$have_sel_get_name" != x"yes" -a x"$have_sel_getName" != x"yes" && \
	AC_ERROR(You need either sel_get_name or sel_getName in libobjc!)


AC_CHECK_FUNC(asprintf, AC_DEFINE(HAVE_ASPRINTF, 1, "Whether we have asprintf"))


AC_MSG_CHECKING(whether we have IPv6 support)
AC_TRY_RUN([
	#include <stdlib.h>
	#include <string.h>

	#include <sys/types.h>







>
|
>







30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
	AC_DEFINE(HAVE_SEL_GET_NAME, 1, [Whether we have sel_get_name])])
AC_CHECK_LIB(objc, sel_getName, [
	have_sel_getName="yes"
	AC_DEFINE(HAVE_SEL_GETNAME, 1, [Whether we have sel_getName])])
test x"$have_sel_get_name" != x"yes" -a x"$have_sel_getName" != x"yes" && \
	AC_ERROR(You need either sel_get_name or sel_getName in libobjc!)

AC_CHECK_FUNC(asprintf, [
	AC_DEFINE(HAVE_ASPRINTF, 1, "Whether we have asprintf")
	AC_SUBST(ASPRINTF, "asprintf.c")])

AC_MSG_CHECKING(whether we have IPv6 support)
AC_TRY_RUN([
	#include <stdlib.h>
	#include <string.h>

	#include <sys/types.h>

Modified extra.mk.in from [c408765bf4] to [6bf1c1cbe4].


1

TESTS = @TESTS@
>

1
2
ASPRINTF = @ASPRINTF@
TESTS = @TESTS@

Modified src/Makefile from [fd8a00574a] to [522864ef3f].



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

16
17
18
19
20
21
22
23
24
25
26
27


LIB = ${LIB_PREFIX}objfw${LIB_SUFFIX}
LIB_MAJOR = 1
LIB_MINOR = 0

SRCS = OFArray.m		\
       OFExceptions.m		\
       OFHashes.m		\
       OFFile.m			\
       OFList.m			\
       OFListObject.m		\
       OFObject.m		\
       OFString.m		\
       OFTCPSocket.m		\
       OFXMLFactory.m		\
       asprintf.c


INCLUDES = ${SRCS:.m=.h}	\
	   OFMacros.h		\
	   OFStream.h

include ../buildsys.mk

CPPFLAGS += -I..
OBJCFLAGS += ${LIB_CFLAGS}
LD = ${OBJC}
LDFLAGS += ${LIB_LDFLAGS}
LIBS += -lobjc
>
>














<
>












1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

17
18
19
20
21
22
23
24
25
26
27
28
29
include ../extra.mk

LIB = ${LIB_PREFIX}objfw${LIB_SUFFIX}
LIB_MAJOR = 1
LIB_MINOR = 0

SRCS = OFArray.m		\
       OFExceptions.m		\
       OFHashes.m		\
       OFFile.m			\
       OFList.m			\
       OFListObject.m		\
       OFObject.m		\
       OFString.m		\
       OFTCPSocket.m		\
       OFXMLFactory.m		\

       ${ASPRINTF}

INCLUDES = ${SRCS:.m=.h}	\
	   OFMacros.h		\
	   OFStream.h

include ../buildsys.mk

CPPFLAGS += -I..
OBJCFLAGS += ${LIB_CFLAGS}
LD = ${OBJC}
LDFLAGS += ${LIB_LDFLAGS}
LIBS += -lobjc

Modified src/asprintf.c from [f03277aeb4] to [c7322870d9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#include "config.h"

#ifndef HAVE_ASPRINTF
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>

int
asprintf(char **strp, const char *fmt, ...)
{
	int size;
	va_list args;

	va_start(args, fmt);

	if ((size = vsnprintf(NULL, 0, fmt, args)) < 0)
		return size;
	if ((*strp = malloc((size_t)size + 1)) == NULL)
		return -1;

	return vsnprintf(*strp, (size_t)size + 1, fmt, args);
}
#endif













<



















<
1
2
3
4
5
6
7
8
9
10
11
12
13

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#include "config.h"


#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>

int
asprintf(char **strp, const char *fmt, ...)
{
	int size;
	va_list args;

	va_start(args, fmt);

	if ((size = vsnprintf(NULL, 0, fmt, args)) < 0)
		return size;
	if ((*strp = malloc((size_t)size + 1)) == NULL)
		return -1;

	return vsnprintf(*strp, (size_t)size + 1, fmt, args);
}