chad.h gets cucked
This commit is contained in:
parent
18b6128e60
commit
08c9f81f4d
@ -2,32 +2,7 @@
|
|||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#define UNUSED(x) ((void)x)
|
#define UNUSED(x) ((void)x) /* much like this header */
|
||||||
|
|
||||||
// Terminal manipulation
|
|
||||||
#define TERMINAL_RESET "\033[0m"
|
|
||||||
|
|
||||||
#define TERMINAL_COLOR_FG_BLACK "\033[30m"
|
|
||||||
#define TERMINAL_COLOR_FG_RED "\033[31m"
|
|
||||||
#define TERMINAL_COLOR_FG_GREEN "\033[32m"
|
|
||||||
#define TERMINAL_COLOR_FG_YELLOW "\033[33m"
|
|
||||||
#define TERMINAL_COLOR_FG_BLUE "\033[34m"
|
|
||||||
#define TERMINAL_COLOR_FG_MAGENTA "\033[35m"
|
|
||||||
#define TERMINAL_COLOR_FG_CYAN "\033[36m"
|
|
||||||
#define TERMINAL_COLOR_FG_WHITE "\033[37m"
|
|
||||||
|
|
||||||
#define TERMINAL_COLOR_BG_BLACK "\033[40m"
|
|
||||||
#define TERMINAL_COLOR_BG_RED "\033[41m"
|
|
||||||
#define TERMINAL_COLOR_BG_GREEN "\033[42m"
|
|
||||||
#define TERMINAL_COLOR_BG_YELLOW "\033[43m"
|
|
||||||
#define TERMINAL_COLOR_BG_BLUE "\033[44m"
|
|
||||||
#define TERMINAL_COLOR_BG_MAGENTA "\033[45m"
|
|
||||||
#define TERMINAL_COLOR_BG_CYAN "\033[46m"
|
|
||||||
#define TERMINAL_COLOR_BG_WHITE "\033[47m"
|
|
||||||
|
|
||||||
#define TERMINAL_STYLE_BOLD "\033[1m"
|
|
||||||
#define TERMINAL_STYLE_ITALICS "\033[3m"
|
|
||||||
#define TERMINAL_STYLE_REVERSE "\033[7m"
|
|
||||||
|
|
||||||
#define CHAD_H
|
#define CHAD_H
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
#include <uthash.h>
|
#include <uthash.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include "chad.h"
|
#include "chad.h"
|
||||||
#include "regex.h"
|
#include "regex.h"
|
||||||
|
|
||||||
@ -249,7 +250,6 @@ int token_fits(const token_t * const token,
|
|||||||
const int string_offset,
|
const int string_offset,
|
||||||
int * match_offset) {
|
int * match_offset) {
|
||||||
UNUSED(match_offset);
|
UNUSED(match_offset);
|
||||||
|
|
||||||
//return regex_match(pattern, to, string_offset, match_offset);
|
//return regex_match(pattern, to, string_offset, match_offset);
|
||||||
return regex_match(token->syntax, to + string_offset);
|
return regex_match(token->syntax, to + string_offset);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
#ifndef REGEX_H
|
#ifndef REGEX_H
|
||||||
#define REGEX_H
|
#define REGEX_H
|
||||||
|
|
||||||
#include "chad.h"
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "vector.h"
|
#include "vector.h"
|
||||||
|
|
||||||
extern bool is_case_on;
|
extern bool is_case_on;
|
||||||
|
|||||||
@ -1,5 +1,30 @@
|
|||||||
#include "hl.h"
|
#include "hl.h"
|
||||||
|
|
||||||
|
// Terminal manipulation
|
||||||
|
#define TERMINAL_RESET "\033[0m"
|
||||||
|
|
||||||
|
#define TERMINAL_COLOR_FG_BLACK "\033[30m"
|
||||||
|
#define TERMINAL_COLOR_FG_RED "\033[31m"
|
||||||
|
#define TERMINAL_COLOR_FG_GREEN "\033[32m"
|
||||||
|
#define TERMINAL_COLOR_FG_YELLOW "\033[33m"
|
||||||
|
#define TERMINAL_COLOR_FG_BLUE "\033[34m"
|
||||||
|
#define TERMINAL_COLOR_FG_MAGENTA "\033[35m"
|
||||||
|
#define TERMINAL_COLOR_FG_CYAN "\033[36m"
|
||||||
|
#define TERMINAL_COLOR_FG_WHITE "\033[37m"
|
||||||
|
|
||||||
|
#define TERMINAL_COLOR_BG_BLACK "\033[40m"
|
||||||
|
#define TERMINAL_COLOR_BG_RED "\033[41m"
|
||||||
|
#define TERMINAL_COLOR_BG_GREEN "\033[42m"
|
||||||
|
#define TERMINAL_COLOR_BG_YELLOW "\033[43m"
|
||||||
|
#define TERMINAL_COLOR_BG_BLUE "\033[44m"
|
||||||
|
#define TERMINAL_COLOR_BG_MAGENTA "\033[45m"
|
||||||
|
#define TERMINAL_COLOR_BG_CYAN "\033[46m"
|
||||||
|
#define TERMINAL_COLOR_BG_WHITE "\033[47m"
|
||||||
|
|
||||||
|
#define TERMINAL_STYLE_BOLD "\033[1m"
|
||||||
|
#define TERMINAL_STYLE_ITALICS "\033[3m"
|
||||||
|
#define TERMINAL_STYLE_REVERSE "\033[7m"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char * attribute;
|
char * attribute;
|
||||||
char * foreground_color;
|
char * foreground_color;
|
||||||
|
|||||||
@ -1,10 +1,7 @@
|
|||||||
#ifndef VECTOR_H
|
#ifndef VECTOR_H
|
||||||
#define VECTOR_H
|
#define VECTOR_H
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stddef.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
// TODO: Handle error warnings?
|
// TODO: Handle error warnings?
|
||||||
// TODO: Implement more useful functions?
|
// TODO: Implement more useful functions?
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#include "terminal_hl.h"
|
#include "terminal_hl.h"
|
||||||
|
|
||||||
#define ALLOCATION_CHUNK (10UL)
|
#define ALLOCATION_CHUNK (10UL)
|
||||||
@ -14,18 +15,12 @@
|
|||||||
static char * buffer = NULL;
|
static char * buffer = NULL;
|
||||||
static size_t buffer_size = 0;
|
static size_t buffer_size = 0;
|
||||||
|
|
||||||
int main(int argc,
|
int main(void) {
|
||||||
char * * argv) {
|
|
||||||
UNUSED(argc);
|
|
||||||
UNUSED(argv);
|
|
||||||
|
|
||||||
// Buffer init
|
// Buffer init
|
||||||
buffer = realloc(buffer, ALLOCATION_CHUNK);
|
buffer = realloc(buffer, ALLOCATION_CHUNK);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (!((buffer_size + 1) % ALLOCATION_CHUNK)) {
|
if (!((buffer_size + 1) % ALLOCATION_CHUNK)) {
|
||||||
/* Linear incremental reallocation (advanced)!
|
|
||||||
*/
|
|
||||||
size_t chunks = (buffer_size + 1) / ALLOCATION_CHUNK;
|
size_t chunks = (buffer_size + 1) / ALLOCATION_CHUNK;
|
||||||
buffer = realloc(buffer, ++chunks * ALLOCATION_CHUNK);
|
buffer = realloc(buffer, ++chunks * ALLOCATION_CHUNK);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
// ------------------
|
// ------------------
|
||||||
// ### Char tests ###
|
// ### Char tests ###
|
||||||
@ -32,8 +33,6 @@ bool is_magic(const char c) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ----------------------
|
// ----------------------
|
||||||
// ### Internal Types ###
|
// ### Internal Types ###
|
||||||
// ----------------------
|
// ----------------------
|
||||||
|
|||||||
@ -4,6 +4,11 @@
|
|||||||
|
|
||||||
#include "vector.h"
|
#include "vector.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
void vector_init(vector_t * vector,
|
void vector_init(vector_t * vector,
|
||||||
size_t element_size,
|
size_t element_size,
|
||||||
size_t element_count) {
|
size_t element_count) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user