1#!/usr/bin/perl
2# 20100702 Sampo Kellomaki (sampo@iki.fi)
3# sed dependency remover for zxid
4# This program is used to perform substitutions that normal
5# unix programmer would do with sed. We do it in perl to
6# remove sed dependency. We need perl anyway.
7# This program also avoids some Windows shell quoting problems.
8
9$op = shift;
10undef $/;
11$_ = <STDIN>;
12
13if ($op eq 'nss') {
14    #s%^(\#line.*)$%/* $1 */%gm;
15    s/static struct zx_ns_s/struct zx_ns_s/g;
16    print;
17}
18
19if ($op eq 'attrs') {
20    #s%^(\#line.*)$%/* $1 */%gm;
21    s/static struct zx_at_tok/struct zx_at_tok/g;
22    print;
23}
24
25if ($op eq 'elems') {
26    #s%^(\#line.*)$%/* $1 */%gm;
27    s/static struct zx_el_tok/struct zx_el_tok/g;
28    print;
29}
30
31if ($op eq 'version') {
32    $ZXIDREL = shift;
33    s/^Version: .*/Version: $ZXIDREL/m;
34    print;
35}
36
37if ($op eq 'license') {
38    s/[ \t\r\n]+$//s;
39    s/"/\\"/g;
40    s/$/\\n\\/gm;
41    chop; chop; chop;
42    print <<LICENSE;
43char* license = "\\n\\
44Copyright (c) 2012-2013 Synergetics SA (sampo@synergetics.be), All Rights Reserved.\\n\\
45Copyright (c) 2010-2012 Sampo Kellomaki (sampo\@iki.fi), All Rights Reserved.\\n\\
46Copyright (c) 2006-2009 Symlabs (symlabs\@symlabs.com), All Rights Reserved.\\n\\
47Author: Sampo Kellomaki (sampo\@iki.fi), All Rights Reserved.\\n\\
48$_\\n";
49LICENSE
50;
51}
52
53if ($op eq 'zxidvers') {
54    chop;
55    $ZXIDVERSION = shift;
56    $ZXIDREL = shift;
57    $secs = time;
58    print <<ZXIDVERS;
59#ifndef _zxidvers_h
60#define _zxidvers_h
61#define ZXID_VERSION $ZXIDVERSION
62#define ZXID_REL "$ZXIDREL"
63#define ZXID_COMPILE_DATE "$secs"
64#define ZXID_REV "$_"
65#endif
66ZXIDVERS
67;
68
69}
70
71__END__
72