view anagram/support/port.h @ 7:57b2cc9b87f7

Use memcpy instead of strncpy when we know the length anyway. Modern gcc seems to think it knows how to detect misuse of strncpy, but it's wrong (in fact: very, very wrong) and the path of least resistance is to not try to fight with it.
author David A. Holland
date Mon, 30 May 2022 23:47:52 -0400
parents 13d2b8934445
children
line wrap: on
line source

/*
 * AnaGram, A System for Syntax Directed Programming
 * Copyright 1993-2002 Parsifal Software. All Rights Reserved.
 * Copyright 2006 David A. Holland. All rights reserved.
 * See the file COPYING for license and usage terms.
 *
 * port.h - portability file
 */

#ifndef PORT_H
#define PORT_H

/*
 * OS issues
 * (note that a bunch of file-related issues are handled in file.h)
 */

#ifdef AG_ON_UNIX
#define stricmp strcasecmp
#define strnicmp strncasecmp
#define _MAX_PATH PATH_MAX

char *strlwr(char *string);
#endif

#ifdef AG_ON_WINDOWS
#define PATH_MAX _MAX_PATH
#endif

/*
 * Compiler issues
 */

#ifdef __GNUC__
#define PRINTFFY(a,b) __attribute__((__format__(__printf__, a, b)))
#else
#define PRINTFFY(a,b)
#endif

#ifdef __IBMCPP__
/* obsolete compiler, no snprintf */
int snprintf(char *, unsigned, const char *, ...) PRINTFFY(3,4);
#endif

/* this is some kind of function pointer weirdness, maybe dll-related */
#ifdef __IBMCPP__
#define OPTLINK _Optlink
#else
#define OPTLINK
#endif

/*
 * Nothing currently supported has a useful way to check for stack
 * overflow.
 */

//#define check_stack if (stackavail() < 0x100) bad_stack();
#define check_stack

/*
 * these are used by dict.cpp, stk.cpp, and tsd.cpp and it's not at all
 * clear why they're here, or where they should go. (XXX)
 */

#define MAX_BYTES 10000000U
#define MAX_INTS  10000000U

#endif /* PORT_H */