Skip to content

Commit

Permalink
Display debugging and panic messages on Windows
Browse files Browse the repository at this point in the history
Debugging messages are displayed in popup windows.
Panic messages are saved and displayed on the next
invocation of editcp.
  • Loading branch information
Dale Farnsworth committed Oct 30, 2018
1 parent b43a84c commit 09fd042
Show file tree
Hide file tree
Showing 29 changed files with 430 additions and 1,339 deletions.
11 changes: 6 additions & 5 deletions codeplug/codeplug.go
Expand Up @@ -43,6 +43,7 @@ import (
"time"
"unicode"

l "github.com/dalefarnsworth/codeplug/debug"
"github.com/dalefarnsworth/codeplug/dfu"
"github.com/tealeg/xlsx"
)
Expand Down Expand Up @@ -142,7 +143,7 @@ func NewCodeplug(fType FileType, filename string) (*Codeplug, error) {
if !found {
matches, err := filepath.Glob(filename + "*")
if err != nil {
logFatal(err.Error())
l.Fatal(err.Error())
}
if len(matches) != 0 {
found = true
Expand All @@ -154,7 +155,7 @@ func NewCodeplug(fType FileType, filename string) (*Codeplug, error) {
}
}
default:
logFatal("unknown file type")
l.Fatal("unknown file type")
}

cp.filename = filename
Expand Down Expand Up @@ -547,14 +548,14 @@ func (cp *Codeplug) readNew(filename string) error {
if err == io.EOF {
break
}
logFatal(err)
l.Fatal(err)
}
if hdr.Name != filename {
continue
}
bytes, err = ioutil.ReadAll(tarfile)
if err != nil {
logFatal(err)
l.Fatal(err)
}
break
}
Expand Down Expand Up @@ -898,7 +899,7 @@ func (cp *Codeplug) RemoveRecord(r *Record) {
}
}
if index < 0 || index >= len(records) {
logFatal("removeRecord: bad record")
l.Fatal("removeRecord: bad record")
}

deleteRecord(&records, index)
Expand Down
82 changes: 0 additions & 82 deletions codeplug/debug_linux.go

This file was deleted.

97 changes: 0 additions & 97 deletions codeplug/debug_windows.go

This file was deleted.

16 changes: 9 additions & 7 deletions codeplug/field.go
Expand Up @@ -35,6 +35,8 @@ import (
"strings"
"time"
"unicode/utf8"

l "github.com/dalefarnsworth/codeplug/debug"
)

const invalidValueString = "=INVALID="
Expand Down Expand Up @@ -234,7 +236,7 @@ func (f *Field) listNames() []string {
r := f.record.codeplug.FindRecordByName(f.listRecordType, name)
fields := r.AllFields()
if len(fields) != 1 {
logFatal("deref: more than one field")
l.Fatal("deref: more than one field")
}
derefValues[i] = fields[0].String()
}
Expand Down Expand Up @@ -319,7 +321,7 @@ func (f *Field) Strings() []string {
strs = f.SpanStrings()

default:
logFatalf("f.Strings: unexpected f.valueType: %s", f.valueType)
l.Fatalf("f.Strings: unexpected f.valueType: %s", f.valueType)
}

return strs
Expand Down Expand Up @@ -1787,13 +1789,13 @@ func (v *listIndex) valid(f *Field) error {

func (v *listIndex) init(f *Field, str string) {
if len(str) < 1 || str[0:1] != "\000" {
logFatal("listIndex.init() invalid value")
l.Fatal("listIndex.init() invalid value")
}
str = removeSuffix(f, str[1:])

index64, err := strconv.ParseUint(str, 10, 16)
if err != nil {
logFatalf("listIndex ParseInt failure: %s", err.Error())
l.Fatalf("listIndex ParseInt failure: %s", err.Error())
}
index := int(index64)

Expand Down Expand Up @@ -2321,7 +2323,7 @@ func (f *Field) mustDeferValue(str string) bool {
return false
}
if f.isDeferredValue() {
logFatal("already deferred: ", f.FullTypeName())
l.Fatal("already deferred: ", f.FullTypeName())
}

switch f.valueType {
Expand All @@ -2348,7 +2350,7 @@ func (f *Field) mustDeferValue(str string) bool {

func (f *Field) deferValue(str string) {
if f.isDeferredValue() {
logFatal("already deferred: ", f.FullTypeName())
l.Fatal("already deferred: ", f.FullTypeName())
}

f.value = deferredValue{value: f.value, str: str}
Expand All @@ -2357,7 +2359,7 @@ func (f *Field) deferValue(str string) {
func (f *Field) undeferValue() {
dValue, deferred := f.value.(deferredValue)
if !deferred {
logFatal("undeferValue: not deferred: ", f.FullTypeName())
l.Fatal("undeferValue: not deferred: ", f.FullTypeName())
}

f.value = dValue.value
Expand Down
8 changes: 5 additions & 3 deletions codeplug/record.go
Expand Up @@ -30,6 +30,8 @@ import (
"sort"
"strconv"
"strings"

l "github.com/dalefarnsworth/codeplug/debug"
)

// A Record represents a record within a Codeplug.
Expand Down Expand Up @@ -431,7 +433,7 @@ func (r *Record) makeNameUnique() error {
}
n64, err := strconv.ParseInt(suffix, 10, 32)
if err != nil {
logFatal("trailing digits not numeric")
l.Fatal("trailing digits not numeric")
}
n := int(n64)

Expand Down Expand Up @@ -534,7 +536,7 @@ func (rd *rDesc) recordIsDeleted(cp *Codeplug, rIndex int) bool {
func (rd *rDesc) deleteRecord(cp *Codeplug, rIndex int) {
dd := rd.delDesc
if dd == nil {
logFatal("can't delete record %s", rd.records[rIndex])
l.Fatal("can't delete record %s", rd.records[rIndex])
}

offset := rd.offset + rIndex*rd.size + int(dd.offset)
Expand Down Expand Up @@ -605,7 +607,7 @@ func (r *Record) RemoveField(f *Field) {
}
}
if index < 0 {
logFatal("RemoveField: bad field")
l.Fatal("RemoveField: bad field")
}

deleteField(&fields, index)
Expand Down

0 comments on commit 09fd042

Please sign in to comment.