modified: diffout.py
[GalaxyCodeBases.git] / c_cpp / etc / calc / have_newstr.c
blob24d2b14cdf53c0bf459341af41334234b7dbf157
1 /*
2 * have_newstr - Determine if we have a system without ANSI C string functions
4 * Copyright (C) 1999 Landon Curt Noll
6 * Calc is open software; you can redistribute it and/or modify it under
7 * the terms of the version 2.1 of the GNU Lesser General Public License
8 * as published by the Free Software Foundation.
10 * Calc is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
13 * Public License for more details.
15 * A copy of version 2.1 of the GNU Lesser General Public License is
16 * distributed with calc under the filename COPYING-LGPL. You should have
17 * received a copy with calc; if not, write to Free Software Foundation, Inc.
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * @(#) $Revision: 30.1 $
21 * @(#) $Id: have_newstr.c,v 30.1 2007/03/16 11:09:46 chongo Exp $
22 * @(#) $Source: /usr/local/src/bin/calc/RCS/have_newstr.c,v $
24 * Under source code control: 1995/05/02 03:55:08
25 * File existed as early as: 1995
27 * chongo <was here> /\oo/\ http://www.isthe.com/chongo/
28 * Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
32 * usage:
33 * have_newstr
35 * Not all systems support all ANSI C string functions, so this may not
36 * compile on your system.
38 * This prog outputs several defines:
40 * HAVE_NEWSTR
41 * defined ==> use memcpy(), memset(), strchr()
42 * undefined ==> use bcopy() instead of memcpy(),
43 * use bfill() instead of memset(),
44 * use index() instead of strchr()
48 #include <stdio.h>
50 #define MOVELEN 3
52 char src[] = "chongo was here";
53 char dest[MOVELEN+1];
55 int
56 main(void)
58 #if defined(HAVE_NO_NEWSTR)
60 printf("#undef HAVE_NEWSTR /* no */\n");
62 #else /* HAVE_NO_NEWSTR */
64 (void) memcpy(dest, src, MOVELEN);
65 (void) memset(dest, 0, MOVELEN);
66 (void) strchr(src, 'e');
68 printf("#define HAVE_NEWSTR /* yes */\n");
70 #endif /* HAVE_NO_NEWSTR */
72 /* exit(0); */
73 return 0;