4444 if len (sys .argv ) > 3 :
4545 debug_ident = sys .argv [3 ]
4646
47+ # track the statistics of number of lines used by the entries
48+ debug_num_lines = [0 for i in range (40 )]
49+
4750index_file = sys .argv [1 ]
4851output_file = sys .argv [2 ]
4952
@@ -161,14 +164,16 @@ def get_version(decls):
161164
162165def build_abstract (decls , desc ):
163166 line_limit = MAX_CODE_LINES
167+ global debug_num_lines
168+ num_lines = 0
164169
165170 limited = False
166171 all_code = ''
167172
168173 for i ,(code ,ver ) in enumerate (decls ):
169174 code = code .strip ()
170175 code = '<pre><code>' + code + '</code></pre>'
171- num_lines = code .count ('\n ' ) + 1
176+ code_num_lines = code .count ('\n ' ) + 1
172177
173178 # limit the number of code snippets to be included so that total number
174179 # of lines is less than MAX_CODE_LINES. The limit becomes active only
@@ -178,21 +183,41 @@ def build_abstract(decls, desc):
178183
179184 if not first :
180185 if last :
181- if num_lines > line_limit :
186+ if code_num_lines > line_limit :
182187 limited = True
183188 break
184189 else :
185- if num_lines > line_limit - 1 :
190+ if code_num_lines > line_limit - 1 :
186191 # -1 because we need to take into account
187192 # <more overloads omitted> message
188193 limited = True
189194 break
190195
191196 all_code += code
192- line_limit -= num_lines
197+ num_lines += 1
198+ line_limit -= code_num_lines
193199
194200 if limited :
195201 all_code += '<pre><code> <...> </code></pre>'
202+
203+
204+ # count the number of lines used
205+ num_lines += all_code .count ('\n ' )
206+ if len (desc ) > 110 :
207+ num_lines += 2
208+ else :
209+ num_lines += 1
210+ if limited :
211+ num_lines += 1
212+
213+ debug_num_lines [num_lines ] += 1
214+
215+ if debug and num_lines >= 10 :
216+ print ("# error : large number of lines: " )
217+ print ("# BEGIN ======" )
218+ print (all_code + desc )
219+ print ("# END ========" )
220+
196221 return all_code + desc
197222
198223if debug :
@@ -275,3 +300,9 @@ def build_abstract(decls, desc):
275300 if debug :
276301 line = '# error (' + str (err ) + "): " + link + ": " + item_ident + "\n "
277302 out .write (line )
303+
304+ if debug :
305+ print ('=============================' )
306+ print ('Numbers of lines used:' )
307+ for i ,l in enumerate (debug_num_lines ):
308+ print (str (i ) + ': ' + str (l ) + ' line(s)' )
0 commit comments