@@ -27,7 +27,7 @@ import (
2727//nolint:lll
2828var (
2929 // matches warnings or errors
30- matchCompilerProblem = regexp .MustCompile (`^(.*?)\(([0-9]*)[- 0-9]*\) \: (fatal error|error|warning) [0-9]*\: (.*)$` )
30+ matchCompilerProblem = regexp .MustCompile (`^(.*?)\(([0-9]*)[- 0-9]*\) \: (fatal error|error|user warning|warning)\s? [0-9]*\: (.*)$` )
3131
3232 // Header size: 60 bytes
3333 matchHeader = regexp .MustCompile (`^Header size:\s*([0-9]+) bytes$` )
@@ -270,24 +270,35 @@ func CompileWithCommand(
270270 }
271271 }
272272
273- for problem := range problemChan {
274- fmt .Println (problem )
275- problems = append (problems , problem )
276- }
273+ for {
274+ select {
275+ case p , ok := <- problemChan :
276+ if ! ok {
277+ problemChan = nil
278+ } else {
279+ fmt .Println (p .String ())
280+ problems = append (problems , p )
281+ }
282+ case line , ok := <- resultChan :
283+ if g := matchHeader .FindStringSubmatch (line ); len (g ) == 2 {
284+ result .Header , _ = strconv .Atoi (g [1 ])
285+ } else if g := matchCode .FindStringSubmatch (line ); len (g ) == 2 {
286+ result .Code , _ = strconv .Atoi (g [1 ])
287+ } else if g := matchData .FindStringSubmatch (line ); len (g ) == 2 {
288+ result .Data , _ = strconv .Atoi (g [1 ])
289+ } else if g := matchStack .FindStringSubmatch (line ); len (g ) == 3 {
290+ result .StackHeap , _ = strconv .Atoi (g [1 ])
291+ result .Estimate , _ = strconv .Atoi (g [2 ])
292+ } else if g := matchTotal .FindStringSubmatch (line ); len (g ) == 2 {
293+ result .Total , _ = strconv .Atoi (g [1 ])
294+ }
295+ if ! ok {
296+ resultChan = nil
297+ }
298+ }
277299
278- //nolint:errcheck
279- for line := range resultChan {
280- if g := matchHeader .FindStringSubmatch (line ); len (g ) == 2 {
281- result .Header , _ = strconv .Atoi (g [1 ])
282- } else if g := matchCode .FindStringSubmatch (line ); len (g ) == 2 {
283- result .Code , _ = strconv .Atoi (g [1 ])
284- } else if g := matchData .FindStringSubmatch (line ); len (g ) == 2 {
285- result .Data , _ = strconv .Atoi (g [1 ])
286- } else if g := matchStack .FindStringSubmatch (line ); len (g ) == 3 {
287- result .StackHeap , _ = strconv .Atoi (g [1 ])
288- result .Estimate , _ = strconv .Atoi (g [2 ])
289- } else if g := matchTotal .FindStringSubmatch (line ); len (g ) == 2 {
290- result .Total , _ = strconv .Atoi (g [1 ])
300+ if problemChan == nil && resultChan == nil {
301+ break
291302 }
292303 }
293304
@@ -299,8 +310,8 @@ func watchCompiler(
299310 workingDir string ,
300311 errorDir string ,
301312 relative bool ,
302- problemChan chan build.Problem ,
303- resultChan chan string ,
313+ problemChan chan <- build.Problem ,
314+ resultChan chan <- string ,
304315) {
305316 var err error
306317 scanner := bufio .NewScanner (outputReader )
@@ -310,7 +321,6 @@ func watchCompiler(
310321
311322 if len (groups ) == 5 {
312323 // output is a warning or error
313-
314324 problem := build.Problem {}
315325
316326 if filepath .IsAbs (groups [1 ]) {
@@ -320,7 +330,7 @@ func watchCompiler(
320330 }
321331
322332 if string (filepath .Separator ) != `\` {
323- problem .File = strings .Replace (problem .File , "\\ " , "/" , - 1 )
333+ problem .File = strings .ReplaceAll (problem .File , "\\ " , "/" )
324334 }
325335 problem .File = filepath .Clean (problem .File )
326336 if relative {
@@ -337,6 +347,7 @@ func watchCompiler(
337347 }
338348
339349 switch groups [3 ] {
350+ case "user warning" :
340351 case "warning" :
341352 problem .Severity = build .ProblemWarning
342353 case "error" :
@@ -346,7 +357,6 @@ func watchCompiler(
346357 }
347358
348359 problem .Description = groups [4 ]
349-
350360 problemChan <- problem
351361 } else {
352362 // output is pre-roll or post-roll
0 commit comments