home *** CD-ROM | disk | FTP | other *** search
- ;************************************************************************
- ;* *
- ;* H E A D E R . M - Generate Standard File Prologue *
- ;* *
- ;************************************************************************
-
- ;************************************************************************
- ;* *
- ;* Copyright (c) Hardwood Software Associates 1987 *
- ;* *
- ;* Hardwood Software Associates *
- ;* 364 Benson Road *
- ;* Northbridge, Ma 01534 *
- ;* *
- ;************************************************************************
-
- ;************************************************************************
- ;* H E A D E R . M E D I T L O G
- ;*
- ;* Edit Date Person Modification
- ;* ---- ---- ------ ------------
- ;* 3.13 16-Apr-87 R. Evans Add Alt-A - header block
- ;* 4.01 9-May-87 R. Evans Change name to header
- ;* Use _init
- ;*
- ;************************************************************************
-
- ;************************************************************************
- ;* +-------------------+
- ;* Author: R. Evans | F U N C T I O N S |
- ;* Date: April, 1987 +-------------------+
- ;*
- ;* The environment string "owner" points to a complete path name of a
- ;* file that contains the name of the owner of the copyright as the first
- ;* line. Lines following the owner's name are displayed after the
- ;* copyright name. This data is usually the address of the owner.
- ;*
- ;* Two different prologues are created:
- ;* C file prologues
- ;* Assembler/Brief macros
- ;* These formats differ only in the comment character.
- ;*
- ;* The header macros should be called whenever a new file is editted.
- ;* This is done bye inserting a (header) call in "startup.m" for each
- ;* file type desired.
- ;*
- ;* A prologue is created whenever the third character on the first line
- ;* is not a "*". The header may be aborted by typeing escape at
- ;* the description prompt.
- ;*
- ;* Several other useful macros are included:
- ;* c_comment - Generate an empty comment in column 49 for C
- ;* asm_comment - Generate an empty comment in column 49 for ASM
- ;* comment - Call c_comment or asm_comment depending upon
- ;* extension (usually attached to a key)
- ;* function_header - Insert a functin header
- ;************************************************************************
-
- #define LINE_END 73 ; width of heading
-
- (macro _init ;++4.02
- ( ;++4.02
- (string stars) ;++4.02
- (global stars) ;++4.02
- (= stars "**********************************************************************")
- ) ;++4.02
- ) ;Of _init ;++4.02
-
- ; Move to column 49 and insert a C comment
-
- (macro c_comment ;++4.02
- (
- (int col)
- (end_of_line)
- (inq_position NULL col)
- (if (> 49 col)
- (move_abs 0 49)
- ;else
- (move_rel 0 1)
- )
- (insert "/* */")
- (move_rel 0 -3)
- )
- ) ; Of c_comment
- ; Move to column 49 and insert a ASM comment
-
- (macro asm_comment
- (
- (int col)
- (end_of_line)
- (inq_position NULL col)
- (if (> 49 col)
- (move_abs 0 49)
- ;else
- (move_rel 0 1)
- )
- (insert "\; ")
- )
- )
-
- (macro comment ;++4.02
- (
- (int file_type)
- (global file_type)
- (init_header)
- (if (== file_type 1) (c_comment) (asm_comment))
- )
- ) ; Of comment
-
- (macro init_header
- (
- (string temp)
- (inq_names NULL temp NULL)
- (if (== temp "c") (= file_type 1) (= file_type 2))
- ) ; Of init_header
- )
-
- (macro function_header
- (
- (string bname)
- (int line col)
-
- (init_header)
- (if (get_parm 0 bname "Function: ") ; File name
- (
- (create_header bname)
- (if (== file_type 1)
- (
- (insert bname)
- (insert " (")
- (inq_position line col)
- (insert ")\n{\n} /* Of ")
- (insert bname)
- (insert " */\n")
- (move_abs line col)
- )
- )
- )
- )
- ) ; Of function_header
- )
- (macro header
- (
- (int year month day)
- (string bname month_string b_name)
- (string temp_str)
-
- (init_header)
- (date year month day month_string)
- (inq_names NULL NULL bname) ; get name of buffer
- (wide_string bname b_name)
-
- (move_abs 1 3) ; Start of file after comment
- (if (!= (read 1) "*")
- (
- (move_abs 1 1) ; To start of file
-
- ;*** Insert Block defining file
- (if (create_header bname) ; Create header block
- (
- (message "Create standard file prologue")
-
- ;*** Insert copyright notes
- (do_line_2 stars) ; All stars
- (do_copy) ; Copyright
- (do_line_2 stars)
- (insert "\n") ; Skip a Line
-
- ;*** Insert edit log
- (do_line_s stars) ; Line of all stars
- ; Edit heading
- (sprintf temp_str "\t\t\t%s E D I T L O G" b_name)
- (do_line temp_str)
- (do_line "") ; Blank line
- ; Edit heading
- (do_line "\tEdit\tDate\tPerson\t\tModification")
- ; Edit heading
- (do_line "\t----\t----\t------\t\t------------")
- (do_line "") ; Blank line
- (do_line_e stars) ; Line of all stars
- (insert "\n") ; Skip a Line
-
- ;*** Insert function description heading
- (do_line_s stars) ; Line of all stars
- (do_line "") ; FUNCTION
- (move_rel -1 0 ) (move_abs 0 LINE_END) (move_rel 0 -20)
- (insert "+-------------------+\n")
- (do_line "\tAuthor: R. Evans") ; FUNCTION
- (move_rel -1 0 ) (move_abs 0 LINE_END) (move_rel 0 -20)
- (insert "| F U N C T I O N S |\n")
- ; FUNCTION
- (sprintf temp_str "\tDate:\t%s, %d" month_string year)
- (do_line temp_str)
- (move_rel -1 0 ) (move_abs 0 LINE_END) (move_rel 0 -20)
- (insert "+-------------------+\n")
- (do_line "") ; Blank line
- (do_function)
- (do_line_e stars)
- )
- )
- )
- )
- (top_of_buffer)
-
- ) ; Of header
- )
-
- (macro do_line_2
- (
- (string temp)
- (get_parm 0 temp)
- (if (== file_type 1) (insert "/*") (insert "\;*"))
- (move_abs 0 (+ 2 (/ (- LINE_END (strlen temp)) 2)))
- (insert temp)
- (move_abs 0 LINE_END)
- (if (== file_type 1) (insert "*/\n") (insert "*\n"))
- ) ; Of do_line_2
- )
-
- (macro do_line_s
- (
- (string temp)
- (get_parm 0 temp)
- (if (== file_type 1) (insert "/*") (insert "\;*"))
- (move_abs 0 (+ 2 (/ (- LINE_END (strlen temp)) 2)))
- (insert temp)
- (insert "*\n")
- ) ; Of do_line_s
- )
-
- (macro do_line_e
- (
- (string temp)
- (get_parm 0 temp)
- (if (== file_type 1) (insert " *") (insert "\;*"))
- (move_abs 0 (+ 2 (/ (- LINE_END (strlen temp)) 2)))
- (insert temp)
- (if (== file_type 1) (insert "*/\n") (insert "*\n"))
- ) ; Of do_line_e
- )
-
- (macro do_line
- (
- (string temp)
- (get_parm 0 temp)
- (if (== file_type 1) (insert " *") (insert "\;*"))
- (insert temp)
- (insert "\n")
- ) ; Of do_line
- )
-
- (macro do_copy
- (
- (string owner temp)
- (int year file)
- (int old_buffer copy_buffer no_line)
-
- (date year)
- (= owner (inq_environment "OWNER"))
- (if (== 0 (strlen owner))
- (
- (get_parm 1 owner "Owner:")
- (= file 0)
- (= no_line 0)
- )
- ; else
- (
- (= file 1)
- (= old_buffer (inq_buffer))
- (set_buffer (= copy_buffer (create_buffer "Comments" owner 1)))
- (end_of_buffer)
- (inq_position no_line)
- (top_of_buffer)
- (-- no_line)
- (= owner (read))
- (= owner (substr owner 1 (- (strlen owner) 1)))
- (move_rel 1 0)
- (set_buffer old_buffer)
- (-- no_line)
- )
- )
- (do_line_2 "")
- (sprintf temp "Copyright (c) %s %d" owner year)
- (do_line_2 temp)
- (do_line_2 "")
- (do_line_2 owner)
- (while (> no_line 0)
- (
- (set_buffer copy_buffer)
- (= temp (read))
- (move_rel 1 0)
- (set_buffer old_buffer)
- (do_line_2 (substr temp 1 (- (strlen temp) 1)))
- (-- no_line)
- )
- )
- (do_line_2 "")
- (if (== 1 file) (delete_buffer copy_buffer))
- ) ; Of do_copy
- )
-
- (macro do_function
- (
- (do_line "*************")
- (do_line " SYNOPSIS:")
- (do_line "")
- (do_line " DESCRIPTION:")
- (do_line "")
- (do_line " RETURNS:")
- (do_line "")
- (do_line " CAUTIONS:")
- (do_line "")
- ) ; Of do_function
- )
-
- (macro create_header
- (
- (string bname b_name temp_str)
- (get_parm 0 bname) ; Name
- (wide_string bname b_name)
- (sprintf temp_str "%s description:" (upper bname))
- (if (get_parm 1 bname temp_str)
- (
- (insert "\n") (move_rel -1 0) ; Insert a blank line to work from
- (do_line_2 stars) ; First line of all stars
- (do_line_2 "") ; Blank line
- (= temp_str b_name) (+= temp_str "- ") (+= temp_str bname)
- (do_line_2 temp_str)
- (do_line_2 "") ; Blank line
- (do_line_2 stars) ; All stars
- (insert "\n") ; Skip a Line
- (returns 1)
- )
- ; else
- (returns 0)
- )
- ) ; Of create_header
- )
-
- (macro wide_string
- (
- (string input output)
- (int i)
- (get_parm 0 input)
- (= input (upper input))
- (= i 1)
- (while (<= i (strlen input))
- (
- (+= output (substr input i 1))
- (+= output " ")
- (++ i)
- )
- )
- (put_parm 1 output)
- ) ; Of wide_string
- )