From 17f3e3dcb47c4b1f83f6737e61a4a3d47a067038 Mon Sep 17 00:00:00 2001 From: jthorn Date: Fri, 2 May 2003 18:57:57 +0000 Subject: Change from using a private Strlcpy() function to the Util_Strlcpy() one that's now in the Cactus flesh. ***** ***** After this change, you will need to cvs-update your copy of the ***** Cactus flesh (files src/util/String.c and src/util/util_String.h) ***** in order to recompile this thorn. ***** git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/LocalInterp/trunk@149 df1f8a13-aa1d-4dd4-9681-27ded5b42416 --- .../InterpLocalUniform.c | 3 +- .../InterpLocalUniform.h | 1 - src/GeneralizedPolynomial-Uniform/makefile | 15 +----- src/GeneralizedPolynomial-Uniform/util.c | 63 +--------------------- 4 files changed, 5 insertions(+), 77 deletions(-) diff --git a/src/GeneralizedPolynomial-Uniform/InterpLocalUniform.c b/src/GeneralizedPolynomial-Uniform/InterpLocalUniform.c index 9e0bf9f..b98d2b1 100644 --- a/src/GeneralizedPolynomial-Uniform/InterpLocalUniform.c +++ b/src/GeneralizedPolynomial-Uniform/InterpLocalUniform.c @@ -54,6 +54,7 @@ #include "cctk.h" #include "util_ErrorCodes.h" +#include "util_String.h" #include "util_Table.h" #include "InterpLocalUniform.h" @@ -1711,7 +1712,7 @@ status = Util_TableGetString(param_table_handle, if (status == UTIL_ERROR_TABLE_NO_SUCH_KEY) then { /* set the default value */ - LocalInterp_Strlcpy(molecule_family_string_buffer, "cube", buffer_size); + Util_Strlcpy(molecule_family_string_buffer, "cube", buffer_size); molecule_family = molecule_family_cube; /* set this key in the parameter table */ diff --git a/src/GeneralizedPolynomial-Uniform/InterpLocalUniform.h b/src/GeneralizedPolynomial-Uniform/InterpLocalUniform.h index d4821c4..4ff2e52 100644 --- a/src/GeneralizedPolynomial-Uniform/InterpLocalUniform.h +++ b/src/GeneralizedPolynomial-Uniform/InterpLocalUniform.h @@ -260,4 +260,3 @@ int LocalInterp_molecule_posn(fp grid_origin, fp grid_delta, /* functions in util.c */ int LocalInterp_decode_N_parts(int type_code); -size_t LocalInterp_Strlcpy(char* dst, const char* src, size_t dst_size); diff --git a/src/GeneralizedPolynomial-Uniform/makefile b/src/GeneralizedPolynomial-Uniform/makefile index 97920f1..cd9c941 100644 --- a/src/GeneralizedPolynomial-Uniform/makefile +++ b/src/GeneralizedPolynomial-Uniform/makefile @@ -1,8 +1,5 @@ # Makefile for standalone test programs in this directory -# $Header: /mnt/data2/cvs2svn/cvs-repositories/arrangements/CactusBase/LocalInterp/src/GeneralizedPolynomial-Uniform/makefile,v 1.6 2003-02-03 08:57:03 jthorn Exp $ - -.PHONY : all -all : test_molecule_posn test_strlcpy +# $Header: /mnt/data2/cvs2svn/cvs-repositories/arrangements/CactusBase/LocalInterp/src/GeneralizedPolynomial-Uniform/makefile,v 1.7 2003-05-02 18:57:57 jthorn Exp $ test_molecule_posn : test_molecule_posn.c molecule_posn.c \ InterpLocalUniform.h @@ -13,14 +10,6 @@ test_molecule_posn : test_molecule_posn.c molecule_posn.c \ -DLOCALINTERP_STANDALONE_BUILD -o test_molecule_posn \ test_molecule_posn.c molecule_posn.c -lm -test_strlcpy : test_strlcpy.c util.c InterpLocalUniform.h - gcc -g \ - -Wall -W -Wno-unused -Wshadow -Winline -Wpointer-arith \ - -Wbad-function-cast -Wcast-align -Wcast-qual \ - -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations \ - -DLOCALINTERP_STANDALONE_BUILD -o test_strlcpy \ - test_strlcpy.c util.c - .PHONY : clean clean : - -rm test_molecule_posn test_strlcpy + -rm test_molecule_posn diff --git a/src/GeneralizedPolynomial-Uniform/util.c b/src/GeneralizedPolynomial-Uniform/util.c index 03186f0..d17f29b 100644 --- a/src/GeneralizedPolynomial-Uniform/util.c +++ b/src/GeneralizedPolynomial-Uniform/util.c @@ -16,13 +16,8 @@ #include #include -#ifdef LOCALINTERP_STANDALONE_BUILD - #define WANT_STRLCPY -#else +#ifndef LOCALINTERP_STANDALONE_BUILD #include "cctk.h" - #define WANT_ZERO_INT_ARRAY - #define WANT_DECODE_N_PARTS - #define WANT_STRLCPY #endif #include "InterpLocalUniform.h" @@ -35,7 +30,6 @@ static const char *rcsid = "$Header$"; /******************************************************************************/ -#ifdef WANT_DECODE_N_PARTS /*@@ @routine LocalInterp_decode_N_parts @date 22 Jan 2002 @@ -84,58 +78,3 @@ case CCTK_VARIABLE_FPOINTER: return 0; default: return -1; } } -#endif /* WANT_DECODE_N_PARTS */ - -/******************************************************************************/ - -#ifdef WANT_STRLCPY -/*@@ - @routine LocalInterp_Strlcpy - @date 1.Feb.2003 - @author Jonathan Thornburg - @desc This function implements the strlcpy() function - described in - http://www.openbsd.org/papers/strlcpy-paper.ps - - The strlcpy(3) function copies up to size-1 characters - from the null-terminated string src to dst , followed - by a null character (so dst is always null-terminated). - - strlcpy(3) is a replacement for strncpy(3). In comparison - to strncpy(3), strlcpy(3) is safer and easier to use (it - guarantees null termination of the destination buffer), - and faster (it doesn't have to fill the entire buffer with - null characters). - @enddesc - - @var dst - @vdesc A non-null pointer to the destination buffer. - @vtype char* dst - @endvar - - @var src - @vdesc A non-null pointer to the source string. - @vtype const char* dst - @endvar - - @var dst_size - @vdesc The size of the destination buffer. - @vtype size_t dst_size - @endvar - - @returntype size_t - @returndesc This function returns strlen(src). - @endreturndesc - @@*/ -size_t LocalInterp_Strlcpy(char* dst, const char* src, size_t dst_size) -{ -const size_t src_size = strlen(src); -if (src_size < dst_size) - then strcpy(dst, src); - else { - strncpy(dst, src, dst_size-1); - dst[dst_size-1] = '\0'; - } -return src_size; -} -#endif /* WANT_STRLCPY */ -- cgit v1.2.3