Last active
August 29, 2015 13:58
-
-
Save npcardoso/9977269 to your computer and use it in GitHub Desktop.
A script for detecting in-your-face plagiarism in C source files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
FILES=($*) | |
NUM_FILES=${#FILES[@]} | |
function num_diffs() { | |
i=1 | |
for f in $*; do | |
cat $f | uncrustify -q -c uncrustify.conf | grep -v "#" > tmp.c | |
cpp tmp.c > F$i.c | |
i=$((i+1)) | |
done | |
diff -d -c1 -wiB F1.c F2.c | grep -- "^---" | wc -l | |
} | |
echo -n " ID, NAME" | |
for ((i=0; i < NUM_FILES; i++)); do | |
printf ",%4d" $i | |
done | |
echo "" | |
for ((i=0; i < NUM_FILES; i++)); do | |
printf "%4d," $i | |
echo -n ${FILES[i]} | head -c 6 | |
for ((j=0; j < i + 1; j++)); do | |
echo -n ", NA" | |
done | |
for ((j=i+1; j < NUM_FILES; j++)); do | |
OUT=`num_diffs ${FILES[$i]} ${FILES[$j]}` | |
printf ",%4d" $OUT | |
done | |
echo "" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment