summaryrefslogtreecommitdiff
path: root/arg.h
AgeCommit message (Collapse)Author
2018-07-16Correct arg.h licenseHEADmasterLaslo Hunhold
Credit where credit is due.
2017-08-04Rename _i,_argused to i_,argused_Laslo Hunhold
Thanks Michael Forney for reporting this! We cannot use identifiers beginning with an underscore, says the C99-standard, section 7.1.3: "All identifiers that begin with an underscore are always reserved for use as identifiers with file scope in both the ordinary and tag name spaces." We go around this by putting the underscore at the end.
2017-08-04arg.h: Small style changeLaslo Hunhold
2017-08-04arg.h: Reformat warranty clause in line with templateLaslo Hunhold
2017-08-04Change the license formatting a bit to be in line with the OSILaslo Hunhold
The (c)-symbol has become more of a remnant after the Berne convention has been signed. Given the ISC exploits some simplifications introduced with the Berne convention, it just makes sense to drop this relict as well and just state our Copyright without much ado about nothing. https://opensource.org/licenses/ISC
2017-08-04arg.h: Fortify ARGC()Laslo Hunhold
You never know...
2017-08-04arg.h: Refactor ARGF_()Laslo Hunhold
2017-08-04arg.h: Do not modify the array elements of argv[]Laslo Hunhold
The C99 standard explicitly allows to modify argc, argv, but leaves it open what happens if you modify the content of argv. Under OpenBSD, this actually has an effect on how the program is listed (e.g. in ps). To prevent this, we just add a counter variable and use that for iteration. While at it, this commit also includes a few style changes. Thanks Hiltjo for reporting this!
2017-08-04arg.h: Rename argparsed to argusedLaslo Hunhold
We do not really parse anything, we just use/devour something.
2017-08-02arg.h: Handle { NULL } argv[] properlyLaslo Hunhold
Previously, we would return argc as -1, which could cause some problems. This was not an issue introduced in the rewrite and is a bug present in the "old" arg.h as well. Thanks Isabella Parakiss for reporting this!
2017-08-02Minor style change in arg.hLaslo Hunhold
We decrement argc first before incrementing argv, so we never have a state where we potentially point to uncharted territory.
2017-07-27Rewrite arg.hLaslo Hunhold
This was something I wanted to do for quite a while now. The problem with the old arg.h is that it does not allow you to call ARGF() and EARGF() multiple times without messing the argument up. This is an unnecessary limitation and can lead to unexpected results for people not aware of this problem. ARGBEGIN { case 'a': printf("1st call: %s\n", ARGF()); printf("2nd call: %s\n", ARGF()); break; default: break; } $ prog -a ARG 1st call: ARG 2nd call: RG This is fixed now to properly print $ prog -a ARG 1st call: ARG 2nd call: ARG The old version also used more local variables than necessary, as the problem can be reduced to one single local variable within the second loop, which expresses if the argument has been consumed or not. The use of abort() within EARGF() was a bit drastic. exit(1) should suffice here and align with what you expect from an e*-type function. Additionally, the formatting I used should make readability easier and the code deduplication in the *ARGF()-macros helps with maintainability. The license used is ISC, which is compatible with MIT/X, GPL and so forth in case you want to use it in your project. I explicitly added the license header to the file making it easy to just drop it in. There are no plans to support the obsolete ARGNUM, ARGNUMF, LNGARG syntaxes.
2016-03-21add arg.h (needed for ff2ppm)Hiltjo Posthuma
2015-11-10Remove arg.hFRIGN
No need for this when the tools don't accept arguments.
2014-07-19Initial commitFRIGN