|
@@ -712,15 +712,24 @@ func (s *Script) LoadScript(code, script_file string, newstate bool) string {
|
|
if len(text) > 0 {
|
|
if len(text) > 0 {
|
|
textRune := []rune(text)
|
|
textRune := []rune(text)
|
|
textLen := len(textRune)
|
|
textLen := len(textRune)
|
|
- if end == -1 {
|
|
|
|
- if start >= 1 { //正向截取到结尾
|
|
|
|
- result = string(textRune[start-1:])
|
|
|
|
- } else if start < 0 && textLen+start >= 0 { //反向截取后缀
|
|
|
|
- result = string(textRune[textLen+start:])
|
|
|
|
|
|
+ if end < 0 {
|
|
|
|
+ if start > 0 { //正向截取到倒数第end位
|
|
|
|
+ result = string(textRune[start-1 : textLen+1+end])
|
|
|
|
+ } else if start < 0 { //反向截取 从倒数第start位截取到倒数第end位
|
|
|
|
+ result = string(textRune[textLen+start : textLen+1+end])
|
|
}
|
|
}
|
|
- } else if start >= 1 && end <= textLen { //从第start个截取到第end个
|
|
|
|
|
|
+ } else if start > 0 && end >= start && end <= textLen { //从第start个截取到第end个
|
|
result = string(textRune[start-1 : end])
|
|
result = string(textRune[start-1 : end])
|
|
}
|
|
}
|
|
|
|
+ // if end == -1 {
|
|
|
|
+ // if start >= 1 { //正向截取到结尾
|
|
|
|
+ // result = string(textRune[start-1:])
|
|
|
|
+ // } else if start < 0 && textLen+start >= 0 { //反向截取后缀
|
|
|
|
+ // result = string(textRune[textLen+start:])
|
|
|
|
+ // }
|
|
|
|
+ // } else if start >= 1 && end <= textLen { //从第start个截取到第end个
|
|
|
|
+ // result = string(textRune[start-1 : end])
|
|
|
|
+ // }
|
|
}
|
|
}
|
|
S.Push(lua.LString(result))
|
|
S.Push(lua.LString(result))
|
|
return 1
|
|
return 1
|