Skip to content
Snippets Groups Projects
Verified Commit db7390b8 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Improve indentation scripts

— now accept several input arguments
— the script themselves can now be called with an absolute pathname
— clearer output
parent a50845d8
Branches
Tags
No related merge requests found
#!/bin/sh
#!/bin/bash
# Reindents the C++ source code file given in argument.
# Reindents the C++ source code files given in argument
if [ -z "$1" ]; then
echo "Give a filename in argument"
exit 1
fi
[[ -n $1 ]] || { echo "Give filename(s) in argument" 2>&1; exit 1; }
SCRIPTS_DIR=$(pwd)/$(dirname $0)
pushd "$(dirname "$0")" > /dev/null
SCRIPTS_DIR=$(pwd)
popd > /dev/null
uncrustify -l CPP --replace -c ${SCRIPTS_DIR}/uncrustify.cfg $1
for f in "$@"; do
echo "*** Indenting $f…"
cd $(dirname $1)
emacs -batch $(basename $1) -l ${SCRIPTS_DIR}/indent-c++.el
uncrustify -l CPP --replace -c "${SCRIPTS_DIR}"/uncrustify.cfg "$f"
pushd "$(dirname "$f")" > /dev/null
emacs -batch "$(basename "$f")" -l "${SCRIPTS_DIR}"/indent-c++.el
popd > /dev/null
echo
done
#!/bin/sh
#!/bin/bash
# Reindents the MATLAB source code file given in argument.
# Reindents the MATLAB source code files given in argument
if [ -z "$1" ]; then
echo "Give a filename in argument"
exit 1
fi
[[ -n $1 ]] || { echo "Give filename(s) in argument" 2>&1; exit 1; }
SCRIPTS_DIR=$(pwd)/$(dirname $0)
pushd "$(dirname "$0")" > /dev/null
SCRIPTS_DIR=$(pwd)
popd > /dev/null
cd $(dirname $1)
emacs -batch $(basename $1) -l ${SCRIPTS_DIR}/indent-matlab.el
for f in "$@"; do
echo "*** Indenting $f…"
pushd "$(dirname "$f")" > /dev/null
emacs -batch "$(basename "$f")" -l "${SCRIPTS_DIR}"/indent-matlab.el
popd > /dev/null
echo
done
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment