This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public bool ParseTargetPath(const char[] key, char[] buffer, int buffer_len) | |
{ | |
/// parse something like: "root.section1.section2.section3.\\..dotsection" | |
int i = strlen(key) - 1; | |
while( i > 0 ) { | |
/// Patch: allow keys to use dot without interfering with dot path. | |
/// check if we hit a dot. | |
if( key[i]=='.' ) { | |
/// if we hit a dot, check if the previous char is an "escape" char. | |
if( key[i-1]=='\\' ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static bool is_alphabetic(const int c) | |
{ | |
return( (c>='a' && c<='z') || (c>='A' && c<='Z') || c=='_' || c=='$' || c=='@' || c < -1 ); | |
} | |
static bool is_possible_id(const int c) | |
{ | |
return( is_alphabetic(c) || (c>='0' && c<='9') ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
recalloc | |
Copyright 2020 Kevin Yonan aka Nergal | |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOF |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Author: Kevin Yonan | |
* License: MIT | |
*/ | |
package deque | |
type ( | |
QNode[T any] struct { | |
Next, Prev int |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"unsafe" | |
) | |
type ( | |
any interface{} | |
ptr unsafe.Pointer | |
goIface struct { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* ordered map for SourcePawn. | |
* Author: Kevin Yonan, (C) 2021. | |
* License: MIT | |
*/ | |
#ifndef ORDMAP_INCLUDED | |
# define ORDMAP_INCLUDED | |
#include <inttypes.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <stdarg.h> | |
/** | |
* returns a string that contains multiple strings. | |
* 'offsets' is used to store the offset of each string. | |
* 'len' is the number of strings and offsets written. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Bresenham's algorithm in simplistic C | |
void drawline(int const x0, int const y0, int const x1, int const y1) { | |
int const dx = x1 - x0; | |
int const dy = y1 - y0; | |
int p = 2 * dy - dx; | |
for( int x = x0, y = y0; x < x1; x++ ) { | |
if( p >= 0 ) { | |
putpixel(x, y, 7); | |
y++; | |
p += 2 * dy - 2 * dx; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef BITSTACK_INCLUDED | |
# define BITSTACK_INCLUDED | |
#ifdef __cplusplus | |
extern "C" { | |
#endif | |
#include <stdio.h> | |
#include <stdbool.h> | |
#include <inttypes.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// colorful strings for printing. | |
const ( | |
COLOR_RED = "\x1B[31m" // used for errors. | |
COLOR_GREEN = "\x1B[32m" | |
COLOR_YELLOW = "\x1B[33m" | |
COLOR_BLUE = "\x1B[34m" | |
COLOR_MAGENTA = "\x1B[35m" // used for warnings. | |
COLOR_CYAN = "\x1B[36m" | |
COLOR_WHITE = "\x1B[37m" | |
COLOR_RESET = "\033[0m" // used to reset the color. |
OlderNewer