Fellows,
there are some app notes concerning 15x/16x devices.
Shall we add these bits to the toolchain now or after an official release?

~d

Also, having nothing to do I wrote a vim script, which expands macro on F12 in 
cmd mode. this myght be usefull if you're analysing some code of for reverse 
engineering. ...attached


-- 
/********************************************************************
     ("`-''-/").___..--''"`-._     (\   Dimmy the Wild      UA1ACZ
      `6_ 6  )   `-.  (     ).`-.__.`)  Enterprise Information Sys 
      (_Y_.)'  ._   )  `._ `. ``-..-'   Nevsky prospekt,   20 / 44
    _..`--'_..-_/  /--'_.' ,'           Saint Petersburg,   Russia
   (il),-''  (li),'  ((!.-'             +7 (812)  3468202, 5585314
 ********************************************************************/
:map <buffer> <F12> :call ExpandMacro()<cr>
:map <buffer> <S-F12> :call MUO()<cr>

let cppcmd = "cpp"


function! MexpOptions()
  let fn = ".vimexp"
  if !filereadable(fn)
    let fn = $HOME . "/.vimexp"
    if !filereadable(fn)
      return ""
    endif
  endif
  let mres = system("cat " . fn)
  let mres = substitute(mres,"\n", " ", "g")
  let cpp = matchstr(mres,"CPP[ \t]*=[ A-Za-z0-9_\t-]*cpp")
  if cpp == ""
    let cppcmd = "cpp"
    return mres
  endif
  let cpp = substitute(cpp ,"CPP[ \t]*=","","g")
  let g:cppcmd = cpp
  let mres = substitute(mres,"CPP[ \t]*=[ A-Za-z0-9_\t-]*cpp", " ", "g")
  return mres
endfunc

function! MexpUpdateOptions(par)
  let mres = a:par
  let mres = escape(mres,'"\')
  let mres = substitute(mres,"\n", " ", "g")
  let mres = system("echo \'" . mres . "\' >> .vimexp")
endfunc

function! MUO()
  let linenr = line(".")
  let lin = getline(linenr)
  call MexpUpdateOptions(lin)
endfunc

function! M()
  let linenr = line(".")
  let colnr  = col('.') - 1
  let lin = getline(linenr)
  let brace = 1
  while colnr >= 0
    let tmp = match(lin,"[^A-Za-z0-9_]",colnr)
    if tmp == colnr
      break
    endif
    let colnr = colnr - 1
  endwhile
  let macropatternstart = colnr + 1
  let colnr = match(lin,"\(",macropatternstart)
  if colnr == -1
    let colnr = match(lin,"[^A-Za-z0-9_]",macropatternstart)
    if colnr == -1
      return  "Error"
    endif
    return strpart(lin, macropatternstart, colnr - macropatternstart)
  endif
  let colnr = colnr + 1  
  while 1
    while char2nr(lin[colnr]) != 59  && char2nr(lin[colnr]) != 0
      if char2nr(lin[colnr]) == 40
        let brace = brace + 1
      endif
      if char2nr(lin[colnr]) == 41
        let brace = brace - 1
      endif
      if brace == 0
        break
      endif
      let colnr = colnr + 1
    endwhile
    if char2nr(lin[colnr]) == 59 || brace == 0 
      break
    endif
    let linenr = linenr + 1
    let lin = lin . getline(linenr)
  endwhile
 return strpart(lin, macropatternstart, colnr + 1 - macropatternstart)
endfunction

function! OpEnd()
  let linenr = line(".")
  while 1
    let lin = getline(linenr)
    let res = match(lin,"[;{:]")
    if res != -1
     return linenr
    endif
    let linenr = linenr + 1
  endwhile
endfunction

function! OutComm(lline, ldspl,  str, beg)
  let ll = a:lline
  let in = indent(line("."))
  let mre = ""
  while in > 0
    let mre = mre . " "
    let in = in - 1
  endwhile
  let mre = mre . a:beg . a:str
  call append(ll + a:ldspl, mre)
  return mre
endfunction

function! StripDS(str)
  let ms = a:str
  let mp = ms
  while 1
    let ms = substitute(ms,"\t", " ", "g")
    let ms = substitute(ms,"  ", " ", "g")
    let ms = substitute(ms,"\ *,\ *", ",", "g")
    let ms = substitute(ms,"\ *)\ *", ")", "g")
    let ms = substitute(ms,"\ *(\ *", "(", "g")
    let ms = substitute(ms,"\ *]\ *", "]", "g")
    let ms = substitute(ms,"\ *[\ *", "[", "g")
    let ms = substitute(ms,"\ *\\.\ *", ".", "g")
    let ms = substitute(ms,"\ *->\ *", "->", "g")
    if ms == mp
      break
    endif
    let mp = ms
  endwhile
  let mp = ms
  return ms
endfunction

function! ComFil(endline, mac)
  let ll = a:endline
  let tt = bufname("%") . ".cpp-out"
  let h1 = bufname("%") . ".macrodef"
  let mres = system(">" . tt)
  let mres = system(">" . h1)
  let i = 1
  while ll >= i
    let ml = getline(i)
    let ml = substitute(ml,"'"," ", "g")
    let i = i + 1
    call system("echo \'" . ml . "\' >> " . tt)
  endwhile
  let ml = a:mac
  let mres = system("echo \'" . ml . "\' >> " . tt)
  let mres = system(g:cppcmd . " " . MexpOptions() . tt . " 2>&1 | cat > " . h1)
  let mres = system("tail -1 ". h1)
  call delete(tt)
  call delete(h1)
  let mres = substitute(mres,"\n","","g")
  return mres . " " 
endfunction


function! ExpandMacro()
  let maci = M()
  let origmac = maci
  let mac1 = StripDS(maci)
  let lpn = OpEnd()
  let mac = ComFil(lpn,mac1)
  let mac = StripDS(mac)
  let ret = OutComm(lpn, 0,"/*","")
  let ret = OutComm(lpn, 1, bufname("%") . ":" . line("."), " * File: ")
  let ret = OutComm(lpn, 2,mac1." ****"," **** ")
  let ret = OutComm(lpn, 3,mac," *   ")
  let ret = OutComm(lpn, 4,"*/"," ")
endfunction

Reply via email to