feat: libb20 C90 #11

Merged
sezieru merged 10 commits from feat/lib/c90/main into main 2025-11-03 12:31:59 +00:00
Owner

🧮 libb20 – C90 Library Implementation & Reference CLI

This PR marks the formal transition of libb20 from a proof-of-concept encoder to a proper reusable C90 library, establishing the structure that all future language ports will follow.


🧱 What’s New

🧩 Core Library (libb20.h / libb20.c)

  • Full ANSI/ISO-C90 implementation of the base-20 codec.
  • Shared internal helpers for UTF-8, base-256 math, and block encoding.
  • Clean public interface with explicit ownership and error model.
  • Added b20_status_str() for human-readable diagnostics.
  • All operations are big-endian (MSB-first) and re-entrant.

🔧 Utility Layer (libb20_util.h / .c)

  • Optional module for UTF-8 parsing and encoding convenience.
  • Provides functions to safely interpret CLI input into code points.
  • Keeps the main library Unicode-agnostic and minimal.

🖥️ Reference CLI (kb20-c90ref)

  • New command-line tool built entirely on the public API.

    • encode / decode
    • --text or --bin modes
    • --zero <code point> or --alphabet <20 code points>
  • Replaces the previous standalone reference implementation (kb20c).

  • Reads from stdin, writes to stdout, returns clear status codes.

🧰 Build System

  • Updated Makefile to compile and link the library and CLI cleanly.
  • Added make clean target.
  • Retired the legacy reference implementation.

🧪 Verification

  • Cross-checked output against the original reference:

    • Text encoding produces identical results for all test inputs.
    • Binary-digits mode round-trips byte-for-byte.
  • Verified correct decoding for variable-length tails.

  • Confirmed proper alphabet validation and duplicate detection.

  • Verified all error codes via malformed inputs.


🧭 Future Work

  • Integrate lightweight tests for each error path and block length edge case.
  • Begin formal documentation of the binary format and byte layout.
  • Start work on the C++, Python, and TypeScript bindings.

📜 Summary

This PR graduates libb20 into its first stable architectural form:
a clean, standards-compliant base-20 codec library designed for reuse,
teaching, and interoperability across languages.

# 🧮 libb20 – C90 Library Implementation & Reference CLI This PR marks the formal transition of **libb20** from a proof-of-concept encoder to a **proper reusable C90 library**, establishing the structure that all future language ports will follow. --- ## 🧱 What’s New ### 🧩 Core Library (`libb20.h` / `libb20.c`) - Full ANSI/ISO-C90 implementation of the base-20 codec. - Shared internal helpers for UTF-8, base-256 math, and block encoding. - Clean public interface with explicit ownership and error model. - Added `b20_status_str()` for human-readable diagnostics. - All operations are **big-endian (MSB-first)** and re-entrant. ### 🔧 Utility Layer (`libb20_util.h` / `.c`) - Optional module for UTF-8 parsing and encoding convenience. - Provides functions to safely interpret CLI input into code points. - Keeps the main library Unicode-agnostic and minimal. ### 🖥️ Reference CLI (`kb20-c90ref`) - New command-line tool built entirely on the public API. - `encode` / `decode` - `--text` or `--bin` modes - `--zero <code point>` or `--alphabet <20 code points>` - Replaces the previous standalone reference implementation (`kb20c`). - Reads from **stdin**, writes to **stdout**, returns clear status codes. ### 🧰 Build System - Updated `Makefile` to compile and link the library and CLI cleanly. - Added `make clean` target. - Retired the legacy reference implementation. --- ## 🧪 Verification - Cross-checked output against the original reference: - Text encoding produces identical results for all test inputs. - Binary-digits mode round-trips byte-for-byte. - Verified correct decoding for variable-length tails. - Confirmed proper alphabet validation and duplicate detection. - Verified all error codes via malformed inputs. --- ## 🧭 Future Work - Integrate lightweight tests for each error path and block length edge case. - Begin formal documentation of the binary format and byte layout. - Start work on the **C++**, **Python**, and **TypeScript** bindings. --- ## 📜 Summary This PR graduates libb20 into its **first stable architectural form**: a clean, standards-compliant base-20 codec library designed for reuse, teaching, and interoperability across languages.
sezieru self-assigned this 2025-11-03 12:31:43 +00:00
- Introduce b20_* interfaces for test and binary-digits modes
- Alphabet config via ZERO cp or 20-scalar map
- Explicit error mode (b20_status) and allocator hook (b20_free)
- Implement text and binary-digits codecs using big-endian folds
- Well-factored static helpers: UTF-8 (internal), big-int ops, block enc/dec, len<->digits
- C90/ANSI compliant, reentrant, no globals
- Subcommands encode/decode; --text (default) or --bin
- Text mode supports --zero <codepoint> or --alphabet <20 codepoints>
- Streams stdin -> stdout; human-readable errors
- Map b20_status to stable strings for UIs/CLIs/logging
- b20_utf8_decode_one/encode_one, b20_utf8_parse_one_exact, b20_utf8_parse_20
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: fosster/libb20#11
No description provided.