Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1646)

Side by Side Diff: src/pkg/asn1/marshal.go

Issue 4536063: code review 4536063: pkg: spelling tweaks, A-H (Closed)
Patch Set: diff -r 4ce4c75f9bb5 https://go.googlecode.com/hg/ Created 13 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package asn1 5 package asn1
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "fmt" 9 "fmt"
10 "io" 10 "io"
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 return out.WriteByte(0) 344 return out.WriteByte(0)
345 } 345 }
346 case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.In t64: 346 case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.In t64:
347 return marshalInt64(out, int64(v.Int())) 347 return marshalInt64(out, int64(v.Int()))
348 case reflect.Struct: 348 case reflect.Struct:
349 t := v.Type() 349 t := v.Type()
350 350
351 startingField := 0 351 startingField := 0
352 352
353 // If the first element of the structure is a non-empty 353 // If the first element of the structure is a non-empty
354 » » // RawContents, then we don't bother serialising the rest. 354 » » // RawContents, then we don't bother serializing the rest.
355 if t.NumField() > 0 && t.Field(0).Type == rawContentsType { 355 if t.NumField() > 0 && t.Field(0).Type == rawContentsType {
356 s := v.Field(0) 356 s := v.Field(0)
357 if s.Len() > 0 { 357 if s.Len() > 0 {
358 bytes := make([]byte, s.Len()) 358 bytes := make([]byte, s.Len())
359 for i := 0; i < s.Len(); i++ { 359 for i := 0; i < s.Len(); i++ {
360 bytes[i] = uint8(s.Index(i).Uint()) 360 bytes[i] = uint8(s.Index(i).Uint())
361 } 361 }
362 /* The RawContents will contain the tag and 362 /* The RawContents will contain the tag and
363 * length fields but we'll also be writing 363 * length fields but we'll also be writing
364 » » » » * those outselves, so we strip them out of 364 » » » » * those ourselves, so we strip them out of
365 * bytes */ 365 * bytes */
366 _, err = out.Write(stripTagAndLength(bytes)) 366 _, err = out.Write(stripTagAndLength(bytes))
367 return 367 return
368 } else { 368 } else {
369 startingField = 1 369 startingField = 1
370 } 370 }
371 } 371 }
372 372
373 for i := startingField; i < t.NumField(); i++ { 373 for i := startingField; i < t.NumField(); i++ {
374 var pre *forkableWriter 374 var pre *forkableWriter
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 var out bytes.Buffer 495 var out bytes.Buffer
496 v := reflect.ValueOf(val) 496 v := reflect.ValueOf(val)
497 f := newForkableWriter() 497 f := newForkableWriter()
498 err := marshalField(f, v, fieldParameters{}) 498 err := marshalField(f, v, fieldParameters{})
499 if err != nil { 499 if err != nil {
500 return nil, err 500 return nil, err
501 } 501 }
502 _, err = f.writeTo(&out) 502 _, err = f.writeTo(&out)
503 return out.Bytes(), nil 503 return out.Bytes(), nil
504 } 504 }
OLDNEW
« no previous file with comments | « src/pkg/asn1/common.go ('k') | src/pkg/big/nat.go » ('j') | src/pkg/container/heap/heap.go » ('J')

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b