]> git.draconx.ca Git - cdecl99.git/blobdiff - src/strtab.sed
Start on a facility to translate error codes into strings.
[cdecl99.git] / src / strtab.sed
diff --git a/src/strtab.sed b/src/strtab.sed
new file mode 100644 (file)
index 0000000..a24c6b2
--- /dev/null
@@ -0,0 +1,44 @@
+1i\
+/*\
+ * Copyright © 2011 Nick Bowler.\
+ *\
+ * License WTFPL2: Do What The Fuck You Want To Public License, version 2.\
+ * This is free software: you are free to do what the fuck you want to.\
+ * There is NO WARRANTY, to the extent permitted by law.\
+ */
+1i\
+/*\
+ * This file is automatically generated by strtab.sed.\
+ */
+:clear
+t clear
+s/\([[:upper:]_][[:upper:]_]*\)[[:space:]]*\(".*"\)/\1@#@#@\2/
+t string
+p
+b
+:string
+H
+${
+       g
+       i\
+static const struct strtab {\
+       char _[1];
+       s/\n\([^\n]*\)@#@#@\([^\n]*\)/  char \1[sizeof \2];\
+/g
+       s/\n$//
+       p
+       g
+       i\
+} strtab = {
+       s/\n\([^\n]*\)@#@#@\([^\n]*\)/  .\1 = N_(\2),\
+/g
+       s/$/};/
+       p
+       g
+       i\
+static const size_t offtab[] = {
+       s/\n\([^\n]*\)@#@#@\([^\n]*\)/  [\1] = offsetof(struct strtab, \1),\
+/g
+       s/$/};/
+       p
+}