#include <cdt/cdt.h>
#include <ctype.h>
#include <cgraph/strcasecmp.h>
+#include <limits.h>
#ifdef HAVE_EXPAT
#include <expat.h>
typedef int (*attrFn) (void *, char *);
typedef int (*bcmpfn) (const void *, const void *);
-#define MAX_CHAR (((unsigned char)(~0)) >> 1)
-#define MIN_CHAR ((signed char)(~MAX_CHAR))
-#define MAX_UCHAR ((unsigned char)(~0))
-#define MAX_USHORT ((unsigned short)(~0))
-
/* Mechanism for automatically processing attributes */
typedef struct {
char *name; /* attribute name */
{
long u;
- if (doInt(v, "BORDER", 0, MAX_UCHAR, &u))
+ if (doInt(v, "BORDER", 0, UCHAR_MAX, &u))
return 1;
p->border = (unsigned char) u;
p->flags |= BORDER_SET;
{
long u;
- if (doInt(v, "CELLPADDING", 0, MAX_UCHAR, &u))
+ if (doInt(v, "CELLPADDING", 0, UCHAR_MAX, &u))
return 1;
p->pad = (unsigned char) u;
p->flags |= PAD_SET;
{
long u;
- if (doInt(v, "CELLSPACING", MIN_CHAR, MAX_CHAR, &u))
+ if (doInt(v, "CELLSPACING", SCHAR_MIN, SCHAR_MAX, &u))
return 1;
p->space = (signed char) u;
p->flags |= SPACE_SET;
{
long u;
- if (doInt(v, "CELLSBORDER", 0, MAX_CHAR, &u))
+ if (doInt(v, "CELLSBORDER", 0, SCHAR_MAX, &u))
return 1;
p->cb = (unsigned char) u;
return 0;
{
long u;
- if (doInt(v, "HEIGHT", 0, MAX_USHORT, &u))
+ if (doInt(v, "HEIGHT", 0, USHRT_MAX, &u))
return 1;
p->height = (unsigned short) u;
return 0;
{
long u;
- if (doInt(v, "WIDTH", 0, MAX_USHORT, &u))
+ if (doInt(v, "WIDTH", 0, USHRT_MAX, &u))
return 1;
p->width = (unsigned short) u;
return 0;
{
long u;
- if (doInt(v, "ROWSPAN", 0, MAX_USHORT, &u))
+ if (doInt(v, "ROWSPAN", 0, USHRT_MAX, &u))
return 1;
if (u == 0) {
agerr(AGWARN, "ROWSPAN value cannot be 0 - ignored\n");
{
long u;
- if (doInt(v, "COLSPAN", 0, MAX_USHORT, &u))
+ if (doInt(v, "COLSPAN", 0, USHRT_MAX, &u))
return 1;
if (u == 0) {
agerr(AGWARN, "COLSPAN value cannot be 0 - ignored\n");
{
long u;
- if (doInt(v, "POINT-SIZE", 0, MAX_UCHAR, &u))
+ if (doInt(v, "POINT-SIZE", 0, UCHAR_MAX, &u))
return 1;
p->size = (double) u;
return 0;