Don't wrap xD-gen-replies in a shell script
AWK doesn't seem to be that friendly to shebangs, so let env, also required for changing LC_ALL, locate it in PATH.
This commit is contained in:
parent
ca33adeeee
commit
ecebeace0e
@ -148,7 +148,7 @@ include_directories (${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR})
|
||||
|
||||
# Generate IRC replies--we need a custom target because of the multiple outputs
|
||||
add_custom_command (OUTPUT xD-replies.c xD.msg
|
||||
COMMAND ${PROJECT_SOURCE_DIR}/xD-gen-replies.sh
|
||||
COMMAND env LC_ALL=C awk -f ${PROJECT_SOURCE_DIR}/xD-gen-replies.awk
|
||||
> xD-replies.c < ${PROJECT_SOURCE_DIR}/xD-replies
|
||||
DEPENDS ${PROJECT_SOURCE_DIR}/xD-replies
|
||||
COMMENT "Generating files from the list of server numerics")
|
||||
|
29
xD-gen-replies.awk
Executable file
29
xD-gen-replies.awk
Executable file
@ -0,0 +1,29 @@
|
||||
#!/usr/bin/awk -f
|
||||
BEGIN {
|
||||
# The message catalog is a by-product
|
||||
msg = "xD.msg"
|
||||
print "$quote \"" > msg;
|
||||
print "$set 1" > msg;
|
||||
}
|
||||
|
||||
/^[0-9]+ *IRC_(ERR|RPL)_[A-Z]+ *".*"$/ {
|
||||
match($0, /".*"/);
|
||||
ids[$1] = $2;
|
||||
texts[$2] = substr($0, RSTART, RLENGTH);
|
||||
print $1 " " texts[$2] > msg
|
||||
}
|
||||
|
||||
END {
|
||||
printf("enum\n{")
|
||||
for (i in ids) {
|
||||
if (seen_first)
|
||||
printf(",")
|
||||
seen_first = 1
|
||||
printf("\n\t%s = %s", ids[i], i)
|
||||
}
|
||||
print "\n};\n"
|
||||
print "static const char *g_default_replies[] =\n{"
|
||||
for (i in ids)
|
||||
print "\t[" ids[i] "] = " texts[ids[i]] ","
|
||||
print "};"
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
#!/bin/sh
|
||||
LC_ALL=C exec awk '
|
||||
BEGIN {
|
||||
# The message catalog is a by-product
|
||||
msg = "xD.msg"
|
||||
print "$quote \"" > msg;
|
||||
print "$set 1" > msg;
|
||||
}
|
||||
/^[0-9]+ *IRC_(ERR|RPL)_[A-Z]+ *".*"$/ {
|
||||
match($0, /".*"/);
|
||||
ids[$1] = $2;
|
||||
texts[$2] = substr($0, RSTART, RLENGTH);
|
||||
print $1 " " texts[$2] > msg
|
||||
}
|
||||
END {
|
||||
printf("enum\n{")
|
||||
for (i in ids) {
|
||||
if (seen_first)
|
||||
printf(",")
|
||||
seen_first = 1
|
||||
printf("\n\t%s = %s", ids[i], i)
|
||||
}
|
||||
print "\n};\n"
|
||||
print "static const char *g_default_replies[] =\n{"
|
||||
for (i in ids)
|
||||
print "\t[" ids[i] "] = " texts[ids[i]] ","
|
||||
print "};"
|
||||
}'
|
Loading…
Reference in New Issue
Block a user