Code Monkey home page Code Monkey logo

ya_getopt's Introduction

ya_getopt - Yet another getopt

What is ya_getopt.

Ya_getopt is a drop-in replacement of GNU C library getopt. getopt(), getopt_long() and getopt_long_only() are implemented excluding the following GNU extension features.

  1. If optstring contains W followed by a semicolon, then -W foo is treated as the long option --foo.

  2. _<PID>_GNU_nonoption_argv_flags_

The license is 2-clause BSD-style license. You can use the Linux getopt compatible function under Windows, Solaris and so on without having to worry about license issue.

Note for contributors

Don't send me a patch if you have looked at GNU C library getopt source code. That's because I made this with clean room design to avoid the influence of the GNU LGPL.

Please make a test script passed by the GNU C library getopt but not by ya_getopt instead.

License

2-clause BSD-style license

Other getopt functions

ya_getopt's People

Contributors

kubo avatar wangp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

wangp songbei6

ya_getopt's Issues

Permute non-option arguments after --

For GNU compatibility, ya_getopt may want to permute non-option arguments to after "--", e.g.

$ ./test1.ya foo bar -- -x -y
foo bar -- -x -y

vs.

$ ./test1.gnu foo bar -- -x -y
-- foo bar -x -y

Here is the test program:

#include <stdio.h>
#ifdef YA
#include "../ya_getopt.h"
#else
#include <getopt.h>
#endif

int main(int argc, char **argv)
{
    char *optstring = "ab:";
    int opt;
    int i;

    while ((opt = getopt(argc, argv, optstring)) != -1) {
    }
    for (i = 1; i < argc; i++) {
        printf("%s ", argv[i]);
    }
    printf("\n");
    return 0;
}

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.