summaryrefslogtreecommitdiff
path: root/sc/util
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2013-10-30 14:10:07 +0100
committerEike Rathke <erack@redhat.com>2013-10-30 14:15:23 +0100
commit01c2853b581b59f35206cfbefebb325427eecd35 (patch)
tree68d0116f782ffd7de6362966bb13da5ef23915ec /sc/util
parent5655b8ede2a5386b9d24d266ae08172a60b04618 (diff)
renumbered string ID defines consecutively to close gaps
... and shrink the resident array a little. Also included the awk script that does this. Change-Id: I47ab6d9d49d229dcffeef1a684f5c6fa836f91d0
Diffstat (limited to 'sc/util')
-rwxr-xr-xsc/util/number-defines-consecutively.awk49
1 files changed, 49 insertions, 0 deletions
diff --git a/sc/util/number-defines-consecutively.awk b/sc/util/number-defines-consecutively.awk
new file mode 100755
index 000000000000..6297dcdb2a35
--- /dev/null
+++ b/sc/util/number-defines-consecutively.awk
@@ -0,0 +1,49 @@
+#!/usr/bin/awk -f
+#
+# -*- Mode: awk; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+# Consecutively number a series of defines, for example sc/inc/globstr.hrc
+# WARNING: this does not expect other defines in between and would mess around
+# with them.
+
+BEGIN {
+ id = 0;
+ lastline = ""
+}
+
+{
+ if ($1 ~ /#define/ && lastline !~ /#ifndef/)
+ {
+ n = split( $0, a, / +/, s);
+ if (dup[a[3]])
+ {
+ dupmsg = " // XXX was duplicate " a[3] " of " dup[a[3]];
+ }
+ else
+ {
+ dup[a[3]] = a[2];
+ dupmsg = "";
+ }
+ a[3] = ++id;
+ lastline = s[0];
+ for (i=1; i<=n; ++i)
+ {
+ lastline = lastline a[i] s[i];
+ }
+ lastline = lastline dupmsg;
+ }
+ else
+ {
+ lastline = $0;
+ }
+ print lastline;
+}
+
+# vim:set shiftwidth=4 softtabstop=4 expandtab: