From 33f9ac4876d89e7072567037c2e1724d99c1542d Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Tue, 17 Apr 2012 21:28:52 -0300 Subject: [PATCH] scripts/dcm2desc: script to convert comments from .dcm files to genex descriptions --- scripts/dcm2desc | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 scripts/dcm2desc diff --git a/scripts/dcm2desc b/scripts/dcm2desc new file mode 100755 index 0000000..148db24 --- /dev/null +++ b/scripts/dcm2desc @@ -0,0 +1,44 @@ +#!/bin/sh +# +# dcm2desc - Convert .dcm files to genex descriptions +# +# Copyright 2012 by Werner Almesberger +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# + + +usage() +{ + echo "usage: $0 [-L libdir ...] [-l lib ...]" 1>&2 + exit 1 +} + + +scan_dcm() +{ + for n in "$@"; do + sed -e '/^\$CMP /{s///;x;}' \ + -e '/^[DKF] /{s///;x;G;s/\n/: /;p;s/: .*//;x;}' \ + -e d <"$n" + done +} + + +while [ "$1" ]; do + case "$1" in + -L) shift + [ "`echo \"$1\"/*.dcm`" != "$1/*.dcm" ] && + scan_dcm "$1"/*.dcm;; + -l) shift + scan_dcm "$1";; + -*) usage;; + *) usage;; + esac + shift +done + +exit 0