{"id":13644040,"url":"https://github.com/wkoszek/mini_printf","last_synced_at":"2026-01-05T13:01:28.862Z","repository":{"id":18058572,"uuid":"21116123","full_name":"wkoszek/mini_printf","owner":"wkoszek","description":"mini_printf - minimal, self-contained and verified printf()","archived":false,"fork":false,"pushed_at":"2015-11-20T05:09:31.000Z","size":26,"stargazers_count":34,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-08-02T01:22:09.802Z","etag":null,"topics":["c","mini-printf","stress-test"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wkoszek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-06-23T06:28:40.000Z","updated_at":"2022-03-30T06:15:41.000Z","dependencies_parsed_at":"2022-08-04T22:15:32.450Z","dependency_job_id":null,"html_url":"https://github.com/wkoszek/mini_printf","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wkoszek%2Fmini_printf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wkoszek%2Fmini_printf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wkoszek%2Fmini_printf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wkoszek%2Fmini_printf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wkoszek","download_url":"https://codeload.github.com/wkoszek/mini_printf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223853000,"owners_count":17214372,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","mini-printf","stress-test"],"created_at":"2024-08-02T01:01:56.771Z","updated_at":"2026-01-05T13:01:28.796Z","avatar_url":"https://github.com/wkoszek.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"## mini_printf - minimal, self-contained and tested printf()\n\n[![Build Status](https://travis-ci.org/wkoszek/mini_printf.svg)](https://travis-ci.org/wkoszek/mini_printf)\n\nThis is a minimal `printf()` implementation that doesn't depend on any other\nlibraries. It's meant to be used for early bootstrapping of DSLs and\nembeddable programs, as well as bare-metal software. It supports `%x` and\n`%d` format string specifiers only. One can easily extend `mini_printf.c`\nfor additional format strings.\n\n# How to use it\n\nThe `mini_printf` comes in 1 C file called `mini_printf.c`. It has a\nfunction called `pf(const char *fmt, ...)` which works exactly how `printf`\ndoes. It's named `pf()` to prevent from eventual collisions with other\nprintf-alike API you may have in your programs.\n\nTo use it, include `mini_printf.c` in your program. It only wants one thing\nfrom you: you must provide it a `io_putc(int c)` function, which is used\ninternally to do an actual I/O. You should be able to later call:\n\n\tpf(\"sample\");\n\nand get yours `io_putc` routine called for each character.\n\n# How it was tested\n\nThe biggest effort went into verification. Testing of `printf` is very\nimportant, since failure of `printf` can lead to many hours of frustration\nand debugging, so I tried to make it less likely.\n\nThe `testprog.c` has a randomized stress test suite proving my `pf()` is\nfairly robust. Stress test basically generates random format strings in a\nsmart way and plays them against system `printf()` and `mini_printf` and\nthen tries to compare the results. Mismatch means a failure of the test.\n\nTo start stress-testing, type:\n\n\tmake stresstest\n\nIt'll try to generate 1,000,000 random settings and play them against\n`mini_printf`.\n\nSeveral other useful targets are:\n\n- make test.vv\n  - very verbose and slow test. Mostly for development.\n- make test.v\n  - less verbose test. Slightly slower due to not all test data printed out.\n- make test\n  - long-running test for very stressful testing. Can make your MacBook Air\n    boil\n- make unittest\n  - unit-testing, for the cases when bugs are found\n\nUnderlying program for all tests is `testprog`. Its usage:\n\nFlag    | Description\n:-------|:-------------------------------------------------\nd       | turn debugging on. Can be specified more than once\nl \u003cnum\u003e | how many loops to run. 1 loop = 1 chunk of format string. Default: 6.\nm       | print mask: frequency of printouts after each test execution\nt \u003cnum\u003e | start only \u003cnum\u003e unit test.\nw \u003cnum\u003e | wait \u003cnum\u003e nanoseconds after each test. For debugging only.\np       | print generated format strings\ns \u003cnum\u003e | stop after \u003cnum\u003e tests.\nv       | verbose mode.\n\n# Examples\n\nYou've looked at the source and want to run only unit test number 11:\n\n\t./testprog -d -t 11\n\nYou want to run all unit tests:\n\n\t./testprog -d\n\nYou want to figure out what's going on: random format strings need to be\nshort (`-l 1`), output must be slow (`-w 500000`) and verbose (`-d -v -p`), and\nevery generated test must be printed out (`-m 0`):\n\n\t./testprog -w 500000 -l 1 -d -v -m 0 -p\n\n# Author\n\n- Wojciech Adam Koszek, [wojciech@koszek.com](mailto:wojciech@koszek.com)\n- [http://www.koszek.com](http://www.koszek.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwkoszek%2Fmini_printf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwkoszek%2Fmini_printf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwkoszek%2Fmini_printf/lists"}