;+ ; NAME: ; www_help_is_section ; PURPOSE: ; Tests a header for the presence of a specific section header ; CATEGORY: ; www_help ; CALLING SEQUENCE: FUNCTION www_help_is_section, style, section, lines ; INPUTS: ; style array[1]; type: structure ; www_help_style structure ; Only uses style.anycase ; section scalar; type: string ; section heading ; lines array; type: string ; all lines from a documentation header ; OUTPUTS: ; Result scalar; type: integer ; -1: if not start of section ; otherwise index into 'lines' where section starts ; INCLUDE: @compile_opt.pro ; On error, return to caller ; PROCEDURE: ; If style.anycase is not set, then the header a case-sensitive search for lines ; containing the specified section heading anywhere in the line is done. ; If style.anycase is set, then the search is case insensitive; the section heading ; must be at the beginning of the line, and whitespace before the trailing colon is ; permitted. ; MODIFICATION HISTORY: ; JULY-2001, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ;- CASE style.anycase OF 0: iline = (where(strpos(lines, section) ne -1))[0] 1: BEGIN ; We need to check for whitespace before the colon at the end of a section name. ; Using strcompress(..,/rem) doesn't work for multiple word section headings like COMMON BLOCKS. ; The colon also does not need to be the last character on the line. So we look for a colon ; and use strtrim to get rid of whitespace before the colon. tmp_lines = strupcase(lines) ; Uppercase test FOR i=0,n_elements(tmp_lines)-1 DO BEGIN ; Remove whitespace before trailing colon p = strpos(tmp_lines[i],':') IF p NE -1 THEN tmp_lines[i] = strtrim(strmid(tmp_lines[i],0,p))+strmid(tmp_lines[i],p) ENDFOR ; The section name must be at the start of the line, but there may some whitespace ; preceding it (not too much though). iline = -1 tmp = where(strpos(strtrim(tmp_lines,2), section) EQ 0) ; Section name must start the line iline = tmp[0] ;IF tmp[0] NE -1 THEN BEGIN ; in_tmp = (where(strpos(tmp_lines[tmp], section) LT 4))[0] ; IF in_tmp NE -1 THEN iline = tmp[in_tmp] ;ENDIF END ENDCASE RETURN, iline & END