mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-01 11:22:25 -05:00
[chore]: Bump modernc.org/sqlite from 1.28.0 to 1.29.2 (#2718)
This commit is contained in:
parent
ea0efb8094
commit
adb4cdcf6c
356 changed files with 2619858 additions and 1869411 deletions
118
vendor/modernc.org/token/position.go
generated
vendored
118
vendor/modernc.org/token/position.go
generated
vendored
|
|
@ -17,7 +17,6 @@ import (
|
|||
// Position describes an arbitrary source position
|
||||
// including the file, line, and column location.
|
||||
// A Position is valid if the line number is > 0.
|
||||
//
|
||||
type Position struct {
|
||||
Filename string // filename, if any
|
||||
Offset int // offset, starting at 0
|
||||
|
|
@ -31,17 +30,21 @@ func (pos *Position) IsValid() bool { return pos.Line > 0 }
|
|||
// String returns a string in one of several forms:
|
||||
//
|
||||
// file:line:column valid position with file name
|
||||
// file:line valid position with file name but no column (column == 0)
|
||||
// line:column valid position without file name
|
||||
// line valid position without file name and no column (column == 0)
|
||||
// file invalid position with file name
|
||||
// - invalid position without file name
|
||||
//
|
||||
func (pos Position) String() string {
|
||||
s := pos.Filename
|
||||
if pos.IsValid() {
|
||||
if s != "" {
|
||||
s += ":"
|
||||
}
|
||||
s += fmt.Sprintf("%d:%d", pos.Line, pos.Column)
|
||||
s += fmt.Sprintf("%d", pos.Line)
|
||||
if pos.Column != 0 {
|
||||
s += fmt.Sprintf(":%d", pos.Column)
|
||||
}
|
||||
}
|
||||
if s == "" {
|
||||
s = "-"
|
||||
|
|
@ -54,8 +57,11 @@ func (pos Position) String() string {
|
|||
// larger, representation.
|
||||
//
|
||||
// The Pos value for a given file is a number in the range [base, base+size],
|
||||
// where base and size are specified when adding the file to the file set via
|
||||
// AddFile.
|
||||
// where base and size are specified when a file is added to the file set.
|
||||
// The difference between a Pos value and the corresponding file base
|
||||
// corresponds to the byte offset of that position (represented by the Pos value)
|
||||
// from the beginning of the file. Thus, the file base offset is the Pos value
|
||||
// representing the first byte in the file.
|
||||
//
|
||||
// To create the Pos value for a specific source offset (measured in bytes),
|
||||
// first add the respective file to the current file set using FileSet.AddFile
|
||||
|
|
@ -68,14 +74,12 @@ func (pos Position) String() string {
|
|||
// equivalent to comparing the respective source file offsets. If p and q
|
||||
// are in different files, p < q is true if the file implied by p was added
|
||||
// to the respective file set before the file implied by q.
|
||||
//
|
||||
type Pos int
|
||||
|
||||
// NoPos is the zero value of Pos; there is no file and line information
|
||||
// The zero value for Pos is NoPos; there is no file and line information
|
||||
// associated with it, and NoPos.IsValid() is false. NoPos is always
|
||||
// smaller than any other Pos value. The corresponding Position value
|
||||
// for NoPos is the zero value for Position.
|
||||
//
|
||||
const NoPos Pos = 0
|
||||
|
||||
// IsValid reports whether the position is valid.
|
||||
|
|
@ -86,9 +90,8 @@ func (p Pos) IsValid() bool {
|
|||
// -----------------------------------------------------------------------------
|
||||
// File
|
||||
|
||||
// A File is a handle for a file. A File has a name, size, and line offset
|
||||
// table.
|
||||
//
|
||||
// A File is a handle for a file belonging to a FileSet.
|
||||
// A File has a name, size, and line offset table.
|
||||
type File struct {
|
||||
name string // file name as provided to AddFile
|
||||
base int // Pos value range for this file is [base...base+size]
|
||||
|
|
@ -128,7 +131,6 @@ func (f *File) LineCount() int {
|
|||
// AddLine adds the line offset for a new line.
|
||||
// The line offset must be larger than the offset for the previous line
|
||||
// and smaller than the file size; otherwise the line offset is ignored.
|
||||
//
|
||||
func (f *File) AddLine(offset int) {
|
||||
if i := len(f.lines); (i == 0 || f.lines[i-1] < offset) && offset < f.size {
|
||||
f.lines = append(f.lines, offset)
|
||||
|
|
@ -139,13 +141,12 @@ func (f *File) AddLine(offset int) {
|
|||
// the newline character at the end of the line with a space (to not change the
|
||||
// remaining offsets). To obtain the line number, consult e.g. Position.Line.
|
||||
// MergeLine will panic if given an invalid line number.
|
||||
//
|
||||
func (f *File) MergeLine(line int) {
|
||||
if line <= 0 {
|
||||
panic("illegal line number (line numbering starts at 1)")
|
||||
if line < 1 {
|
||||
panic(fmt.Sprintf("invalid line number %d (should be >= 1)", line))
|
||||
}
|
||||
if line >= len(f.lines) {
|
||||
panic("illegal line number")
|
||||
panic(fmt.Sprintf("invalid line number %d (should be < %d)", line, len(f.lines)))
|
||||
}
|
||||
// To merge the line numbered <line> with the line numbered <line+1>,
|
||||
// we need to remove the entry in lines corresponding to the line
|
||||
|
|
@ -164,7 +165,6 @@ func (f *File) MergeLine(line int) {
|
|||
// and smaller than the file size; otherwise SetLines fails and returns
|
||||
// false.
|
||||
// Callers must not mutate the provided slice after SetLines returns.
|
||||
//
|
||||
func (f *File) SetLines(lines []int) bool {
|
||||
// verify validity of lines table
|
||||
size := f.size
|
||||
|
|
@ -198,37 +198,55 @@ func (f *File) SetLinesForContent(content []byte) {
|
|||
f.lines = lines
|
||||
}
|
||||
|
||||
// A lineInfo object describes alternative file and line number
|
||||
// information (such as provided via a //line comment in a .go
|
||||
// file) for a given file offset.
|
||||
type lineInfo struct {
|
||||
// fields are exported to make them accessible to gob
|
||||
Offset int
|
||||
Filename string
|
||||
Line int
|
||||
// LineStart returns the Pos value of the start of the specified line.
|
||||
// It ignores any alternative positions set using AddLineColumnInfo.
|
||||
// LineStart panics if the 1-based line number is invalid.
|
||||
func (f *File) LineStart(line int) Pos {
|
||||
if line < 1 {
|
||||
panic(fmt.Sprintf("invalid line number %d (should be >= 1)", line))
|
||||
}
|
||||
if line > len(f.lines) {
|
||||
panic(fmt.Sprintf("invalid line number %d (should be < %d)", line, len(f.lines)))
|
||||
}
|
||||
return Pos(f.base + f.lines[line-1])
|
||||
}
|
||||
|
||||
// AddLineInfo adds alternative file and line number information for
|
||||
// a given file offset. The offset must be larger than the offset for
|
||||
// the previously added alternative line info and smaller than the
|
||||
// file size; otherwise the information is ignored.
|
||||
//
|
||||
// AddLineInfo is typically used to register alternative position
|
||||
// information for //line filename:line comments in source files.
|
||||
//
|
||||
// A lineInfo object describes alternative file, line, and column
|
||||
// number information (such as provided via a //line directive)
|
||||
// for a given file offset.
|
||||
type lineInfo struct {
|
||||
// fields are exported to make them accessible to gob
|
||||
Offset int
|
||||
Filename string
|
||||
Line, Column int
|
||||
}
|
||||
|
||||
// AddLineInfo is like AddLineColumnInfo with a column = 1 argument.
|
||||
// It is here for backward-compatibility for code prior to Go 1.11.
|
||||
func (f *File) AddLineInfo(offset int, filename string, line int) {
|
||||
f.AddLineColumnInfo(offset, filename, line, 1)
|
||||
}
|
||||
|
||||
// AddLineColumnInfo adds alternative file, line, and column number
|
||||
// information for a given file offset. The offset must be larger
|
||||
// than the offset for the previously added alternative line info
|
||||
// and smaller than the file size; otherwise the information is
|
||||
// ignored.
|
||||
//
|
||||
// AddLineColumnInfo is typically used to register alternative position
|
||||
// information for line directives such as //line filename:line:column.
|
||||
func (f *File) AddLineColumnInfo(offset int, filename string, line, column int) {
|
||||
if i := len(f.infos); i == 0 || f.infos[i-1].Offset < offset && offset < f.size {
|
||||
f.infos = append(f.infos, lineInfo{offset, filename, line})
|
||||
f.infos = append(f.infos, lineInfo{offset, filename, line, column})
|
||||
}
|
||||
}
|
||||
|
||||
// Pos returns the Pos value for the given file offset;
|
||||
// the offset must be <= f.Size().
|
||||
// f.Pos(f.Offset(p)) == p.
|
||||
//
|
||||
func (f *File) Pos(offset int) Pos {
|
||||
if offset > f.size {
|
||||
panic("illegal file offset")
|
||||
panic(fmt.Sprintf("invalid file offset %d (should be <= %d)", offset, f.size))
|
||||
}
|
||||
return Pos(f.base + offset)
|
||||
}
|
||||
|
|
@ -236,17 +254,15 @@ func (f *File) Pos(offset int) Pos {
|
|||
// Offset returns the offset for the given file position p;
|
||||
// p must be a valid Pos value in that file.
|
||||
// f.Offset(f.Pos(offset)) == offset.
|
||||
//
|
||||
func (f *File) Offset(p Pos) int {
|
||||
if int(p) < f.base || int(p) > f.base+f.size {
|
||||
panic("illegal Pos value")
|
||||
panic(fmt.Sprintf("invalid Pos value %d (should be in [%d, %d])", p, f.base, f.base+f.size))
|
||||
}
|
||||
return int(p) - f.base
|
||||
}
|
||||
|
||||
// Line returns the line number for the given file position p;
|
||||
// p must be a Pos value in that file or NoPos.
|
||||
//
|
||||
func (f *File) Line(p Pos) int {
|
||||
return f.Position(p).Line
|
||||
}
|
||||
|
|
@ -258,19 +274,31 @@ func searchLineInfos(a []lineInfo, x int) int {
|
|||
// unpack returns the filename and line and column number for a file offset.
|
||||
// If adjusted is set, unpack will return the filename and line information
|
||||
// possibly adjusted by //line comments; otherwise those comments are ignored.
|
||||
//
|
||||
func (f *File) unpack(offset int, adjusted bool) (filename string, line, column int) {
|
||||
filename = f.name
|
||||
if i := searchInts(f.lines, offset); i >= 0 {
|
||||
line, column = i+1, offset-f.lines[i]+1
|
||||
}
|
||||
if adjusted && len(f.infos) > 0 {
|
||||
// almost no files have extra line infos
|
||||
// few files have extra line infos
|
||||
if i := searchLineInfos(f.infos, offset); i >= 0 {
|
||||
alt := &f.infos[i]
|
||||
filename = alt.Filename
|
||||
if i := searchInts(f.lines, alt.Offset); i >= 0 {
|
||||
line += alt.Line - i - 1
|
||||
// i+1 is the line at which the alternative position was recorded
|
||||
d := line - (i + 1) // line distance from alternative position base
|
||||
line = alt.Line + d
|
||||
if alt.Column == 0 {
|
||||
// alternative column is unknown => relative column is unknown
|
||||
// (the current specification for line directives requires
|
||||
// this to apply until the next PosBase/line directive,
|
||||
// not just until the new newline)
|
||||
column = 0
|
||||
} else if d == 0 {
|
||||
// the alternative position base is on the current line
|
||||
// => column is relative to alternative column
|
||||
column = alt.Column + (offset - alt.Offset)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -288,11 +316,10 @@ func (f *File) position(p Pos, adjusted bool) (pos Position) {
|
|||
// If adjusted is set, the position may be adjusted by position-altering
|
||||
// //line comments; otherwise those comments are ignored.
|
||||
// p must be a Pos value in f or NoPos.
|
||||
//
|
||||
func (f *File) PositionFor(p Pos, adjusted bool) (pos Position) {
|
||||
if p != NoPos {
|
||||
if int(p) < f.base || int(p) > f.base+f.size {
|
||||
panic("illegal Pos value")
|
||||
panic(fmt.Sprintf("invalid Pos value %d (should be in [%d, %d])", p, f.base, f.base+f.size))
|
||||
}
|
||||
pos = f.position(p, adjusted)
|
||||
}
|
||||
|
|
@ -301,7 +328,6 @@ func (f *File) PositionFor(p Pos, adjusted bool) (pos Position) {
|
|||
|
||||
// Position returns the Position value for the given file position p.
|
||||
// Calling f.Position(p) is equivalent to calling f.PositionFor(p, true).
|
||||
//
|
||||
func (f *File) Position(p Pos) (pos Position) {
|
||||
return f.PositionFor(p, true)
|
||||
}
|
||||
|
|
@ -321,7 +347,7 @@ func searchInts(a []int, x int) int {
|
|||
// TODO(gri): Remove this when compilers have caught up.
|
||||
i, j := 0, len(a)
|
||||
for i < j {
|
||||
h := i + (j-i)/2 // avoid overflow when computing h
|
||||
h := int(uint(i+j) >> 1) // avoid overflow when computing h
|
||||
// i ≤ h < j
|
||||
if a[h] <= x {
|
||||
i = h + 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue