mirror of https://github.com/OpenTTD/OpenTTD
Fix: keep the line ending when generating widget enums with bash/gawk on windows
parent
c3dbe836b4
commit
636fcc2cc0
|
@ -24,6 +24,8 @@ BEGIN {
|
||||||
skiptillend = 0;
|
skiptillend = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{ CR = (match($0, "\\r$") > 0 ? "\r" : "") }
|
||||||
|
|
||||||
/@enum/ {
|
/@enum/ {
|
||||||
print;
|
print;
|
||||||
add_indent = gensub("[^ ]*", "", "g");
|
add_indent = gensub("[^ ]*", "", "g");
|
||||||
|
@ -42,7 +44,7 @@ BEGIN {
|
||||||
active_comment = 0;
|
active_comment = 0;
|
||||||
comment = "";
|
comment = "";
|
||||||
file = filearray[i];
|
file = filearray[i];
|
||||||
print add_indent "/* automatically generated from " file " */"
|
print add_indent "/* automatically generated from " file " */" CR
|
||||||
while ((getline < file) > 0) {
|
while ((getline < file) > 0) {
|
||||||
sub(rm_indent, "");
|
sub(rm_indent, "");
|
||||||
|
|
||||||
|
@ -65,7 +67,7 @@ BEGIN {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Forget doxygen comment, if no enum follows
|
# Forget doxygen comment, if no enum follows
|
||||||
if (active_comment == 2 && $0 != "") {
|
if (active_comment == 2 && $0 != "" CR) {
|
||||||
active_comment = 0;
|
active_comment = 0;
|
||||||
comment = "";
|
comment = "";
|
||||||
}
|
}
|
||||||
|
@ -78,22 +80,21 @@ BEGIN {
|
||||||
sub(" *//", " //");
|
sub(" *//", " //");
|
||||||
|
|
||||||
match($0, "^( *)([A-Za-z0-9_]+),(.*)", parts);
|
match($0, "^( *)([A-Za-z0-9_]+),(.*)", parts);
|
||||||
enumwidth - length(parts[2])
|
|
||||||
|
|
||||||
if (parts[3] == "") {
|
if (parts[3] == "" CR) {
|
||||||
printf "%s%s%-45s= ::%s\n", add_indent, parts[1], parts[2], (parts[2] ",")
|
printf "%s%s%-45s= ::%s\n", add_indent, parts[1], parts[2], (parts[2] "," CR)
|
||||||
} else {
|
} 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 == "") {
|
} else if ($0 == "" CR) {
|
||||||
print "";
|
print "" CR;
|
||||||
} else {
|
} else {
|
||||||
print add_indent $0;
|
print add_indent $0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match($0, "^ *\\};") > 0) {
|
if (match($0, "^ *\\};") > 0) {
|
||||||
if (active != 0) print "";
|
if (active != 0) print "" CR;
|
||||||
active = 0;
|
active = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue