@@ -1019,81 +1019,31 @@ func scanTrailerDictStart(s *bufio.Scanner, line *string) error {
10191019}
10201020
10211021func scanTrailerDictRemainder (s * bufio.Scanner , line string , buf bytes.Buffer ) (string , error ) {
1022- var err error
1023- var i , j , k int
1024-
1025- buf .WriteString (line )
1026- buf .WriteString ("\x0a " )
1027- // log.Read.Printf("scanTrailer dictBuf after start tag: <%s>\n", line)
1028-
1029- line = line [2 :]
1030-
1031- for {
1022+ var (
1023+ i int
1024+ err error
1025+ )
10321026
1033- if len (line ) == 0 {
1034- if line , err = scanLine (s ); err != nil {
1035- return "" , err
1036- }
1037- buf .WriteString (line )
1038- buf .WriteString ("\x0a " )
1039- // log.Read.Printf("scanTrailer dictBuf next line: <%s>\n", line)
1040- }
1041-
1042- i = strings .Index (line , "<<" )
1043- if i < 0 {
1044- // No <<
1045- j = strings .Index (line , ">>" )
1046- if j >= 0 {
1047- // Yes >>
1048- if k == 0 {
1049- // Check for dict
1050- ok , err := isDict (buf .String ())
1051- if err == nil && ok {
1052- return buf .String (), nil
1053- }
1054- } else {
1055- k --
1056- }
1057- line = line [j + 2 :]
1058- continue
1059- }
1060- // No >>
1061- line , err = scanLine (s )
1062- if err != nil {
1063- return "" , err
1064- }
1065- buf .WriteString (line )
1066- buf .WriteString ("\x0a " )
1067- // log.Read.Printf("scanTrailer dictBuf next line: <%s>\n", line)
1068- } else {
1069- // Yes <<
1070- j = strings .Index (line , ">>" )
1071- if j < 0 {
1072- // No >>
1073- k ++
1074- line = line [i + 2 :]
1075- } else {
1076- // Yes >>
1077- if i < j {
1078- // handle <<
1079- k ++
1080- line = line [i + 2 :]
1081- } else {
1082- // handle >>
1083- if k == 0 {
1084- // Check for dict
1085- ok , err := isDict (buf .String ())
1086- if err == nil && ok {
1087- return buf .String (), nil
1088- }
1089- } else {
1090- k --
1091- }
1092- line = line [j + 2 :]
1093- }
1094- }
1027+ for i = strings .Index (line , "startxref" ); i < 0 ; {
1028+ if log .ReadEnabled () {
1029+ log .Read .Printf ("line: <%s>\n " , line )
10951030 }
1031+ buf .WriteString (line )
1032+ buf .WriteString ("\x0a " )
1033+ if line , err = scanLine (s ); err != nil {
1034+ return "" , err
1035+ }
1036+ i = strings .Index (line , "startxref" )
10961037 }
1038+
1039+ line = line [:i ]
1040+ if log .ReadEnabled () {
1041+ log .Read .Printf ("line: <%s>\n " , line )
1042+ }
1043+ buf .WriteString (line [:i ])
1044+ buf .WriteString ("\x0a " )
1045+
1046+ return buf .String (), nil
10971047}
10981048
10991049func scanTrailer (s * bufio.Scanner , line string ) (string , error ) {
@@ -1102,12 +1052,10 @@ func scanTrailer(s *bufio.Scanner, line string) (string, error) {
11021052 log .Read .Printf ("line: <%s>\n " , line )
11031053 }
11041054
1105- // Scan for dict start tag "<<".
11061055 if err := scanTrailerDictStart (s , & line ); err != nil {
11071056 return "" , err
11081057 }
11091058
1110- // Scan for dict end tag ">>" but account for inner dicts.
11111059 return scanTrailerDictRemainder (s , line , buf )
11121060}
11131061
0 commit comments