Krolyxon
Commit 8e1d8a9

Branches

Refs →

nsxiv8e1d8a9

Simplified config.c

Author
Bert Münnich
Date
2011-09-23 00:18 +0200
Parent
515e410
Commit
8e1d8a97d3558d704a764d75234729fa2440d527

+19 −27

2 files changed

  1. M Makefile +1 −1
  2. M config.c +18 −26
M Makefile View
@@ -1,4 +1,4 @@
1−VERSION = git-20110917
1+VERSION = git-20110923
22
33 CC = gcc
44 CFLAGS = -Wall -pedantic -O2
M config.c View
@@ -2,44 +2,36 @@
22 #define _FEATURE_CONFIG
33
44 #include <stdio.h>
5−#include <string.h>
65
76 #include "config.h"
87
98 #define QUOTE(m) #m
109 #define PUT_MACRO(m) \
11− printf("%s-D%s=%s", n++ ? " " : "", #m, QUOTE(m))
10+ printf(" -D%s=%s", #m, QUOTE(m))
1211
13−int n = 0;
14−
15−inline void puts_if(const char *s, int c) {
16− if (c)
17− printf("%s%s", n++ ? " " : "", s);
18−}
19−
20−inline void endl() {
21− if (n) {
22− printf("\n");
23− n = 0;
24− }
12+inline int puts_if(const char *s, int c) {
13+ return c ? printf(" %s", s) : 0;
2514 }
2615
2716 int main(int argc, char **argv) {
28− int i;
17+ int i, n = 0;
2918
3019 for (i = 1; i < argc; i++) {
31− if (!strcmp(argv[i], "-D")) {
32− PUT_MACRO(EXIF_SUPPORT);
33− PUT_MACRO(GIF_SUPPORT);
34− endl();
35− } else if (!strcmp(argv[i], "-l")) {
36− puts_if("-lexif", EXIF_SUPPORT);
37− puts_if("-lgif", GIF_SUPPORT);
38− endl();
39− } else {
40− fprintf(stderr, "%s: invalid argument: %s\n", argv[0], argv[i]);
41− return 1;
20+ switch (argv[i][0] != '-' || argv[i][2] ? -1 : argv[i][1]) {
21+ case 'D':
22+ n += PUT_MACRO(EXIF_SUPPORT);
23+ n += PUT_MACRO(GIF_SUPPORT);
24+ break;
25+ case 'l':
26+ n += puts_if("-lexif", EXIF_SUPPORT);
27+ n += puts_if("-lgif", GIF_SUPPORT);
28+ break;
29+ default:
30+ fprintf(stderr, "%s: invalid argument: %s\n", argv[0], argv[i]);
31+ return 1;
4232 }
4333 }
34+ if (n)
35+ printf("\n");
4436 return 0;
4537 }