summaryrefslogtreecommitdiff
path: root/ff2png.1
diff options
context:
space:
mode:
authorLaslo Hunhold <dev@frign.de>2017-07-27 19:01:16 +0200
committerLaslo Hunhold <dev@frign.de>2017-07-27 19:19:58 +0200
commit31651271e1afd99983fb3d0ec51a273e31aaf4e9 (patch)
tree0257338759c4e3d0864429acce9955cf021e5946 /ff2png.1
parent360eccf00a6de6287a3e4c19b59835ff5d4834dd (diff)
Rewrite arg.h
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.
Diffstat (limited to 'ff2png.1')
0 files changed, 0 insertions, 0 deletions