~ubuntu-branches/ubuntu/saucy/golang/saucy

« back to all changes in this revision

Viewing changes to src/pkg/fmt/scan.go

  • Committer: Package Import Robot
  • Author(s): Adam Conrad
  • Date: 2013-07-08 05:52:37 UTC
  • mfrom: (29.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20130708055237-at01839e0hp8z3ni
Tags: 2:1.1-1ubuntu1
016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
        ReadRune() (r rune, size int, err error)
34
34
        // UnreadRune causes the next call to ReadRune to return the same rune.
35
35
        UnreadRune() error
36
 
        // SkipSpace skips space in the input. Newlines are treated as space 
37
 
        // unless the scan operation is Scanln, Fscanln or Sscanln, in which case 
 
36
        // SkipSpace skips space in the input. Newlines are treated as space
 
37
        // unless the scan operation is Scanln, Fscanln or Sscanln, in which case
38
38
        // a newline is treated as EOF.
39
39
        SkipSpace()
40
40
        // Token skips space in the input if skipSpace is true, then returns the
312
312
        return !isSpace(r)
313
313
}
314
314
 
315
 
// skipSpace provides Scan() methods the ability to skip space and newline characters 
316
 
// in keeping with the current scanning mode set by format strings and Scan()/Scanln().
 
315
// SkipSpace provides Scan methods the ability to skip space and newline
 
316
// characters in keeping with the current scanning mode set by format strings
 
317
// and Scan/Scanln.
317
318
func (s *ss) SkipSpace() {
318
319
        s.skipSpace(false)
319
320
}
337
338
                r.pending--
338
339
                return
339
340
        }
340
 
        _, err = r.reader.Read(r.pendBuf[0:1])
 
341
        n, err := io.ReadFull(r.reader, r.pendBuf[0:1])
 
342
        if n != 1 {
 
343
                return 0, err
 
344
        }
341
345
        return r.pendBuf[0], err
342
346
}
343
347
 
378
382
 
379
383
var ssFree = newCache(func() interface{} { return new(ss) })
380
384
 
381
 
// Allocate a new ss struct or grab a cached one.
 
385
// newScanState allocates a new ss struct or grab a cached one.
382
386
func newScanState(r io.Reader, nlIsSpace, nlIsEnd bool) (s *ss, old ssave) {
383
387
        // If the reader is a *ss, then we've got a recursive
384
388
        // call to Scan, so re-use the scan state.
410
414
        return
411
415
}
412
416
 
413
 
// Save used ss structs in ssFree; avoid an allocation per invocation.
 
417
// free saves used ss structs in ssFree; avoid an allocation per invocation.
414
418
func (s *ss) free(old ssave) {
415
419
        // If it was used recursively, just restore the old state.
416
420
        if old.validSave {
1090
1094
                        // There was space in the format, so there should be space (EOF)
1091
1095
                        // in the input.
1092
1096
                        inputc := s.getRune()
1093
 
                        if inputc == eof {
 
1097
                        if inputc == eof || inputc == '\n' {
 
1098
                                // If we've reached a newline, stop now; don't read ahead.
1094
1099
                                return
1095
1100
                        }
1096
1101
                        if !isSpace(inputc) {