getopt
POSIX getopt() as a portable header library (by skeeto)
rust-fnv
Fowler–Noll–Vo hash function (by servo)
getopt | rust-fnv | |
---|---|---|
8 | 2 | |
97 | 325 | |
- | 1.2% | |
0.0 | 5.1 | |
10 months ago | about 2 months ago | |
C | Rust | |
The Unlicense | Apache License 2.0 |
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
getopt
Posts with mentions or reviews of getopt.
We have used some of these posts to build our list of alternatives
and similar projects. The last one was on 2024-05-04.
- Automated integer hash function discovery
-
Porting my very simple C code from Unixen/macOS to Windows
Between -std=c99 and removing these headers, you're missing time definitions (struct timeval, gettimeofday) and option parsing definitions (struct option, getopt_long). Mingw-w64 provides all this for compatibility, but MSVC has none of these, so you'll need to write replacements. I've written embeddable, public domain implementations of getopt and something like getopt_long, in case that helps. These are how I deal with option parsing portability.
-
I recently made a simple project in C. Would be really helpful if someone could review my code.
The option parser is crude and doesn't follow conventions. Particularly the lack of -- support (disables option parsing) would make it impossible to use safely in scripts. If you don't want to use the system or toolchain-provided getopt, here's a public domain, embeddable implementation: getopt.h
-
How to properly handle position non-specific program arguments? ./my_prog --format:"mp3"
On unix-like systems there's a getopt function for parsing short options. Mingw-w64 has one as well, to cover Windows programs. If I care about portability, I just embed my own so it not only works everywhere, it behave the same everywhere, too.
- How to make programs for linux
-
[ Feed back wanted ] Is this a good way to handle lot of if instead of if else?
https://github.com/skeeto/getopt/blob/master/getopt.h (short)
-
Debian discusses vendoring again
Not only the GNU, you have an example in this thread where someone suggested to use or roll something similar to https://github.com/skeeto/getopt/blob/master/getopt.h, which, surprise, depends on strchr, a function that solves a much trivial problem than POSIX getopt, to begin with.
rust-fnv
Posts with mentions or reviews of rust-fnv.
We have used some of these posts to build our list of alternatives
and similar projects. The last one was on 2021-08-01.
-
How to write slow Rust code. My battle to beat Common Lisp and Java on a phone number encoding problem.
Use faster hashing function (e.g. fnv, there are other potentially faster options as well). By default Rust std uses a DoS-resistant function, which is relatively slow.
-
Debian discusses vendoring again
Looking at ripgrep myself, I'm seeing some trivial dependencies. One is fnv. Perhaps you're not aware, but FNV-1a is literally ~4 lines of code. It's about as sophisticated as left-pad. I've written it from scratch a dozen times off the top of my head (the official offset basis and prime are really not special, so you can just generate your own). It would take you about a minute to eliminate it.
What are some alternatives?
When comparing getopt and rust-fnv you can also consider the following projects:
optparse - Portable, reentrant, getopt-like option parser
cargs - A lightweight cross-platform getopt alternative that is tested on Linux, Windows, FreeBSD and macOS. Command line argument parser library for C/C++. Can be used to parse argv and argc parameters.
pre-commit - A framework for managing and maintaining multi-language pre-commit hooks.
perl5 - 🐪 The Perl programming language
fst - Represent large sets and maps compactly with finite state transducers.
rust-base64 - base64, in rust
itoa - Fast function for printing integer primitives to a decimal string
ripgrep-all - rga: ripgrep, but also search in PDFs, E-Books, Office documents, zip, tar.gz, etc.
nixpkgs - Nix Packages collection & NixOS