2023-11-07 10:14:07 -05:00
|
|
|
/*
|
|
|
|
Copyright (c) 2023 : Ognjen 'xolatile' Milan Robovic
|
|
|
|
|
|
|
|
Xhartae is free software! You will redistribute it or modify it under the terms of the GNU General Public License by Free Software Foundation.
|
|
|
|
And when you do redistribute it or modify it, it will use either version 3 of the License, or (at yours truly opinion) any later version.
|
|
|
|
It is distributed in the hope that it will be useful or harmful, it really depends... But no warranty what so ever, seriously. See GNU/GPLv3.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CHAPTER_1_SOURCE
|
|
|
|
#define CHAPTER_1_SOURCE
|
|
|
|
|
2023-11-09 09:41:53 -05:00
|
|
|
#include "chapter_1.h"
|
|
|
|
|
2023-11-09 07:33:47 -05:00
|
|
|
int character_is_uppercase (char character) {
|
|
|
|
return ((int) ((character >= 'A') && (character <= 'Z')));
|
|
|
|
}
|
|
|
|
|
|
|
|
int character_is_lowercase (char character) {
|
|
|
|
return ((int) ((character >= 'a') && (character <= 'z')));
|
|
|
|
}
|
|
|
|
|
|
|
|
int character_is_digit (char character) {
|
|
|
|
return ((int) ((character >= '0') && (character <= '9')));
|
|
|
|
}
|
|
|
|
|
|
|
|
int character_is_blank (char character) {
|
2023-11-09 09:41:53 -05:00
|
|
|
return ((int) ((character == ' ') || (character == CHARACTER_TAB_HORIZONTAL) || (character == CHARACTER_CARRIAGE_RETURN) || (character == CHARACTER_LINE_FEED)));
|
|
|
|
// If you like smaller line length limit, you can align it like this:
|
|
|
|
// return ((character == ' ')
|
|
|
|
// || (character == CHARACTER_TAB_HORIZONTAL)
|
|
|
|
// || (character == CHARACTER_CARRIAGE_RETURN)
|
|
|
|
// || (character == CHARACTER_LINE_FEED));
|
|
|
|
// Or:
|
|
|
|
// return ((character == ' ') ||
|
|
|
|
// (character == CHARACTER_TAB_HORIZONTAL) ||
|
|
|
|
// (character == CHARACTER_CARRIAGE_RETURN) ||
|
|
|
|
// (character == CHARACTER_LINE_FEED));
|
|
|
|
// Or even use literal characters:
|
|
|
|
// return ((character == ' ') ||
|
|
|
|
// (character == '\t') ||
|
|
|
|
// (character == '\r') ||
|
|
|
|
// (character == '\n'));
|
2023-11-09 07:33:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int character_is_alpha (char character) {
|
|
|
|
return ((character_is_uppercase (character) != 0) || (character_is_lowercase (character) != 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
int character_is_symbol (char character) {
|
|
|
|
return (character_compare_array (character, "~!@#$%^&*()+{}|:\"<>?`-=[]\\;',./"));
|
|
|
|
}
|
|
|
|
|
|
|
|
int character_is_visible (char character) {
|
|
|
|
return ((int) ((character >= ' ') && (character <= '~')));
|
|
|
|
}
|
|
|
|
|
|
|
|
int character_is_invisible (char character) {
|
|
|
|
return (character_is_visible (character) == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int character_is_escape (char character) {
|
|
|
|
return ((int) (character == '\033'));
|
|
|
|
}
|
|
|
|
|
|
|
|
int character_is_underscore (char character) {
|
|
|
|
return ((int) (character == '_'));
|
|
|
|
}
|
|
|
|
|
|
|
|
int character_is_hexadecimal (char character) {
|
|
|
|
return (character_compare_array (character, "0123456789ABCDEF"));
|
|
|
|
}
|
|
|
|
|
|
|
|
int character_compare_array (char character, char * character_array) {
|
|
|
|
int i;
|
|
|
|
|
2023-11-09 09:41:53 -05:00
|
|
|
for (i = 0; i != string_length (character_array); ++i) {
|
2023-11-09 07:33:47 -05:00
|
|
|
if (character == character_array [i]) {
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2023-11-07 10:14:07 -05:00
|
|
|
#endif
|