Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions acme/Watch/sig_generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !linux && !darwin && !freebsd && !netbsd && !openbsd && !solaris
// +build !linux,!darwin,!freebsd,!netbsd,!openbsd,!solaris

package main
Expand Down
1 change: 1 addition & 0 deletions acme/Watch/sig_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build linux || darwin || freebsd || netbsd || openbsd || solaris
// +build linux darwin freebsd netbsd openbsd solaris

package main
Expand Down
14 changes: 7 additions & 7 deletions acme/acme.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ func Open(id int, ctl *client.Fid) (*Win, error) {
}

// Addr writes format, ... to the window's addr file.
func (w *Win) Addr(format string, args ...interface{}) error {
func (w *Win) Addr(format string, args ...any) error {
return w.Fprintf("addr", format, args...)
}

Expand Down Expand Up @@ -300,7 +300,7 @@ func (w *Win) CloseFiles() {
}

// Ctl writes the command format, ... to the window's ctl file.
func (w *Win) Ctl(format string, args ...interface{}) error {
func (w *Win) Ctl(format string, args ...any) error {
return w.Fprintf("ctl", format+"\n", args...)
}

Expand Down Expand Up @@ -373,7 +373,7 @@ func (w *Win) ID() int {
return w.id
}

func (w *Win) Name(format string, args ...interface{}) error {
func (w *Win) Name(format string, args ...any) error {
name := fmt.Sprintf(format, args...)
if err := w.Ctl("name %s", name); err != nil {
return err
Expand All @@ -382,7 +382,7 @@ func (w *Win) Name(format string, args ...interface{}) error {
return nil
}

func (w *Win) Fprintf(file, format string, args ...interface{}) error {
func (w *Win) Fprintf(file, format string, args ...any) error {
f, err := w.fid(file)
if err != nil {
return err
Expand Down Expand Up @@ -962,7 +962,7 @@ func (w *Win) Err(msg string) {
Err(w.errorPrefix, msg)
}

func (w *Win) Errf(format string, args ...interface{}) {
func (w *Win) Errf(format string, args ...any) {
w.Err(fmt.Sprintf(format, args...))
}

Expand Down Expand Up @@ -999,7 +999,7 @@ func Err(src, msg string) {
}

// Errf is like Err but accepts a printf-style formatting.
func Errf(src, format string, args ...interface{}) {
func Errf(src, format string, args ...any) {
Err(src, fmt.Sprintf(format, args...))
}

Expand All @@ -1011,7 +1011,7 @@ func Errf(src, format string, args ...interface{}) {
// String fields are expected to be space terminated.
//
// It returns the rest of line after all the fields have been parsed.
func splitFields(line string, fields ...interface{}) (string, error) {
func splitFields(line string, fields ...any) (string, error) {
n := 0
for len(fields) > 0 {
switch f := fields[0].(type) {
Expand Down
1 change: 1 addition & 0 deletions acme/acme_p9p.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !plan9
// +build !plan9

package acme
Expand Down
1 change: 0 additions & 1 deletion acme/acmego/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
//
// .rs - rustfmt
// .py - yapf
//
package main

import (
Expand Down
2 changes: 1 addition & 1 deletion cmd/acme/dat.h.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ type Fid struct {
}

type Xfid struct {
arg interface{}
arg any
fcall *plan9.Fcall
next *Xfid
c chan func(*Xfid)
Expand Down
2 changes: 1 addition & 1 deletion cmd/acme/internal/addr/addr.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func regexp(showerr bool, t runes.Text, lim runes.Range, r runes.Range, pat []ru
return sel.R[0]
}

func Eval(showerr bool, t runes.Text, lim runes.Range, ar runes.Range, a interface{}, q0 int, q1 int, getc func(interface{}, int) rune, evalp *bool, qp *int) runes.Range {
func Eval(showerr bool, t runes.Text, lim runes.Range, ar runes.Range, a any, q0 int, q1 int, getc func(any, int) rune, evalp *bool, qp *int) runes.Range {
r := ar
q := q0
dir := None
Expand Down
2 changes: 1 addition & 1 deletion cmd/acme/internal/alog/alog.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func Init(w func(string)) {
warn = w
}

func Printf(format string, args ...interface{}) {
func Printf(format string, args ...any) {
s := fmt.Sprintf(format, args...)
if s != "" && s[len(s)-1] != '\n' {
s += "\n"
Expand Down
4 changes: 2 additions & 2 deletions cmd/acme/internal/bufs/buf.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const Len = 32 * 1024
const RuneLen = Len / runes.RuneSize

var runesPool = sync.Pool{
New: func() interface{} { return make([]rune, RuneLen) },
New: func() any { return make([]rune, RuneLen) },
}

func AllocRunes() []rune {
Expand All @@ -25,7 +25,7 @@ func FreeRunes(buf []rune) {
}

var bytesPool = sync.Pool{
New: func() interface{} { return make([]byte, Len) },
New: func() any { return make([]byte, Len) },
}

func AllocBytes() []byte {
Expand Down
6 changes: 3 additions & 3 deletions cmd/acme/internal/disk/buff.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (b *Buffer) Read(q0 int, s []rune) {

for n > 0 {
b.setCache(q0)
m := util.Min(n, len(b.c)-(q0-b.cq))
m := min(n, len(b.c)-(q0-b.cq))
copy(s[:m], b.c[q0-b.cq:])
q0 += m
s = s[m:]
Expand Down Expand Up @@ -150,7 +150,7 @@ func (b *Buffer) Insert(q0 int, s []rune) {
if b.cdirty {
b.flushCache()
}
m = util.Min(n, maxblock)
m = min(n, maxblock)
var i int
if b.bl == nil { /* allocate */
if len(b.c) != 0 {
Expand Down Expand Up @@ -184,7 +184,7 @@ func (b *Buffer) Insert(q0 int, s []rune) {
* Now at end of block. Take as much input
* as possible and tack it on end of block.
*/
m = util.Min(n, maxblock-len(b.c))
m = min(n, maxblock-len(b.c))
n := len(b.c)
b.resizeCache(n + m)
copy(b.c[n:], s)
Expand Down
9 changes: 4 additions & 5 deletions cmd/acme/internal/dump/rows1.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"9fans.net/go/cmd/acme/internal/bufs"
"9fans.net/go/cmd/acme/internal/fileload"
"9fans.net/go/cmd/acme/internal/ui"
"9fans.net/go/cmd/acme/internal/util"
"9fans.net/go/cmd/acme/internal/wind"
"9fans.net/go/draw"
)
Expand Down Expand Up @@ -73,7 +72,7 @@ func Dump(row *wind.Row, file *string) {
}
}
dumpid := make(map[*wind.File]int)
m := util.Min(bufs.RuneLen, row.Tag.Len())
m := min(bufs.RuneLen, row.Tag.Len())
row.Tag.File.Read(0, r[:m])
n := 0
for n < m && r[n] != '\n' {
Expand All @@ -82,7 +81,7 @@ func Dump(row *wind.Row, file *string) {
fmt.Fprintf(b, "w %s\n", string(r[:n]))
for i = 0; i < len(row.Col); i++ {
c = row.Col[i]
m = util.Min(bufs.RuneLen, c.Tag.Len())
m = min(bufs.RuneLen, c.Tag.Len())
c.Tag.File.Read(0, r[:m])
n = 0
for n < m && r[n] != '\n' {
Expand Down Expand Up @@ -138,7 +137,7 @@ func Dump(row *wind.Row, file *string) {
fmt.Fprintf(b, "F%11d %11d %11d %11d %11.7f %11d %s\n", i, j, w.Body.Q0, w.Body.Q1, 100.0*float64(w.R.Min.Y-c.R.Min.Y)/float64(c.R.Dy()), w.Body.Len(), fontname)
}
b.WriteString(wind.Winctlprint(w, false))
m = util.Min(bufs.RuneLen, w.Tag.Len())
m = min(bufs.RuneLen, w.Tag.Len())
w.Tag.File.Read(0, r[:m])
if !containsRune(r[:m], '|') {
alog.Printf("dump: window %d has no | in tag %q!", w.ID, string(r[:m]))
Expand Down Expand Up @@ -535,7 +534,7 @@ func Load(row *wind.Row, file *string, initing bool) bool {
q0 = q1
}
wind.Textshow(&w.Body, q0, q1, true)
w.Maxlines = util.Min(w.Body.Fr.NumLines, util.Max(w.Maxlines, w.Body.Fr.MaxLines))
w.Maxlines = min(w.Body.Fr.NumLines, max(w.Maxlines, w.Body.Fr.MaxLines))
OnNewWindow(w)
}
return true
Expand Down
10 changes: 5 additions & 5 deletions cmd/acme/internal/edit/ecmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ type Looper struct {

var loopstruct Looper // only one; X and Y can't nest

func alllooper(w *wind.Window, v interface{}) {
func alllooper(w *wind.Window, v any) {
lp := v.(*Looper)
cp := lp.cp
// if(w->isscratch || w->isdir)
Expand All @@ -870,7 +870,7 @@ func alllooper(w *wind.Window, v interface{}) {
}
}

func alllocker(w *wind.Window, v interface{}) {
func alllocker(w *wind.Window, v any) {
if v.(bool) {
util.Incref(&w.Ref)
} else {
Expand Down Expand Up @@ -1073,7 +1073,7 @@ type Tofile struct {
r *String
}

func alltofile(w *wind.Window, v interface{}) {
func alltofile(w *wind.Window, v any) {
tp := v.(*Tofile)
if tp.f != nil {
return
Expand Down Expand Up @@ -1106,7 +1106,7 @@ func tofile(r *String) *wind.File {
return t.f
}

func allmatchfile(w *wind.Window, v interface{}) {
func allmatchfile(w *wind.Window, v any) {
tp := v.(*Tofile)
if w.IsScratch || w.IsDir {
return
Expand Down Expand Up @@ -1256,7 +1256,7 @@ type Filecheck struct {
r []rune
}

func allfilecheck(w *wind.Window, v interface{}) {
func allfilecheck(w *wind.Window, v any) {
fp := v.(*Filecheck)
f := w.Body.File
if w.Body.File == fp.f {
Expand Down
8 changes: 4 additions & 4 deletions cmd/acme/internal/edit/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,18 @@ func editthread() {
editerrc <- ""
}

func allelogterm(w *wind.Window, x interface{}) {
func allelogterm(w *wind.Window, x any) {
if ef := elogfind(w.Body.File); ef != nil {
elogterm(ef)
}
}

func alleditinit(w *wind.Window, x interface{}) {
func alleditinit(w *wind.Window, x any) {
wind.Textcommit(&w.Tag, true)
wind.Textcommit(&w.Body, true)
}

func allupdate(w *wind.Window, x interface{}) {
func allupdate(w *wind.Window, x any) {
t := &w.Body
if t.File.Curtext != t { // do curtext only
return
Expand All @@ -143,7 +143,7 @@ func allupdate(w *wind.Window, x interface{}) {
wind.Winsettag(w)
}

func editerror(format string, args ...interface{}) {
func editerror(format string, args ...any) {
s := fmt.Sprintf(format, args...)
freecmd()
wind.All(allelogterm, nil) // truncate the edit logs
Expand Down
5 changes: 2 additions & 3 deletions cmd/acme/internal/edit/elog.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"9fans.net/go/cmd/acme/internal/disk"
"9fans.net/go/cmd/acme/internal/runes"
"9fans.net/go/cmd/acme/internal/ui"
"9fans.net/go/cmd/acme/internal/util"
"9fans.net/go/cmd/acme/internal/wind"
)

Expand Down Expand Up @@ -359,8 +358,8 @@ func elogapply(f *elogFile) {
if !warned {
alog.Printf("elogapply: can't happen %d %d %d\n", t.Q0, t.Q1, f.Len())
}
t.Q1 = util.Min(t.Q1, f.Len())
t.Q0 = util.Min(t.Q0, t.Q1)
t.Q1 = min(t.Q1, f.Len())
t.Q0 = min(t.Q0, t.Q1)
}

if t.W != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/acme/internal/exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ func indentval(s []rune) int {
return Ioff
}

func fixindent(w *wind.Window, arg interface{}) {
func fixindent(w *wind.Window, arg any) {
w.Autoindent = wind.GlobalAutoindent
}

Expand Down
9 changes: 4 additions & 5 deletions cmd/acme/internal/ui/look.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"9fans.net/go/cmd/acme/internal/alog"
"9fans.net/go/cmd/acme/internal/bufs"
"9fans.net/go/cmd/acme/internal/runes"
"9fans.net/go/cmd/acme/internal/util"
"9fans.net/go/cmd/acme/internal/wind"
"9fans.net/go/draw"
"9fans.net/go/plan9/client"
Expand Down Expand Up @@ -179,7 +178,7 @@ func Search(ct *wind.Text, r []rune) bool {
alog.Printf("string too long\n") // TODO(rsc): why???????
return false
}
maxn := util.Max(2*len(r), bufs.RuneLen)
maxn := max(2*len(r), bufs.RuneLen)
s := bufs.AllocRunes()
b := s[:0]
around := 0
Expand Down Expand Up @@ -525,13 +524,13 @@ type Expand struct {
Name []rune
Bname string
Jump bool
Arg interface{}
Agetc func(interface{}, int) rune
Arg any
Agetc func(any, int) rune
A0 int
A1 int
}

func tgetc(a interface{}, n int) rune {
func tgetc(a any, n int) rune {
t := a.(*wind.Text)
if n >= t.Len() {
return 0
Expand Down
8 changes: 4 additions & 4 deletions cmd/acme/internal/ui/text.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import (
var Textcomplete func(*wind.Text) []rune

func Textconstrain(t *wind.Text, q0 int, q1 int, p0 *int, p1 *int) {
*p0 = util.Min(q0, t.Len())
*p1 = util.Min(q1, t.Len())
*p0 = min(q0, t.Len())
*p1 = min(q1, t.Len())
}

func Texttype(t *wind.Text, r rune) {
Expand Down Expand Up @@ -482,8 +482,8 @@ func Textselect(t *wind.Text) {
}
}

var BigLock = func(){}
var BigUnlock = func(){}
var BigLock = func() {}
var BigUnlock = func() {}

/*
* Release the button in less than DELAY ms and it's considered a null selection
Expand Down
14 changes: 0 additions & 14 deletions cmd/acme/internal/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,6 @@ import (
"sync/atomic"
)

func Min(a int, b int) int {
if a < b {
return a
}
return b
}

func Max(a int, b int) int {
if a > b {
return a
}
return b
}

func Fatal(s string) {
log.Fatalf("acme: %s\n", s)
}
Expand Down
Loading