Permalink
Browse files

Minor update to WOS search, run gofmt

  • Loading branch information...
1 parent 5f06655 commit 3c15915e88517b04f243f383837b262666da3721 ��� committed Mar 30, 2012
View
2 .gitignore
@@ -1,3 +1 @@
-*~
-gospeccy
scripts/startup_local*
View
3 src/gospeccy/gospeccy.go
@@ -35,6 +35,7 @@ import (
"github.com/remogatto/gospeccy/src/formats"
"github.com/remogatto/gospeccy/src/interpreter"
"github.com/remogatto/gospeccy/src/spectrum"
+ "net/url"
"os"
pathutil "path"
"runtime"
@@ -270,7 +271,7 @@ func main() {
}
} else if *wos != "" {
var records []spectrum.WosRecord
- records, err := spectrum.WosQuery(app, *wos)
+ records, err := spectrum.WosQuery(app, "regexp="+url.QueryEscape(strings.Replace(*wos, " ", "*", -1)))
if err != nil {
app.PrintfMsg("%s", err)
exit(app)
View
9 src/interpreter/functions.go
@@ -7,6 +7,8 @@ import (
"github.com/remogatto/gospeccy/src/formats"
"github.com/remogatto/gospeccy/src/spectrum"
"io/ioutil"
+ "net/url"
+ "strings"
"time"
)
@@ -247,7 +249,7 @@ func wrapper_wait(t *eval.Thread, in []eval.Value, out []eval.Value) {
func wrapper_script(t *eval.Thread, in []eval.Value, out []eval.Value) {
scriptName := in[0].(eval.StringValue).Get(t)
- err := runScript(w, scriptName, /*optional*/ false)
+ err := runScript(w, scriptName, false /*optional*/)
if err != nil {
fmt.Fprintf(stdout, "%s\n", err)
return
@@ -258,7 +260,7 @@ func wrapper_script(t *eval.Thread, in []eval.Value, out []eval.Value) {
func wrapper_optionalScript(t *eval.Thread, in []eval.Value, out []eval.Value) {
scriptName := in[0].(eval.StringValue).Get(t)
- err := runScript(w, scriptName, /*optional*/ true)
+ err := runScript(w, scriptName, true /*optional*/)
if err != nil {
fmt.Fprintf(stdout, "%s\n", err)
return
@@ -346,9 +348,10 @@ func wrapper_wosFind(t *eval.Thread, in []eval.Value, out []eval.Value) {
}
pattern := in[0].(eval.StringValue).Get(t)
+ pattern = strings.Replace(pattern, " ", "*", -1)
var records []spectrum.WosRecord
- records, err := spectrum.WosQuery(app, pattern)
+ records, err := spectrum.WosQuery(app, "regexp="+url.QueryEscape(pattern))
if err != nil {
fmt.Fprintf(stdout, "%s", err)
View
4 src/interpreter/interpreter.go
@@ -209,7 +209,7 @@ func (i *Interpreter) compile(w *eval.World, fileSet *token.FileSet, sourceCode
// For each successfully found/verified variable, the variable's name is added to 'i.vars'.
func (i *Interpreter) tryToAddVars(w *eval.World, fileSet *token.FileSet, vars []string) {
for _, name := range vars {
- _, err := w.Compile(fileSet, /*sourceCode*/ name)
+ _, err := w.Compile(fileSet, name /*sourceCode*/)
if err == nil {
// The variable exists, add its name to 'i.vars'
i.vars[name] = true
@@ -281,7 +281,7 @@ func Init(_app *spectrum.Application, _cmdLineArg string, _speccy *spectrum.Spec
// Run the startup script
var err error
- err = runScript(w, STARTUP_SCRIPT, /*optional*/ IgnoreStartupScript)
+ err = runScript(w, STARTUP_SCRIPT, IgnoreStartupScript /*optional*/)
if err != nil {
app.PrintfMsg("%s", err)
app.RequestExit()
View
2 src/output/sdl/sdl.go
@@ -10,10 +10,10 @@ import (
"fmt"
"github.com/0xe2-0x9a-0x9b/Go-SDL/sdl"
"github.com/0xe2-0x9a-0x9b/Go-SDL/ttf"
+ "github.com/remogatto/clingon"
"github.com/remogatto/gospeccy/src/env"
"github.com/remogatto/gospeccy/src/interpreter"
"github.com/remogatto/gospeccy/src/spectrum"
- "github.com/remogatto/clingon"
"reflect"
"sync"
)
View
4 src/output/sdl/sdl_display.go
@@ -230,7 +230,7 @@ func (display *SDLScreen) render(screen *spectrum.DisplayData) {
screen.CompletionTime_orNil <- time.Now()
}
- SDL_updateRects(surface.surface, unscaledDisplay.changedRegions, /*scale*/ 1, display.updatedRectsCh)
+ SDL_updateRects(surface.surface, unscaledDisplay.changedRegions, 1 /*scale*/, display.updatedRectsCh)
unscaledDisplay.releaseMemory()
}
@@ -325,7 +325,7 @@ func (display *SDLScreen2x) render(screen *spectrum.DisplayData) {
screen.CompletionTime_orNil <- time.Now()
}
- SDL_updateRects(surface.surface, unscaledDisplay.changedRegions, /*scale*/ 2, display.updatedRectsCh)
+ SDL_updateRects(surface.surface, unscaledDisplay.changedRegions, 2 /*scale*/, display.updatedRectsCh)
unscaledDisplay.releaseMemory()
}
View
1 src/output/sdl/sdl_display_test.go
@@ -14,7 +14,6 @@ import (
//"unsafe"
)
-
// func (s *SDLSurface) At(x, y int) image.Color {
// var bpp = int(s.surface.Format.BytesPerPixel)
View
6 src/spectrum/helpers.go
@@ -137,7 +137,7 @@ func SystemRomPath(fileName string) (string, error) {
var (
currDir = "roms"
userDir = path.Join(DefaultUserDir, "roms")
- srcDir = path.Join(srcDir, "roms")
+ srcDir = path.Join(srcDir, "roms")
)
var paths []string
@@ -161,7 +161,7 @@ func ScriptPath(fileName string) (string, error) {
var (
currDir = "scripts"
userDir = path.Join(DefaultUserDir, "scripts")
- srcDir = path.Join(srcDir, "scripts")
+ srcDir = path.Join(srcDir, "scripts")
)
var paths []string
@@ -185,7 +185,7 @@ func FontPath(fileName string) (string, error) {
var (
currDir = "fonts"
userDir = path.Join(DefaultUserDir, "fonts")
- srcDir = path.Join(srcDir, "fonts")
+ srcDir = path.Join(srcDir, "fonts")
)
var paths []string
View
6 src/spectrum/wos.go
@@ -14,7 +14,7 @@ import (
var (
fileSuffixes = []string{".tap.zip", ".sna.zip", ".z80.zip"}
- queryBaseURL = "http://www.worldofspectrum.org/infoseek.cgi?regexp="
+ queryBaseURL = "http://www.worldofspectrum.org/infoseek.cgi?"
)
func knownType(filename string) bool {
@@ -40,7 +40,7 @@ func WosQuery(app *Application, query string) ([]WosRecord, error) {
client := new(http.Client)
query = queryBaseURL + query
if app.Verbose {
- app.PrintfMsg("Query string: %s", query)
+ app.PrintfMsg("WOS query: %s", query)
app.PrintfMsg("Fetching...")
}
response, err := client.Get(query)
@@ -54,7 +54,7 @@ func WosQuery(app *Application, query string) ([]WosRecord, error) {
return nil, err
}
if app.Verbose {
- app.PrintfMsg(response.Status)
+ app.PrintfMsg("Response status: %s", response.Status)
}
var matches []WosRecord
View
4 src/spectrum/z80.go
@@ -137,7 +137,7 @@ func NewZ80(memory MemoryAccessor, ports PortAccessor) *Z80 {
z80.iy = register16{&z80.iyh, &z80.iyl}
z80.de_ = register16{&z80.d_, &z80.e_}
- z80.perfCounter_hostCpuInstr, _ = perf.NewCounter_Instructions( /*user*/ true, /*kernel*/ false)
+ z80.perfCounter_hostCpuInstr, _ = perf.NewCounter_Instructions(true /*user*/, false /*kernel*/)
return z80
}
@@ -220,7 +220,7 @@ func (z80 *Z80) loadSnapshot(s formats.Snapshot) error {
z80.sp = cpu.SP
// Border color
- z80.ports.writePortInternal(0xfe, ula.Border&0x07, /*contend*/ false)
+ z80.ports.writePortInternal(0xfe, ula.Border&0x07, false /*contend*/)
// Populate memory
copy(z80.memory.Data()[0x4000:], mem[:])
View
6 src/spectrum/z80_test.go
@@ -279,7 +279,7 @@ func TestDoOpcodes(t *testing.T) {
// Instantiate a Z80 processor
z80 := NewZ80(&memory, &port)
ula := NewULA()
- z80.init(ula, /*tapeDrive_orNil*/ nil)
+ z80.init(ula, nil /*tapeDrive_orNil*/)
ula.init(z80, &memory, &port)
memory.z80 = z80
@@ -393,7 +393,7 @@ func TestDoOpcodes(t *testing.T) {
byte := memWrites[i]
if byte != "-1" {
value, _ := strconv.ParseUint(byte, 16, 0)
- z80.memory.Write(uint16(addr), uint8(value), /*protectROM*/ false)
+ z80.memory.Write(uint16(addr), uint8(value), false /*protectROM*/)
addr++
}
}
@@ -496,7 +496,7 @@ func BenchmarkZ80(b *testing.B) {
for i := 0; i < b.N; i++ {
speccy.CommandChannel <- Cmd_RenderFrame{CompletionTime_orNil: nil}
- //speccy.renderFrame(/*completionTime_orNil*/ nil)
+ //speccy.renderFrame(nil /*completionTime_orNil*/)
}
app.RequestExit()
View
4 src/test/test.go
@@ -3,11 +3,11 @@ package test
import (
"github.com/0xe2-0x9a-0x9b/Go-SDL/sdl"
"github.com/0xe2-0x9a-0x9b/Go-SDL/ttf"
+ "github.com/remogatto/clingon"
"github.com/remogatto/gospeccy/src/formats"
"github.com/remogatto/gospeccy/src/interpreter"
output "github.com/remogatto/gospeccy/src/output/sdl"
"github.com/remogatto/gospeccy/src/spectrum"
- "github.com/remogatto/clingon"
"github.com/remogatto/prettytest"
"io/ioutil"
)
@@ -246,7 +246,7 @@ Welcome to the GoSpeccy CLI Testing Mode
----------------------------------------
`)
}
- audio, err := output.NewSDLAudio(app, output.PLAYBACK_FREQUENCY, /*hqAudio*/ true)
+ audio, err := output.NewSDLAudio(app, output.PLAYBACK_FREQUENCY, true /*hqAudio*/)
if err == nil {
speccy.CommandChannel <- spectrum.Cmd_AddAudioReceiver{audio}
} else {

0 comments on commit 3c15915

Please sign in to comment.