diff --git a/cmd/parse_line.go b/cmd/parse_line.go index 87029c4..c1c34b9 100644 --- a/cmd/parse_line.go +++ b/cmd/parse_line.go @@ -60,6 +60,7 @@ var regexpIsOMname = regexp.MustCompile("^@") var regexpIsGridLoc = regexp.MustCompile("^#") var regexpIsRst = regexp.MustCompile("^[\\d]{1,3}$") var regexpIsFreq = regexp.MustCompile("^[\\d]+\\.[\\d]+$") +var regexpIsSotaKeyWord = regexp.MustCompile("(?i)^sota") // ParseLine cuts a FLE line into useful bits func ParseLine(inputStr string, previousLine LogLine) (logLine LogLine, errorMsg string) { @@ -232,7 +233,13 @@ func ParseLine(inputStr string, previousLine LogLine) (logLine LogLine, errorMsg continue } - // Is it a WWFF to WWFF reference? + // If the "sota" keyword is used, skip it + if regexpIsSotaKeyWord.MatchString(element) { + // this keyword is not supported anymore with FLE 3 and doesn't add any value + continue + } + + // Is it a Summit to Summit (sota) reference? workRef, sotaErr := ValidateSota(element) if sotaErr == "" { logLine.SOTA = workRef diff --git a/cmd/parse_line_test.go b/cmd/parse_line_test.go index 1501a46..06e0c70 100644 --- a/cmd/parse_line_test.go +++ b/cmd/parse_line_test.go @@ -106,6 +106,11 @@ func TestParseLine(t *testing.T) { args{inputStr: "1230 on4kjm 5 599", previousLine: LogLine{Mode: "FM", ModeType: "PHONE"}}, LogLine{Call: "ON4KJM", Time: "1230", ActualTime: "1230", RSTsent: "55", RSTrcvd: "*599", Mode: "FM", ModeType: "PHONE"}, "Invalid report (599) for PHONE mode ", }, + { + "SOTA keywork ", + args{inputStr: "1230 oe6cud/p sota oe/st-309", previousLine: LogLine{Mode: "FM", ModeType: "PHONE"}}, + LogLine{Call: "OE6CUD/P", Time: "1230", ActualTime: "1230", RSTsent: "59", RSTrcvd: "59", Mode: "FM", ModeType: "PHONE", SOTA: "OE/ST-309"}, "", + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/cmd/validate.go b/cmd/validate.go index c95a2f1..e6c1ff1 100644 --- a/cmd/validate.go +++ b/cmd/validate.go @@ -50,7 +50,7 @@ func ValidateWwff(inputStr string) (ref, errorMsg string) { } var validCallRegexp = regexp.MustCompile(`[\d]{0,1}[A-Z]{1,2}\d([A-Z]{1,4}|\d{3,3}|\d{1,3}[A-Z])[A-Z]{0,5}`) -var validPrefixRegexp = regexp.MustCompile(`\A\d?[a-zA-Z]{1,2}$`) +var validPrefixRegexp = regexp.MustCompile(`\A[a-zA-Z0-9]{1,3}$`) // ValidateCall verifies whether the supplied string is a valid callsign. // prefix and suffix are not checked for validity diff --git a/cmd/validate_test.go b/cmd/validate_test.go index a6cba3e..c9083a2 100644 --- a/cmd/validate_test.go +++ b/cmd/validate_test.go @@ -182,7 +182,17 @@ func TestValidateCall(t *testing.T) { args{sign: "DL/on4KJm/qrpp "}, "DL/ON4KJM/QRPP", "", }, - //Error cases + { + "Valid prefix (issue #2)", + args{sign: "e7/z35m/p"}, + "E7/Z35M/P", "", + }, + { + "Valid E7 callsign (issue #2)", + args{sign: "e7xyz"}, + "E7XYZ", "", + }, + //*** Error cases ***** { "Pure junk passed", args{sign: "aaaaaa"}, @@ -200,8 +210,8 @@ func TestValidateCall(t *testing.T) { }, { "invalid prefix", - args{sign: "xyz/on4kjm"}, - "*XYZ/ON4KJM", "Invalid prefix", + args{sign: "xyz4/on4kjm"}, + "*XYZ4/ON4KJM", "Invalid prefix", }, { "Too many /", diff --git a/test/data/fle-2.txt b/test/data/fle-2.txt new file mode 100644 index 0000000..091e5b4 --- /dev/null +++ b/test/data/fle-2.txt @@ -0,0 +1,60 @@ +date 2020-07-19 +mycall ON6ZQ/P +mysota ON/ON-018 + +# No 1 + +# Spotlite +# ON6ZQ/P ON ON-018 7.032 cw + +# parking: +# Rue du Broux +# 6940 Durbuy +# 50.326490, 5.532476 + +cw +30m +1150 + +55 ix1ihr +f8dgf +56 ea2dt +57 oe6cud/p sota oe/st-309 +yo6cfb +1200 e7/z35m/p +dl2hwi +04 oe7phi +04 dl8dxl +05 ok1dpu +ei5hj +iw0hk +g3rtu +07 ok2uz +08 ct1drb +ok2k +11 dd6do +12 oz6abz +13 ea2if/p sota ea2/nv-189 +dl5dxs/p oo25 +15 dl7uxg + +40m +25 dl1fu +26 hb9agh +30 oe8spw +yl3cw +hb9bhu/p sota hb/bl-005 +dl7vkd +31 hb9cbr/p sota hb/NE-007 +hb9afi/p sota hb/VS-239 +m0tcl/p +f6dra +35 g0aol + +# Parsing error at line 22: Unable to parse sota +# Parsing error at line 24: Invalid prefix +# Parsing error at line 37: Unable to parse sota +# Parsing error at line 38: Unable to parse oo25 +# Parsing error at line 46: Unable to parse sota +# Parsing error at line 48: Unable to parse sota +# Parsing error at line 49: Unable to parse sota \ No newline at end of file