Category : Miscellaneous Language Source Code
Archive   : BRIEFSRC.ZIP
Filename : ROUTINES.M

 
Output of file : ROUTINES.M contained in archive : BRIEFSRC.ZIP
;**
;** BRIEF -- Basic Reconfigurable Interactive Editing Facility
;**
;** Written by Dave Nanian and Michael Strickman.
;**

;**
;** routines.m:
;**
;** This file contains macros that allow a programmer to select a
;** C routine from a menu and then go to it. It makes a few assumptions
;** about programming style: routines must begin in column one, and
;** the line with the declaration must end with a close paren (")").
;**
;**
;** Revision history:
;** -----------------

(extern _menu_process
_menu_exit
)

;**
;** routines:
;**
;** This macro implements the "go to a routine" feature of BRIEF. It
;** scans the file for routine declarations, and builds a menu that gets
;** passed to the BRIEF menu macros. If a routine is selected from this
;** menu, on exit "_r_line" will have a non-zero value, and we go to that
;** line of the file.
;**

(macro routines
(
(int menu_buf_id
old_buf_id
line
_r_line
loc
)
(string menu_line
routine_name
)
(global _r_line)

(= _r_line 0)
(save_position)
(top_of_buffer)
(= old_buf_id (inq_buffer))
(= menu_buf_id (create_buffer "Routines" NULL 1))
(message "Scanning for routines...")

(while (search_fwd "<[~ \t#/\\*;\n\\{\\}( ]")
(
(= routine_name (read))
(= loc (strlen routine_name))

(while (index " \t\n" (substr routine_name loc 1))
(-- loc)
)
(if (&& (!= loc 1) (== (substr routine_name loc 1) ")"))
(
(++ _r_line)
(message "Scanning for routines [#%d]..." _r_line)
(= loc (search_string "[~ \t(\\*]\\c[ \t]@(" routine_name))
(= routine_name (+ (substr routine_name 1 (-- loc)) "\n"))
(= routine_name (substr routine_name (search_string "[~ \t\\*][~ \t\\*]@>" routine_name)))
(= routine_name (substr routine_name 1 (- (strlen routine_name) 1)))

(inq_position line)
(sprintf menu_line "\n%s ;_r_goto;%d;" routine_name line)

(set_buffer menu_buf_id)
(insert menu_line)
(set_buffer old_buf_id)
)
)
(next_char)
)
)
(= _r_line 0)
(restore_position)
(set_buffer menu_buf_id)
(inq_position line)
(top_of_buffer)

(if (> line 1)
(
(if (> (+= line 3) 20)
(= line 20)
)
(sprintf menu_line "30;%d;50;3;" line)
(insert menu_line)
(beginning_of_line)
(set_buffer old_buf_id)
(_menu_process NULL "Routines" NULL menu_buf_id)

(if _r_line
(goto_line _r_line)
)
)
;else
(
(set_buffer old_buf_id)
(delete_buffer menu_buf_id)
(message "No routines found.")
)
)
)
)

;**
;** _r_goto:
;**
;** This routine is called by the menu package when a routine is
;** selected.
;**

(macro _r_goto
(
(string line_string)

(get_parm 0 line_string)
(= _r_line (atoi line_string))
(_menu_exit)
)
)


  3 Responses to “Category : Miscellaneous Language Source Code
Archive   : BRIEFSRC.ZIP
Filename : ROUTINES.M

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/