-/* $NetBSD: cgram.c,v 1.20 2021/04/25 20:19:19 rillig Exp $ */
+/* $NetBSD: cgram.c,v 1.21 2021/04/25 20:38:03 rillig Exp $ */
/*-
* Copyright (c) 2013, 2021 The NetBSD Foundation, Inc.
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.c,v 1.20 2021/04/25 20:19:19 rillig Exp $");
+__RCSID("$NetBSD: cgram.c,v 1.21 2021/04/25 20:38:03 rillig Exp $");
#endif
#include <assert.h>
#include "pathnames.h"
-////////////////////////////////////////////////////////////
-static char
-ch_toupper(char ch)
+static bool
+ch_isspace(char ch)
{
- return (char)toupper((unsigned char)ch);
+ return isspace((unsigned char)ch) != 0;
}
-static char
-ch_tolower(char ch)
+static bool
+ch_islower(char ch)
{
- return (char)tolower((unsigned char)ch);
+ return ch >= 'a' && ch <= 'z';
}
static bool
-ch_isalpha(char ch)
+ch_isupper(char ch)
{
- return isalpha((unsigned char)ch) != 0;
+ return ch >= 'A' && ch <= 'Z';
}
static bool
-ch_islower(char ch)
+ch_isalpha(char ch)
{
- return islower((unsigned char)ch) != 0;
+ return ch_islower(ch) || ch_isupper(ch);
}
-static bool
-ch_isspace(char ch)
+static char
+ch_toupper(char ch)
{
- return isspace((unsigned char)ch) != 0;
+ return ch_islower(ch) ? (char)(ch - 'a' + 'A') : ch;
}
-static bool
-ch_isupper(char ch)
+static char
+ch_tolower(char ch)
{
- return isupper((unsigned char)ch) != 0;
+ return ch_isupper(ch) ? (char)(ch - 'A' + 'a') : ch;
}
static int