summaryrefslogtreecommitdiff
path: root/xS
diff options
context:
space:
mode:
Diffstat (limited to 'xS')
-rw-r--r--xS/.gitignore2
-rw-r--r--xS/Makefile13
-rw-r--r--xS/go.mod3
-rwxr-xr-xxS/xS-gen-replies.awk14
-rw-r--r--xS/xS.go (renamed from xS/main.go)2
-rw-r--r--xS/xS_test.go (renamed from xS/main_test.go)0
6 files changed, 27 insertions, 7 deletions
diff --git a/xS/.gitignore b/xS/.gitignore
new file mode 100644
index 0000000..4f7b84d
--- /dev/null
+++ b/xS/.gitignore
@@ -0,0 +1,2 @@
+/xS
+/xS-replies.go
diff --git a/xS/Makefile b/xS/Makefile
new file mode 100644
index 0000000..55ad4d2
--- /dev/null
+++ b/xS/Makefile
@@ -0,0 +1,13 @@
+.POSIX:
+.SUFFIXES:
+AWK = env LC_ALL=C awk
+
+outputs = xS xS-replies.go
+all: $(outputs)
+
+xS: xS.go xS-replies.go
+ go build -o $@
+xS-replies.go: xS-gen-replies.awk xS-replies
+ $(AWK) -f xS-gen-replies.awk xS-replies > $@
+clean:
+ rm -f $(outputs)
diff --git a/xS/go.mod b/xS/go.mod
new file mode 100644
index 0000000..9752c95
--- /dev/null
+++ b/xS/go.mod
@@ -0,0 +1,3 @@
+module janouch.name/xK/xS
+
+go 1.19
diff --git a/xS/xS-gen-replies.awk b/xS/xS-gen-replies.awk
index fce7b50..94a338f 100755
--- a/xS/xS-gen-replies.awk
+++ b/xS/xS-gen-replies.awk
@@ -1,15 +1,19 @@
#!/usr/bin/awk -f
/^[0-9]+ *(ERR|RPL)_[A-Z]+ *".*"$/ {
- match($0, /".*"/);
- ids[$1] = $2;
- texts[$2] = substr($0, RSTART, RLENGTH);
+ match($0, /".*"/)
+ ids[$1] = $2
+ texts[$2] = substr($0, RSTART, RLENGTH)
}
END {
- print "package " ENVIRON["GOPACKAGE"] "\n\nconst ("
+ print "package main"
+ print ""
+ print "const ("
for (i in ids)
printf("\t%s = %s\n", ids[i], i)
- print ")\n\nvar defaultReplies = map[int]string{"
+ print ")"
+ print ""
+ print "var defaultReplies = map[int]string{"
for (i in ids)
print "\t" ids[i] ": " texts[ids[i]] ","
print "}"
diff --git a/xS/main.go b/xS/xS.go
index 21851f1..e6c3b3c 100644
--- a/xS/main.go
+++ b/xS/xS.go
@@ -460,8 +460,6 @@ func (fd *floodDetector) check() bool {
// --- IRC protocol ------------------------------------------------------------
-//go:generate sh -c "LC_ALL=C awk -f xS-gen-replies.awk > xS-replies.go < xS-replies"
-
func ircToLower(c byte) byte {
switch c {
case '[':
diff --git a/xS/main_test.go b/xS/xS_test.go
index 8241b4e..8241b4e 100644
--- a/xS/main_test.go
+++ b/xS/xS_test.go