Commits

N.Y. Lin committed adaec18

Add scripts for convert cpp comment style into c's [Beta]

  • Participants
  • Parent commits e97aeec

Comments (0)

Files changed (2)

topics/scripts/format_regex.sh

+#!/bin/bash
+if [ "$#" == "2" ] ; then
+    echo "== BEGIN"
+    mkdir -p $2
+    for i in $(find $1 -type f) ; do
+        filename=$(basename "$i")
+        newfile=$2${i:${#1}}
+        newdir=$(dirname $newfile)
+        if [ ! -d "$newdir" ]; then
+            mkdir -p $newdir
+        fi
+        if [[ "${filename##*.}" =~ (cpp|c) ]]; then
+            echo "* Processing $i"
+            echo \
+"#pragma section INIT=HOST_3RD_INIT, attr=DATA
+#pragma section CONST=HOST_3RD_CONST, attr=CONST
+#pragma section CODE=HOST_3RD_CODE, attr=CODE
+" | cat - $i > $newfile
+            echo "* Processing $i DONE"
+        else
+            echo "* Copying $i to $newfile"
+            cp $i $newfile
+            echo "* Copying $i to $newfile DONE"
+        fi
+    done
+    echo "== DONE"
+else
+    echo usage: $0 [srcdir] [dstdir]
+fi

topics/scripts/format_sed.sh

+#!/bin/bash
+if [ "$#" == "2" ] ; then
+    echo "== BEGIN"
+    mkdir -p $2
+    for i in $(find $1 -regex ".*\.\(h\)") ; do
+        echo "* Processing $i"
+        newfile=$2${i:${#1}}
+        newdir=$(dirname $newfile)
+        if [ ! -d "$newdir" ]; then
+            mkdir -p $newdir
+        fi
+        sed 's/\/\/\(.*\)$/\/*\1*\//p' $i > $newfile
+        echo "* Processing $i Done"
+    done
+    for i in $(find $1 -regex ".*\.\(cpp\|c\)") ; do
+        echo "* Processing $i"
+        newfile=$2${i:${#1}}
+        newdir=$(dirname $newfile)
+        if [ ! -d "$newdir" ]; then
+            mkdir -p $newdir
+        fi
+        echo "
+#pragma section INIT=HOST_3RD_INIT, attr=DATA
+#pragma section CONST=HOST_3RD_CONST, attr=CONST
+#pragma section CODE=HOST_3RD_CODE, attr=CODE" \
+    | cat - $i | sed 's/\/\/\(.*\)$/\/*\1*\//p' > $newfile
+        echo "* Processing $i Done"
+    done
+    echo "== DONE"
+else
+    echo usage: $0 [srcdir] [dstdir]
+fi