cleanup: removed all non-42 files
This commit is contained in:
parent
46bd637d1a
commit
468169c783
31 changed files with 0 additions and 2475 deletions
|
|
@ -1,9 +0,0 @@
|
||||||
BasedOnStyle: Microsoft
|
|
||||||
IndentWidth: 4
|
|
||||||
ColumnLimit: 800
|
|
||||||
UseTab: Always
|
|
||||||
SortIncludes: CaseInsensitive
|
|
||||||
IndentPPDirectives: AfterHash
|
|
||||||
PPIndentWidth: 1
|
|
||||||
AllowShortIfStatementsOnASingleLine: false
|
|
||||||
AlignConsecutiveDeclarations: true
|
|
||||||
79
.clangd
79
.clangd
|
|
@ -1,79 +0,0 @@
|
||||||
CompileFlags: # Tweak the parse settings
|
|
||||||
Compiler: clang
|
|
||||||
Add:
|
|
||||||
- "-xc"
|
|
||||||
- "-I/nix/store/fwh4fxd747m0py3ib3s5abamia9nrf90-glibc-2.39-52-dev/include/"
|
|
||||||
- "-I/nix/store/wxxgsgjxbnkkyczgf8lkbfrsqiywm8bi-clang-17.0.6-lib/lib/clang/17/include/"
|
|
||||||
- "-I/nix/store/3mmvgb08qy8n6n37mnprf77fnp4rssi9-glibc-2.38-27-dev/include/"
|
|
||||||
- "-I/nix/store/3jlclvmii9b6qmpqw9w09cp3zdnngvhk-clang-18.1.8/bin/clanglib/clang/17/include/"
|
|
||||||
- "-I/nix/store/8mh0vrd6ll02j61612wz28vvsww1ps1z-glibc-2.39-52/include/"
|
|
||||||
- "-I/nix/store/8vbzvmsm0iy931mdm4hk2vza7gsyc4gs-clang-17.0.6-lib/lib/clang/17/include/"
|
|
||||||
- "-I/usr/include/"
|
|
||||||
- "-I/home/maiboyer/Documents/ring-2/shcat/vendor/"
|
|
||||||
- "-I/home/maiboyer/Documents/ring-2/shcat/stdme/include/"
|
|
||||||
- "-I/home/maiboyer/Documents/ring-2/shcat/allocator/include/"
|
|
||||||
- "-I/home/maiboyer/Documents/ring-2/shcat/stdme/vendor/"
|
|
||||||
- "-I/home/maiboyer/Documents/ring-2/shcat/stdme/output/include/"
|
|
||||||
- "-I/home/maiboyer/Documents/ring-2/shcat/stdme/generic_sources/header/"
|
|
||||||
- "-I/home/maiboyer/Documents/ring-2/shcat/includes/"
|
|
||||||
- "-I/home/maiboyer/Documents/ring-2/shcat/output/include/"
|
|
||||||
- "-I/home/maiboyer/Documents/ring-2/shcat/generic_sources/header/"
|
|
||||||
- "-I/home/maiboyer/Documents/ring-2/shcat/exec/src/arith/"
|
|
||||||
- "-I/home/nixos/shcat/vendor/"
|
|
||||||
- "-I/home/nixos/shcat/stdme/include/"
|
|
||||||
- "-I/home/nixos/shcat/allocator/include/"
|
|
||||||
- "-I/home/nixos/shcat/stdme/vendor/"
|
|
||||||
- "-I/home/nixos/shcat/stdme/output/include/"
|
|
||||||
- "-I/home/nixos/shcat/stdme/generic_sources/header/"
|
|
||||||
- "-I/home/nixos/shcat/includes/"
|
|
||||||
- "-I/home/nixos/shcat/parser/include"
|
|
||||||
- "-I/home/nixos/shcat/output/include/"
|
|
||||||
- "-I/home/nixos/shcat/generic_sources/header/"
|
|
||||||
- "-I/home/nixos/shcat/exec/src/arith/"
|
|
||||||
- "-I/home/maix/school/shcat/vendor/"
|
|
||||||
- "-I/home/maix/school/shcat/stdme/include/"
|
|
||||||
- "-I/home/maix/school/shcat/allocator/include/"
|
|
||||||
- "-I/home/maix/school/shcat/stdme/vendor/"
|
|
||||||
- "-I/home/maix/school/shcat/stdme/output/include/"
|
|
||||||
- "-I/home/maix/school/shcat/stdme/generic_sources/header/"
|
|
||||||
- "-I/home/maix/school/shcat/includes/"
|
|
||||||
- "-I/home/maix/school/shcat/output/include/"
|
|
||||||
- "-I/home/maix/school/shcat/generic_sources/header/"
|
|
||||||
- "-I/home/maix/school/shcat/exec/src/arith/"
|
|
||||||
- "-I/home/maix/shcat/vendor/"
|
|
||||||
- "-I/home/maix/shcat/stdme/include/"
|
|
||||||
- "-I/home/maix/shcat/allocator/include/"
|
|
||||||
- "-I/home/maix/shcat/stdme/vendor/"
|
|
||||||
- "-I/home/maix/shcat/stdme/output/include/"
|
|
||||||
- "-I/home/maix/shcat/stdme/generic_sources/header/"
|
|
||||||
- "-I/home/maix/shcat/includes/"
|
|
||||||
- "-I/home/maix/shcat/output/include/"
|
|
||||||
- "-I/home/maix/shcat/generic_sources/header/"
|
|
||||||
- "-I/home/maix/shcat/exec/src/arith/"
|
|
||||||
- "-I/home/raphael/Documents/shcat/vendor/"
|
|
||||||
- "-I/home/raphael/Documents/shcat/stdme/include/"
|
|
||||||
- "-I/home/raphael/Documents/shcat/allocator/include/"
|
|
||||||
- "-I/home/raphael/Documents/shcat/stdme/vendor/"
|
|
||||||
- "-I/home/raphael/Documents/shcat/stdme/output/include/"
|
|
||||||
- "-I/home/raphael/Documents/shcat/stdme/generic_sources/header/"
|
|
||||||
- "-I/home/raphael/Documents/shcat/includes/"
|
|
||||||
- "-I/home/raphael/Documents/shcat/output/include/"
|
|
||||||
- "-I/home/raphael/Documents/shcat/exec/src/arith/"
|
|
||||||
- "-I/home/rparodi/Documents/shcat/vendor/"
|
|
||||||
- "-I/home/rparodi/Documents/shcat/stdme/include/"
|
|
||||||
- "-I/home/rparodi/Documents/shcat/allocator/include/"
|
|
||||||
- "-I/home/rparodi/Documents/shcat/stdme/vendor/"
|
|
||||||
- "-I/home/rparodi/Documents/shcat/stdme/output/include/"
|
|
||||||
- "-I/home/rparodi/Documents/shcat/stdme/generic_sources/header/"
|
|
||||||
- "-I/home/rparodi/Documents/shcat/includes/"
|
|
||||||
- "-I/home/rparodi/Documents/shcat/output/include/"
|
|
||||||
- "-I/home/rparodi/Documents/shcat/exec/src/arith/"
|
|
||||||
- "-I/Users/raphael/Documents/shcat/vendor/"
|
|
||||||
- "-I/Users/raphael/Documents/shcat/stdme/include/"
|
|
||||||
- "-I/Users/raphael/Documents/shcat/allocator/include/"
|
|
||||||
- "-I/Users/raphael/Documents/shcat/stdme/vendor/"
|
|
||||||
- "-I/Users/raphael/Documents/shcat/stdme/output/include/"
|
|
||||||
- "-I/Users/raphael/Documents/shcat/stdme/generic_sources/header/"
|
|
||||||
- "-I/Users/raphael/Documents/shcat/includes/"
|
|
||||||
- "-I/Users/raphael/Documents/shcat/output/include/"
|
|
||||||
- "-I/Users/raphael/Documents/shcat/generic_sources/header/"
|
|
||||||
6
close.sh
6
close.sh
|
|
@ -1,6 +0,0 @@
|
||||||
for fd in $(/usr/bin/env ls /proc/$$/fd); do
|
|
||||||
if [ "$fd" -gt 10 ]; then
|
|
||||||
#echo "$fd"
|
|
||||||
exec {fd}>&-
|
|
||||||
fi;
|
|
||||||
done
|
|
||||||
313
flake.lock
generated
313
flake.lock
generated
|
|
@ -1,313 +0,0 @@
|
||||||
{
|
|
||||||
"nodes": {
|
|
||||||
"c_formatter_42": {
|
|
||||||
"inputs": {
|
|
||||||
"c_formatter_42_src": "c_formatter_42_src",
|
|
||||||
"flake-utils": "flake-utils",
|
|
||||||
"nixpkgs": "nixpkgs"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1728739769,
|
|
||||||
"narHash": "sha256-Y/rVXn1rpZeE2D1HdcE30mpuzhwE/l6B0v7hu7lvrZw=",
|
|
||||||
"owner": "Maix0",
|
|
||||||
"repo": "c_formatter_42-flake",
|
|
||||||
"rev": "245ef44f1881a4839bd8a5957512dd5e0c342654",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "Maix0",
|
|
||||||
"repo": "c_formatter_42-flake",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"c_formatter_42_src": {
|
|
||||||
"flake": false,
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1727700580,
|
|
||||||
"narHash": "sha256-GFnYVipVE6G1GFUqAzRkBSg7GgPgcLWX48GZtmM4i2Q=",
|
|
||||||
"owner": "dawnbeen",
|
|
||||||
"repo": "c_formatter_42",
|
|
||||||
"rev": "a255930b4be508a94bf6d8523d96556bdb4660ad",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "dawnbeen",
|
|
||||||
"repo": "c_formatter_42",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"flake-utils": {
|
|
||||||
"inputs": {
|
|
||||||
"systems": "systems"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1726560853,
|
|
||||||
"narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"flake-utils_2": {
|
|
||||||
"inputs": {
|
|
||||||
"systems": "systems_2"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1726560853,
|
|
||||||
"narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"flake-utils_3": {
|
|
||||||
"inputs": {
|
|
||||||
"systems": "systems_3"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1705309234,
|
|
||||||
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"flake-utils_4": {
|
|
||||||
"inputs": {
|
|
||||||
"systems": "systems_4"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1705309234,
|
|
||||||
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"generic_c": {
|
|
||||||
"inputs": {
|
|
||||||
"flake-utils": "flake-utils_3",
|
|
||||||
"naersk": "naersk",
|
|
||||||
"nixpkgs": "nixpkgs_3",
|
|
||||||
"rust-overlay": "rust-overlay"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1706829609,
|
|
||||||
"narHash": "sha256-A0imQ9AIJafdL1/+j/1b3G7bm2j+N+VhzTsvKikKjz4=",
|
|
||||||
"owner": "Maix0",
|
|
||||||
"repo": "generic_c",
|
|
||||||
"rev": "a470c2c5a8c8aadc852a7a50d72853f2a3873595",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "Maix0",
|
|
||||||
"repo": "generic_c",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"naersk": {
|
|
||||||
"inputs": {
|
|
||||||
"nixpkgs": "nixpkgs_2"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1698420672,
|
|
||||||
"narHash": "sha256-/TdeHMPRjjdJub7p7+w55vyABrsJlt5QkznPYy55vKA=",
|
|
||||||
"owner": "nix-community",
|
|
||||||
"repo": "naersk",
|
|
||||||
"rev": "aeb58d5e8faead8980a807c840232697982d47b9",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-community",
|
|
||||||
"repo": "naersk",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 0,
|
|
||||||
"narHash": "sha256-9UTxR8eukdg+XZeHgxW5hQA9fIKHsKCdOIUycTryeVw=",
|
|
||||||
"path": "/nix/store/60sn02zhawl3kwn0r515zff3h6hg6ydz-source",
|
|
||||||
"type": "path"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"id": "nixpkgs",
|
|
||||||
"type": "indirect"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs_2": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1706683685,
|
|
||||||
"narHash": "sha256-FtPPshEpxH/ewBOsdKBNhlsL2MLEFv1hEnQ19f/bFsQ=",
|
|
||||||
"owner": "NixOS",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "5ad9903c16126a7d949101687af0aa589b1d7d3d",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"id": "nixpkgs",
|
|
||||||
"type": "indirect"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs_3": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1706683685,
|
|
||||||
"narHash": "sha256-FtPPshEpxH/ewBOsdKBNhlsL2MLEFv1hEnQ19f/bFsQ=",
|
|
||||||
"owner": "NixOS",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "5ad9903c16126a7d949101687af0aa589b1d7d3d",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "NixOS",
|
|
||||||
"ref": "nixpkgs-unstable",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs_4": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1706487304,
|
|
||||||
"narHash": "sha256-LE8lVX28MV2jWJsidW13D2qrHU/RUUONendL2Q/WlJg=",
|
|
||||||
"owner": "NixOS",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "90f456026d284c22b3e3497be980b2e47d0b28ac",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "NixOS",
|
|
||||||
"ref": "nixpkgs-unstable",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs_5": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1728738154,
|
|
||||||
"narHash": "sha256-BKniFdCCST/4gmDPjHgfVOOvCyVk5sp3PX+f4SKSFM0=",
|
|
||||||
"owner": "nixos",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "54cce652cb480258b12f15b2915e7a6c79ac51ae",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nixos",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"root": {
|
|
||||||
"inputs": {
|
|
||||||
"c_formatter_42": "c_formatter_42",
|
|
||||||
"flake-utils": "flake-utils_2",
|
|
||||||
"generic_c": "generic_c",
|
|
||||||
"nixpkgs": "nixpkgs_5"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"rust-overlay": {
|
|
||||||
"inputs": {
|
|
||||||
"flake-utils": "flake-utils_4",
|
|
||||||
"nixpkgs": "nixpkgs_4"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1706753617,
|
|
||||||
"narHash": "sha256-ZKqTFzhFwSWFEpQTJ0uXnfJBs5Y/po9/8TK4bzssdbs=",
|
|
||||||
"owner": "oxalica",
|
|
||||||
"repo": "rust-overlay",
|
|
||||||
"rev": "58be43ae223034217ea1bd58c73210644031b687",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "oxalica",
|
|
||||||
"repo": "rust-overlay",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"systems": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1681028828,
|
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"systems_2": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1681028828,
|
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"systems_3": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1681028828,
|
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"systems_4": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1681028828,
|
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"root": "root",
|
|
||||||
"version": 7
|
|
||||||
}
|
|
||||||
47
flake.nix
47
flake.nix
|
|
@ -1,47 +0,0 @@
|
||||||
{
|
|
||||||
description = "Flake utils demo";
|
|
||||||
|
|
||||||
inputs.nixpkgs.url = "github:nixos/nixpkgs";
|
|
||||||
inputs.flake-utils.url = "github:numtide/flake-utils";
|
|
||||||
inputs.generic_c.url = "github:Maix0/generic_c";
|
|
||||||
inputs.c_formatter_42.url = "github:Maix0/c_formatter_42-flake";
|
|
||||||
|
|
||||||
outputs = {
|
|
||||||
self,
|
|
||||||
nixpkgs,
|
|
||||||
flake-utils,
|
|
||||||
generic_c,
|
|
||||||
c_formatter_42,
|
|
||||||
}:
|
|
||||||
flake-utils.lib.eachDefaultSystem (
|
|
||||||
system: let
|
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
|
||||||
in {
|
|
||||||
devShell = pkgs.mkShell {
|
|
||||||
packages = with pkgs;
|
|
||||||
[
|
|
||||||
(clang-analyzer.override {
|
|
||||||
clang = pkgs.llvmPackages_18.clang;
|
|
||||||
llvmPackages = pkgs.llvmPackages_18;
|
|
||||||
})
|
|
||||||
clang
|
|
||||||
gnumake
|
|
||||||
llvmPackages_18.bintools
|
|
||||||
tokei
|
|
||||||
norminette
|
|
||||||
coreutils
|
|
||||||
generic_c.packages.${system}.default
|
|
||||||
c_formatter_42.packages.${system}.default
|
|
||||||
python312
|
|
||||||
tree
|
|
||||||
]
|
|
||||||
++ (
|
|
||||||
if system == "x86_64-linux" || system == "aarch64-linux"
|
|
||||||
then [valgrind valgrind.dev]
|
|
||||||
else []
|
|
||||||
);
|
|
||||||
#ASAN_OPTIONS = "strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
92
input.toml
92
input.toml
|
|
@ -1,92 +0,0 @@
|
||||||
[definition.vec]
|
|
||||||
headers = ["stdme/generic_sources/header/vec_C__PREFIX__.h__TEMPLATE__"]
|
|
||||||
sources = [
|
|
||||||
"stdme/generic_sources/src/vec/C__PREFIX__.c__TEMPLATE__",
|
|
||||||
"stdme/generic_sources/src/vec/C__PREFIX___sort.c__TEMPLATE__",
|
|
||||||
"stdme/generic_sources/src/vec/C__PREFIX___functions2.c__TEMPLATE__",
|
|
||||||
"stdme/generic_sources/src/vec/C__PREFIX___functions3.c__TEMPLATE__",
|
|
||||||
"stdme/generic_sources/src/vec/C__PREFIX___functions4.c__TEMPLATE__",
|
|
||||||
]
|
|
||||||
replace.C__TYPENAME__ = "type"
|
|
||||||
replace.C__TYPEHEADER__ = "header_include"
|
|
||||||
replace.C__PREFIX__ = "prefix"
|
|
||||||
replace.C__PREFIXUP__ = "prefix"
|
|
||||||
|
|
||||||
|
|
||||||
[definition.hashmap]
|
|
||||||
headers = ["stdme/generic_sources/header/hashmap_C__PREFIX__.h__TEMPLATE__"]
|
|
||||||
sources = [
|
|
||||||
"stdme/generic_sources/src/hashmap/C__PREFIX__.c__TEMPLATE__",
|
|
||||||
"stdme/generic_sources/src/hashmap/C__PREFIX___utils.c__TEMPLATE__",
|
|
||||||
"stdme/generic_sources/src/hashmap/C__PREFIX___iter.c__TEMPLATE__",
|
|
||||||
"stdme/generic_sources/src/hashmap/C__PREFIX___clone.c__TEMPLATE__",
|
|
||||||
"stdme/generic_sources/src/hashmap/C__PREFIX___clear.c__TEMPLATE__",
|
|
||||||
]
|
|
||||||
replace.C__VALTYPE__ = "type"
|
|
||||||
replace.C__KEYTYPE__ = "type"
|
|
||||||
replace.C__TYPEHEADER__ = "header_include"
|
|
||||||
replace.C__PREFIX__ = "prefix"
|
|
||||||
replace.C__PREFIXUP__ = "prefix"
|
|
||||||
|
|
||||||
[definition.str_to_num]
|
|
||||||
headers = []
|
|
||||||
sources = [
|
|
||||||
"stdme/generic_sources/src/convert/str_to_C__PREFIX__.c__TEMPLATE__",
|
|
||||||
"stdme/generic_sources/src/convert/str_to_C__PREFIX___utils.c__TEMPLATE__",
|
|
||||||
]
|
|
||||||
replace.C__TYPE__ = "type"
|
|
||||||
replace.C__UNSIGNED_TYPE__ = "type"
|
|
||||||
replace.C__PREFIX__ = "prefix"
|
|
||||||
replace.C__MAX__ = "value"
|
|
||||||
replace.C__MIN__ = "value"
|
|
||||||
replace.C__ZERO__ = "value"
|
|
||||||
replace.C__SIGNED_TYPE__ = "bool"
|
|
||||||
|
|
||||||
[[create.vec]]
|
|
||||||
sources_output = "src/vec/C__PREFIX__/"
|
|
||||||
headers_output = "include/me/vec/"
|
|
||||||
replace.C__TYPENAME__ = "t_str"
|
|
||||||
replace.C__TYPEHEADER__ = ''
|
|
||||||
replace.C__PREFIX__ = "str"
|
|
||||||
replace.C__PREFIXUP__ = "STR"
|
|
||||||
|
|
||||||
[[create.hashmap]]
|
|
||||||
sources_output = "src/hashmap/C__PREFIX__/"
|
|
||||||
headers_output = "include/me/hashmap/"
|
|
||||||
replace.C__VALTYPE__ = "t_str"
|
|
||||||
replace.C__KEYTYPE__ = "t_str"
|
|
||||||
replace.C__TYPEHEADER__ = ''
|
|
||||||
replace.C__PREFIX__ = "env"
|
|
||||||
replace.C__PREFIXUP__ = "ENV"
|
|
||||||
|
|
||||||
[[create.vec]]
|
|
||||||
sources_output = "src/vec/C__PREFIX__/"
|
|
||||||
headers_output = "include/me/vec/"
|
|
||||||
replace.C__TYPENAME__ = "t_ast_node"
|
|
||||||
replace.C__TYPEHEADER__ = '#include "ast/_forward_def.h"'
|
|
||||||
replace.C__PREFIX__ = "ast"
|
|
||||||
replace.C__PREFIXUP__ = "AST"
|
|
||||||
|
|
||||||
[[create.vec]]
|
|
||||||
sources_output = "src/vec/C__PREFIX__/"
|
|
||||||
headers_output = "include/me/vec/"
|
|
||||||
replace.C__TYPENAME__ = "t_expandable_str"
|
|
||||||
replace.C__TYPEHEADER__ = '#include "exec/_tuple_expanded_str.h"'
|
|
||||||
replace.C__PREFIX__ = "estr"
|
|
||||||
replace.C__PREFIXUP__ = "ESTR"
|
|
||||||
|
|
||||||
[[create.vec]]
|
|
||||||
sources_output = "src/vec/C__PREFIX__/"
|
|
||||||
headers_output = "include/me/vec/"
|
|
||||||
replace.C__TYPENAME__ = "t_pid"
|
|
||||||
replace.C__TYPEHEADER__ = '#include "me/os/os.h"'
|
|
||||||
replace.C__PREFIX__ = "pid"
|
|
||||||
replace.C__PREFIXUP__ = "PID"
|
|
||||||
|
|
||||||
[[create.vec]]
|
|
||||||
sources_output = "src/vec/C__PREFIX__/"
|
|
||||||
headers_output = "include/me/vec/"
|
|
||||||
replace.C__TYPENAME__ = "t_token"
|
|
||||||
replace.C__TYPEHEADER__ = '#include "parser/token.h"'
|
|
||||||
replace.C__PREFIX__ = "token"
|
|
||||||
replace.C__PREFIXUP__ = "TOKEN"
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2023 Maix0
|
|
||||||
|
|
||||||
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 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
# meclib
|
|
||||||
My C "standard library" used for my school projects
|
|
||||||
314
stdme/flake.lock
generated
314
stdme/flake.lock
generated
|
|
@ -1,314 +0,0 @@
|
||||||
{
|
|
||||||
"nodes": {
|
|
||||||
"c_formatter_42": {
|
|
||||||
"inputs": {
|
|
||||||
"c_formatter_42_src": "c_formatter_42_src",
|
|
||||||
"flake-utils": "flake-utils",
|
|
||||||
"nixpkgs": "nixpkgs"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1700259489,
|
|
||||||
"narHash": "sha256-Ye2zwphDUY/eDjyFCPFt0r9RyqMr4ZQprCE4bydNdpw=",
|
|
||||||
"owner": "maix0",
|
|
||||||
"repo": "c_formatter_42-flake",
|
|
||||||
"rev": "3d4f6a40bd1edf9fdb4959051edc172473d9544d",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "maix0",
|
|
||||||
"repo": "c_formatter_42-flake",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"c_formatter_42_src": {
|
|
||||||
"flake": false,
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1696506114,
|
|
||||||
"narHash": "sha256-jUScF2lAHhjTWOWZsIAocE6FN8+HG+kLdpbYsEA1SZs=",
|
|
||||||
"owner": "dawnbeen",
|
|
||||||
"repo": "c_formatter_42",
|
|
||||||
"rev": "ef91ff383966885374695c327fa6015f9cfbc364",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "dawnbeen",
|
|
||||||
"repo": "c_formatter_42",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"flake-utils": {
|
|
||||||
"inputs": {
|
|
||||||
"systems": "systems"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1694529238,
|
|
||||||
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"flake-utils_2": {
|
|
||||||
"inputs": {
|
|
||||||
"systems": "systems_2"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1705309234,
|
|
||||||
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"flake-utils_3": {
|
|
||||||
"inputs": {
|
|
||||||
"systems": "systems_3"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1705309234,
|
|
||||||
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"flake-utils_4": {
|
|
||||||
"inputs": {
|
|
||||||
"systems": "systems_4"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1705309234,
|
|
||||||
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"generic_c": {
|
|
||||||
"inputs": {
|
|
||||||
"flake-utils": "flake-utils_3",
|
|
||||||
"naersk": "naersk",
|
|
||||||
"nixpkgs": "nixpkgs_3",
|
|
||||||
"rust-overlay": "rust-overlay"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1706829609,
|
|
||||||
"narHash": "sha256-A0imQ9AIJafdL1/+j/1b3G7bm2j+N+VhzTsvKikKjz4=",
|
|
||||||
"owner": "maix0",
|
|
||||||
"repo": "generic_c",
|
|
||||||
"rev": "a470c2c5a8c8aadc852a7a50d72853f2a3873595",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "maix0",
|
|
||||||
"repo": "generic_c",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"naersk": {
|
|
||||||
"inputs": {
|
|
||||||
"nixpkgs": "nixpkgs_2"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1698420672,
|
|
||||||
"narHash": "sha256-/TdeHMPRjjdJub7p7+w55vyABrsJlt5QkznPYy55vKA=",
|
|
||||||
"owner": "nix-community",
|
|
||||||
"repo": "naersk",
|
|
||||||
"rev": "aeb58d5e8faead8980a807c840232697982d47b9",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-community",
|
|
||||||
"repo": "naersk",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1700108881,
|
|
||||||
"narHash": "sha256-+Lqybl8kj0+nD/IlAWPPG/RDTa47gff9nbei0u7BntE=",
|
|
||||||
"owner": "NixOS",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "7414e9ee0b3e9903c24d3379f577a417f0aae5f1",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"id": "nixpkgs",
|
|
||||||
"type": "indirect"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs_2": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1706683685,
|
|
||||||
"narHash": "sha256-FtPPshEpxH/ewBOsdKBNhlsL2MLEFv1hEnQ19f/bFsQ=",
|
|
||||||
"owner": "NixOS",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "5ad9903c16126a7d949101687af0aa589b1d7d3d",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"id": "nixpkgs",
|
|
||||||
"type": "indirect"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs_3": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1706683685,
|
|
||||||
"narHash": "sha256-FtPPshEpxH/ewBOsdKBNhlsL2MLEFv1hEnQ19f/bFsQ=",
|
|
||||||
"owner": "NixOS",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "5ad9903c16126a7d949101687af0aa589b1d7d3d",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "NixOS",
|
|
||||||
"ref": "nixpkgs-unstable",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs_4": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1706487304,
|
|
||||||
"narHash": "sha256-LE8lVX28MV2jWJsidW13D2qrHU/RUUONendL2Q/WlJg=",
|
|
||||||
"owner": "NixOS",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "90f456026d284c22b3e3497be980b2e47d0b28ac",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "NixOS",
|
|
||||||
"ref": "nixpkgs-unstable",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs_5": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1708976803,
|
|
||||||
"narHash": "sha256-yvRygcySjjSvj5JTaCdo7lPqJ/2mBV2XQ94Oaq/14qw=",
|
|
||||||
"owner": "NixOS",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "548a86b335d7ecd8b57ec617781f5e652ab0c38e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"id": "nixpkgs",
|
|
||||||
"type": "indirect"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"root": {
|
|
||||||
"inputs": {
|
|
||||||
"c_formatter_42": "c_formatter_42",
|
|
||||||
"flake-utils": "flake-utils_2",
|
|
||||||
"generic_c": "generic_c",
|
|
||||||
"nixpkgs": "nixpkgs_5"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"rust-overlay": {
|
|
||||||
"inputs": {
|
|
||||||
"flake-utils": "flake-utils_4",
|
|
||||||
"nixpkgs": "nixpkgs_4"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1706753617,
|
|
||||||
"narHash": "sha256-ZKqTFzhFwSWFEpQTJ0uXnfJBs5Y/po9/8TK4bzssdbs=",
|
|
||||||
"owner": "oxalica",
|
|
||||||
"repo": "rust-overlay",
|
|
||||||
"rev": "58be43ae223034217ea1bd58c73210644031b687",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "oxalica",
|
|
||||||
"repo": "rust-overlay",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"systems": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1681028828,
|
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"systems_2": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1681028828,
|
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"systems_3": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1681028828,
|
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"systems_4": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1681028828,
|
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"root": "root",
|
|
||||||
"version": 7
|
|
||||||
}
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
{
|
|
||||||
description = "Flake utils demo";
|
|
||||||
|
|
||||||
inputs = {
|
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
|
||||||
generic_c.url = "github:maix0/generic_c";
|
|
||||||
c_formatter_42.url = "github:maix0/c_formatter_42-flake";
|
|
||||||
};
|
|
||||||
outputs = {
|
|
||||||
self,
|
|
||||||
nixpkgs,
|
|
||||||
flake-utils,
|
|
||||||
generic_c,
|
|
||||||
c_formatter_42,
|
|
||||||
}:
|
|
||||||
flake-utils.lib.eachDefaultSystem (
|
|
||||||
system: let
|
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
|
||||||
in {
|
|
||||||
devShell = pkgs.mkShell {
|
|
||||||
packages = [
|
|
||||||
generic_c.packages.${system}.default
|
|
||||||
c_formatter_42.packages.${system}.default
|
|
||||||
pkgs.clang
|
|
||||||
pkgs.clang-tools
|
|
||||||
pkgs.fastmod
|
|
||||||
pkgs.libbsd
|
|
||||||
pkgs.norminette
|
|
||||||
pkgs.valgrind
|
|
||||||
pkgs.tree
|
|
||||||
];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,138 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* hashmap_C__PREFIX__.h :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/12/06 11:00:22 by maiboyer #+# #+# */
|
|
||||||
/* Updated: 2023/12/11 15:24:44 by maiboyer ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#ifndef HASHMAP_C__PREFIXUP___H
|
|
||||||
#define HASHMAP_C__PREFIXUP___H
|
|
||||||
|
|
||||||
#define DEFAULT_BUCKETS 750
|
|
||||||
|
|
||||||
C__TYPEHEADER__
|
|
||||||
|
|
||||||
#include "me/hash/hasher.h"
|
|
||||||
#include "me/types.h"
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
/// @struct A key-value pair for the hashmap
|
|
||||||
typedef struct s_kv_C__PREFIX__
|
|
||||||
{
|
|
||||||
C__KEYTYPE__ key;
|
|
||||||
C__VALTYPE__ val;
|
|
||||||
} t_kv_C__PREFIX__;
|
|
||||||
|
|
||||||
/// @typedef A function that hashes a key
|
|
||||||
typedef void (*t_hash_C__PREFIX___fn)(t_hasher *hasher, C__KEYTYPE__ *key);
|
|
||||||
/// @typedef A function that drops a key-value pair
|
|
||||||
typedef void (*t_free_C__PREFIX___fn)(t_kv_C__PREFIX__ val);
|
|
||||||
/// @typedef A function that compares two keys and returns true if they are equal
|
|
||||||
typedef bool (*t_eq_C__PREFIX___fn)(C__KEYTYPE__ *lhs, C__KEYTYPE__ *rhs);
|
|
||||||
|
|
||||||
|
|
||||||
/// @struct A single entry in the hashmap
|
|
||||||
/// @var hash_id The hash of the key
|
|
||||||
/// @var kv The key-value pair
|
|
||||||
/// @var next The next entry in the bucket
|
|
||||||
typedef struct s_entry_C__PREFIX__
|
|
||||||
{
|
|
||||||
t_usize hash_id;
|
|
||||||
t_kv_C__PREFIX__ kv;
|
|
||||||
struct s_entry_C__PREFIX__ *next;
|
|
||||||
} t_entry_C__PREFIX__;
|
|
||||||
|
|
||||||
/// @struct A hashmap of keys C__KEYTYPE__ and values C__VALTYPE__
|
|
||||||
/// @var buckets The array of buckets
|
|
||||||
/// @var num_buckets The number of buckets
|
|
||||||
/// @var hasher The hasher function
|
|
||||||
/// @var hfunc The hash function
|
|
||||||
/// @var cfunc The comparison function
|
|
||||||
/// @var free The free function
|
|
||||||
typedef struct s_hashmap_C__PREFIX__
|
|
||||||
{
|
|
||||||
t_entry_C__PREFIX__ **buckets;
|
|
||||||
t_usize num_buckets;
|
|
||||||
t_hasher hasher;
|
|
||||||
t_hash_C__PREFIX___fn hfunc;
|
|
||||||
t_eq_C__PREFIX___fn cfunc;
|
|
||||||
t_free_C__PREFIX___fn free;
|
|
||||||
} t_hashmap_C__PREFIX__;
|
|
||||||
|
|
||||||
/// @brief Creates a new hashmap with the given hash, comparison, and free functions
|
|
||||||
/// @param hash The hash function
|
|
||||||
/// @param cmp The comparison function
|
|
||||||
/// @param free The free function
|
|
||||||
/// @return A new hashmap
|
|
||||||
t_hashmap_C__PREFIX__ *hmap_C__PREFIX___new(t_hash_C__PREFIX___fn hash, t_eq_C__PREFIX___fn cmp, t_free_C__PREFIX___fn free);
|
|
||||||
|
|
||||||
/// @brief Creates a new hashmap with the given hash, comparison, and free functions
|
|
||||||
/// @param hash The hash function
|
|
||||||
/// @param cmp The comparison function
|
|
||||||
/// @param free The free function
|
|
||||||
/// @param cap The number of buckets
|
|
||||||
/// @return A new hashmap
|
|
||||||
t_hashmap_C__PREFIX__ *hmap_C__PREFIX___new_with_buckets(t_hash_C__PREFIX___fn hash, t_eq_C__PREFIX___fn cmp, t_free_C__PREFIX___fn free, size_t cap);
|
|
||||||
|
|
||||||
/// @brief Free the hashmap and all of its entries
|
|
||||||
/// @param hmap The hashmap to free
|
|
||||||
void hmap_C__PREFIX___free(t_hashmap_C__PREFIX__ *hmap);
|
|
||||||
|
|
||||||
/// @brief Clear the hashmap, removing all of its entries
|
|
||||||
/// @param hmap The hashmap to clear
|
|
||||||
void hmap_C__PREFIX___clear(t_hashmap_C__PREFIX__ *hmap);
|
|
||||||
|
|
||||||
/// @brief Inserts a key-value pair into the hashmap
|
|
||||||
/// @param hmap The hashmap
|
|
||||||
/// @param key The key
|
|
||||||
/// @param value The value
|
|
||||||
/// @return true if the key already existed before, false otherwise
|
|
||||||
bool hmap_C__PREFIX___insert(t_hashmap_C__PREFIX__ *hmap, C__KEYTYPE__ key, C__VALTYPE__ value);
|
|
||||||
|
|
||||||
/// @brief Gets the value associated with the key
|
|
||||||
/// @param hmap The hashmap
|
|
||||||
/// @param key The key
|
|
||||||
/// @return The value associated with the key, or NULL if the key is not in the hashmap
|
|
||||||
C__VALTYPE__ *hmap_C__PREFIX___get(t_hashmap_C__PREFIX__ *hmap, C__KEYTYPE__ *key);
|
|
||||||
|
|
||||||
/// @brief Removes the key-value pair from the hashmap
|
|
||||||
/// @param hmap The hashmap
|
|
||||||
/// @param key The key
|
|
||||||
void hmap_C__PREFIX___remove(t_hashmap_C__PREFIX__ *hmap, C__KEYTYPE__ *key);
|
|
||||||
|
|
||||||
/// @brief Get an entry from the hashmap
|
|
||||||
/// @param hmap The hashmap
|
|
||||||
/// @param hash The hash of the key
|
|
||||||
/// @param key The key
|
|
||||||
/// @param prev The previous entry in the bucket
|
|
||||||
/// @return The entry, or NULL if the key is not in the hashmap
|
|
||||||
/// @note this is an internal function
|
|
||||||
t_entry_C__PREFIX__ *hmap_C__PREFIX___get_entry(t_hashmap_C__PREFIX__ *hmap, t_usize hash, C__KEYTYPE__ *key, t_entry_C__PREFIX__ **prev);
|
|
||||||
|
|
||||||
/// @brief Iterates over the hashmap and calls the given function for each key-value pair
|
|
||||||
/// @param self The hashmap
|
|
||||||
/// @param func The function to call
|
|
||||||
/// @param ctx The context to pass to the function
|
|
||||||
/// @return An error code
|
|
||||||
/// @note The iteration can be stopped by returning an error code from the function
|
|
||||||
t_error hmap_C__PREFIX___iter(t_hashmap_C__PREFIX__ *self, t_error (*func)(t_usize idx, const C__KEYTYPE__ *key, C__VALTYPE__ *val, void *ctx), void *ctx);
|
|
||||||
|
|
||||||
|
|
||||||
/// @brief Clone an entire hashmap, using the given function to duplicate the items
|
|
||||||
/// @param self The hashmap
|
|
||||||
/// @param func The function to call
|
|
||||||
/// @param ctx The context to pass to the function
|
|
||||||
/// @param out The cloned hashmap
|
|
||||||
/// @return An error code
|
|
||||||
t_error hmap_C__PREFIX___clone(t_hashmap_C__PREFIX__ *self, t_error (*clone)(const t_kv_C__PREFIX__ *val, void *ctx, t_kv_C__PREFIX__ *out), void *ctx, t_hashmap_C__PREFIX__ **out);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,174 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* vec_C__PREFIX__.h :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/12/04 18:46:53 by maiboyer #+# #+# */
|
|
||||||
/* Updated: 2023/12/09 17:53:00 by maiboyer ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#ifndef VEC_C__PREFIXUP___H
|
|
||||||
#define VEC_C__PREFIXUP___H
|
|
||||||
|
|
||||||
C__TYPEHEADER__
|
|
||||||
#include "me/types.h"
|
|
||||||
|
|
||||||
/// @brief A function that takes two C__TYPENAME__ and compare them
|
|
||||||
typedef bool (*t_vec_C__PREFIX___sort_fn)(C__TYPENAME__ *lhs, C__TYPENAME__ *rhs);
|
|
||||||
/// @brief A function that free an C__TYPENAME__
|
|
||||||
typedef void (*t_free_C__PREFIX___item)(C__TYPENAME__ elem);
|
|
||||||
|
|
||||||
/// @brief A dynamic array of C__TYPENAME__
|
|
||||||
typedef struct s_vec_C__PREFIX__ t_vec_C__PREFIX__;
|
|
||||||
|
|
||||||
struct s_vec_C__PREFIX__
|
|
||||||
{
|
|
||||||
t_free_C__PREFIX___item free_func;
|
|
||||||
t_usize len;
|
|
||||||
t_usize capacity;
|
|
||||||
C__TYPENAME__ *buffer;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct s_vec_C__PREFIX___splice_arguments
|
|
||||||
{
|
|
||||||
t_usize index;
|
|
||||||
t_usize old_count;
|
|
||||||
t_usize new_count;
|
|
||||||
const C__TYPENAME__ *elements;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// @brief Create a new vec_C__PREFIX__ with a given capacity
|
|
||||||
/// @param capacity The capacity of the new vec_C__PREFIX__ (in terms of
|
|
||||||
/// elements)
|
|
||||||
/// @param free_function The function that will be used to free the elements of
|
|
||||||
/// the vec_C__PREFIX__
|
|
||||||
t_vec_C__PREFIX__ vec_C__PREFIX___new(t_usize capacity,
|
|
||||||
t_free_C__PREFIX___item free_function);
|
|
||||||
/// @brief Push an element to the last position of the vec_C__PREFIX__
|
|
||||||
/// @param vec The vec_C__PREFIX__ to push the element to
|
|
||||||
/// @param element The element to push
|
|
||||||
t_error vec_C__PREFIX___push(t_vec_C__PREFIX__ *vec, C__TYPENAME__ element);
|
|
||||||
|
|
||||||
/// @brief Push an element to the first position of the vec_C__PREFIX__
|
|
||||||
/// @param vec The vec_C__PREFIX__ to push the element to
|
|
||||||
/// @param element The element to push
|
|
||||||
/// @note This operation is O(n)
|
|
||||||
t_error vec_C__PREFIX___push_front(t_vec_C__PREFIX__ *vec,
|
|
||||||
C__TYPENAME__ element);
|
|
||||||
|
|
||||||
/// @brief Get the last element from the vec_C__PREFIX__, and remove it from the
|
|
||||||
/// vec_C__PREFIX__
|
|
||||||
/// @param vec The vec_C__PREFIX__ to get the element from
|
|
||||||
/// @param[out] out The last element of the vec_C__PREFIX__
|
|
||||||
/// @return true if the operation failed, false otherwise
|
|
||||||
t_error vec_C__PREFIX___pop(t_vec_C__PREFIX__ *vec, C__TYPENAME__ *value);
|
|
||||||
|
|
||||||
/// @brief Get the first element from the vec_C__PREFIX__, and remove it from
|
|
||||||
/// the vec_C__PREFIX__
|
|
||||||
/// @param vec The vec_C__PREFIX__ to get the element from
|
|
||||||
/// @param[out] out The first element of the vec_C__PREFIX__
|
|
||||||
/// @return true if the operation failed, false otherwise
|
|
||||||
/// @note This operation is O(n)
|
|
||||||
t_error vec_C__PREFIX___pop_front(t_vec_C__PREFIX__ *vec, C__TYPENAME__ *value);
|
|
||||||
|
|
||||||
/// @brief Free the vector and all its elements
|
|
||||||
/// @param vec The vec_C__PREFIX__ to free
|
|
||||||
void vec_C__PREFIX___free(t_vec_C__PREFIX__ vec);
|
|
||||||
|
|
||||||
/// @brief Make the vec_C__PREFIX__ at least the given capacity
|
|
||||||
/// @param vec The vec_C__PREFIX__ to reserve
|
|
||||||
/// @param wanted_capacity The minimum capacity to reserve
|
|
||||||
/// @return true if the operation failed, false otherwise
|
|
||||||
t_error vec_C__PREFIX___reserve(t_vec_C__PREFIX__ *vec,
|
|
||||||
t_usize wanted_capacity);
|
|
||||||
|
|
||||||
/// @brief Run the function and returns the index of the first element that
|
|
||||||
/// returns true
|
|
||||||
/// @param vec The vec_C__PREFIX__ to search in
|
|
||||||
/// @param fn The function to run on each element
|
|
||||||
/// @param[out] index The index of the first element that returns true
|
|
||||||
t_error vec_C__PREFIX___find(t_vec_C__PREFIX__ *vec,
|
|
||||||
bool (*fn)(const C__TYPENAME__ *), t_usize *index);
|
|
||||||
|
|
||||||
/// @brief Run the function and returns the index of the first element that
|
|
||||||
/// returns true, but starting at index starting_index
|
|
||||||
/// @param vec The vec_C__PREFIX__ to search in
|
|
||||||
/// @param fn The function to run on each element
|
|
||||||
/// @param starting_index The index to start the search from
|
|
||||||
/// @param[out] index The index of the first element that returns true
|
|
||||||
t_error vec_C__PREFIX___find_starting(t_vec_C__PREFIX__ *vec,
|
|
||||||
bool (*fn)(const C__TYPENAME__ *),
|
|
||||||
t_usize starting_index, t_usize *index);
|
|
||||||
|
|
||||||
/// @brief Run the function on every element of the vec_C__PREFIX__ and returns
|
|
||||||
/// if all elements returned true
|
|
||||||
/// @param vec The vec_C__PREFIX__ to search in
|
|
||||||
/// @param fn The function to run on each element
|
|
||||||
/// @param[out] result The result of the operation
|
|
||||||
/// @return true if the operation failed, false otherwise
|
|
||||||
/// @note If the vec_C__PREFIX__ is empty, result will be true
|
|
||||||
t_error vec_C__PREFIX___all(t_vec_C__PREFIX__ *vec,
|
|
||||||
bool (*fn)(const C__TYPENAME__ *), bool *result);
|
|
||||||
|
|
||||||
/// @brief Run the function on every element of the vec_C__PREFIX__ and returns
|
|
||||||
/// if any element returned true
|
|
||||||
/// @param vec The vec_C__PREFIX__ to search in
|
|
||||||
/// @param fn The function to run on each element
|
|
||||||
/// @param[out] result The result of the operation
|
|
||||||
/// @return true if the operation failed, false otherwise
|
|
||||||
/// @note If the vec_C__PREFIX__ is empty, result will be false
|
|
||||||
t_error vec_C__PREFIX___any(t_vec_C__PREFIX__ *vec,
|
|
||||||
bool (*fn)(const C__TYPENAME__ *), bool *result);
|
|
||||||
|
|
||||||
/// @brief Run the function on every element of the vec_C__PREFIX__
|
|
||||||
/// @param vec The vec_C__PREFIX__ to iterate over
|
|
||||||
/// @param fn The function to run on each element
|
|
||||||
/// @param state The state to pass to the function
|
|
||||||
void vec_C__PREFIX___iter(t_vec_C__PREFIX__ *vec,
|
|
||||||
void (*fn)(t_usize index, C__TYPENAME__ *value,
|
|
||||||
void *state),
|
|
||||||
void *state);
|
|
||||||
|
|
||||||
/// @brief Reverse the order of the elements in the vec_C__PREFIX__
|
|
||||||
/// @param vec The vec_C__PREFIX__ to reverse
|
|
||||||
void vec_C__PREFIX___reverse(t_vec_C__PREFIX__ *vec);
|
|
||||||
|
|
||||||
/// @brief Sort the elements of the vec_C__PREFIX__
|
|
||||||
/// @param vec The vec_C__PREFIX__ to sort
|
|
||||||
/// @param is_sorted The function to use to compare the elements
|
|
||||||
void vec_C__PREFIX___sort(t_vec_C__PREFIX__ *vec,
|
|
||||||
t_vec_C__PREFIX___sort_fn is_sorted);
|
|
||||||
|
|
||||||
/// @brief Get a pointer to the last element of the vec_C__PREFIX__
|
|
||||||
/// @param vec The vec_C__PREFIX__ to get the element from
|
|
||||||
/// @param[out] out A pointer to the last element of the vec_C__PREFIX__
|
|
||||||
/// @return true if the operation failed, false otherwise
|
|
||||||
t_error vec_C__PREFIX___back(t_vec_C__PREFIX__ *vec, C__TYPENAME__ **out);
|
|
||||||
|
|
||||||
/// @brief Get a pointer to the i'th element, or NULL otherwise
|
|
||||||
/// @param vec The vec_C__PREFIX__ to get the element from
|
|
||||||
/// @return A pointer to the element or NULL
|
|
||||||
C__TYPENAME__ *vec_C__PREFIX___get(t_vec_C__PREFIX__ *vec, t_usize i);
|
|
||||||
|
|
||||||
/// @brief Get a pointer to the last element, or NULL otherwise
|
|
||||||
/// @param vec The vec_C__PREFIX__ to get the element from
|
|
||||||
/// @return A pointer to the last element or NULL
|
|
||||||
C__TYPENAME__ *vec_C__PREFIX___last(t_vec_C__PREFIX__ *vec);
|
|
||||||
|
|
||||||
/// @brief Perform a simple bytewise copy into the other vector
|
|
||||||
/// @param vec The vec_C__PREFIX__ to be copied from
|
|
||||||
/// @param dest The vec_C__PREFIX__ to be copied to
|
|
||||||
void vec_C__PREFIX___copy_into(t_vec_C__PREFIX__ *vec, t_vec_C__PREFIX__ *dest);
|
|
||||||
|
|
||||||
/// read code lol
|
|
||||||
void vec_C__PREFIX___splice(t_vec_C__PREFIX__ *self,
|
|
||||||
struct s_vec_C__PREFIX___splice_arguments args);
|
|
||||||
|
|
||||||
struct s_vec_C__PREFIX___splice_arguments vec_C__PREFIX___splice_args(
|
|
||||||
t_usize index, t_usize old_count, t_usize new_count,
|
|
||||||
const C__TYPENAME__ *elements);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* str_to_i64.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2024/02/01 21:15:19 by maiboyer #+# #+# */
|
|
||||||
/* Updated: 2024/02/01 23:18:52 by maiboyer ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "me/char/char.h"
|
|
||||||
#include "me/convert/numbers_to_str.h"
|
|
||||||
#include "me/str/str.h"
|
|
||||||
#include "me/types.h"
|
|
||||||
|
|
||||||
t_error _format_u64(t_num_str args, t_str *out);
|
|
||||||
|
|
||||||
t_error C__PREFIX___to_str_base_prefix(C__TYPE__ val, t_str base, t_str prefix,
|
|
||||||
t_str *out)
|
|
||||||
{
|
|
||||||
union u_nums value;
|
|
||||||
bool is_nonnegative;
|
|
||||||
|
|
||||||
if (out == NULL || base == NULL || prefix == NULL)
|
|
||||||
return (ERROR);
|
|
||||||
value.C__FIELD__ = val;
|
|
||||||
is_nonnegative = val & C__NEG__BITMASK__;
|
|
||||||
if (is_nonnegative)
|
|
||||||
value.C__UFIELD__ = ~value.C__UFIELD__ + 1;
|
|
||||||
return (_format_u64((t_num_str){.value = value.u64, \
|
|
||||||
.is_nonnegative = is_nonnegative, \
|
|
||||||
.base = base, \
|
|
||||||
.prefix = prefix}, \
|
|
||||||
out));
|
|
||||||
}
|
|
||||||
|
|
||||||
t_error C__PREFIX___to_str_base(C__TYPE__ val, t_str base, t_str *out)
|
|
||||||
{
|
|
||||||
if (out == NULL || base == NULL)
|
|
||||||
return (ERROR);
|
|
||||||
return (C__PREFIX___to_str_base_prefix(val, base, "", out));
|
|
||||||
}
|
|
||||||
|
|
||||||
t_error C__PREFIX___to_str(C__TYPE__ val, t_str *out)
|
|
||||||
{
|
|
||||||
if (out == NULL)
|
|
||||||
return (ERROR);
|
|
||||||
return (C__PREFIX___to_str_base_prefix(val, "0123456789", "", out));
|
|
||||||
}
|
|
||||||
|
|
@ -1,130 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* str_to_i64.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2024/02/01 21:15:19 by maiboyer #+# #+# */
|
|
||||||
/* Updated: 2024/02/01 23:18:52 by maiboyer ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "me/char/char.h"
|
|
||||||
#include "me/convert/str_to_numbers.h"
|
|
||||||
#include "me/str/str.h"
|
|
||||||
#include "me/types.h"
|
|
||||||
|
|
||||||
#define OP_ADD 0b0001
|
|
||||||
#define OP_SUB 0b0010
|
|
||||||
#define OP_MUL 0b0100
|
|
||||||
#define OP_CHK 0b1000
|
|
||||||
|
|
||||||
t_error checked_add_C__PREFIX__(C__TYPE__ lhs, C__TYPE__ rhs, C__TYPE__ *out);
|
|
||||||
t_error checked_sub_C__PREFIX__(C__TYPE__ lhs, C__TYPE__ rhs, C__TYPE__ *out);
|
|
||||||
t_error checked_mul_C__PREFIX__(C__TYPE__ lhs, C__TYPE__ rhs, C__TYPE__ *out);
|
|
||||||
|
|
||||||
static inline bool can_not_overflow(t_u32 radix, bool is_signed_type,
|
|
||||||
t_usize digits_len)
|
|
||||||
{
|
|
||||||
return (radix <= 16 &&
|
|
||||||
digits_len <= sizeof(C__TYPE__) * 2 - (t_usize)is_signed_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline t_error to_digit(t_u8 ascii, t_u32 radix, t_u32 *out)
|
|
||||||
{
|
|
||||||
t_u32 digit;
|
|
||||||
|
|
||||||
if (radix < 2 || radix > 36)
|
|
||||||
return (ERROR);
|
|
||||||
digit = ascii - '0';
|
|
||||||
if (radix > 10 && digit >= 10)
|
|
||||||
{
|
|
||||||
if (!me_isalpha(ascii))
|
|
||||||
return (ERROR);
|
|
||||||
digit = ((ascii | 0b100000) - 'a') + 10;
|
|
||||||
}
|
|
||||||
if (digit >= radix)
|
|
||||||
return (ERROR);
|
|
||||||
*out = digit;
|
|
||||||
return (NO_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline t_error do_operation(C__TYPE__ digit, t_u8 op, C__TYPE__ *result)
|
|
||||||
{
|
|
||||||
C__TYPE__ rhs;
|
|
||||||
C__TYPE__ res;
|
|
||||||
|
|
||||||
rhs = *result;
|
|
||||||
res = *result;
|
|
||||||
if (op & OP_CHK)
|
|
||||||
{
|
|
||||||
if (op & OP_MUL && checked_mul_C__PREFIX__(rhs, digit, &res))
|
|
||||||
return (ERROR);
|
|
||||||
else if (op & OP_ADD && checked_add_C__PREFIX__(rhs, digit, &res))
|
|
||||||
return (ERROR);
|
|
||||||
else if (op & OP_SUB && checked_sub_C__PREFIX__(rhs, digit, &res))
|
|
||||||
return (ERROR);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (op & OP_MUL)
|
|
||||||
res = rhs * digit;
|
|
||||||
else if (op & OP_ADD)
|
|
||||||
res = rhs + digit;
|
|
||||||
else if (op & OP_SUB)
|
|
||||||
res = rhs - digit;
|
|
||||||
}
|
|
||||||
*result = res;
|
|
||||||
return (NO_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline t_error loop_inner(t_const_str s, t_u32 radix, t_u8 op,
|
|
||||||
C__TYPE__ *out)
|
|
||||||
{
|
|
||||||
t_u32 digit;
|
|
||||||
C__TYPE__ result;
|
|
||||||
|
|
||||||
result = C__ZERO__;
|
|
||||||
|
|
||||||
while (*s)
|
|
||||||
{
|
|
||||||
if (do_operation(radix, (op & OP_CHK) | OP_MUL, &result))
|
|
||||||
return (ERROR);
|
|
||||||
if (to_digit(*s, radix, &digit))
|
|
||||||
return (ERROR);
|
|
||||||
if (do_operation(digit, op, &result))
|
|
||||||
return (ERROR);
|
|
||||||
s++;
|
|
||||||
}
|
|
||||||
if (out)
|
|
||||||
*out = result;
|
|
||||||
return (NO_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
t_error str_to_C__PREFIX__(t_const_str s, t_u32 radix, C__TYPE__ *out)
|
|
||||||
{
|
|
||||||
t_usize digits_len;
|
|
||||||
bool is_positive;
|
|
||||||
t_u8 op;
|
|
||||||
|
|
||||||
if (radix < 2 || radix > 36)
|
|
||||||
return (ERROR);
|
|
||||||
digits_len = str_len(s);
|
|
||||||
is_positive = true;
|
|
||||||
if (digits_len == 0)
|
|
||||||
return (ERROR);
|
|
||||||
if ((s[0] == '-' || s[0] == '+') && s[1] == '\0')
|
|
||||||
return (ERROR);
|
|
||||||
else if (s[0] == '+')
|
|
||||||
is_positive = (s++, digits_len--, true);
|
|
||||||
else if (s[0] == '-' && C__SIGNED_TYPE__)
|
|
||||||
is_positive = (s++, digits_len--, false);
|
|
||||||
if (is_positive)
|
|
||||||
op = OP_ADD;
|
|
||||||
else
|
|
||||||
op = OP_SUB;
|
|
||||||
if (!can_not_overflow(radix, C__SIGNED_TYPE__, digits_len))
|
|
||||||
op |= OP_CHK;
|
|
||||||
return (loop_inner(s, radix, op, out));
|
|
||||||
}
|
|
||||||
|
|
@ -1,45 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* str_to_i64.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2024/02/01 21:15:19 by maiboyer #+# #+# */
|
|
||||||
/* Updated: 2024/02/01 23:18:52 by maiboyer ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
|
|
||||||
#include "me/char/char.h"
|
|
||||||
#include "me/convert/str_to_numbers.h"
|
|
||||||
#include "me/str/str.h"
|
|
||||||
#include "me/types.h"
|
|
||||||
#include "me/printf/printf.h"
|
|
||||||
|
|
||||||
t_error checked_add_C__PREFIX__(C__TYPE__ lhs, C__TYPE__ rhs, C__TYPE__ *out)
|
|
||||||
{
|
|
||||||
if (rhs > 0 && (lhs > C__MAX__ - rhs))
|
|
||||||
return (ERROR);
|
|
||||||
*out = (C__TYPE__)(lhs + rhs);
|
|
||||||
return (NO_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
t_error checked_sub_C__PREFIX__(C__TYPE__ lhs, C__TYPE__ rhs, C__TYPE__ *out)
|
|
||||||
{
|
|
||||||
if ((((rhs & (1 << (sizeof(C__TYPE__) - 1)) || rhs == 0) || !C__SIGNED_TYPE__) && (lhs < C__MIN__ + rhs)))
|
|
||||||
return (ERROR);
|
|
||||||
*out = (C__TYPE__)(lhs - rhs);
|
|
||||||
return (NO_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
t_error checked_mul_C__PREFIX__(C__TYPE__ lhs, C__TYPE__ rhs, C__TYPE__ *out)
|
|
||||||
{
|
|
||||||
C__TYPE__ mul;
|
|
||||||
|
|
||||||
mul = lhs * rhs;
|
|
||||||
if (lhs != 0 && mul / lhs != rhs)
|
|
||||||
return (ERROR);
|
|
||||||
*out = mul;
|
|
||||||
return (NO_ERROR);
|
|
||||||
}
|
|
||||||
|
|
@ -1,125 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* hashmap_C__PREFIX__.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/12/06 10:58:20 by maiboyer #+# #+# */
|
|
||||||
/* Updated: 2023/12/11 15:32:51 by maiboyer ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "me/hash/hasher.h"
|
|
||||||
#include "me/hash/sip.h"
|
|
||||||
#include "me/hashmap/hashmap_C__PREFIX__.h"
|
|
||||||
#include "me/mem/mem.h"
|
|
||||||
#include "me/types.h"
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
t_hashmap_C__PREFIX__ *hmap_C__PREFIX___new(t_hash_C__PREFIX___fn hfunc,
|
|
||||||
t_eq_C__PREFIX___fn cfunc,
|
|
||||||
t_free_C__PREFIX___fn free)
|
|
||||||
{
|
|
||||||
return (
|
|
||||||
hmap_C__PREFIX___new_with_buckets(hfunc, cfunc, free, DEFAULT_BUCKETS));
|
|
||||||
}
|
|
||||||
|
|
||||||
t_hashmap_C__PREFIX__ *hmap_C__PREFIX___new_with_buckets(
|
|
||||||
t_hash_C__PREFIX___fn hfunc, t_eq_C__PREFIX___fn cfunc,
|
|
||||||
t_free_C__PREFIX___fn free, t_usize buckets)
|
|
||||||
{
|
|
||||||
t_hashmap_C__PREFIX__ *hmap;
|
|
||||||
|
|
||||||
hmap = mem_alloc(sizeof(*hmap));
|
|
||||||
if (hmap == NULL)
|
|
||||||
return (NULL);
|
|
||||||
hmap->buckets = mem_alloc_array(buckets, sizeof(t_entry_C__PREFIX__ *));
|
|
||||||
hmap->num_buckets = buckets;
|
|
||||||
hmap->hasher = hasher_sip13_new();
|
|
||||||
hmap->hfunc = hfunc;
|
|
||||||
hmap->cfunc = cfunc;
|
|
||||||
hmap->free = free;
|
|
||||||
if (hmap->buckets == NULL)
|
|
||||||
return ((void)mem_free(hmap), NULL);
|
|
||||||
return (hmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
void hmap_C__PREFIX___free(t_hashmap_C__PREFIX__ *hmap)
|
|
||||||
{
|
|
||||||
t_usize index;
|
|
||||||
t_entry_C__PREFIX__ *entry;
|
|
||||||
t_entry_C__PREFIX__ *tmp;
|
|
||||||
|
|
||||||
index = 0;
|
|
||||||
while (index < hmap->num_buckets)
|
|
||||||
{
|
|
||||||
entry = hmap->buckets[index];
|
|
||||||
while (entry != NULL)
|
|
||||||
{
|
|
||||||
hmap->free(entry->kv);
|
|
||||||
tmp = entry->next;
|
|
||||||
mem_free(entry);
|
|
||||||
entry = tmp;
|
|
||||||
}
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
hasher_finish(&hmap->hasher);
|
|
||||||
mem_free(hmap->buckets);
|
|
||||||
mem_free(hmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
t_entry_C__PREFIX__ *hmap_C__PREFIX___get_entry(t_hashmap_C__PREFIX__ *hmap,
|
|
||||||
t_usize hashed_key,
|
|
||||||
C__KEYTYPE__ *key,
|
|
||||||
t_entry_C__PREFIX__ **prev)
|
|
||||||
{
|
|
||||||
t_entry_C__PREFIX__ *entry;
|
|
||||||
|
|
||||||
entry = hmap->buckets[hashed_key % hmap->num_buckets];
|
|
||||||
while (entry != NULL)
|
|
||||||
{
|
|
||||||
if (!hmap->cfunc(&entry->kv.key, key))
|
|
||||||
{
|
|
||||||
*prev = entry;
|
|
||||||
entry = entry->next;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return (entry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hmap_C__PREFIX___insert(t_hashmap_C__PREFIX__ *hmap, C__KEYTYPE__ key,
|
|
||||||
C__VALTYPE__ value)
|
|
||||||
{
|
|
||||||
t_usize hashed_key;
|
|
||||||
t_entry_C__PREFIX__ *prev;
|
|
||||||
t_entry_C__PREFIX__ *entry;
|
|
||||||
|
|
||||||
hmap->hfunc(&hmap->hasher, &key);
|
|
||||||
hashed_key = hasher_reset_and_finish(&hmap->hasher);
|
|
||||||
prev = NULL;
|
|
||||||
entry = hmap_C__PREFIX___get_entry(hmap, hashed_key, &key, &prev);
|
|
||||||
if (entry == NULL)
|
|
||||||
{
|
|
||||||
entry = mem_alloc(sizeof(t_entry_C__PREFIX__));
|
|
||||||
entry->hash_id = hashed_key;
|
|
||||||
entry->kv = (t_kv_C__PREFIX__){.key = key, .val = value};
|
|
||||||
entry->next = NULL;
|
|
||||||
if (prev == NULL)
|
|
||||||
hmap->buckets[hashed_key % hmap->num_buckets] = entry;
|
|
||||||
else
|
|
||||||
prev->next = entry;
|
|
||||||
return (false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hmap->free(entry->kv);
|
|
||||||
entry->kv.key = key;
|
|
||||||
entry->kv.val = value;
|
|
||||||
return (true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* hashmap_C__PREFIX__.h :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/12/06 11:00:22 by maiboyer #+# #+# */
|
|
||||||
/* Updated: 2023/12/11 15:24:44 by maiboyer ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "me/types.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "me/hashmap/hashmap_C__PREFIX__.h"
|
|
||||||
#include "me/mem/mem.h"
|
|
||||||
|
|
||||||
|
|
||||||
void hmap_C__PREFIX___clear(t_hashmap_C__PREFIX__ *self)
|
|
||||||
{
|
|
||||||
t_usize bucket_id;
|
|
||||||
t_entry_C__PREFIX__ *cur;
|
|
||||||
t_entry_C__PREFIX__ *next;
|
|
||||||
|
|
||||||
bucket_id = 0;
|
|
||||||
while (bucket_id < self->num_buckets)
|
|
||||||
{
|
|
||||||
cur = self->buckets[bucket_id];
|
|
||||||
while (cur != NULL)
|
|
||||||
{
|
|
||||||
next = cur->next;
|
|
||||||
self->free(cur->kv);
|
|
||||||
mem_free(cur);
|
|
||||||
cur = next;
|
|
||||||
}
|
|
||||||
bucket_id++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* hashmap_C__PREFIX__.h :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/12/06 11:00:22 by maiboyer #+# #+# */
|
|
||||||
/* Updated: 2023/12/11 15:24:44 by maiboyer ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "me/types.h"
|
|
||||||
|
|
||||||
#include "me/hashmap/hashmap_C__PREFIX__.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
t_error hmap_C__PREFIX___clone(t_hashmap_C__PREFIX__ *self,
|
|
||||||
t_error (*clone)(const t_kv_C__PREFIX__ *val, void *ctx, t_kv_C__PREFIX__ *out),
|
|
||||||
void *ctx,
|
|
||||||
t_hashmap_C__PREFIX__ **out)
|
|
||||||
{
|
|
||||||
t_usize bucket_id;
|
|
||||||
t_entry_C__PREFIX__ *cur;
|
|
||||||
t_kv_C__PREFIX__ kv;
|
|
||||||
t_hashmap_C__PREFIX__ *ret;
|
|
||||||
|
|
||||||
bucket_id = 0;
|
|
||||||
ret = hmap_C__PREFIX___new_with_buckets(self->hfunc, self->cfunc, self->free, self->num_buckets);
|
|
||||||
if (ret == NULL)
|
|
||||||
return (ERROR);
|
|
||||||
while (bucket_id < self->num_buckets)
|
|
||||||
{
|
|
||||||
cur = self->buckets[bucket_id];
|
|
||||||
while (cur != NULL)
|
|
||||||
{
|
|
||||||
if (clone(&cur->kv, ctx, &kv))
|
|
||||||
return (hmap_C__PREFIX___free(ret),ERROR);
|
|
||||||
hmap_C__PREFIX___insert(ret, kv.key, kv.val);
|
|
||||||
cur = cur->next;
|
|
||||||
}
|
|
||||||
bucket_id++;
|
|
||||||
}
|
|
||||||
*out = ret;
|
|
||||||
return (NO_ERROR);
|
|
||||||
}
|
|
||||||
|
|
@ -1,39 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* hashmap_C__PREFIX__.h :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/12/06 11:00:22 by maiboyer #+# #+# */
|
|
||||||
/* Updated: 2023/12/11 15:24:44 by maiboyer ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "me/hashmap/hashmap_C__PREFIX__.h"
|
|
||||||
|
|
||||||
t_error hmap_C__PREFIX___iter(t_hashmap_C__PREFIX__ *self,
|
|
||||||
t_error (*func)(t_usize idx,
|
|
||||||
const C__KEYTYPE__ *key,
|
|
||||||
C__VALTYPE__ *val, void *ctx),
|
|
||||||
void *ctx)
|
|
||||||
{
|
|
||||||
t_usize bucket_id;
|
|
||||||
t_usize all_id;
|
|
||||||
t_entry_C__PREFIX__ *cur;
|
|
||||||
|
|
||||||
bucket_id = 0;
|
|
||||||
all_id = 0;
|
|
||||||
while (bucket_id < self->num_buckets)
|
|
||||||
{
|
|
||||||
cur = self->buckets[bucket_id];
|
|
||||||
while (cur != NULL)
|
|
||||||
{
|
|
||||||
if (func(all_id++, &cur->kv.key, &cur->kv.val, ctx))
|
|
||||||
return (ERROR);
|
|
||||||
cur = cur->next;
|
|
||||||
}
|
|
||||||
bucket_id++;
|
|
||||||
}
|
|
||||||
return (NO_ERROR);
|
|
||||||
}
|
|
||||||
|
|
@ -1,53 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* hashmap_C__PREFIX___utils.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/12/06 10:58:20 by maiboyer #+# #+# */
|
|
||||||
/* Updated: 2023/12/11 15:35:37 by maiboyer ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "me/hash/sip.h"
|
|
||||||
#include "me/hashmap/hashmap_C__PREFIX__.h"
|
|
||||||
#include "me/mem/mem.h"
|
|
||||||
#include "me/types.h"
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
C__VALTYPE__ *hmap_C__PREFIX___get(t_hashmap_C__PREFIX__ *hmap,
|
|
||||||
C__KEYTYPE__ *key)
|
|
||||||
{
|
|
||||||
t_usize hashed_key;
|
|
||||||
t_entry_C__PREFIX__ *entry;
|
|
||||||
t_entry_C__PREFIX__ *prev;
|
|
||||||
|
|
||||||
hmap->hfunc(&hmap->hasher, key);
|
|
||||||
hashed_key = hasher_reset_and_finish(&hmap->hasher);
|
|
||||||
entry = hmap_C__PREFIX___get_entry(hmap, hashed_key, key, &prev);
|
|
||||||
if (entry == NULL)
|
|
||||||
return (NULL);
|
|
||||||
return (&entry->kv.val);
|
|
||||||
}
|
|
||||||
|
|
||||||
void hmap_C__PREFIX___remove(t_hashmap_C__PREFIX__ *hmap, C__KEYTYPE__ *key)
|
|
||||||
{
|
|
||||||
t_usize hashed_key;
|
|
||||||
t_entry_C__PREFIX__ *prev;
|
|
||||||
t_entry_C__PREFIX__ *entry;
|
|
||||||
|
|
||||||
hmap->hfunc(&hmap->hasher, key);
|
|
||||||
hashed_key = hasher_reset_and_finish(&hmap->hasher);
|
|
||||||
prev = NULL;
|
|
||||||
entry = hmap_C__PREFIX___get_entry(hmap, hashed_key, key, &prev);
|
|
||||||
if (entry == NULL)
|
|
||||||
return;
|
|
||||||
if (prev == NULL)
|
|
||||||
hmap->buckets[hashed_key % hmap->num_buckets] = entry->next;
|
|
||||||
else
|
|
||||||
prev->next = entry->next;
|
|
||||||
hmap->free(entry->kv);
|
|
||||||
mem_free(entry);
|
|
||||||
hmap->buckets[hashed_key % hmap->num_buckets] = NULL;
|
|
||||||
}
|
|
||||||
|
|
@ -1,93 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* vec_C__PREFIX__.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/12/05 18:46:28 by maiboyer #+# #+# */
|
|
||||||
/* Updated: 2023/12/09 17:54:11 by maiboyer ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "me/mem/mem.h"
|
|
||||||
#include "me/types.h"
|
|
||||||
#include "me/vec/vec_C__PREFIX__.h"
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
t_vec_C__PREFIX__ vec_C__PREFIX___new(t_usize capacity,
|
|
||||||
t_free_C__PREFIX___item free_function)
|
|
||||||
{
|
|
||||||
t_vec_C__PREFIX__ out;
|
|
||||||
|
|
||||||
out = (t_vec_C__PREFIX__){0};
|
|
||||||
out.free_func = free_function;
|
|
||||||
out.buffer = mem_alloc_array(capacity, sizeof(C__TYPENAME__));
|
|
||||||
if (out.buffer)
|
|
||||||
out.capacity = capacity;
|
|
||||||
return (out);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Return true in case of an error
|
|
||||||
t_error vec_C__PREFIX___push(t_vec_C__PREFIX__ *vec, C__TYPENAME__ element)
|
|
||||||
{
|
|
||||||
if (vec == NULL)
|
|
||||||
return (ERROR);
|
|
||||||
vec_C__PREFIX___reserve(vec, vec->len + 1);
|
|
||||||
vec->buffer[vec->len] = element;
|
|
||||||
vec->len += 1;
|
|
||||||
return (NO_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Return true in case of an error
|
|
||||||
t_error vec_C__PREFIX___reserve(t_vec_C__PREFIX__ *vec, t_usize wanted_capacity)
|
|
||||||
{
|
|
||||||
size_t new_capacity;
|
|
||||||
|
|
||||||
if (vec == NULL)
|
|
||||||
return (ERROR);
|
|
||||||
if (wanted_capacity > vec->capacity)
|
|
||||||
{
|
|
||||||
new_capacity = (vec->capacity * 3) / 2 + 1;
|
|
||||||
while (wanted_capacity > new_capacity)
|
|
||||||
new_capacity = (new_capacity * 3) / 2 + 1;
|
|
||||||
vec->buffer =
|
|
||||||
mem_realloc_array(vec->buffer, new_capacity, sizeof(C__TYPENAME__));
|
|
||||||
vec->capacity = new_capacity;
|
|
||||||
}
|
|
||||||
return (NO_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Return true if the vector is empty
|
|
||||||
/// This function is safe to call with value being NULL
|
|
||||||
t_error vec_C__PREFIX___pop(t_vec_C__PREFIX__ *vec, C__TYPENAME__ *value)
|
|
||||||
{
|
|
||||||
C__TYPENAME__ temp_value;
|
|
||||||
C__TYPENAME__ *ptr;
|
|
||||||
|
|
||||||
if (vec == NULL || vec->len == 0)
|
|
||||||
return (ERROR);
|
|
||||||
ptr = value;
|
|
||||||
if (value == NULL)
|
|
||||||
ptr = &temp_value;
|
|
||||||
vec->len--;
|
|
||||||
*ptr = vec->buffer[vec->len];
|
|
||||||
mem_set_zero(&vec->buffer[vec->len], sizeof(C__TYPENAME__));
|
|
||||||
return (NO_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// This function is safe to call with `free_elem` being NULL
|
|
||||||
void vec_C__PREFIX___free(t_vec_C__PREFIX__ vec)
|
|
||||||
{
|
|
||||||
if (vec.buffer == NULL)
|
|
||||||
return;
|
|
||||||
if (vec.free_func)
|
|
||||||
{
|
|
||||||
while (vec.len)
|
|
||||||
{
|
|
||||||
vec.free_func(vec.buffer[vec.len - 1]);
|
|
||||||
vec.len--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mem_free(vec.buffer);
|
|
||||||
}
|
|
||||||
|
|
@ -1,112 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* vec_C__PREFIX__.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/12/30 17:59:28 by maiboyer #+# #+# */
|
|
||||||
/* Updated: 2023/12/30 17:59:28 by maiboyer ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "me/mem/mem.h"
|
|
||||||
#include "me/mem/mem.h"
|
|
||||||
#include "me/mem/mem.h"
|
|
||||||
#include "me/types.h"
|
|
||||||
#include "me/vec/vec_C__PREFIX__.h"
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
t_error vec_C__PREFIX___find(t_vec_C__PREFIX__ *vec,
|
|
||||||
bool (*fn)(const C__TYPENAME__ *), t_usize *index)
|
|
||||||
{
|
|
||||||
t_usize idx;
|
|
||||||
|
|
||||||
if (vec == NULL || fn == NULL || index == NULL)
|
|
||||||
return (ERROR);
|
|
||||||
idx = 0;
|
|
||||||
while (idx < vec->len)
|
|
||||||
{
|
|
||||||
if (fn((const C__TYPENAME__ *)&vec->buffer[idx]))
|
|
||||||
{
|
|
||||||
*index = idx;
|
|
||||||
return (NO_ERROR);
|
|
||||||
}
|
|
||||||
idx++;
|
|
||||||
}
|
|
||||||
return (ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
t_error vec_C__PREFIX___find_starting(t_vec_C__PREFIX__ *vec,
|
|
||||||
bool (*fn)(const C__TYPENAME__ *),
|
|
||||||
t_usize starting_index, t_usize *index)
|
|
||||||
{
|
|
||||||
t_usize idx;
|
|
||||||
|
|
||||||
if (vec == NULL || fn == NULL || index == NULL)
|
|
||||||
return (ERROR);
|
|
||||||
idx = starting_index;
|
|
||||||
while (idx < vec->len)
|
|
||||||
{
|
|
||||||
if (fn((const C__TYPENAME__ *)&vec->buffer[idx]))
|
|
||||||
{
|
|
||||||
*index = idx;
|
|
||||||
return (NO_ERROR);
|
|
||||||
}
|
|
||||||
idx++;
|
|
||||||
}
|
|
||||||
return (ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
t_error vec_C__PREFIX___all(t_vec_C__PREFIX__ *vec,
|
|
||||||
bool (*fn)(const C__TYPENAME__ *), bool *result)
|
|
||||||
{
|
|
||||||
t_usize idx;
|
|
||||||
|
|
||||||
if (vec == NULL || fn == NULL || result == NULL)
|
|
||||||
return (ERROR);
|
|
||||||
idx = 0;
|
|
||||||
*result = true;
|
|
||||||
while (*result && idx < vec->len)
|
|
||||||
{
|
|
||||||
if (!fn((const C__TYPENAME__ *)&vec->buffer[idx]))
|
|
||||||
*result = false;
|
|
||||||
idx++;
|
|
||||||
}
|
|
||||||
return (ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
t_error vec_C__PREFIX___any(t_vec_C__PREFIX__ *vec,
|
|
||||||
bool (*fn)(const C__TYPENAME__ *), bool *result)
|
|
||||||
{
|
|
||||||
t_usize idx;
|
|
||||||
|
|
||||||
if (vec == NULL || fn == NULL || result == NULL)
|
|
||||||
return (ERROR);
|
|
||||||
idx = 0;
|
|
||||||
*result = false;
|
|
||||||
while (*result && idx < vec->len)
|
|
||||||
{
|
|
||||||
if (fn((const C__TYPENAME__ *)&vec->buffer[idx]))
|
|
||||||
*result = true;
|
|
||||||
idx++;
|
|
||||||
}
|
|
||||||
return (ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
void vec_C__PREFIX___iter(t_vec_C__PREFIX__ *vec,
|
|
||||||
void (*fn)(t_usize index, C__TYPENAME__ *value,
|
|
||||||
void *state),
|
|
||||||
void *state)
|
|
||||||
{
|
|
||||||
t_usize idx;
|
|
||||||
|
|
||||||
if (vec == NULL || fn == NULL)
|
|
||||||
return;
|
|
||||||
idx = 0;
|
|
||||||
while (idx < vec->len)
|
|
||||||
{
|
|
||||||
fn(idx, &vec->buffer[idx], state);
|
|
||||||
idx++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,82 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* vec_C__PREFIX__.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/12/30 17:59:28 by maiboyer #+# #+# */
|
|
||||||
/* Updated: 2023/12/30 17:59:28 by maiboyer ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "me/mem/mem.h"
|
|
||||||
#include "me/types.h"
|
|
||||||
#include "me/vec/vec_C__PREFIX__.h"
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
t_error vec_C__PREFIX___push_front(t_vec_C__PREFIX__ *vec,
|
|
||||||
C__TYPENAME__ element)
|
|
||||||
{
|
|
||||||
t_usize i;
|
|
||||||
|
|
||||||
if (vec->len == 0)
|
|
||||||
return (vec_C__PREFIX___push(vec, element));
|
|
||||||
i = vec->len - 1;
|
|
||||||
if (vec->capacity < vec->len + 1 &&
|
|
||||||
vec_C__PREFIX___reserve(vec, 3 * vec->len / 2 + 1))
|
|
||||||
return (ERROR);
|
|
||||||
while (i > 0)
|
|
||||||
{
|
|
||||||
vec->buffer[i + 1] = vec->buffer[i];
|
|
||||||
i--;
|
|
||||||
}
|
|
||||||
vec->buffer[1] = vec->buffer[0];
|
|
||||||
vec->buffer[0] = element;
|
|
||||||
vec->len++;
|
|
||||||
return (NO_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
t_error vec_C__PREFIX___pop_front(t_vec_C__PREFIX__ *vec, C__TYPENAME__ *value)
|
|
||||||
{
|
|
||||||
t_usize i;
|
|
||||||
|
|
||||||
if (vec->len <= 1)
|
|
||||||
return (vec_C__PREFIX___pop(vec, value));
|
|
||||||
i = 0;
|
|
||||||
*value = vec->buffer[0];
|
|
||||||
vec->len--;
|
|
||||||
while (i < vec->len)
|
|
||||||
{
|
|
||||||
vec->buffer[i] = vec->buffer[i + 1];
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
mem_set_zero(&vec->buffer[i], sizeof(*vec->buffer));
|
|
||||||
return (NO_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
void vec_C__PREFIX___reverse(t_vec_C__PREFIX__ *vec)
|
|
||||||
{
|
|
||||||
C__TYPENAME__ temporary;
|
|
||||||
t_usize i;
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
while (i < vec->len / 2)
|
|
||||||
{
|
|
||||||
temporary = vec->buffer[vec->len - 1 - i];
|
|
||||||
vec->buffer[vec->len - 1 - i] = vec->buffer[i];
|
|
||||||
vec->buffer[i] = temporary;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
t_error vec_C__PREFIX___back(t_vec_C__PREFIX__ *vec, C__TYPENAME__ **out)
|
|
||||||
{
|
|
||||||
C__TYPENAME__ *temporary;
|
|
||||||
|
|
||||||
if (out == NULL)
|
|
||||||
out = &temporary;
|
|
||||||
if (vec->len != 0)
|
|
||||||
return (*out = &vec->buffer[vec->len - 1], true);
|
|
||||||
return (false);
|
|
||||||
}
|
|
||||||
|
|
@ -1,77 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* vec_C__PREFIX__.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/12/30 17:59:28 by maiboyer #+# #+# */
|
|
||||||
/* Updated: 2023/12/30 17:59:28 by maiboyer ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "me/mem/mem.h"
|
|
||||||
#include "me/types.h"
|
|
||||||
#include "me/vec/vec_C__PREFIX__.h"
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
C__TYPENAME__ *vec_C__PREFIX___get(t_vec_C__PREFIX__ *vec, t_usize i)
|
|
||||||
{
|
|
||||||
if (vec == NULL || vec->buffer == NULL)
|
|
||||||
return (NULL);
|
|
||||||
if (i < vec->len)
|
|
||||||
return (&vec->buffer[i]);
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
C__TYPENAME__ *vec_C__PREFIX___last(t_vec_C__PREFIX__ *vec)
|
|
||||||
{
|
|
||||||
if (vec == NULL || vec->len == 0)
|
|
||||||
return (NULL);
|
|
||||||
return (&vec->buffer[vec->len - 1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
void vec_C__PREFIX___copy_into(t_vec_C__PREFIX__ *vec, t_vec_C__PREFIX__ *dest)
|
|
||||||
{
|
|
||||||
if (vec == NULL || dest == NULL)
|
|
||||||
return ;
|
|
||||||
vec_C__PREFIX___reserve(dest, vec->capacity);
|
|
||||||
mem_copy(dest->buffer, vec->buffer, vec->len * sizeof(C__TYPENAME__));
|
|
||||||
}
|
|
||||||
|
|
||||||
struct s_vec_C__PREFIX___splice_arguments vec_C__PREFIX___splice_args(
|
|
||||||
t_usize index, t_usize old_count, t_usize new_count,
|
|
||||||
const C__TYPENAME__ *elements)
|
|
||||||
{
|
|
||||||
return ((struct s_vec_C__PREFIX___splice_arguments){index, old_count,
|
|
||||||
new_count, elements});
|
|
||||||
}
|
|
||||||
|
|
||||||
void vec_C__PREFIX___splice(t_vec_C__PREFIX__ *self,
|
|
||||||
struct s_vec_C__PREFIX___splice_arguments args)
|
|
||||||
{
|
|
||||||
C__TYPENAME__ *contents;
|
|
||||||
t_u32 new_size;
|
|
||||||
t_u32 old_end;
|
|
||||||
t_u32 new_end;
|
|
||||||
|
|
||||||
new_size = self->len + args.new_count - args.old_count;
|
|
||||||
old_end = args.index + args.old_count;
|
|
||||||
new_end = args.index + args.new_count;
|
|
||||||
vec_C__PREFIX___reserve(self, new_size);
|
|
||||||
contents = self->buffer;
|
|
||||||
if (self->len > old_end)
|
|
||||||
mem_move(contents + new_end,
|
|
||||||
contents + old_end,
|
|
||||||
(self->len - old_end) * sizeof(C__TYPENAME__));
|
|
||||||
if (args.new_count > 0)
|
|
||||||
{
|
|
||||||
if (args.elements)
|
|
||||||
mem_copy((contents + args.index * sizeof(C__TYPENAME__)),
|
|
||||||
args.elements, args.new_count * sizeof(C__TYPENAME__));
|
|
||||||
else
|
|
||||||
mem_set_zero((contents + args.index * sizeof(C__TYPENAME__)),
|
|
||||||
args.new_count * sizeof(C__TYPENAME__));
|
|
||||||
}
|
|
||||||
self->len += args.new_count - args.old_count;
|
|
||||||
}
|
|
||||||
|
|
@ -1,41 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* best_move.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2024/01/29 20:04:33 by maiboyer #+# #+# */
|
|
||||||
/* Updated: 2024/01/31 14:25:00 by maiboyer ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "me/types.h"
|
|
||||||
#include "me/vec/vec_C__PREFIX__.h"
|
|
||||||
|
|
||||||
void vec_C__PREFIX___sort(t_vec_C__PREFIX__ *v,
|
|
||||||
t_vec_C__PREFIX___sort_fn is_sorted_fn)
|
|
||||||
{
|
|
||||||
t_usize sorted_part;
|
|
||||||
t_usize i;
|
|
||||||
C__TYPENAME__ tmp;
|
|
||||||
|
|
||||||
if (v == NULL)
|
|
||||||
return;
|
|
||||||
sorted_part = v->len;
|
|
||||||
while (sorted_part > 0)
|
|
||||||
{
|
|
||||||
i = 0;
|
|
||||||
while (i < sorted_part - 1)
|
|
||||||
{
|
|
||||||
if (!is_sorted_fn(&v->buffer[i], &v->buffer[i + 1]))
|
|
||||||
{
|
|
||||||
tmp = v->buffer[i];
|
|
||||||
v->buffer[i] = v->buffer[i + 1];
|
|
||||||
v->buffer[i + 1] = tmp;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
sorted_part--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
236
stdme/input.toml
236
stdme/input.toml
|
|
@ -1,236 +0,0 @@
|
||||||
[definition.vec]
|
|
||||||
headers = ["generic_sources/header/vec_C__PREFIX__.h__TEMPLATE__"]
|
|
||||||
sources = [
|
|
||||||
"generic_sources/src/vec/C__PREFIX__.c__TEMPLATE__",
|
|
||||||
"generic_sources/src/vec/C__PREFIX___sort.c__TEMPLATE__",
|
|
||||||
"generic_sources/src/vec/C__PREFIX___functions2.c__TEMPLATE__",
|
|
||||||
"generic_sources/src/vec/C__PREFIX___functions3.c__TEMPLATE__",
|
|
||||||
"generic_sources/src/vec/C__PREFIX___functions4.c__TEMPLATE__",
|
|
||||||
]
|
|
||||||
replace.C__TYPENAME__ = "type"
|
|
||||||
replace.C__TYPEHEADER__ = "header_include"
|
|
||||||
replace.C__PREFIX__ = "prefix"
|
|
||||||
replace.C__PREFIXUP__ = "prefix"
|
|
||||||
|
|
||||||
|
|
||||||
[definition.hashmap]
|
|
||||||
headers = ["generic_sources/header/hashmap_C__PREFIX__.h__TEMPLATE__"]
|
|
||||||
sources = [
|
|
||||||
"generic_sources/src/hashmap/C__PREFIX__.c__TEMPLATE__",
|
|
||||||
"generic_sources/src/hashmap/C__PREFIX___utils.c__TEMPLATE__",
|
|
||||||
]
|
|
||||||
replace.C__VALTYPE__ = "type"
|
|
||||||
replace.C__KEYTYPE__ = "type"
|
|
||||||
replace.C__TYPEHEADER__ = "header_include"
|
|
||||||
replace.C__PREFIX__ = "prefix"
|
|
||||||
replace.C__PREFIXUP__ = "prefix"
|
|
||||||
|
|
||||||
[definition.str_to_num]
|
|
||||||
headers = []
|
|
||||||
sources = [
|
|
||||||
"generic_sources/src/convert/str_to_C__PREFIX__.c__TEMPLATE__",
|
|
||||||
"generic_sources/src/convert/str_to_C__PREFIX___utils.c__TEMPLATE__",
|
|
||||||
]
|
|
||||||
replace.C__TYPE__ = "type"
|
|
||||||
replace.C__UNSIGNED_TYPE__ = "type"
|
|
||||||
replace.C__PREFIX__ = "prefix"
|
|
||||||
replace.C__MAX__ = "value"
|
|
||||||
replace.C__MIN__ = "value"
|
|
||||||
replace.C__ZERO__ = "value"
|
|
||||||
replace.C__SIGNED_TYPE__ = "bool"
|
|
||||||
|
|
||||||
[definition.num_to_str]
|
|
||||||
headers = []
|
|
||||||
sources = ["generic_sources/src/convert/C__PREFIX___to_str.c__TEMPLATE__"]
|
|
||||||
replace.C__TYPE__ = "type"
|
|
||||||
replace.C__PREFIX__ = "prefix"
|
|
||||||
replace.C__FIELD__ = "type"
|
|
||||||
replace.C__UFIELD__ = "type"
|
|
||||||
replace.C__NEG__BITMASK__ = "value"
|
|
||||||
|
|
||||||
|
|
||||||
[[create.num_to_str]]
|
|
||||||
sources_output = "src/convert/"
|
|
||||||
headers_output = ""
|
|
||||||
replace.C__TYPE__ = "t_i64"
|
|
||||||
replace.C__UFIELD__ = "u64"
|
|
||||||
replace.C__FIELD__ = "i64"
|
|
||||||
replace.C__PREFIX__ = "i64"
|
|
||||||
replace.C__NEG__BITMASK__ = "0x8000000000000000"
|
|
||||||
|
|
||||||
[[create.num_to_str]]
|
|
||||||
sources_output = "src/convert/"
|
|
||||||
headers_output = ""
|
|
||||||
replace.C__TYPE__ = "t_u64"
|
|
||||||
replace.C__UFIELD__ = "u64"
|
|
||||||
replace.C__FIELD__ = "u64"
|
|
||||||
replace.C__PREFIX__ = "u64"
|
|
||||||
replace.C__NEG__BITMASK__ = "0x0000000000000000"
|
|
||||||
|
|
||||||
[[create.num_to_str]]
|
|
||||||
sources_output = "src/convert/"
|
|
||||||
headers_output = ""
|
|
||||||
replace.C__TYPE__ = "t_i32"
|
|
||||||
replace.C__UFIELD__ = "u32"
|
|
||||||
replace.C__FIELD__ = "i32"
|
|
||||||
replace.C__PREFIX__ = "i32"
|
|
||||||
replace.C__NEG__BITMASK__ = "0x80000000"
|
|
||||||
|
|
||||||
[[create.num_to_str]]
|
|
||||||
sources_output = "src/convert/"
|
|
||||||
headers_output = ""
|
|
||||||
replace.C__TYPE__ = "t_u32"
|
|
||||||
replace.C__UFIELD__ = "u32"
|
|
||||||
replace.C__FIELD__ = "u32"
|
|
||||||
replace.C__PREFIX__ = "u32"
|
|
||||||
replace.C__NEG__BITMASK__ = "0x00000000"
|
|
||||||
|
|
||||||
[[create.num_to_str]]
|
|
||||||
sources_output = "src/convert/"
|
|
||||||
headers_output = ""
|
|
||||||
replace.C__TYPE__ = "t_i16"
|
|
||||||
replace.C__UFIELD__ = "u16"
|
|
||||||
replace.C__FIELD__ = "i16"
|
|
||||||
replace.C__PREFIX__ = "i16"
|
|
||||||
replace.C__NEG__BITMASK__ = "0x8000"
|
|
||||||
|
|
||||||
[[create.num_to_str]]
|
|
||||||
sources_output = "src/convert/"
|
|
||||||
headers_output = ""
|
|
||||||
replace.C__TYPE__ = "t_u16"
|
|
||||||
replace.C__UFIELD__ = "u16"
|
|
||||||
replace.C__FIELD__ = "u16"
|
|
||||||
replace.C__PREFIX__ = "u16"
|
|
||||||
replace.C__NEG__BITMASK__ = "0x0000"
|
|
||||||
|
|
||||||
[[create.num_to_str]]
|
|
||||||
sources_output = "src/convert/"
|
|
||||||
headers_output = ""
|
|
||||||
replace.C__TYPE__ = "t_i8"
|
|
||||||
replace.C__UFIELD__ = "u8"
|
|
||||||
replace.C__FIELD__ = "i8"
|
|
||||||
replace.C__PREFIX__ = "i8"
|
|
||||||
replace.C__NEG__BITMASK__ = "0x80"
|
|
||||||
|
|
||||||
[[create.num_to_str]]
|
|
||||||
sources_output = "src/convert/"
|
|
||||||
headers_output = ""
|
|
||||||
replace.C__TYPE__ = "t_u8"
|
|
||||||
replace.C__UFIELD__ = "u8"
|
|
||||||
replace.C__FIELD__ = "u8"
|
|
||||||
replace.C__PREFIX__ = "u8"
|
|
||||||
replace.C__NEG__BITMASK__ = "0x00"
|
|
||||||
|
|
||||||
[[create.str_to_num]]
|
|
||||||
sources_output = "src/convert/"
|
|
||||||
headers_output = ""
|
|
||||||
replace.C__TYPE__ = "t_i64"
|
|
||||||
replace.C__UNSIGNED_TYPE__ = "t_u64"
|
|
||||||
replace.C__PREFIX__ = "i64"
|
|
||||||
replace.C__MAX__ = "9223372036854775807ll"
|
|
||||||
replace.C__MIN__ = "-(~9223372036854775807ll + 1)"
|
|
||||||
replace.C__ZERO__ = "0ll"
|
|
||||||
replace.C__SIGNED_TYPE__ = "true"
|
|
||||||
|
|
||||||
[[create.str_to_num]]
|
|
||||||
sources_output = "src/convert/"
|
|
||||||
headers_output = ""
|
|
||||||
replace.C__TYPE__ = "t_i32"
|
|
||||||
replace.C__UNSIGNED_TYPE__ = "t_u32"
|
|
||||||
replace.C__PREFIX__ = "i32"
|
|
||||||
replace.C__MAX__ = "2147483647"
|
|
||||||
replace.C__MIN__ = "-2147483648"
|
|
||||||
replace.C__ZERO__ = "0"
|
|
||||||
replace.C__SIGNED_TYPE__ = "true"
|
|
||||||
|
|
||||||
[[create.str_to_num]]
|
|
||||||
sources_output = "src/convert/"
|
|
||||||
headers_output = ""
|
|
||||||
replace.C__TYPE__ = "t_i16"
|
|
||||||
replace.C__UNSIGNED_TYPE__ = "t_u16"
|
|
||||||
replace.C__PREFIX__ = "i16"
|
|
||||||
replace.C__MAX__ = "32767"
|
|
||||||
replace.C__MIN__ = "-32768"
|
|
||||||
replace.C__ZERO__ = "0"
|
|
||||||
replace.C__SIGNED_TYPE__ = "true"
|
|
||||||
|
|
||||||
[[create.str_to_num]]
|
|
||||||
sources_output = "src/convert/"
|
|
||||||
headers_output = ""
|
|
||||||
replace.C__TYPE__ = "t_i8"
|
|
||||||
replace.C__UNSIGNED_TYPE__ = "t_u8"
|
|
||||||
replace.C__PREFIX__ = "i8"
|
|
||||||
replace.C__MAX__ = "127"
|
|
||||||
replace.C__MIN__ = "-128"
|
|
||||||
replace.C__ZERO__ = "0"
|
|
||||||
replace.C__SIGNED_TYPE__ = "true"
|
|
||||||
|
|
||||||
[[create.str_to_num]]
|
|
||||||
sources_output = "src/convert/"
|
|
||||||
headers_output = ""
|
|
||||||
replace.C__TYPE__ = "t_u64"
|
|
||||||
replace.C__UNSIGNED_TYPE__ = "t_u64"
|
|
||||||
replace.C__PREFIX__ = "u64"
|
|
||||||
replace.C__MAX__ = "18446744073709551615llu"
|
|
||||||
replace.C__MIN__ = "0llu"
|
|
||||||
replace.C__ZERO__ = "0llu"
|
|
||||||
replace.C__SIGNED_TYPE__ = "false"
|
|
||||||
|
|
||||||
[[create.str_to_num]]
|
|
||||||
sources_output = "src/convert/"
|
|
||||||
headers_output = ""
|
|
||||||
replace.C__TYPE__ = "t_u32"
|
|
||||||
replace.C__UNSIGNED_TYPE__ = "t_u32"
|
|
||||||
replace.C__PREFIX__ = "u32"
|
|
||||||
replace.C__MAX__ = "4294967295u"
|
|
||||||
replace.C__MIN__ = "0u"
|
|
||||||
replace.C__ZERO__ = "0u"
|
|
||||||
replace.C__SIGNED_TYPE__ = "false"
|
|
||||||
|
|
||||||
[[create.str_to_num]]
|
|
||||||
sources_output = "src/convert/"
|
|
||||||
headers_output = ""
|
|
||||||
replace.C__TYPE__ = "t_u16"
|
|
||||||
replace.C__UNSIGNED_TYPE__ = "t_u16"
|
|
||||||
replace.C__PREFIX__ = "u16"
|
|
||||||
replace.C__MAX__ = "65535u"
|
|
||||||
replace.C__MIN__ = "0u"
|
|
||||||
replace.C__ZERO__ = "0u"
|
|
||||||
replace.C__SIGNED_TYPE__ = "false"
|
|
||||||
|
|
||||||
|
|
||||||
[[create.str_to_num]]
|
|
||||||
sources_output = "src/convert/"
|
|
||||||
headers_output = ""
|
|
||||||
replace.C__TYPE__ = "t_u8"
|
|
||||||
replace.C__UNSIGNED_TYPE__ = "t_u8"
|
|
||||||
replace.C__PREFIX__ = "u8"
|
|
||||||
replace.C__MAX__ = "128u"
|
|
||||||
replace.C__MIN__ = "0u"
|
|
||||||
replace.C__ZERO__ = "0u"
|
|
||||||
replace.C__SIGNED_TYPE__ = "false"
|
|
||||||
|
|
||||||
|
|
||||||
[[create.vec]]
|
|
||||||
sources_output = "src/vec/C__PREFIX__"
|
|
||||||
headers_output = "include/me/vec/"
|
|
||||||
replace.C__TYPENAME__ = "t_u8"
|
|
||||||
replace.C__TYPEHEADER__ = ''
|
|
||||||
replace.C__PREFIX__ = "u8"
|
|
||||||
replace.C__PREFIXUP__ = "U8"
|
|
||||||
|
|
||||||
[[create.vec]]
|
|
||||||
sources_output = "src/vec/C__PREFIX__"
|
|
||||||
headers_output = "include/me/vec/"
|
|
||||||
replace.C__TYPENAME__ = "t_str"
|
|
||||||
replace.C__TYPEHEADER__ = ''
|
|
||||||
replace.C__PREFIX__ = "str"
|
|
||||||
replace.C__PREFIXUP__ = "STR"
|
|
||||||
|
|
||||||
[[create.vec]]
|
|
||||||
sources_output = "src/vec/C__PREFIX__"
|
|
||||||
headers_output = "include/me/vec/"
|
|
||||||
replace.C__TYPENAME__ = "t_string"
|
|
||||||
replace.C__TYPEHEADER__ = '#include "me/string/string.h"'
|
|
||||||
replace.C__PREFIX__ = "buf_str"
|
|
||||||
replace.C__PREFIXUP__ = "BUF_STR"
|
|
||||||
56
symdif.py
56
symdif.py
|
|
@ -1,56 +0,0 @@
|
||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
import subprocess
|
|
||||||
import os
|
|
||||||
|
|
||||||
archive_files = [
|
|
||||||
"libaq.a",
|
|
||||||
"libast.a",
|
|
||||||
"libexec.a",
|
|
||||||
"libline.a",
|
|
||||||
"libme.a",
|
|
||||||
"libparser.a",
|
|
||||||
"libsh.a",
|
|
||||||
]
|
|
||||||
build_dir = "./build/"
|
|
||||||
binary_file = "./minishell"
|
|
||||||
|
|
||||||
|
|
||||||
dump_archive = subprocess.run(
|
|
||||||
["/usr/bin/env", "readelf", "--symbols", "--wide"]
|
|
||||||
+ [f"{build_dir}/{name}" for name in archive_files],
|
|
||||||
text=True,
|
|
||||||
capture_output=True,
|
|
||||||
)
|
|
||||||
dump_binary = subprocess.run(
|
|
||||||
["/usr/bin/env", "readelf", "--symbols", "--wide"] + [binary_file],
|
|
||||||
text=True,
|
|
||||||
capture_output=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
if dump_archive.returncode != 0 or dump_binary.returncode != 0:
|
|
||||||
print("Error when getting the symbols out of the objects files or binary (or both)")
|
|
||||||
print(f"{dump_archive.stderr}")
|
|
||||||
print(f"{dump_binary.stderr}")
|
|
||||||
exit(1)
|
|
||||||
|
|
||||||
symbols_archive = set()
|
|
||||||
symbols_binary = set()
|
|
||||||
|
|
||||||
for line in dump_archive.stdout.split('\n'):
|
|
||||||
words = line.split()
|
|
||||||
if (len (words) >= 8 and words[3] == 'FUNC'):
|
|
||||||
symbols_archive.add(words[7])
|
|
||||||
|
|
||||||
for line in dump_binary.stdout.split('\n'):
|
|
||||||
words = line.split()
|
|
||||||
if (len (words) >= 8 and words[3] == 'FUNC'):
|
|
||||||
symbols_binary.add(words[7])
|
|
||||||
|
|
||||||
diff = list(symbols_archive - symbols_binary)
|
|
||||||
#diff = list(symbols_binary - symbols_archive)
|
|
||||||
diff.sort()
|
|
||||||
for sym in diff:
|
|
||||||
print(f"{sym}")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
make && valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --track-fds=yes --trace-children=yes --read-var-info=yes --read-inline-info=yes ./minishell <<<'/usr/bin/env echo *'
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
make && valgrind --leak-check=full --show-leak-kinds=none --track-origins=yes --track-fds=yes --trace-children=yes --read-var-info=yes --read-inline-info=yes --vgdb=no --vgdb-error=0 ./minishell <<<'cat <<EOF | xargs printf "\\x1b[32m%s\\x1b[0m\\n"
|
|
||||||
bonjour je suis un heredoc
|
|
||||||
le saviez tu je dois finir par EOF mais qui est sur la ligne
|
|
||||||
donc par example si j ai cette ligne qui fini avec EOF
|
|
||||||
rien ne se passe
|
|
||||||
mais la ligne d en dessous fini le heredoc :D
|
|
||||||
EOF'
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
make bonus && valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --track-fds=yes --trace-children=yes --read-var-info=yes --read-inline-info=yes ./minishell_bonus <<<'cat </dev/null | cat | cat "./.envrc" | cat | cat'
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
make && valgrind --leak-check=full --show-leak-kinds=none --track-origins=yes --track-fds=no --trace-children=yes --read-var-info=yes --read-inline-info=yes ./minishell <<<'/usr/bin/env echo this\ is\ a\ concat" $PATH"'"'jklfsjhklgfd'"
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue