这段代码是LISP程序。不知发在哪个版上合适,选发到这里。
功能是:删除VC里面的注释。
(defun c:ezx(/) (if(SETQ SG(GETFILED "选择Cpp文件" "C:\\" "cpp" 8))(progn (SETQ NB(strcat(vl-filename-directory sg)(STRCAT"\\"(vl-filename-base SG)"-New")(vl-filename-extension sg))) (setq file1 (open SG "R")) (setq file2 (open NB "W")) (while(setq re1(read-line file1)) (if(not(equal re1 "")) (progn (setq n(vl-string-search "//"re1)) (cond ((> n 0) (setq re1(strcat "\n"(substr re1 1 (vl-string-search "//"re1)))) ;(setq re1"asdfas/*123*/pijl/*8965*/") (while(and(setq a1 (vl-string-search "/*"re1)) (setq a2 (vl-string-search "*/"re1)) ) (setq re1(strcat(substr re1 1 a1)(substr re1 (+ a2 3)(strlen re1)))) ) (princ re1 file2) ) ((not n) (setq re1(strcat "\n"re1)) (while(and(setq a1 (vl-string-search "/*"re1)) (setq a2 (vl-string-search "*/"re1)) ) (setq re1(strcat(substr re1 1 a1)(substr re1 (+ a2 3)(strlen re1)))) ) (princ re1 file2) ) ) )) ) (close file1) (close file2) (setq file1 (open NB"R")) (setq file2 (open SG "W")) (while(setq re1(read-line file1)) (setq re1(strcat "\n"re1)) (princ re1 file2)) (close file1) (close file2) (vl-file-delete NB) )) ) |