Changed naming to redo standard...
This commit is contained in:
parent
add6b442eb
commit
5e706af311
61
xyntax.c
61
xyntax.c
@ -1,11 +1,3 @@
|
||||
/*
|
||||
Copyright (c) 2023 : Ognjen 'xolatile' Milan Robovic
|
||||
|
||||
Xyntax 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 XYNTAX_SOURCE
|
||||
#define XYNTAX_SOURCE
|
||||
|
||||
@ -14,19 +6,19 @@ It is distributed in the hope that it will be useful or harmful, it really depen
|
||||
#include <xolatile/xyntax.h>
|
||||
|
||||
static int syntax_count = 0;
|
||||
static int syntax_active = FALSE;
|
||||
static int * syntax_enrange = NULL;
|
||||
static int * syntax_derange = NULL;
|
||||
static char * * syntax_begin = NULL;
|
||||
static char * * syntax_end = NULL;
|
||||
static char * syntax_escape = NULL;
|
||||
static int * syntax_colour = NULL;
|
||||
static int * syntax_effect = NULL;
|
||||
static int syntax_active = false;
|
||||
static int * syntax_enrange = null;
|
||||
static int * syntax_derange = null;
|
||||
static char * * syntax_begin = null;
|
||||
static char * * syntax_end = null;
|
||||
static char * syntax_escape = null;
|
||||
static int * syntax_colour = null;
|
||||
static int * syntax_effect = null;
|
||||
|
||||
static void syntax_delete (void) {
|
||||
int offset;
|
||||
|
||||
if (syntax_active == FALSE) {
|
||||
if (syntax_active == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -43,19 +35,19 @@ static void syntax_delete (void) {
|
||||
syntax_colour = deallocate (syntax_colour);
|
||||
syntax_effect = deallocate (syntax_effect);
|
||||
|
||||
syntax_active = FALSE;
|
||||
syntax_active = false;
|
||||
syntax_count = 0;
|
||||
}
|
||||
|
||||
int syntax_define (int enrange, int derange, char * begin, char * end, char escape, int colour, int effect) {
|
||||
if (syntax_active == FALSE) {
|
||||
syntax_active = TRUE;
|
||||
if (syntax_active == false) {
|
||||
syntax_active = true;
|
||||
|
||||
atexit (syntax_delete);
|
||||
}
|
||||
|
||||
fatal_failure (begin == NULL, "syntax_define: Begin string is null pointer.");
|
||||
fatal_failure (end == NULL, "syntax_define: End string is null pointer.");
|
||||
fatal_failure (begin == null, "syntax_define: Begin string is null pointer.");
|
||||
fatal_failure (end == null, "syntax_define: End string is null pointer.");
|
||||
|
||||
++syntax_count;
|
||||
|
||||
@ -85,25 +77,22 @@ int syntax_define (int enrange, int derange, char * begin, char * end, char esca
|
||||
int syntax_select (char * string, int * length) {
|
||||
int offset, subset, select;
|
||||
|
||||
fatal_failure (syntax_active == FALSE, "syntax_select: Syntax is not active.");
|
||||
fatal_failure (string == NULL, "syntax_select: String is null.");
|
||||
fatal_failure (length == NULL, "syntax_select: Length is null.");
|
||||
fatal_failure (syntax_active == false, "syntax_select: Syntax is not active.");
|
||||
fatal_failure (string == null, "syntax_select: String is null.");
|
||||
fatal_failure (length == null, "syntax_select: Length is null.");
|
||||
|
||||
for (select = offset = 0; select != syntax_count; ++select) {
|
||||
if (syntax_enrange [select] == FALSE) {
|
||||
if (syntax_derange [select] == FALSE) {
|
||||
if (string_compare_limit (string, syntax_begin [select], string_length (syntax_begin [select])) == TRUE) {
|
||||
if (syntax_enrange [select] == false) {
|
||||
if (syntax_derange [select] == false) {
|
||||
if (string_compare_limit (string, syntax_begin [select], string_length (syntax_begin [select])) == true) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if ((string_compare_limit (string, syntax_begin [select], string_length (syntax_begin [select])) == TRUE)
|
||||
&& (character_compare_array (string [offset + string_length (syntax_begin [select])], syntax_end [select]) == TRUE)) {
|
||||
if ((string_compare_limit (string, syntax_begin [select], string_length (syntax_begin [select])) == true)
|
||||
&& (character_compare_array (string [offset + string_length (syntax_begin [select])], syntax_end [select]) == true)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*if (string_compare_limit (string, syntax_begin [select], string_length (syntax_begin [select])) == TRUE) {
|
||||
break;
|
||||
}*/
|
||||
} else {
|
||||
for (subset = 0; subset != string_length (syntax_begin [select]); ++subset) {
|
||||
if (string [offset] == syntax_begin [select] [subset]) {
|
||||
@ -127,14 +116,14 @@ int syntax_select (char * string, int * length) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (syntax_derange [select] == FALSE) {
|
||||
if (string_compare_limit (& string [offset], syntax_end [select], string_length (syntax_end [select])) == TRUE) {
|
||||
if (syntax_derange [select] == false) {
|
||||
if (string_compare_limit (& string [offset], syntax_end [select], string_length (syntax_end [select])) == true) {
|
||||
* length = offset + string_length (syntax_end [select]);
|
||||
return (select);
|
||||
}
|
||||
} else {
|
||||
subset = 0;
|
||||
if (string_compare (syntax_end [select], "") == FALSE) {
|
||||
if (string_compare (syntax_end [select], "") == false) {
|
||||
break;
|
||||
} do {
|
||||
if (string [offset] == syntax_end [select] [subset]) {
|
||||
|
8
xyntax.h
8
xyntax.h
@ -1,11 +1,3 @@
|
||||
/*
|
||||
Copyright (c) 2023 : Ognjen 'xolatile' Milan Robovic
|
||||
|
||||
Xyntax 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 XYNTAX_HEADER
|
||||
#define XYNTAX_HEADER
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user