Sigmapitech / myprintf

Allocation free, C99 printf function recreation focused of a small memory footprint

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

C99 Printf Recreation

Recreating infamous printf function as described by standard C99.

Caution

Copying the content of this repository for your own delivery will grade you a -42 for cheating.

πŸ“• C99 limitations

Please refer to the fprintf format specification for information about supported features.

The current implementation follows strictly the C99 compliance, with the following known exceptions:

  • long double (IEEE float 80) support has not been implemented.
  • multibyte character (wchar_t) are not supported.
  • %e as not been kept due to its incorrectness.

Note

Ask requested by the assignment, conversion specifier B and b from c2x standard have been implemented, corresponding to binary format.

❓ Invalid format

In case of invalid format, as specified by C99,our function will treat the given sequence as regular text and continue.

πŸ”§ Setup

Note

To ensure a consistent development environment and to simplify dependency management, we strongly recommend using Nix. The project is configured to work seamlessly with Nix, providing reproducible builds and a standardized development environment.

If you haven't already, consider installing Nix by following the instructions on nix installation page.

🌸 Nix

You can use the standard nix flakes commands to clone, build, ... this project.

nix build github:Sigmapitech/myprintf

outputs libmy.a containing my_printf.

πŸ“Ž Non-nix

0. Install the required dependencies

Make sure to have the following dependencies available within your environment:

  • The Coreutils command set, which are expected to exist on every operating system.
  • a recent version of Gnu make ~4.x.x
  • GCC, preferably, version 13.x.x along the GNU C Library.
  • The GNU ar archive program, provided by binutils.
  • Optionally, tput command to support colors within the Makefile.
  • criterion library to compile tests.
  • gcovr to retrieve coverage report.

Epitest Docker

If you want to use the epitest container provided by Epitech, you can use the following command:

docker run -it --rm -v $(pwd):/home/project -w /home/project epitechcontent/epitest-docker:latest /bin/bash

I. Clone the repository

git clone https://github.com/Sigmapitech/myprintf.git myprintf
cd myprintf

II. Compile the library

Tip

you can touch .fast to use parralel building.

make

To see other available targets, you can use a program such as fzf-make.

πŸ“‘ DEVELOPMENT

if you are using Nix, you can access a devShell that you can develop with the project dependencies to build and develop.

nix develop
nix develop github:Sigmapitech/myrpg

Using direnv

You may load the devShell automatically using direnv shell integration.

echo "use flake" | tee .envrc
direnv allow

πŸ”¬ TESTING

A tester is provided to compared the implementation along-side printf from glibc. Test table only features defined behaviour described by the standard.

To run the tests and get a coverage report:

make cov

About

Allocation free, C99 printf function recreation focused of a small memory footprint


Languages

Language:C 93.1%Language:Makefile 3.7%Language:Nix 3.2%