func goFoo() {
x := 1
for i := 0; i < 10000; i++ {
- // variadic call mallocs + writes to
+ // variadic call mallocs + writes to
variadic(x, x, x)
if x != 1 {
panic("bad x")
import "testing"
-// The actual test functions are in non-_test.go files
+// The actual test functions are in non-_test.go files
// so that they can use cgo (import "C").
// These wrappers are here for gotest to find.
}()
}
-// wasteCPU starts a background goroutine to waste CPU
-// to cause the power management to raise the CPU frequency.
+// wasteCPU starts a background goroutine to waste CPU
+// to cause the power management to raise the CPU frequency.
// On ARM this has the side effect of making sleep more accurate.
func wasteCPU() chan struct{} {
done := make(chan struct{})
package cgotest
/*
-#include <dlfcn.h>
+#include <dlfcn.h>
#cgo linux LDFLAGS: -ldl
*/
import "C"
Log string `datastore:"-"` // for JSON unmarshaling only
LogHash string `datastore:",noindex"` // Key to the Log record.
- RunTime int64 // time to build+test in nanoseconds
+ RunTime int64 // time to build+test in nanoseconds
}
func (r *Result) Key(c appengine.Context) *datastore.Key {
/*
-Go Builder is a continuous build client for the Go project.
+Go Builder is a continuous build client for the Go project.
It integrates with the Go Dashboard AppEngine application.
Go Builder is intended to run continuously as a background process.
-It periodically pulls updates from the Go Mercurial repository.
+It periodically pulls updates from the Go Mercurial repository.
When a newer revision is found, Go Builder creates a clone of the repository,
-runs all.bash, and reports build success or failure to the Go Dashboard.
+runs all.bash, and reports build success or failure to the Go Dashboard.
For a release revision (a change description that matches "release.YYYY-MM-DD"),
Go Builder will create a tar.gz archive of the GOROOT and deliver it to the
gobuilder goos-goarch...
- Several goos-goarch combinations can be provided, and the builder will
+ Several goos-goarch combinations can be provided, and the builder will
build them in serial.
Optional flags:
return waitWithTimeout(timeout, cmd)
}
-// runLog runs a process and returns the combined stdout/stderr,
+// runLog runs a process and returns the combined stdout/stderr,
// as well as writing it to logfile (if specified). It returns
// process combined stdout and stderr output, exit status and error.
// The error returned is nil, if process is started successfully,
}
// build checks for a new commit for this builder
-// and builds it if one is found.
+// and builds it if one is found.
// It returns true if a build was attempted.
func (b *Builder) build() bool {
hash, err := b.todo("build-go-commit", "", "")
}
// failBuild checks for a new commit for this builder
-// and fails it if one is found.
+// and fails it if one is found.
// It returns true if a build was "attempted".
func (b *Builder) failBuild() bool {
hash, err := b.todo("build-go-commit", "", "")
// trailingSpaceRE matches trailing spaces.
var trailingSpaceRE = regexp.MustCompile(`(?m)[ \t\r]+$`)
-// removeRE is the list of patterns to skip over at the beginning of a
+// removeRE is the list of patterns to skip over at the beginning of a
// message when looking for message text.
var removeRE = regexp.MustCompile(`(?m-s)\A(` +
// Skip leading "Hello so-and-so," generated by codereview plugin.
// Goplay is a web interface for experimenting with Go code.
// It is similar to the Go Playground: http://golang.org/doc/play/
-//
+//
// To use goplay:
// $ cd $GOROOT/misc/goplay
// $ go run goplay.go
// and load http://localhost:3999/ in a web browser.
-//
+//
// You should see a Hello World program, which you can compile and run by
// pressing shift-enter. There is also a "compile-on-keypress" feature that can
// be enabled by checking a checkbox.
-//
+//
// WARNING! CUIDADO! ACHTUNG! ATTENZIONE!
// A note on security: anyone with access to the goplay web interface can run
// arbitrary code on your computer. Goplay is not a sandbox, and has no other
-// security mechanisms. Do not deploy it in untrusted environments.
-// By default, goplay listens only on localhost. This can be overridden with
+// security mechanisms. Do not deploy it in untrusted environments.
+// By default, goplay listens only on localhost. This can be overridden with
// the -http parameter. Do so at your own risk.
package documentation
log.Fatal(http.ListenAndServe(*httpListen, nil))
}
-// FrontPage is an HTTP handler that renders the goplay interface.
+// FrontPage is an HTTP handler that renders the goplay interface.
// If a filename is supplied in the path component of the URI,
// its contents will be put in the interface's text area.
// Otherwise, the default "hello, world" program is displayed.
}
// fieldPrefix returns the prefix that should be removed from all the
-// field names when generating the C or Go code. For generated
+// field names when generating the C or Go code. For generated
// C, we leave the names as is (tv_sec, tv_usec), since that's what
// people are used to seeing in C. For generated Go code, such as
// package syscall's data structures, we drop a common prefix
// named, say, _pad in an otherwise prefixed header.
// If the struct has 3 fields tv_sec, tv_usec, _pad1, then we
// still want to remove the tv_ prefix.
- // The check for "orig_" here handles orig_eax in the
+ // The check for "orig_" here handles orig_eax in the
// x86 ptrace register sets, which otherwise have all fields
// with reg_ prefixes.
if strings.HasPrefix(n.Name, "orig_") || strings.HasPrefix(n.Name, "_") {
case "O_TRUNC":
foundTrunc = true
case "O_RDONLY", "O_WRONLY", "O_RDWR":
- // okay
+ // okay
default:
// Unexpected flag, like O_APPEND or O_EXCL.
// Be conservative and do not rewrite.
//
// If z is an ordinary variable name and x is not subsequently assigned to,
// references to x can be replaced by z and the assignment deleted.
-// We only bother if x and z are the same name.
+// We only bother if x and z are the same name.
// If y is not subsequently assigned to and neither is x, references to
// y can be replaced by its expression. We only bother when there is
// just one use or when the use appears in an if clause.
//
// Because the type check assignment includes a type assertion in its
// syntax and the rewrite traversal is bottom up, we must do a pass to
-// rewrite the type check assignments and then a separate pass to
+// rewrite the type check assignments and then a separate pass to
// rewrite the type assertions.
//
// The same process applies to the API changes for reflect.Value.
//
// For both cases, but especially Value, the code needs to be aware
// of the type of a receiver when rewriting a method call. For example,
-// x.(*reflect.ArrayValue).Elem(i) becomes x.Index(i) while
+// x.(*reflect.ArrayValue).Elem(i) becomes x.Index(i) while
// x.(*reflect.MapValue).Elem(v) becomes x.MapIndex(v).
// In general, reflectFn needs to know the type of the receiver expression.
// In most cases (and in all the cases in the Go source tree), the toy
//
// The fact that it is partial is very important: the input is
// an AST and a description of some type information to
-// assume about one or more packages, but not all the
+// assume about one or more packages, but not all the
// packages that the program imports. The checker is
// expected to do as much as it can with what it has been
// given. There is not enough information supplied to do
// not worry about other processes inheriting the fd accidentally.
// The answer is that running a command is fork and exec.
// A child forked while the cgo fd is open inherits that fd.
- // Until the child has called exec, it holds the fd open and the
+ // Until the child has called exec, it holds the fd open and the
// kernel will not let us run cgo. Even if the child were to close
// the fd explicitly, it would still be open from the time of the fork
// until the time of the explicit close, and the race would remain.
bar.a (installed package object)
Go searches each directory listed in GOPATH to find source code,
-but new packages are always downloaded into the first directory
+but new packages are always downloaded into the first directory
in the list.
Otherwise, the import path P denotes the package found in
the directory DIR/src/P for some DIR listed in the GOPATH
-environment variable (see 'go help gopath').
+environment variable (see 'go help gopath').
If no import paths are given, the action applies to the
package in the current directory.
The special import path "all" expands to all package directories
-found in all the GOPATH trees. For example, 'go list all'
+found in all the GOPATH trees. For example, 'go list all'
lists all the packages on the local system.
The special import path "std" is like all but expands to just the
if strings.Contains(a, "...") {
var expand []string
// Use matchPackagesInFS to avoid printing
- // warnings. They will be printed by the
+ // warnings. They will be printed by the
// eventual call to importPaths instead.
if build.IsLocalImport(a) {
expand = matchPackagesInFS(a)
f, value, extraWord := testFlag(args, i)
if f == nil {
// This is a flag we do not know; we must assume
- // that any args we see after this might be flag
+ // that any args we see after this might be flag
// arguments, not package names.
inPkg = false
if packageNames == nil {
Height int // = DirList.MaxHeight - Depth, > 0
Path string // directory path; includes Name, relative to DirList root
Name string // directory name
- HasPkg bool // true if the directory contains at least one package
+ HasPkg bool // true if the directory contains at least one package
Synopsis string // package documentation, if any
}
// paths can assume they are slash-separated and should be using
// package path (often imported as pathpkg) to manipulate them,
// even on Windows.
-//
+//
var fs = nameSpace{} // the underlying file system for godoc
// Setting debugNS = true will enable debugging prints about
// but we want to be able to mount multiple file systems on a single
// mount point and have the system behave as if the union of those
// file systems were present at the mount point.
-// For example, if the OS file system has a Go installation in
+// For example, if the OS file system has a Go installation in
// c:\Go and additional Go path trees in d:\Work1 and d:\Work2, then
// this name space creates the view we want for the godoc server:
//
// OS(`d:\Work1').ReadDir("/src/code")
// OS(`d:\Work2').ReadDir("/src/code")
//
-// Note that the "/src/pkg" in "/src/pkg/code" has been replaced by
+// Note that the "/src/pkg" in "/src/pkg/code" has been replaced by
// just "/src" in the final two calls.
//
// OS is itself an implementation of a file system: it implements
} else {
// we have a selection change:
// format the previous selection segment, determine
- // the new selection bitset and start a new segment
+ // the new selection bitset and start a new segment
segment(offs)
lastOffs = offs
mask := 1 << uint(index)
// license that can be found in the LICENSE file.
// Template support for writing HTML documents.
-// Documents that include Template: true in their
+// Documents that include Template: true in their
// metadata are executed as input to text/template.
//
// This file defines functions for those templates to invoke.
It prints the name list (symbol table) for programs compiled by gc as well as the
Plan 9 C compiler.
-This implementation adds the flag -S, which prints each symbol's size
+This implementation adds the flag -S, which prints each symbol's size
in decimal after its address.
Usage:
Non-standard signatures for methods with familiar names, including:
Format GobEncode GobDecode MarshalJSON MarshalXML
- Peek ReadByte ReadFrom ReadRune Scan Seek
+ Peek ReadByte ReadFrom ReadRune Scan Seek
UnmarshalJSON UnreadByte UnreadRune WriteByte
WriteTo
}
// CreateHeader adds a file to the zip file using the provided FileHeader
-// for the file metadata.
+// for the file metadata.
// It returns a Writer to which the file contents should be written.
// The file's contents must be written to the io.Writer before the next
// call to Create, CreateHeader, or Close.
var makeFieldsInput = func() []byte {
x := make([]byte, 1<<20)
- // Input is ~10% space, ~10% 2-byte UTF-8, rest ASCII non-space.
+ // Input is ~10% space, ~10% 2-byte UTF-8, rest ASCII non-space.
for i := range x {
switch rand.Intn(10) {
case 0:
err error
}
-// newBitReader returns a new bitReader reading from r. If r is not
+// newBitReader returns a new bitReader reading from r. If r is not
// already an io.ByteReader, it will be converted via a bufio.Reader.
func newBitReader(r io.Reader) bitReader {
byter, ok := r.(io.ByteReader)
}
type PrecomputedValues struct {
- Dp, Dq *big.Int // D mod (P-1) (or mod Q-1)
+ Dp, Dq *big.Int // D mod (P-1) (or mod Q-1)
Qinv *big.Int // Q^-1 mod Q
// CRTValues is used for the 3rd and subsequent primes. Due to a
// First message, be extra suspicious:
// this might not be a TLS client.
// Bail out before reading a full 'body', if possible.
- // The current max version is 3.1.
+ // The current max version is 3.1.
// If the version is >= 16.0, it's probably not real.
// Similarly, a clientHello message encodes in
// well under a kilobyte. If the length is >= 12 kB,
}
// Subjects returns a list of the DER-encoded subjects of
-// all of the certificates in the pool.
+// all of the certificates in the pool.
func (s *CertPool) Subjects() (res [][]byte) {
res = make([][]byte, len(s.certs))
for i, c := range s.certs {
"fmt"
)
-// pkcs8 reflects an ASN.1, PKCS#8 PrivateKey. See
+// pkcs8 reflects an ASN.1, PKCS#8 PrivateKey. See
// ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-8/pkcs-8v1_2.asn.
type pkcs8 struct {
Version int
//
// pkcs-1 OBJECT IDENTIFIER ::= {
// iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) 1 }
-//
-//
+//
+//
// RFC 3279 2.2.1 RSA Signature Algorithms
//
// md2WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 2 }
// md5WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 4 }
//
// sha-1WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 5 }
-//
+//
// dsaWithSha1 OBJECT IDENTIFIER ::= {
-// iso(1) member-body(2) us(840) x9-57(10040) x9cm(4) 3 }
+// iso(1) member-body(2) us(840) x9-57(10040) x9cm(4) 3 }
//
// RFC 3279 2.2.3 ECDSA Signature Algorithm
-//
+//
// ecdsa-with-SHA1 OBJECT IDENTIFIER ::= {
// iso(1) member-body(2) us(840) ansi-x962(10045)
// signatures(4) ecdsa-with-SHA1(1)}
//
//
// RFC 4055 5 PKCS #1 Version 1.5
-//
+//
// sha256WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 11 }
//
// sha384WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 12 }
return true
}
-// sendType sends the type info to the other side, if necessary.
+// sendType sends the type info to the other side, if necessary.
func (enc *Encoder) sendType(w io.Writer, state *encoderState, origt reflect.Type) (sent bool) {
ut := userType(origt)
if ut.isGobEncoder {
//
// Anonymous struct fields are usually marshaled as if their inner exported fields
// were fields in the outer struct, subject to the usual Go visibility rules.
-// An anonymous struct field with a name given in its JSON tag is treated as
+// An anonymous struct field with a name given in its JSON tag is treated as
// having that name instead of as anonymous.
//
// Handling of anonymous struct fields is new in Go 1.1.
)
// parseDoctype parses the data from a DoctypeToken into a name,
-// public identifier, and system identifier. It returns a Node whose Type
+// public identifier, and system identifier. It returns a Node whose Type
// is DoctypeNode, whose Data is the name, and which has attributes
// named "system" and "public" for the two identifiers if they were present.
// quirks is whether the document should be parsed in "quirks mode".
"unicode/utf8"
)
-// These replacements permit compatibility with old numeric entities that
+// These replacements permit compatibility with old numeric entities that
// assumed Windows-1252 encoding.
// http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#consume-a-character-reference
var replacementTable = [...]rune{
'\u009D',
'\u017E',
'\u0178', // Last entry is 0x9F.
- // 0x00->'\uFFFD' is handled programmatically.
+ // 0x00->'\uFFFD' is handled programmatically.
// 0x0D->'\u000D' is a no-op.
}
return p.doc, nil
}
-// ParseFragment parses a fragment of HTML and returns the nodes that were
+// ParseFragment parses a fragment of HTML and returns the nodes that were
// found. If the fragment is the InnerHTML for an existing element, pass that
// element in context.
func ParseFragment(r io.Reader, context *Node) ([]*Node, error) {
// children; the <a> is reparented to the <table>'s parent. However, calling
// Parse on "<a><table><a>" does not return an error, but the result has an <a>
// element with an <a> child, and is therefore not 'well-formed'.
-//
+//
// Programmatically constructed trees are typically also 'well-formed', but it
// is possible to construct a tree that looks innocuous but, when rendered and
// re-parsed, results in a different tree. A simple example is that a solitary
return buf.Flush()
}
-// plaintextAbort is returned from render1 when a <plaintext> element
+// plaintextAbort is returned from render1 when a <plaintext> element
// has been rendered. No more end tags should be rendered after that.
var plaintextAbort = errors.New("html: internal error (plaintext abort)")
}
// readRawEndTag attempts to read a tag like "</foo>", where "foo" is z.rawTag.
-// If it succeeds, it backs up the input position to reconsume the tag and
+// If it succeeds, it backs up the input position to reconsume the tag and
// returns true. Otherwise it returns false. The opening "</" has already been
// consumed.
func (z *Tokenizer) readRawEndTag() bool {
// compacted.
// - Compress secondary weights into 8 bits.
// - Some LDML specs specify a context element. Currently we simply concatenate
-// those. Context can be implemented using the contraction trie. If Builder
+// those. Context can be implemented using the contraction trie. If Builder
// could analyze and detect when using a context makes sense, there is no
// need to expose this construct in the API.
}
}
-// Tailoring returns a Tailoring for the given locale. One should
+// Tailoring returns a Tailoring for the given locale. One should
// have completed all calls to Add before calling Tailoring.
func (b *Builder) Tailoring(locale string) *Tailoring {
t := &Tailoring{
return t
}
-// Add adds an entry to the collation element table, mapping
+// Add adds an entry to the collation element table, mapping
// a slice of runes to a sequence of collation elements.
// A collation element is specified as list of weights: []int{primary, secondary, ...}.
// The entries are typically obtained from a collation element table
// See http://www.unicode.org/reports/tr10/#Tailoring_Example for details
// on parametric tailoring and http://unicode.org/reports/tr35/#Collation_Elements
// for full details on LDML.
-//
+//
// Examples: create a tailoring for Swedish, where "ä" is ordered after "z"
// at the primary sorting level:
// t := b.Tailoring("se")
return expandID + uint32(index), nil
}
-// Each list of collation elements corresponding to an expansion starts with
+// Each list of collation elements corresponding to an expansion starts with
// a header indicating the length of the sequence.
func makeExpansionHeader(n int) (uint32, error) {
return uint32(n), nil
return int(r) + otherOffset
}
-// convertLargeWeights converts collation elements with large
+// convertLargeWeights converts collation elements with large
// primaries (either double primaries or for illegal runes)
// to our own representation.
// A CJK character C is represented in the DUCET as
// This file contains code for detecting contractions and generating
// the necessary tables.
// Any Unicode Collation Algorithm (UCA) table entry that has more than
-// one rune one the left-hand side is called a contraction.
+// one rune one the left-hand side is called a contraction.
// See http://www.unicode.org/reports/tr10/#Contractions for more details.
//
// We define the following terms:
// A rune may be both a initial and a non-initial and may be so in
// many contractions. An initial may typically also appear by itself.
// In case of ambiguities, the UCA requires we match the longest
-// contraction.
+// contraction.
//
// Many contraction rules share the same set of possible suffixes.
// We store sets of suffixes in a trie that associates an index with
// is represented as a subsequence of ctEntries, where each entry corresponds to
// a possible match of a next character in the search string. An entry
// also includes the length and offset to the next sequence of entries
-// to check in case of a match.
+// to check in case of a match.
const (
final = 0
noIndex = 0xFF
)
-// ctEntry associates to a matching byte an offset and/or next sequence of
+// ctEntry associates to a matching byte an offset and/or next sequence of
// bytes to check. A ctEntry c is called final if a match means that the
// longest suffix has been found. An entry c is final if c.n == 0.
// A single final entry can match a range of characters to an offset.
// {'a', 1, 1, noIndex}, // 'a' by itself does not match, so i is 0xFF.
// {'b', 'c', 0, 1}, // "ab" -> 1, "ac" -> 2
// }
-//
+//
// The suffix strings "ab", "abc", "abd", and "abcd" can be represented as:
// []ctEntry{
// {'a', 1, 1, noIndex}, // 'a' must be followed by 'b'.
l uint8 // non-final: byte value to match; final: lowest match in range.
h uint8 // non-final: relative index to next block; final: highest match in range.
n uint8 // non-final: length of next block; final: final
- i uint8 // result offset. Will be noIndex if more bytes are needed to complete.
+ i uint8 // result offset. Will be noIndex if more bytes are needed to complete.
}
// contractTrieSet holds a set of contraction tries. The tries are stored
// The trie in this file is used to associate the first full character
// in a UTF-8 string to a collation element.
-// All but the last byte in a UTF-8 byte sequence are
+// All but the last byte in a UTF-8 byte sequence are
// used to look up offsets in the index table to be used for the next byte.
// The last byte is used to index into a table of collation elements.
// This file contains the code for the generation of the trie.
"testing"
)
-// We take the smallest, largest and an arbitrary value for each
+// We take the smallest, largest and an arbitrary value for each
// of the UTF-8 sequence lengths.
var testRunes = []rune{
0x01, 0x0C, 0x7F, // 1-byte sequences
// AlternateHandling identifies the various ways in which variables are handled.
// A rune with a primary weight lower than the variable top is considered a
-// variable.
+// variable.
// See http://www.unicode.org/reports/tr10/#Variable_Weighting for details.
type AlternateHandling int
return &nt
}
-// appendNext appends the weights corresponding to the next rune or
+// appendNext appends the weights corresponding to the next rune or
// contraction in s. If a contraction is matched to a discontinuous
-// sequence of runes, the weights for the interstitial runes are
+// sequence of runes, the weights for the interstitial runes are
// appended as well. It returns a new slice that includes the appended
// weights and the number of bytes consumed from s.
func (t *table) appendNext(w []weights, s []byte) ([]weights, int) {
// The trie in this file is used to associate the first full character
// in an UTF-8 string to a collation element.
-// All but the last byte in a UTF-8 byte sequence are
+// All but the last byte in a UTF-8 byte sequence are
// used to lookup offsets in the index table to be used for the next byte.
// The last byte is used to index into a table of collation elements.
// For a full description, see exp/locale/collate/build/trie.go.
"testing"
)
-// We take the smallest, largest and an arbitrary value for each
+// We take the smallest, largest and an arbitrary value for each
// of the UTF-8 sequence lengths.
var testRunes = []rune{
0x01, 0x0C, 0x7F, // 1-byte sequences
// We do not distinguish between boundaries for NFC, NFD, etc. to avoid
// unexpected behavior for the user. For example, in NFD, there is a boundary
// after 'a'. However, 'a' might combine with modifiers, so from the application's
-// perspective it is not a good boundary. We will therefore always use the
+// perspective it is not a good boundary. We will therefore always use the
// boundaries for the combining variants.
// BoundaryBefore returns true if this rune starts a new segment and
// 0: NFD_QC Yes (0) or No (1). No also means there is a decomposition.
// 1..2: NFC_QC Yes(00), No (10), or Maybe (11)
// 3: Combines forward (0 == false, 1 == true)
-//
+//
// When all 4 bits are zero, the character is inert, meaning it is never
// influenced by normalization.
type qcInfo uint8
}
// Next writes f(i.input[i.Pos():n]...) to buffer buf, where n is the
-// largest boundary of i.input such that the result fits in buf.
+// largest boundary of i.input such that the result fits in buf.
// It returns the number of bytes written to buf.
-// len(buf) should be at least MaxSegmentSize.
+// len(buf) should be at least MaxSegmentSize.
// Done must be false before calling Next.
func (i *Iter) Next(buf []byte) int {
return i.next(i, buf)
// Quick Check properties of runes allow us to quickly
// determine whether a rune may occur in a normal form.
// For a given normal form, a rune may be guaranteed to occur
-// verbatim (QC=Yes), may or may not combine with another
+// verbatim (QC=Yes), may or may not combine with another
// rune (QC=Maybe), or may not occur (QC=No).
type QCResult int
printTestTables()
}
-// We take the smallest, largest and an arbitrary value for each
+// We take the smallest, largest and an arbitrary value for each
// of the UTF-8 sequence lengths.
var testRunes = []rune{
0x01, 0x0C, 0x7F, // 1-byte sequences
// 1E0A;1E0A;0044 0307;1E0A;0044 0307; # (Ḋ; Ḋ; D◌̇; Ḋ; D◌̇; ) LATIN CAPITAL LETTER D WITH DOT ABOVE
// 1E0C;1E0C;0044 0323;1E0C;0044 0323; # (Ḍ; Ḍ; D◌̣; Ḍ; D◌̣; ) LATIN CAPITAL LETTER D WITH DOT BELOW
//
-// Each test has 5 columns (c1, c2, c3, c4, c5), where
+// Each test has 5 columns (c1, c2, c3, c4, c5), where
// (c1, c2, c3, c4, c5) == (c1, NFC(c1), NFD(c1), NFKC(c1), NFKD(c1))
//
// CONFORMANCE:
// required to represent the constant, independent of actual
// type. Non-numeric constants are always normalized.
-// Representation of complex numbers.
+// Representation of complex numbers.
type complex struct {
re, im *big.Rat
}
// matchConst returns the matching representation (same type) with the
// smallest complexity for two constant values x and y. They must be
// of the same "kind" (boolean, numeric, string, or nilType).
-//
+//
func matchConst(x, y interface{}) (_, _ interface{}) {
if complexity(x) > complexity(y) {
y, x = matchConst(y, x)
switch typ := x.typ.(type) {
case *Struct:
if fld := lookupField(typ, e.Sel.Name); fld != nil {
- // TODO(gri) only variable if struct is variable
+ // TODO(gri) only variable if struct is variable
x.mode = variable
x.expr = e
x.typ = fld.Type
return buf.String()
}
-// setConst sets x to the untyped constant for literal lit.
+// setConst sets x to the untyped constant for literal lit.
func (x *operand) setConst(tok token.Token, lit string) {
x.mode = invalid
%X base 16, with upper-case letters for A-F
%U Unicode format: U+1234; same as "U+%04X"
Floating-point and complex constituents:
- %b decimalless scientific notation with exponent a power of two,
- in the manner of strconv.FormatFloat with the 'b' format,
+ %b decimalless scientific notation with exponent a power of two,
+ in the manner of strconv.FormatFloat with the 'b' format,
e.g. -123456p-78
%e scientific notation, e.g. -1234.456e+78
%E scientific notation, e.g. -1234.456E+78
return s
}
-// Errorf formats according to a format specifier and returns the string
+// Errorf formats according to a format specifier and returns the string
// as a value that satisfies error.
func Errorf(format string, a ...interface{}) error {
return errors.New(Sprintf(format, a...))
ReadRune() (r rune, size int, err error)
// UnreadRune causes the next call to ReadRune to return the same rune.
UnreadRune() error
- // SkipSpace skips space in the input. Newlines are treated as space
- // unless the scan operation is Scanln, Fscanln or Sscanln, in which case
+ // SkipSpace skips space in the input. Newlines are treated as space
+ // unless the scan operation is Scanln, Fscanln or Sscanln, in which case
// a newline is treated as EOF.
SkipSpace()
// Token skips space in the input if skipSpace is true, then returns the
return !isSpace(r)
}
-// skipSpace provides Scan() methods the ability to skip space and newline characters
+// skipSpace provides Scan() methods the ability to skip space and newline characters
// in keeping with the current scanning mode set by format strings and Scan()/Scanln().
func (s *ss) SkipSpace() {
s.skipSpace(false)
// A nodeStack keeps track of nested nodes.
// A node lower on the stack lexically contains the nodes higher on the stack.
-//
+//
type nodeStack []Node
// push pops all nodes that appear lexically before n
// pop pops all nodes that appear lexically before pos
// (i.e., whose lexical extent has ended before or at pos).
// It returns the last node popped.
-//
+//
func (s *nodeStack) pop(pos token.Pos) (top Node) {
i := len(*s)
for i > 0 && (*s)[i-1].End() <= pos {
if path := imp.Path.Value; !seen[path] {
// TODO: consider handling cases where:
// - 2 imports exist with the same import path but
- // have different local names (one should probably
+ // have different local names (one should probably
// keep both of them)
// - 2 imports exist but only one has a comment
// - 2 imports exist and they both have (possibly
// An Importer must determine the canonical import path and
// check the map to see if it is already present in the imports map.
// If so, the Importer can return the map entry. Otherwise, the
-// Importer should load the package data for the given path into
+// Importer should load the package data for the given path into
// a new *Object (pkg), record pkg in the imports map, and then
// return pkg.
type Importer func(imports map[string]*Object, path string) (pkg *Object, err error)
// be used as dependencies by other rules.
//
// DO NOT CHANGE THIS DATA TO FIX BUILDS.
-//
+//
var pkgDeps = map[string][]string{
// L0 is the lowest level, core, nearly unavoidable packages.
"errors": {},
// As in the Go tree, each target operating system and
// architecture pair has its own subdirectory of pkg
// (pkg/GOOS_GOARCH).
-//
+//
// If DIR is a directory listed in the Go path, a package with
// source in DIR/src/foo/bar can be imported as "foo/bar" and
// has its compiled form installed to "DIR/pkg/GOOS_GOARCH/foo/bar.a"
// (or, for gccgo, "DIR/pkg/gccgo/foo/libbar.a").
-//
+//
// The bin/ directory holds compiled commands.
// Each command is named for its source directory, but only
// using the final element, not the entire path. That is, the
// DIR/bin/quux, not DIR/bin/foo/quux. The foo/ is stripped
// so that you can add DIR/bin to your PATH to get at the
// installed commands.
-//
+//
// Here's an example directory layout:
-//
+//
// GOPATH=/home/user/gocode
-//
+//
// /home/user/gocode/
// src/
// foo/
}
// heading returns the trimmed line if it passes as a section heading;
-// otherwise it returns the empty string.
+// otherwise it returns the empty string.
func heading(line string) string {
line = strings.TrimSpace(line)
if len(line) == 0 {
return nil
}
- // Find unresolved identifiers
+ // Find unresolved identifiers
unresolved := make(map[string]bool)
ast.Inspect(body, func(n ast.Node) bool {
// For an expression like fmt.Println, only add "fmt" to the
return &f
}
-// stripOutputComment finds and removes an "Output:" commment from body
+// stripOutputComment finds and removes an "Output:" commment from body
// and comments, and adjusts the body block's end position.
func stripOutputComment(body *ast.BlockStmt, comments []*ast.CommentGroup) (*ast.BlockStmt, []*ast.CommentGroup) {
// Do nothing if no "Output:" comment found.
// filterType strips any unexported struct fields or method types from typ
// in place. If fields (or methods) have been removed, the corresponding
-// struct or interface type has the Incomplete field set to true.
+// struct or interface type has the Incomplete field set to true.
//
func (r *reader) filterType(parent *namedType, typ ast.Expr) {
switch t := typ.(type) {
// since it has documentation, assume f is simply another
// implementation and ignore it. This does not happen if the
// caller is using go/build.ScanDir to determine the list of
- // files implementing a package.
+ // files implementing a package.
return
}
// function doesn't exist or has no documentation; use f
// types that have no declaration. Instead, these functions and methods
// are shown at the package level. It also removes types with missing
// declarations or which are not visible.
-//
+//
func (r *reader) cleanupTypes() {
for _, t := range r.types {
visible := r.isVisible(t.name)
*u5
}
-// U4.M should appear as method of U4.
+// U4.M should appear as method of U4.
func (*U4) M() {}
type u5 struct {
c.FailNow()
}
-// Parallel signals that this test is to be run in parallel with (and only with)
+// Parallel signals that this test is to be run in parallel with (and only with)
// other parallel tests in this CPU group.
func (t *T) Parallel() {
t.signal <- (*T)(nil) // Release main testing loop
t.start = time.Now()
// When this goroutine is done, either because test.F(t)
- // returned normally or because a test failure triggered
+ // returned normally or because a test failure triggered
// a call to runtime.Goexit, record the duration and send
// a signal saying that the test is done.
defer func() {
// ParseExpr is a convenience function for obtaining the AST of an expression x.
// The position information recorded in the AST is undefined.
-//
+//
func ParseExpr(x string) (ast.Expr, error) {
// parse x within the context of a complete package for correct scopes;
// use //line directive for correct positions in error messages and put
// license that can be found in the LICENSE file.
// This file implements a simple printer performance benchmark:
-// go test -bench=BenchmarkPrint
+// go test -bench=BenchmarkPrint
package printer
// 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 returns true if the position is valid.
// Iterate calls f for the files in the file set in the order they were added
// until f returns false.
-//
+//
func (s *FileSet) Iterate(f func(*File) bool) {
for i := 0; ; i++ {
var file *File
WriteString(string) (int, error)
}
-// These replacements permit compatibility with old numeric entities that
+// These replacements permit compatibility with old numeric entities that
// assumed Windows-1252 encoding.
// http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#consume-a-character-reference
var replacementTable = [...]rune{
'\u009D',
'\u017E',
'\u0178', // Last entry is 0x9F.
- // 0x00->'\uFFFD' is handled programmatically.
+ // 0x00->'\uFFFD' is handled programmatically.
// 0x0D->'\u000D' is a no-op.
}
HTMLAttr string
// JS encapsulates a known safe EcmaScript5 Expression, for example,
- // `(x + y * z())`.
+ // `(x + y * z())`.
// Template authors are responsible for ensuring that typed expressions
// do not break the intended precedence and that there is no
// statement/expression ambiguity as when passing an expression like
//
// {{define "main"}} <script>{{template "helper"}}</script> {{end}}
// {{define "helper"}} document.write(' <div title=" ') {{end}}
- //
+ //
// "helper" does not produce a valid document fragment, so should
// not be Executed directly.
ErrEndContext
// In the example, there is missing a quote, so it is not clear
// whether {{.}} is meant to be inside a JS string or in a JS value
// context. The second iteration would produce something like
- //
+ //
// <script>var x = ['firstValue,'secondValue]</script>
ErrRangeLoopReentry
'<': "<",
'=': "=",
'>': ">",
- // A parse error in the attribute value (unquoted) and
+ // A parse error in the attribute value (unquoted) and
// before attribute value states.
// Treated as a quoting character by IE.
'`': "`",
'<': "<",
'=': "=",
'>': ">",
- // A parse error in the attribute value (unquoted) and
+ // A parse error in the attribute value (unquoted) and
// before attribute value states.
// Treated as a quoting character by IE.
'`': "`",
if repl := replacementTable[r]; len(repl) != 0 {
b.WriteString(s[written:i])
b.WriteString(repl)
- // Valid as long as replacementTable doesn't
+ // Valid as long as replacementTable doesn't
// include anything above 0x7f.
written = i + utf8.RuneLen(r)
}
if precisionSet {
switch {
case len(digits) < precision:
- zeroes = precision - len(digits) // count of zero padding
+ zeroes = precision - len(digits) // count of zero padding
case digits == "0" && precision == 0:
return // print nothing if zero value (x == 0) and zero precision ("." or ".0")
}
z[2*k:].clear() // upper portion of z is garbage (and 2*k <= m+n since k <= n <= m)
// If xh != 0 or yh != 0, add the missing terms to z. For
- //
- // xh = xi*b^i + ... + x2*b^2 + x1*b (0 <= xi < b)
- // yh = y1*b (0 <= y1 < b)
- //
- // the missing terms are
- //
- // x0*y1*b and xi*y0*b^i, xi*y1*b^(i+1) for i > 0
- //
- // since all the yi for i > 1 are 0 by choice of k: If any of them
- // were > 0, then yh >= b^2 and thus y >= b^2. Then k' = k*2 would
- // be a larger valid threshold contradicting the assumption about k.
+ //
+ // xh = xi*b^i + ... + x2*b^2 + x1*b (0 <= xi < b)
+ // yh = y1*b (0 <= y1 < b)
+ //
+ // the missing terms are
+ //
+ // x0*y1*b and xi*y0*b^i, xi*y1*b^(i+1) for i > 0
+ //
+ // since all the yi for i > 1 are 0 by choice of k: If any of them
+ // were > 0, then yh >= b^2 and thus y >= b^2. Then k' = k*2 would
+ // be a larger valid threshold contradicting the assumption about k.
//
if k < n || m != n {
var t nat
// by nat/nat division using tabulated divisors. Otherwise, it is converted iteratively using
// repeated nat/Word divison.
//
-// The iterative method processes n Words by n divW() calls, each of which visits every Word in the
-// incrementally shortened q for a total of n + (n-1) + (n-2) ... + 2 + 1, or n(n+1)/2 divW()'s.
-// Recursive conversion divides q by its approximate square root, yielding two parts, each half
+// The iterative method processes n Words by n divW() calls, each of which visits every Word in the
+// incrementally shortened q for a total of n + (n-1) + (n-2) ... + 2 + 1, or n(n+1)/2 divW()'s.
+// Recursive conversion divides q by its approximate square root, yielding two parts, each half
// the size of q. Using the iterative method on both halves means 2 * (n/2)(n/2 + 1)/2 divW()'s
// plus the expensive long div(). Asymptotically, the ratio is favorable at 1/2 the divW()'s, and
-// is made better by splitting the subblocks recursively. Best is to split blocks until one more
-// split would take longer (because of the nat/nat div()) than the twice as many divW()'s of the
-// iterative approach. This threshold is represented by leafSize. Benchmarking of leafSize in the
-// range 2..64 shows that values of 8 and 16 work well, with a 4x speedup at medium lengths and
-// ~30x for 20000 digits. Use nat_test.go's BenchmarkLeafSize tests to optimize leafSize for
+// is made better by splitting the subblocks recursively. Best is to split blocks until one more
+// split would take longer (because of the nat/nat div()) than the twice as many divW()'s of the
+// iterative approach. This threshold is represented by leafSize. Benchmarking of leafSize in the
+// range 2..64 shows that values of 8 and 16 work well, with a 4x speedup at medium lengths and
+// ~30x for 20000 digits. Use nat_test.go's BenchmarkLeafSize tests to optimize leafSize for
// specific hardware.
//
func (q nat) convertWords(s []byte, charset string, b Word, ndigits int, bb Word, table []divisor) {
}
}
-// allocBytes returns the number of bytes allocated by invoking f.
+// allocBytes returns the number of bytes allocated by invoking f.
func allocBytes(f func()) uint64 {
var stats runtime.MemStats
runtime.ReadMemStats(&stats)
func BenchmarkLeafSize14(b *testing.B) { LeafSizeHelper(b, 10, 14) }
func BenchmarkLeafSize15(b *testing.B) { LeafSizeHelper(b, 10, 15) }
func BenchmarkLeafSize16(b *testing.B) { LeafSizeHelper(b, 10, 16) }
-func BenchmarkLeafSize32(b *testing.B) { LeafSizeHelper(b, 10, 32) } // try some large lengths
+func BenchmarkLeafSize32(b *testing.B) { LeafSizeHelper(b, 10, 32) } // try some large lengths
func BenchmarkLeafSize64(b *testing.B) { LeafSizeHelper(b, 10, 64) }
func LeafSizeHelper(b *testing.B, base Word, size int) {
// on our 386 builder, this Dial succeeds, connecting
// to an IIS web server somewhere. The data center
// or VM or firewall must be stealing the TCP connection.
- //
+ //
// IANA Service Name and Transport Protocol Port Number Registry
// <http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xml>
go func() {
}
// shuffleByWeight shuffles SRV records by weight using the algorithm
-// described in RFC 2782.
+// described in RFC 2782.
func (addrs byPriorityWeight) shuffleByWeight() {
sum := 0
for _, addr := range addrs {
log.Fatal(err)
}
for {
- // Wait for a connection.
+ // Wait for a connection.
conn, err := l.Accept()
if err != nil {
log.Fatal(err)
"testing"
)
-// Issue 3590. netFd.AddFD should return an error
+// Issue 3590. netFd.AddFD should return an error
// from the underlying pollster rather than panicing.
func TestAddFDReturnsError(t *testing.T) {
l, err := Listen("tcp", "127.0.0.1:0")
var ErrLineTooLong = errors.New("header line too long")
// newChunkedReader returns a new chunkedReader that translates the data read from r
-// out of HTTP "chunked" format before returning it.
+// out of HTTP "chunked" format before returning it.
// The chunkedReader returns io.EOF when the final 0-length chunk is read.
//
// newChunkedReader is not needed by normal applications. The http package
Expires time.Time
RawExpires string
- // MaxAge=0 means no 'Max-Age' attribute specified.
+ // MaxAge=0 means no 'Max-Age' attribute specified.
// MaxAge<0 means delete cookie now, equivalently 'Max-Age: 0'
// MaxAge>0 means Max-Age attribute present and given in seconds
MaxAge int
func TestReadCookies(t *testing.T) {
for i, tt := range readCookiesTests {
- for n := 0; n < 2; n++ { // to verify readCookies doesn't mutate its input
+ for n := 0; n < 2; n++ { // to verify readCookies doesn't mutate its input
c := readCookies(tt.Header, tt.Filter)
if !reflect.DeepEqual(c, tt.Cookies) {
t.Errorf("#%d readCookies:\nhave: %s\nwant: %s\n", i, toJSON(c), toJSON(tt.Cookies))
var ErrLineTooLong = errors.New("header line too long")
// NewChunkedReader returns a new chunkedReader that translates the data read from r
-// out of HTTP "chunked" format before returning it.
+// out of HTTP "chunked" format before returning it.
// The chunkedReader returns io.EOF when the final 0-length chunk is read.
//
// NewChunkedReader is not needed by normal applications. The http package
{"[::2]", true}, // not a loopback address
{"barbaz.net", false}, // match as .barbaz.net
- {"foobar.com", false}, // have a port but match
+ {"foobar.com", false}, // have a port but match
{"foofoobar.com", true}, // not match as a part of foobar.com
{"baz.com", true}, // not match as a part of barbaz.com
{"localhost.net", true}, // not match as suffix of address
}
func TestMultipartRequest(t *testing.T) {
- // Test that we can read the values and files of a
+ // Test that we can read the values and files of a
// multipart request with FormValue and FormFile,
// and that ParseMultipartForm can be called multiple times.
req := newTestMultipartRequest(t)
l.Close()
}
-// TestIdentityResponse verifies that a handler can unset
+// TestIdentityResponse verifies that a handler can unset
func TestIdentityResponse(t *testing.T) {
handler := HandlerFunc(func(rw ResponseWriter, req *Request) {
rw.Header().Set("Content-Length", "3")
// license that can be found in the LICENSE file.
// HTTP client implementation. See RFC 2616.
-//
+//
// This is the low-level Transport implementation of RoundTripper.
// The high-level interface is in client.go.
// requested it.
requestedGzip := false
if !pc.t.DisableCompression && req.Header.Get("Accept-Encoding") == "" {
- // Request gzip only, not deflate. Deflate is ambiguous and
+ // Request gzip only, not deflate. Deflate is ambiguous and
// not as universally supported anyway.
// See: http://www.gzip.org/zlib/zlib_faq.html#faq38
requestedGzip = true
return DialHTTPPath(network, address, DefaultRPCPath)
}
-// DialHTTPPath connects to an HTTP RPC server
+// DialHTTPPath connects to an HTTP RPC server
// at the specified network address and path.
func DialHTTPPath(network, address, path string) (*Client, error) {
var err error
return server.register(rcvr, "", false)
}
-// RegisterName is like Register but uses the provided name for the type
+// RegisterName is like Register but uses the provided name for the type
// instead of the receiver's concrete type.
func (server *Server) RegisterName(name string, rcvr interface{}) error {
return server.register(rcvr, name, true)
// Register publishes the receiver's methods in the DefaultServer.
func Register(rcvr interface{}) error { return DefaultServer.Register(rcvr) }
-// RegisterName is like Register but uses the provided name for the type
+// RegisterName is like Register but uses the provided name for the type
// instead of the receiver's concrete type.
func RegisterName(name string, rcvr interface{}) error {
return DefaultServer.RegisterName(name, rcvr)
}
// Accept accepts connections on the listener and serves requests
-// to DefaultServer for each incoming connection.
+// to DefaultServer for each incoming connection.
// Accept blocks; the caller typically invokes it in a go statement.
func Accept(lis net.Listener) { DefaultServer.Accept(lis) }
// Test cases and expected results for the attemping 2nd listen on the same port
// 1st listen 2nd listen darwin freebsd linux openbsd
// ------------------------------------------------------------------------------------
- // "tcp" "" "tcp" "" - - - -
- // "tcp" "" "tcp" "0.0.0.0" - - - -
- // "tcp" "0.0.0.0" "tcp" "" - - - -
+ // "tcp" "" "tcp" "" - - - -
+ // "tcp" "" "tcp" "0.0.0.0" - - - -
+ // "tcp" "0.0.0.0" "tcp" "" - - - -
// ------------------------------------------------------------------------------------
// "tcp" "" "tcp" "[::]" - - - ok
// "tcp" "[::]" "tcp" "" - - - ok
// all messages <=N have been seen by the recipient. We check anyway.
expLog("sequence out of order:", client.ackNum, hdr.SeqNum)
}
- if client.ackNum < hdr.SeqNum { // If there has been an error, don't back up the count.
+ if client.ackNum < hdr.SeqNum { // If there has been an error, don't back up the count.
client.ackNum = hdr.SeqNum
}
client.mu.Unlock()
}
// Null assigns members of d with special "don't care" values indicating
-// they should not be written by syscall.Wstat.
+// they should not be written by syscall.Wstat.
func (d *dir) Null() {
*d = nullDir
}
// pdir appends a 9P Stat message based on the contents of Dir d to a byte slice b.
func pdir(b []byte, d *dir) []byte {
n := len(b)
- b = pbit16(b, 0) // length, filled in later
+ b = pbit16(b, 0) // length, filled in later
b = pbit16(b, d.Type)
b = pbit32(b, d.Dev)
b = pqid(b, d.Qid)
return &SyscallError{syscall, err}
}
-// IsExist returns whether the error is known to report that a file or directory
+// IsExist returns whether the error is known to report that a file or directory
// already exists. It is satisfied by ErrExist as well as some syscall errors.
func IsExist(err error) bool {
return isExist(err)
// Args holds command line arguments, including the command as Args[0].
// If the Args field is empty or nil, Run uses {Path}.
- //
+ //
// In typical use, both Path and Args are set by calling Command.
Args []string
// if a call that takes a file name fails, such as Open or Stat, the error
// will include the failing file name when printed and will be of type
// *PathError, which may be unpacked for more information.
-//
+//
// The os interface is intended to be uniform across all operating systems.
// Features not generally available appear in the system-specific package syscall.
//
return fs
}
-// arg is an open *File or a path string.
+// arg is an open *File or a path string.
func dirstat(arg interface{}) (d *dir, err error) {
var name string
*/
import "C"
-// Current returns the current user.
+// Current returns the current user.
func Current() (*User, error) {
return lookup(syscall.Getuid(), "", false)
}
// prefix; that is, if Walk is called with "dir", which is a directory
// containing the file "a", the walk function will be called with argument
// "dir/a". The info argument is the os.FileInfo for the named path.
-//
+//
// If there was a problem walking to the file or directory named by path, the
// incoming error will describe the problem and the function can decide how
// to handle that error (and Walk will not descend into that directory). If
return vol + dir
}
-// VolumeName returns leading volume name.
+// VolumeName returns leading volume name.
// Given "C:\foo\bar" it returns "C:" under windows.
// Given "\\host\share\foo" it returns "\\host\share".
// On other platforms it returns "".
// selectWatch and the selectWatcher are a watchdog mechanism for running Select.
// If the selectWatcher notices that the select has been blocked for >1 second, it prints
-// an error describing the select and panics the entire test binary.
+// an error describing the select and panics the entire test binary.
var selectWatch struct {
sync.Mutex
once sync.Once
}
}
{
- // convert channel direction
+ // convert channel direction
m := make(map[<-chan int]chan int)
mv := ValueOf(m)
c1 := make(chan int)
// PkgPath is the package path that qualifies a lower case (unexported)
// method name. It is empty for upper case (exported) method names.
// The combination of PkgPath and Name uniquely identifies a method
- // in a method set.
+ // in a method set.
// See http://golang.org/ref/spec#Uniqueness_of_identifiers
Name string
PkgPath string
}
// CallSlice calls the variadic function v with the input arguments in,
-// assigning the slice in[len(in)-1] to v's final variadic argument.
+// assigning the slice in[len(in)-1] to v's final variadic argument.
// For example, if len(in) == 3, v.Call(in) represents the Go call v(in[0], in[1], in[2]...).
// Call panics if v's Kind is not Func or if v is not variadic.
// It returns the output results as Values.
if safe && v.flag&flagRO != 0 {
// Do not allow access to unexported values via Interface,
- // because they might be pointers that should not be
+ // because they might be pointers that should not be
// writable or methods or function that should not be callable.
panic("reflect.Value.Interface: cannot return value obtained from unexported field or method")
}
default:
panic("reflect.Select: invalid Dir")
- case SelectDefault: // default
+ case SelectDefault: // default
if haveDefault {
panic("reflect.Select: multiple default cases")
}
// implementation. If the first character is not [BEASKLP] then the
// specification is a global control line. One or more of [BEASKLP] may be
// specified; the test will be repeated for each mode.
- //
+ //
// B basic BRE (grep, ed, sed)
// E REG_EXTENDED ERE (egrep)
// A REG_AUGMENTED ARE (egrep with negation)
// S REG_SHELL SRE (sh glob)
// K REG_SHELL|REG_AUGMENTED KRE (ksh glob)
// L REG_LITERAL LRE (fgrep)
- //
+ //
// a REG_LEFT|REG_RIGHT implicit ^...$
// b REG_NOTBOL lhs does not match ^
// c REG_COMMENT ignore space and #...\n
// $ expand C \c escapes in fields 2 and 3
// / field 2 is a regsubcomp() expression
// = field 3 is a regdecomp() expression
- //
+ //
// Field 1 control lines:
- //
+ //
// C set LC_COLLATE and LC_CTYPE to locale in field 2
- //
+ //
// ?test ... output field 5 if passed and != EXPECTED, silent otherwise
// &test ... output field 5 if current and previous passed
// |test ... output field 5 if current passed and previous failed
// ; ... output field 2 if previous failed
// {test ... skip if failed until }
// } end of skip
- //
+ //
// : comment comment copied as output NOTE
// :comment:test :comment: ignored
// N[OTE] comment comment copied as output NOTE
// T[EST] comment comment
- //
+ //
// number use number for nmatch (20 by default)
flag := field[0]
switch flag[0] {
// Field 2: the regular expression pattern; SAME uses the pattern from
// the previous specification.
- //
+ //
if field[1] == "SAME" {
field[1] = lastRegexp
}
// append, Expand replaces variables in the template with corresponding
// matches drawn from src. The match slice should have been returned by
// FindSubmatchIndex.
-//
+//
// In the template, a variable is denoted by a substring of the form
// $name or ${name}, where name is a non-empty sequence of letters,
// digits, and underscores. A purely numeric name like $1 refers to
// capturing parentheses named with the (?P<name>...) syntax. A
// reference to an out of range or unmatched index or a name that is not
// present in the regular expression is replaced with an empty slice.
-//
+//
// In the $name form, name is taken to be as long as possible: $1x is
// equivalent to ${1x}, not ${1}x, and, $10 is equivalent to ${10}, not ${1}0.
-//
+//
// To insert a literal $ in the output, use $$ in the template.
func (re *Regexp) Expand(dst []byte, template []byte, src []byte, match []int) []byte {
return re.expand(dst, string(template), src, "", match)
// Because the pointers haven't been filled in yet, we can reuse their storage
// to hold the list. It's kind of sleazy, but works well in practice.
// See http://swtch.com/~rsc/regexp/regexp1.html for inspiration.
-//
+//
// These aren't really pointers: they're integers, so we can reinterpret them
// this way without using package unsafe. A value l denotes
-// p.inst[l>>1].Out (l&1==0) or .Arg (l&1==1).
+// p.inst[l>>1].Out (l&1==0) or .Arg (l&1==1).
// l == 0 denotes the empty list, okay because we start every program
// with a fail instruction, so we'll never want to point at its output link.
type patchList uint32
// Construct factored form: prefix(suffix1|suffix2|...)
prefix := first
for j := start; j < i; j++ {
- reuse := j != start // prefix came from sub[start]
+ reuse := j != start // prefix came from sub[start]
sub[j] = p.removeLeadingRegexp(sub[j], reuse)
}
suffix := p.collapse(sub[start:i], OpAlternate) // recurse
import "unsafe"
-// Note: the MemStats struct should be kept in sync with
+// Note: the MemStats struct should be kept in sync with
// struct MStats in malloc.h
// A MemStats records statistics about the memory allocator.
"unsafe"
)
-// RaceDisable disables handling of race events in the current goroutine.
+// RaceDisable disables handling of race events in the current goroutine.
func RaceDisable()
-// RaceEnable re-enables handling of race events in the current goroutine.
+// RaceEnable re-enables handling of race events in the current goroutine.
func RaceEnable()
func RaceAcquire(addr unsafe.Pointer)
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// Test stack split logic by calling functions of every frame size
+// Test stack split logic by calling functions of every frame size
// from near 0 up to and beyond the default segment size (4k).
// Each of those functions reports its SP + stack limit, and then
// the test (the caller) checks that those make sense. By not
import "testing"
-// arm soft division benchmarks adapted from
+// arm soft division benchmarks adapted from
// http://ridiculousfish.com/files/division_benchmarks.tar.gz
const numeratorsSize = 1 << 21
package sort
// Search uses binary search to find and return the smallest index i
-// in [0, n) at which f(i) is true, assuming that on the range [0, n),
+// in [0, n) at which f(i) is true, assuming that on the range [0, n),
// f(i) == true implies f(i+1) == true. That is, Search requires that
// f is false for some (possibly empty) prefix of the input range [0, n)
// and then true for the (possibly empty) remainder; Search returns
// SearchFloat64s searches for x in a sorted slice of float64s and returns the index
// as specified by Search. The slice must be sorted in ascending order.
-//
+//
func SearchFloat64s(a []float64, x float64) int {
return Search(len(a), func(i int) bool { return a[i] >= x })
}
// SearchStrings searches for x in a sorted slice of strings and returns the index
// as specified by Search. The slice must be sorted in ascending order.
-//
+//
func SearchStrings(a []string, x string) int {
return Search(len(a), func(i int) bool { return a[i] >= x })
}
panic("strconv: internal error: extFloat.FixedDecimal called with n == 0")
}
// Multiply by an appropriate power of ten to have a reasonable
- // number to process.
+ // number to process.
f.Normalize()
exp10, _ := f.frexp10()
return false
}
-// adjustLastDigit modifies d = x-currentDiff*ε, to get closest to
+// adjustLastDigit modifies d = x-currentDiff*ε, to get closest to
// d = x-targetDiff*ε, without becoming smaller than x-maxDiff*ε.
// It assumes that a decimal digit is worth ulpDecimal*ε, and that
// all data is known with a error estimate of ulpBinary*ε.
var makeFieldsInput = func() string {
x := make([]byte, 1<<20)
- // Input is ~10% space, ~10% 2-byte UTF-8, rest ASCII non-space.
+ // Input is ~10% space, ~10% 2-byte UTF-8, rest ASCII non-space.
for i := range x {
switch rand.Intn(10) {
case 0:
}
}
- // Allocate child status pipe close on exec.
+ // Allocate child status pipe close on exec.
e = cexecPipe(p[:])
if e != nil {
}
func Gettimeofday(tv *Timeval) (err error) {
- // TODO(paulzhol):
+ // TODO(paulzhol):
// avoid reopening a file descriptor for /dev/bintime on each call,
// use lower-level calls to avoid allocation.
char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
};
-// copied from /usr/include/linux/un.h
+// copied from /usr/include/linux/un.h
struct my_sockaddr_un {
sa_family_t sun_family;
#ifdef __ARM_EABI__
-// mksysnum_freebsd.pl
+// mksysnum_freebsd.pl
// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
package syscall
-// mksysnum_freebsd.pl
+// mksysnum_freebsd.pl
// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
package syscall
-// mksysnum_freebsd.pl
+// mksysnum_freebsd.pl
// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
package syscall
-// mksysnum_linux.pl
+// mksysnum_linux.pl
// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
package syscall
-// mksysnum_netbsd.pl
+// mksysnum_netbsd.pl
// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
package syscall
-// mksysnum_netbsd.pl
+// mksysnum_netbsd.pl
// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
package syscall
-// mksysnum_openbsd.pl
+// mksysnum_openbsd.pl
// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
package syscall
-// mksysnum_openbsd.pl
+// mksysnum_openbsd.pl
// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
package syscall
// func BenchmarkXxx(*testing.B)
// are considered benchmarks, and are executed by the "go test" command when
// the -test.bench flag is provided. Benchmarks are run sequentially.
-//
+//
// For a description of the testing flags, see
// http://golang.org/cmd/go/#Description_of_testing_flags.
//
c.FailNow()
}
-// Parallel signals that this test is to be run in parallel with (and only with)
+// Parallel signals that this test is to be run in parallel with (and only with)
// other parallel tests in this CPU group.
func (t *T) Parallel() {
t.signal <- (*T)(nil) // Release main testing loop
t.start = time.Now()
// When this goroutine is done, either because test.F(t)
- // returned normally or because a test failure triggered
+ // returned normally or because a test failure triggered
// a call to runtime.Goexit, record the duration and send
// a signal saying that the test is done.
defer func() {
// Output:
// Dear Aunt Mildred,
- //
+ //
// It was a pleasure to see you at the wedding.
// Thank you for the lovely bone china tea set.
- //
+ //
// Best wishes,
// Josie
- //
+ //
// Dear Uncle John,
- //
+ //
// It is a shame you couldn't make it to the wedding.
// Thank you for the lovely moleskin pants.
- //
+ //
// Best wishes,
// Josie
- //
+ //
// Dear Cousin Rodney,
- //
+ //
// It is a shame you couldn't make it to the wedding.
- //
+ //
// Best wishes,
// Josie
}
// 42 off[4]
// 46 name[namelen]
// 46+namelen+xlen+fclen - next header
- //
+ //
if get4(buf) != zcheader {
break
}
// BUG(brainman,rsc): On Windows, the operating system does not provide complete
// time zone information.
// The implementation assumes that this year's rules for daylight savings
-// time apply to all previous and future years as well.
+// time apply to all previous and future years as well.
// Also, time zone abbreviations are unavailable. The implementation constructs
-// them using the capital letters from a longer time zone description.
+// them using the capital letters from a longer time zone description.
// abbrev returns the abbreviation to use for the given zone name.
func abbrev(name []uint16) string {
// SimpleFold iterates over Unicode code points equivalent under
// the Unicode-defined simple case folding. Among the code points
// equivalent to rune (including rune itself), SimpleFold returns the
-// smallest rune >= r if one exists, or else the smallest rune >= 0.
+// smallest rune >= r if one exists, or else the smallest rune >= 0.
//
// For example:
// SimpleFold('A') = 'a'
// Running 'go test -calibrate' runs the calibration to find a plausible
// cutoff point for linear search of a range list vs. binary search.
// We create a fake table and then time how long it takes to do a
-// sequence of searches within that table, for all possible inputs
+// sequence of searches within that table, for all possible inputs
// relative to the ranges (something before all, in each, between each, after all).
// This assumes that all possible runes are equally likely.
// In practice most runes are ASCII so this is a conservative estimate