# Freestanding `snprintf` and `vsnprintf`
Included in this repository is a relatively simple implementation of
`snprintf` and `vsnprintf` that I wrote in the course of an hour or two
for use in a hobbyist microkernel. I've found myself writing this code
or similar several times in the past, so decided to write a reasonably
comprehensive implementation of `snprintf` that covers most of my use
cases.
It does *not* include support for:
- Floating point: FP shouldn't be used in a kernel, and printing
floating point isn't something I'm interesting in figuring out at
the moment.
- `%n`: I've never needed it. It would be reasonably trivial (5 or 6
lines) to implement.
- Wide characters: I don't plan on supporting anything other than
UTF-8. Again, this should be a short patch if you need it.
- `*` precision, i.e. specifying precision in the next argument: I
haven't needed it in the kernel. If you need it, it's a short patch
away.
- POSIX extensions such as `%m$` and `*n$` style format specifiers, as
well as the `'` (thousands separator) format flag. These are avoided
purely for simplicity of the implementation.
The code has been written with extensibility in mind, so all but the
POSIX extensions and floating point support would be easy to add if
needed.
# License: ISC
> Copyright © 2018, Joe Davis <me@jo.ie>
>
> Permission to use, copy, modify, and/or distribute this software for
> any purpose with or without fee is hereby granted, provided that the
> above copyright notice and this permission notice appear in all
> copies.
>
> THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
> WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
> WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
> AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
> DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
> PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
> TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
> PERFORMANCE OF THIS SOFTWARE.
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
独立的snprintf和vsnprintf 该存储库中包含一个相对简单的snprintf和vsnprintf ,我在一两个小时的时间内编写了这些信息,用于业余爱好者的微内核。 我发现自己过去几次编写此代码或类似代码,因此决定编写一个涵盖我大部分用例的snprintf合理全面的实现。 它不包括支持: 浮点数:FP不应该在内核中使用,而打印浮点数并不是我现在很感兴趣的事情。 %n :我从不需要它。 实施起来相当琐碎(5或6行)。 宽字符:除了UTF-8,我不打算支持任何其他功能。 同样,如果需要,这应该是一个简短的补丁。 * precision,即在下一个参数中指定精度:内核中不需要它。 如果您需要它,很短的路程。 POSIX扩展,例如%m$和*n$样式格式说明符,以及' (千位分隔符)格式标志。 纯粹为了实现的简单性而避免了这些。 该代码在编写时就考虑了可扩展性,因此,如果需
资源推荐
资源详情
资源评论
收起资源包目录
snprintf-master.zip (3个子文件)
snprintf-master
snprintf.h 1KB
README.md 2KB
snprintf.c 9KB
共 3 条
- 1
资源评论
yueyhangcheuk
- 粉丝: 27
- 资源: 4701
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功