2022-03-15 17:38:45 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
)
|
|
|
|
|
2022-03-15 18:31:12 +00:00
|
|
|
const header = "/* This file is automatically generated. */\n"
|
|
|
|
|
2022-03-15 17:38:45 +00:00
|
|
|
var (
|
|
|
|
flagDumpSequences bool
|
|
|
|
flagDumpTransitions bool
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
flag.BoolVar(&flagDumpSequences, "dump-sequences", false, "dump Unicode sequences")
|
|
|
|
flag.BoolVar(&flagDumpTransitions, "dump-transitions", false, "dump state machine state transition tables")
|
|
|
|
}
|
|
|
|
|
|
|
|
func getSrcdir() (string, error) {
|
|
|
|
exe, err := os.Executable()
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
return filepath.Dir(filepath.Dir(exe)), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func mainE() error {
|
|
|
|
srcdir, err := getSrcdir()
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("could not find source dir: %v", err)
|
|
|
|
}
|
|
|
|
if err := os.Chdir(srcdir); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
d, err := readData()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2022-03-15 18:31:12 +00:00
|
|
|
m := genMap(&d)
|
|
|
|
if err := writeMap(&d, m, "src/getcharmap.c"); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2022-03-15 19:34:39 +00:00
|
|
|
if err := writeRez(&d, "src/charmaps.r"); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2022-03-15 17:38:45 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
flag.Parse()
|
|
|
|
if err := mainE(); err != nil {
|
|
|
|
fmt.Fprintln(os.Stderr, "Error:", err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
}
|