Bump version to 6.4-15
[LibreOffice.git] / sc / util / number-defines-consecutively.awk
blob6712490ea7514a5081f4969ef6a138e192e37239
1 #!/usr/bin/awk -f
3 # -*- Mode: awk; tab-width: 4; indent-tabs-mode: t -*-
5 # This file is part of the LibreOffice project.
7 # This Source Code Form is subject to the terms of the Mozilla Public
8 # License, v. 2.0. If a copy of the MPL was not distributed with this
9 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
12 # Consecutively number a series of defines, for example sc/inc/globstr.hrc
13 # Duplicated values are renumbered but preserved, i.e. for ...START and ...END
14 # definitions, and commented with "XXX was duplicate".
15 # To insert and renumber use a higher value for the inserted definition than
16 # any other used, for example 9999.
17 # WARNING: this does not expect other defines in between and would mess around
18 # with them.
20 BEGIN {
21 id = 0;
22 lastline = ""
26 if ($1 ~ /#define/ && lastline !~ /#ifndef/)
28 n = split( $0, a, / +/, s);
29 if (dup[a[3]])
31 dupmsg = " // XXX was duplicate " a[3] " of " dup[a[3]];
32 a[3] = map[a[3]];
34 else
36 dup[a[3]] = a[2];
37 dupmsg = "";
38 ++id;
39 map[a[3]] = id;
40 a[3] = id;
42 lastline = s[0];
43 for (i=1; i<=n; ++i)
45 lastline = lastline a[i] s[i];
47 lastline = lastline dupmsg;
49 else
51 lastline = $0;
53 print lastline;
56 # vim:set shiftwidth=4 softtabstop=4 expandtab: