File tree Expand file tree Collapse file tree 6 files changed +383
-763
lines changed Expand file tree Collapse file tree 6 files changed +383
-763
lines changed Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -10,8 +10,6 @@ import (
1010 "sync"
1111 "sync/atomic"
1212 "time"
13- "unicode"
14- "unicode/utf8"
1513)
1614
1715const (
@@ -336,139 +334,3 @@ func appendTextValue(buf *buffer, v slog.Value) {
336334 appendString (buf , fmt .Sprintf ("%s" , v ))
337335 }
338336}
339-
340- // Copied from log/slog/text_handler.go.
341- //
342- // needsQuoting returns true if the given strings should be wrapped in quotes.
343- func needsQuoting (s string ) bool {
344- if len (s ) == 0 {
345- return true
346- }
347- for i := 0 ; i < len (s ); {
348- b := s [i ]
349- if b < utf8 .RuneSelf {
350- // Quote anything except a backslash that would need
351- // quoting in a JSON string, as well as space and '='.
352- if b != '\\' && (b == ' ' || b == '=' || ! safeSet [b ]) {
353- return true
354- }
355- i ++
356- continue
357- }
358- r , size := utf8 .DecodeRuneInString (s [i :])
359- if r == utf8 .RuneError || unicode .IsSpace (r ) ||
360- ! unicode .IsPrint (r ) {
361-
362- return true
363- }
364- i += size
365- }
366- return false
367- }
368-
369- // Copied from encoding/json/tables.go.
370- //
371- // safeSet holds the value true if the ASCII character with the given array
372- // position can be represented inside a JSON string without any further
373- // escaping.
374- //
375- // All values are true except for the ASCII control characters (0-31), the
376- // double quote ("), and the backslash character ("\").
377- var safeSet = [utf8 .RuneSelf ]bool {
378- ' ' : true ,
379- '!' : true ,
380- '"' : false ,
381- '#' : true ,
382- '$' : true ,
383- '%' : true ,
384- '&' : true ,
385- '\'' : true ,
386- '(' : true ,
387- ')' : true ,
388- '*' : true ,
389- '+' : true ,
390- ',' : true ,
391- '-' : true ,
392- '.' : true ,
393- '/' : true ,
394- '0' : true ,
395- '1' : true ,
396- '2' : true ,
397- '3' : true ,
398- '4' : true ,
399- '5' : true ,
400- '6' : true ,
401- '7' : true ,
402- '8' : true ,
403- '9' : true ,
404- ':' : true ,
405- ';' : true ,
406- '<' : true ,
407- '=' : true ,
408- '>' : true ,
409- '?' : true ,
410- '@' : true ,
411- 'A' : true ,
412- 'B' : true ,
413- 'C' : true ,
414- 'D' : true ,
415- 'E' : true ,
416- 'F' : true ,
417- 'G' : true ,
418- 'H' : true ,
419- 'I' : true ,
420- 'J' : true ,
421- 'K' : true ,
422- 'L' : true ,
423- 'M' : true ,
424- 'N' : true ,
425- 'O' : true ,
426- 'P' : true ,
427- 'Q' : true ,
428- 'R' : true ,
429- 'S' : true ,
430- 'T' : true ,
431- 'U' : true ,
432- 'V' : true ,
433- 'W' : true ,
434- 'X' : true ,
435- 'Y' : true ,
436- 'Z' : true ,
437- '[' : true ,
438- '\\' : false ,
439- ']' : true ,
440- '^' : true ,
441- '_' : true ,
442- '`' : true ,
443- 'a' : true ,
444- 'b' : true ,
445- 'c' : true ,
446- 'd' : true ,
447- 'e' : true ,
448- 'f' : true ,
449- 'g' : true ,
450- 'h' : true ,
451- 'i' : true ,
452- 'j' : true ,
453- 'k' : true ,
454- 'l' : true ,
455- 'm' : true ,
456- 'n' : true ,
457- 'o' : true ,
458- 'p' : true ,
459- 'q' : true ,
460- 'r' : true ,
461- 's' : true ,
462- 't' : true ,
463- 'u' : true ,
464- 'v' : true ,
465- 'w' : true ,
466- 'x' : true ,
467- 'y' : true ,
468- 'z' : true ,
469- '{' : true ,
470- '|' : true ,
471- '}' : true ,
472- '~' : true ,
473- '\u007f' : true ,
474- }
You can’t perform that action at this time.
0 commit comments