github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/gnovm/stdlibs/strings/export_test.gno (about)

     1  // Copyright 2011 The Go 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  
     5  package strings
     6  
     7  /*
     8  func (r *Replacer) Replacer() interface{} {
     9  	r.once.Do(r.buildOnce)
    10  	return r.r
    11  }
    12  
    13  func (r *Replacer) PrintTrie() string {
    14  	r.once.Do(r.buildOnce)
    15  	gen := r.r.(*genericReplacer)
    16  	return gen.printNode(&gen.root, 0)
    17  }
    18  
    19  func (r *genericReplacer) printNode(t *trieNode, depth int) (s string) {
    20  	if t.priority > 0 {
    21  		s += "+"
    22  	} else {
    23  		s += "-"
    24  	}
    25  	s += "\n"
    26  
    27  	if t.prefix != "" {
    28  		s += Repeat(".", depth) + t.prefix
    29  		s += r.printNode(t.next, depth+len(t.prefix))
    30  	} else if t.table != nil {
    31  		for b, m := range r.mapping {
    32  			if int(m) != r.tableSize && t.table[m] != nil {
    33  				s += Repeat(".", depth) + string([]byte{byte(b)})
    34  				s += r.printNode(t.table[m], depth+1)
    35  			}
    36  		}
    37  	}
    38  	return
    39  }
    40  */
    41  
    42  func StringFind(pattern, text string) int {
    43  	return makeStringFinder(pattern).next(text)
    44  }
    45  
    46  func DumpTables(pattern string) ([]int, []int) {
    47  	finder := makeStringFinder(pattern)
    48  	return finder.badCharSkip[:], finder.goodSuffixSkip
    49  }