File: autotangle

package info (click to toggle)
lua-lemock 0.6-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 512 kB
  • sloc: makefile: 2
file content (28 lines) | stat: -rw-r--r-- 599 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env rc

nl='
'
tf=`tempfile

for (f in ``($nl){noroots $* |sed 's/^<<\(.*\)>>$/\1/'}) {
  if (~ $f *' '*) {
    echo >[1=2] 'Skipping bad root <<'^$^f^'>>'
  } else {
    d=`{dirname $f} if (! test -d $d) mkdir -p $d
    switch (`{basename $f}) {
      case *.c *.h;   o=(-L'#line %L "%F"%N')
      case *.lua;     o=(-L'-- %F:%L%N')
      case *.sh;      o=(-L'# %F:%L%N')
      case mkfile;    o=(-t8)
      case *;         o=()
    }
    notangle $o -R$f $* >$tf
    if (! cmp -s $tf $f) {
      echo Updating $f
      rm -f $f
      cat $tf > $f
      chmod a-w $f
    }
  }
}
rm $tf