home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / m / me_cd25.zip / ME2MUTT.ZIP / TOKENIZE.MUT < prev   
Text File  |  1992-11-09  |  1KB  |  44 lines

  1.   ; create a token list from a sorted C source list
  2.   ; format of source:
  3.   ;   [<whitespace>]"token-name"<junk>
  4.   ; format of output:
  5.   ;   token-number token-name
  6.  
  7.   ;; How to:
  8.   ;;  1. clear me.tok
  9.   ;;  2. add list from bind.c
  10.   ;;  3. run sys-tokenize
  11.   ;;  4. append list from mmaux.c
  12.   ;;  5. run mutt-tokenize on that list
  13.   ;;  6. run sort-tokens
  14.  
  15. (const sort-flags "+1")        ; "+1" for UNIX, "-p2" for MS-DOS
  16.  
  17. (include me2.h)
  18.  
  19. (defun
  20.   sys-tokenize
  21.   {
  22.     (int n)(n 0)
  23.  
  24.     (beginning-of-buffer)
  25.     (while (TRUE)
  26.     {
  27.       (if (re-search-forward '^\ *"\(\w+\)".+$')()(done))
  28.       (cut-the-line)
  29.       (insert-text n " " (get-matched '\1'))(open-line)(+= n 1)
  30.     })
  31.   }
  32.   mutt-tokenize
  33.   {
  34.     (re-search-replace '^\ *"\(.+\)",\ *\(\d+\).*$'    '\2 \1')
  35.   }
  36.   sort-tokens
  37.   {
  38.     (beginning-of-buffer)(set-mark)(end-of-buffer)
  39.     (clear-bag CUT-BUFFER)(append-to-bag CUT-BUFFER APPEND-REGION)
  40.     (delete-region)
  41.     (OS-filter (concat "sort " sort-flags) CUT-BUFFER -1 TRUE)
  42.   }
  43. )    
  44.