From 59bcbb4cfbab6d1c07f829f3cac03388ce6d926a Mon Sep 17 00:00:00 2001 From: cpickett Date: Fri, 13 Oct 2006 03:33:25 +0000 Subject: [PATCH] * fix money example somewhat git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@293 64e312b2-a51f-0410-8e61-82d0ca0eb02a --- doc/example/configure.ac | 2 ++ doc/example/src/Makefile.am | 6 +++--- doc/example/src/money.c | 10 +++++++++- doc/example/tests/Makefile.am | 2 +- doc/example/tests/check_money.c | 2 +- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/doc/example/configure.ac b/doc/example/configure.ac index 60b33bd..670a9dc 100644 --- a/doc/example/configure.ac +++ b/doc/example/configure.ac @@ -16,6 +16,8 @@ AM_INIT_AUTOMAKE([-Wall -Werror foreign 1.9.6]) # Checks for programs. AC_PROG_CC +AC_PROG_LIBTOOL +AC_PROG_RANLIB # Checks for libraries. diff --git a/doc/example/src/Makefile.am b/doc/example/src/Makefile.am index 58938f4..0ab2add 100644 --- a/doc/example/src/Makefile.am +++ b/doc/example/src/Makefile.am @@ -1,8 +1,8 @@ ## Process this file with automake to produce Makefile.in -lib_LTLIBRARIES = money.la -money_SOURCES = money.c money.h +lib_LTLIBRARIES = libmoney.la +libmoney_la_SOURCES = money.c money.h bin_PROGRAMS = main main_SOURCES = main.c -main_LDADD = money.la +main_LDADD = libmoney.la diff --git a/doc/example/src/money.c b/doc/example/src/money.c index b551e96..1b8af58 100644 --- a/doc/example/src/money.c +++ b/doc/example/src/money.c @@ -10,9 +10,17 @@ struct Money Money * money_create (int amount, char *currency) { + if (amount < 0) + { + return NULL; + } + Money *m = malloc (sizeof (Money)); if (m == NULL) - return NULL; + { + return NULL; + } + m->amount = amount; m->currency = currency; return m; diff --git a/doc/example/tests/Makefile.am b/doc/example/tests/Makefile.am index 35bc176..e48703f 100644 --- a/doc/example/tests/Makefile.am +++ b/doc/example/tests/Makefile.am @@ -2,4 +2,4 @@ TESTS=check_money noinst_PROGRAMS=check_money check_money_SOURCES= check_money.c check_money_INCLUDES = @CHECK_CFLAGS@ -check_money_LDADD = @CHECK_LIBS@ $(top_builddir)/src/money.la +check_money_LDADD = @CHECK_LIBS@ $(top_builddir)/src/libmoney.la diff --git a/doc/example/tests/check_money.c b/doc/example/tests/check_money.c index 4444660..9c563cc 100644 --- a/doc/example/tests/check_money.c +++ b/doc/example/tests/check_money.c @@ -1,6 +1,6 @@ #include #include -#include "money.h" +#include "../src/money.h" Money *five_dollars; void -- 2.40.0