stringset.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright 2023 The Knuth Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package kpath
  5. type strset struct {
  6. db map[string]struct{}
  7. ks []string
  8. }
  9. func newStrSet(vs ...string) strset {
  10. set := strset{
  11. db: make(map[string]struct{}, len(vs)),
  12. ks: make([]string, len(vs)),
  13. }
  14. for i, v := range vs {
  15. set.db[v] = struct{}{}
  16. set.ks[i] = v
  17. }
  18. return set
  19. }
  20. func (set strset) has(k string) bool {
  21. _, ok := set.db[k]
  22. return ok
  23. }
  24. var (
  25. strsets = map[string]strset{
  26. "tex": newStrSet(
  27. ".tex",
  28. ".sty", ".cls", ".fd", ".aux", ".bbl", ".def", ".clo", ".ldf",
  29. ),
  30. "texpool": newStrSet(".pool"),
  31. "TeX system sources": newStrSet(".dtx", ".ins"),
  32. "gf": newStrSet(".gf"),
  33. "pk": newStrSet(".pk"),
  34. "tfm": newStrSet(".tfm"),
  35. "afm": newStrSet(".afm"),
  36. "base": newStrSet(".base"),
  37. "bib": newStrSet(".bib"),
  38. "bst": newStrSet(".bst"),
  39. "cnf": newStrSet(".cnf"),
  40. "fmt": newStrSet(".fmt"),
  41. "mf": newStrSet(".mf"),
  42. "mft": newStrSet(".mft"),
  43. "mp": newStrSet(".mp"),
  44. "ofm": newStrSet(".ofm", ".tfm"),
  45. "vf": newStrSet(".vf"),
  46. "lig": newStrSet(".lig"),
  47. "enc files": newStrSet(".enc"),
  48. "type1 fonts": newStrSet(".pfa", ".pfb"),
  49. "truetype fonts": newStrSet(".ttf", ".ttc", ".TTF", ".TTC", ".dfont"),
  50. "type42 fonts": newStrSet(".t42", ".T42"),
  51. "opentype fonts": newStrSet(".otf", ".OTF"),
  52. }
  53. )