Coder Social home page Coder Social logo

argp-standalone's Introduction

argp-standalone

This is a continuation of Niels Möller's work on an argp library for systems which don't provide one themselves (most non-GNU ones).

After noticing issues with executables built against argp-standalone 1.3, I decided to fork it and continue the effort.

This repository is the result of making a timeline with releases 1.0 to 1.3 (obtained from here) of the original argp-standalone, copying files from glibc 2.33 and fixing them up for compatibility, and finally some general clean up. I commited many trivial changes from the glibc version in order to make updating easier.

It is my expectation that this library will be useful to others. Feel free to open an issue or make a PR.

License

Since this repository is based on GNU C Library source code and changes from Niels and collaborators, it is licensed primarily under the GNU Lesser General Public License, version 2.1 or later (SPDX: LGPL-2.1-or-later).

argp-standalone's People

Contributors

diizzyy avatar ericonr avatar guijan avatar wdlkmpx avatar wolfv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

argp-standalone's Issues

can't get/set the program name on Windows and BSD

We don't have a fallback for getting/setting the program name on Windows and the BSDs, it would be nice to add one:

case OPT_PROGNAME: /* Set the program name. */
#if HAVE_DECL_PROGRAM_INVOCATION_NAME
program_invocation_name = arg;
#endif
/* [Note that some systems only have PROGRAM_INVOCATION_SHORT_NAME (aka
__PROGNAME), in which case, PROGRAM_INVOCATION_NAME is just defined
to be that, so we have to be a bit careful here.] */
/* Update what we use for messages. */
state->name = __argp_basename(arg);
#if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
program_invocation_short_name = state->name;
#endif
if ((state->flags & (ARGP_PARSE_ARGV0 | ARGP_NO_ERRS)) == ARGP_PARSE_ARGV0)
/* Update what getopt uses too. */
state->argv[0] = arg;
break;

The BSDs have getprogname() and setprogname() which get and set the program's name: https://man.openbsd.org/getprogname
Windows has a "_pgmptr" variable: https://learn.microsoft.com/en-us/cpp/c-runtime-library/pgmptr-wpgmptr?view=msvc-170 with the program's full path.

Notice that the code (which we imported from glibc) has getting program's name nicely parametrized into an __argp_basename() function. However, it doesn't do the same with setting the program's name. We could perhaps cooperate with glibc and gnulib to add an __argp_setbasename() (or whichever name is better) function to make everyone's life easier and remove a little #ifdef from glibc.

licensing mess

Our argp-parse.c says its license is actually LGPL-2.0-or-later:

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.

Maybe rebase on the latest glibc code which is LGPL-2.1-or-later?

Symbol visibility issues

We're exporting some symbols we shouldn't be exporting:

$ nm -gC build/libargp.so | grep T
000050a0 T __argp_basename
000052f0 T __argp_error_internal
00005590 T __argp_failure_internal
00005110 T __argp_short_program_name
00004920 T _argp_fmtstream_ensure
00004050 T _argp_fmtstream_update
0000a1f0 T _argp_input
0000b550 T _fini
0000b540 T _init
0000a390 T _option_is_end
0000a2f0 T _option_is_short
000054d0 T argp_error
00005750 T argp_failure
00003fb0 T argp_fmtstream_free
00004b20 T argp_fmtstream_printf
00004c90 T argp_help
00003ea0 T argp_make_fmtstream
00008f30 T argp_parse
00005170 T argp_state_help
0000a2a0 T argp_usage
0000b4e0 T mempcpy
0000b460 T strchrnul

In the example above, these are at least __argp_basename, __argp_error_internal,
__argp_failure_internal, __argp_short_program_name, mempcpy, and strchrnul. Possibly, that is also the case for _argp_fmtstream_ensure,
_argp_fmtstream_update, and _argp_input, but I don't yet understand the code enough to tell.

Keep in mind some of these symbols are compat code, so some symbols that aren't present at all on my system (OpenBSD) are probably wrongly exported on others. We're probably exporting strndup on mingw-w64, for instance.

Also, fixing this should generate slightly faster and smaller assembly which is always nice.

Port the glibc test suite

glibc has some tests for the argp family of functions in argp/argp-test.c, argp/bug-argp1,c, argp/bug-argp2.c argp/tst-argp1.c, argp/tst-argp2.c, and argp/tst-ldbl-argp.c (check argp/Makefile's tests target). It would be nice to port them over to this project.

Make a new release

Maybe it's time to make a new release? #18 (comment)
We have a few bugfixes and it has been 1 year, 1 release per year seems pretty good.

I suggest we use semver. This release would be version 1.6.0 because e4b4248 added a shared library.

Might want to decide on #25 before that because otherwise our shared library will be libargp.so.0.0.0.

I should also point out the current latest release of 1.5.0 had Autotools, tagging a new stable will remove it and use Meson instead.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.