Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 89 lines (80 sloc) 2.072 kb
966e29d @steveicarus Unify the version stamp in the version_*.h header files.
authored
1 /*
2 * Copyright (c) 2009 Stephen Williams (steve@icarus.com)
3 *
4 * This source code is free software; you can redistribute it
5 * and/or modify it in source code form under the terms of the GNU
6 * General Public License as published by the Free Software
7 * Foundation; either version 2 of the License, or (at your option)
8 * any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
f5aafc3 @arunpersaud updated FSF-address
arunpersaud authored
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
966e29d @steveicarus Unify the version stamp in the version_*.h header files.
authored
18 */
19
20 # include "version_base.h"
21 # include "version_tag.h"
22 # include <stdio.h>
23 # include <string.h>
24
25 static void run_string(const char*txt)
26 {
27 const char*cp = txt;
28 while (*cp) {
29 if (cp[0] == '%' && cp[1] != 0) {
30 switch (cp[1]) {
31 case 'M':
32 fprintf(stdout, "%u", VERSION_MAJOR1);
33 break;
34 case 'm':
35 fprintf(stdout, "%u", VERSION_MAJOR2);
36 break;
37 case 'n':
38 fprintf(stdout, "%u", VERSION_MINOR);
39 break;
40 case 'E':
41 fprintf(stdout, "%s", VERSION_EXTRA);
42 break;
43 case 'T':
44 fprintf(stdout, "%s", VERSION_TAG);
45 break;
46 case '%':
47 putc('%', stdout);
48 break;
49 default:
50 break;
51 }
52 cp += 2;
53
54 } else if (cp[0] == '\\' && cp[1] != 0) {
55 switch (cp[1]) {
56 case 'n':
57 putc('\n', stdout);
58 break;
59 default:
60 putc(cp[1], stdout);
61 break;
62 }
63 cp += 2;
64
65 } else {
66 putc(cp[0], stdout);
67 cp += 1;
68 }
69 }
70 }
71
72 int main(int argc, char*argv[])
73 {
74 int idx;
75
76 if (argc == 1) {
77 printf("%s\n", VERSION);
78 return 0;
79 }
80
81 run_string(argv[1]);
82 for (idx = 2 ; idx < argc ; idx += 1) {
83 printf(" ");
84 run_string(argv[idx]);
85 }
86
87 return 0;
88 }
Something went wrong with that request. Please try again.