Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: third_party/golang/src/fmt/print.go

Issue 1426513005: Modify local copy of fmt package to deep print structures with pointers. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Fix comment. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/golang/README ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 fmt 5 package fmt
6 6
7 import ( 7 import (
8 "errors" 8 "errors"
9 "io" 9 "io"
10 "os" 10 "os"
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 } 991 }
992 if p.fmt.sharpV { 992 if p.fmt.sharpV {
993 p.buf.WriteByte('}') 993 p.buf.WriteByte('}')
994 } else { 994 } else {
995 p.buf.WriteByte(']') 995 p.buf.WriteByte(']')
996 } 996 }
997 case reflect.Ptr: 997 case reflect.Ptr:
998 v := f.Pointer() 998 v := f.Pointer()
999 // pointer to array or slice or struct? ok at top level 999 // pointer to array or slice or struct? ok at top level
1000 // but not embedded (avoid loops) 1000 // but not embedded (avoid loops)
1001 » » if v != 0 && depth == 100 { 1001 » » // Note(rudominer) Local change. Deep print structures
1002 » » // that contain pointers. Original code reads:
1003 » » // if v != 0 && depth == 0 {
1004 » » if v != 0 && depth < 50 {
1002 switch a := f.Elem(); a.Kind() { 1005 switch a := f.Elem(); a.Kind() {
1003 case reflect.Array, reflect.Slice: 1006 case reflect.Array, reflect.Slice:
1004 p.buf.WriteByte('&') 1007 p.buf.WriteByte('&')
1005 p.printValue(a, verb, depth+1) 1008 p.printValue(a, verb, depth+1)
1006 break BigSwitch 1009 break BigSwitch
1007 case reflect.Struct: 1010 case reflect.Struct:
1008 p.buf.WriteByte('&') 1011 p.buf.WriteByte('&')
1009 p.printValue(a, verb, depth+1) 1012 p.printValue(a, verb, depth+1)
1010 break BigSwitch 1013 break BigSwitch
1011 case reflect.Map: 1014 case reflect.Map:
1012 p.buf.WriteByte('&') 1015 p.buf.WriteByte('&')
1013 p.printValue(a, verb, depth+1) 1016 p.printValue(a, verb, depth+1)
1014 break BigSwitch 1017 break BigSwitch
1018 // Note(rudominer) Local change. Deep print pointers to strings.
1019 case reflect.String:
1020 p.buf.WriteByte('&')
1021 p.printValue(a, verb, depth+1)
1022 break BigSwitch
1015 } 1023 }
1016 } 1024 }
1017 fallthrough 1025 fallthrough
1018 case reflect.Chan, reflect.Func, reflect.UnsafePointer: 1026 case reflect.Chan, reflect.Func, reflect.UnsafePointer:
1019 p.fmtPointer(value, verb) 1027 p.fmtPointer(value, verb)
1020 default: 1028 default:
1021 p.unknownType(f) 1029 p.unknownType(f)
1022 } 1030 }
1023 p.value = oldValue 1031 p.value = oldValue
1024 return wasString 1032 return wasString
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 if addspace || !isString && !prevString { 1258 if addspace || !isString && !prevString {
1251 p.buf.WriteByte(' ') 1259 p.buf.WriteByte(' ')
1252 } 1260 }
1253 } 1261 }
1254 prevString = p.printArg(arg, 'v', 0) 1262 prevString = p.printArg(arg, 'v', 0)
1255 } 1263 }
1256 if addnewline { 1264 if addnewline {
1257 p.buf.WriteByte('\n') 1265 p.buf.WriteByte('\n')
1258 } 1266 }
1259 } 1267 }
OLDNEW
« no previous file with comments | « third_party/golang/README ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698