summaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2019-01-08 03:36:47 +0100
committerglx22 <glx22@users.noreply.github.com>2019-01-23 19:44:43 +0100
commit636fcc2cc02d502f6e0ebddf7fc2d1d2c60f0cb8 (patch)
tree8f41e228df7e65736ff95d7868b93829b21cd440 /src/script
parentc3dbe836b40215d48691356d7bf1298217ba8edc (diff)
downloadopenttd-636fcc2cc02d502f6e0ebddf7fc2d1d2c60f0cb8.tar.xz
Fix: keep the line ending when generating widget enums with bash/gawk on windows
Diffstat (limited to 'src/script')
-rw-r--r--src/script/api/generate_widget.awk19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/script/api/generate_widget.awk b/src/script/api/generate_widget.awk
index 81d9592d7..cdbe59d97 100644
--- a/src/script/api/generate_widget.awk
+++ b/src/script/api/generate_widget.awk
@@ -24,6 +24,8 @@ BEGIN {
skiptillend = 0;
}
+{ CR = (match($0, "\\r$") > 0 ? "\r" : "") }
+
/@enum/ {
print;
add_indent = gensub("[^ ]*", "", "g");
@@ -42,7 +44,7 @@ BEGIN {
active_comment = 0;
comment = "";
file = filearray[i];
- print add_indent "/* automatically generated from " file " */"
+ print add_indent "/* automatically generated from " file " */" CR
while ((getline < file) > 0) {
sub(rm_indent, "");
@@ -65,7 +67,7 @@ BEGIN {
}
# Forget doxygen comment, if no enum follows
- if (active_comment == 2 && $0 != "") {
+ if (active_comment == 2 && $0 != "" CR) {
active_comment = 0;
comment = "";
}
@@ -78,22 +80,21 @@ BEGIN {
sub(" *//", " //");
match($0, "^( *)([A-Za-z0-9_]+),(.*)", parts);
- enumwidth - length(parts[2])
- if (parts[3] == "") {
- printf "%s%s%-45s= ::%s\n", add_indent, parts[1], parts[2], (parts[2] ",")
+ if (parts[3] == "" CR) {
+ printf "%s%s%-45s= ::%s\n", add_indent, parts[1], parts[2], (parts[2] "," CR)
} else {
- printf "%s%s%-45s= ::%-45s%s\n", add_indent, parts[1], parts[2], (parts[2] ","), parts[3];
+ printf "%s%s%-45s= ::%-45s%s\n", add_indent, parts[1], parts[2], (parts[2] ","), (parts[3]);
}
- } else if ($0 == "") {
- print "";
+ } else if ($0 == "" CR) {
+ print "" CR;
} else {
print add_indent $0;
}
}
if (match($0, "^ *\\};") > 0) {
- if (active != 0) print "";
+ if (active != 0) print "" CR;
active = 0;
}
}