gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit 65ae6c0bb8c8cd2feed1e9f5603bae1358c68694 parent a2151f7e6eac64afee6d187509bbd23923e9ed9f Author: bbbbbr <reg+github@roughhousing.com> Date: Tue, 8 Jun 2021 19:22:55 -0700 Merge pull request #196 from bbbbbr/use_stdbool lib: Use stdbool Diffstat:
| M | docs/pages/04_coding_guidelines.md | 4 | ++-- |
| M | gbdk-lib/include/ctype.h | 11 | ++++++----- |
| M | gbdk-lib/libc/isalpha.c | 3 | ++- |
| M | gbdk-lib/libc/isdigit.c | 3 | ++- |
| M | gbdk-lib/libc/islower.c | 3 | ++- |
| M | gbdk-lib/libc/isspace.c | 3 | ++- |
| M | gbdk-lib/libc/isupper.c | 3 | ++- |
7 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/docs/pages/04_coding_guidelines.md b/docs/pages/04_coding_guidelines.md @@ -43,8 +43,8 @@ If you wish to use the original tools, you must add the `const` keyword every ti - Prefer unsigned variables to signed ones: The code generated will be generally more efficient, especially when comparing two values. - - Use explicit types so you always know the size of your variables. `int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t`. - These are standard types defined in `stdint.h` (`#include <stdint.h>`). + - Use explicit types so you always know the size of your variables. `int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t` and `bool`. + These are standard types defined in `stdint.h` (`#include <stdint.h>`) and `stdbool.h` (`#include <stdbool.h>`). - Global and local static variables are generally more efficient than local non-static variables (which go on the stack and are slower and can result in slower code). diff --git a/gbdk-lib/include/ctype.h b/gbdk-lib/include/ctype.h @@ -5,35 +5,36 @@ #define _CTYPE_H #include <types.h> +#include <stdbool.h> /** Returns TRUE if the character __c__ is a letter (a-z, A-Z), otherwise FALSE @param c Character to test */ -BOOLEAN +bool isalpha(char c); /** Returns TRUE if the character __c__ is an uppercase letter (A-Z), otherwise FALSE @param c Character to test */ -BOOLEAN +bool isupper(char c); /** Returns TRUE if the character __c__ is a lowercase letter (a-z), otherwise FALSE @param c Character to test */ -BOOLEAN +bool islower(char c); /** Returns TRUE if the character __c__ is a digit (0-9), otherwise FALSE @param c Character to test */ -BOOLEAN +bool isdigit(char c); /** Returns TRUE if the character __c__ is a space (' '), tab (\\t), or newline (\\n) character, otherwise FALSE @param c Character to test */ -BOOLEAN +bool isspace(char c); /** Returns uppercase version of character __c__ if it is a letter (a-z), otherwise it returns the input value unchanged. diff --git a/gbdk-lib/libc/isalpha.c b/gbdk-lib/libc/isalpha.c @@ -1,6 +1,7 @@ #include <ctype.h> +#include <stdbool.h> -BOOLEAN isalpha(char c) +bool isalpha(char c) { if((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) return 1; diff --git a/gbdk-lib/libc/isdigit.c b/gbdk-lib/libc/isdigit.c @@ -1,6 +1,7 @@ #include <ctype.h> +#include <stdbool.h> -BOOLEAN isdigit(char c) +bool isdigit(char c) { if(c >= '0' && c <= '9') return 1; diff --git a/gbdk-lib/libc/islower.c b/gbdk-lib/libc/islower.c @@ -1,6 +1,7 @@ #include <ctype.h> +#include <stdbool.h> -BOOLEAN islower(char c) +bool islower(char c) { if(c >= 'a' && c <= 'z') return 1; diff --git a/gbdk-lib/libc/isspace.c b/gbdk-lib/libc/isspace.c @@ -1,6 +1,7 @@ #include <ctype.h> +#include <stdbool.h> -BOOLEAN isspace(char c) +bool isspace(char c) { if(c == ' ' || c == '\t' || c == '\n') return 1; diff --git a/gbdk-lib/libc/isupper.c b/gbdk-lib/libc/isupper.c @@ -1,6 +1,7 @@ #include <ctype.h> +#include <stdbool.h> -BOOLEAN isupper(char c) +bool isupper(char c) { if(c >= 'A' && c <= 'Z') return 1;
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.