Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 |
|
rudominer
2015/11/04 23:02:34
Note that I screwed up the initial checkin. It was
| |
| 1002 » » // that contain pointers. Original code reads: | |
| 1003 » » //if v != 0 && depth == 0 { | |
|
azani
2015/11/04 23:07:47
nit: add space after //
| |
| 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 Loading... | |
| 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 } |
| OLD | NEW |