C, C++ 주석 인식해 비교하는 diff 스크립트 (sh, sed)

Posted at 2014/07/03 17:05 // in Programming // by Daniel

제가 잊어버릴까봐 공유합니다.

사용자 스크립트로 먼저 코멘트를 strip 하고
그 결과를 가지고 비교하여 diff 여부를 리턴합니다.

#!/bin/sh
	
  1. C, C++ comments aware diff
  2. this uses stripcomment script to strip comments

Usage=“Usage: {script name} {file1} {file2}”
if [ $# -eq 0 ]; then # if no argument specified echo $Usage # print Usage string value exit 1
fi
if [ $# -eq 1 ]; then # if no argument specified echo $Usage # print Usage string value exit 1
fi
FILE1=$1
FILE2=$2
TMPFILE1=/tmp/aa$$
TMPFILE2=/tmp/bb$$

~/bin/stripcomment $FILE1 > $TMPFILE1
~/bin/stripcomment $FILE2 > $TMPFILE2

#echo diff $TMPFILE1 $TMPFILE2
diff $TMPFILE1 $TMPFILE2
exit $?


위 스크립트는 제가 짠 거고

아래는 http://bash.cyberciti.biz/academic/sed-remove-c-cpp-comments/ 여기서 퍼왔습니다.

#! /bin/sed -nf

  1. Remove C and C++ comments, by Brian Hiles (brian_hiles@rocketmail.com)
  1. Sped up (and bugfixed to some extent) by Paolo Bonzini (bonzini@gnu.org)
  2. Works its way through the line, copying to hold space the text up to the
  3. first special character (/, “, ‘). The original version went exactly a
  4. character at a time, hence the greater speed of this one. But the concept
  5. and especially the trick of building the line in hold space are entirely
  6. merit of Brian.

:loop

  1. This line is sufficient to remove C++ comments!

/^\/\// s,.*,,

/^$/{

x p n b loop

}

/^”/{

:double /^$/{ x p n /^”/b break b double } H x s,\n\(.[^\”]*\).*,\1, x s,.[^\”]*,, /^”/b break /^\\/{ H x s,\n\(.\).*,\1, x s/.// } b double

}

/^’/{

:single /^$/{ x p n /^’/b break b single } H x s,\n\(.[^\’]*\).*,\1, x s,.[^\’]*,, /^’/b break /^\\/{ H x s,\n\(.\).*,\1, x s/.// } b single

}

/^\/\*/{

s/.// :ccom s,.[*]*,, /^$/ n /^\*\//{ s/..// b loop } b ccom

}

:break

H

x

s,\n\(.[^”’/]*\).*,\1,

x

s/.[^”’/]*//

b loop

크리에이티브 커먼즈 라이센스
Creative Commons License

추천 받은 복식 가계부, 후잉 - Whooing

Posted at 2014/05/27 08:01 // in Misc // by Daniel

https://whooing.com/

복식계좌 형태의 가계부라고 합니다.
문자 자동입력 등은 네이버 가계부에 비해 떨어지지만,

웹으로 쉽게 사용가능하다고 하고
복식 기입이고
보고서가 좋다

라는 군요. http://atin.tistory.com/496

크리에이티브 커먼즈 라이센스
Creative Commons License

간단한 종이상자 만들기

Posted at 2014/04/25 13:45 // in Tips // by Daniel

http://terms.naver.com/entry.nhn?docid= ··· id%3D288

우리가 정말 알아야 할 우리 놀이 백가지

「네모 상자」 만들기

1) 반 접는다.
2) 다시 반 접는다.
3) 윗장을 세우고 가운데 등쪽을 눌러 접는다.
4) 뒤도 ③과 같은 방법으로 접는다.
5) 윗장을 반 접는다. 뒤는 반대쪽으로 반 접는다.
6) 윗장 양쪽을 점선 표시대로 반보다 조금 더 지나 접는다. 뒤도 똑같이 한다.
7) 점선 표시에서 밑으로 접는다. 뒤도 똑같이 한다.
8) 안을 벌려 바닥 모양을 잡는다.

  • 빳빳한 신문지로 크게 만들면 야외나 가정에서 수납 박스로 요긴하게 쓸 수 있다.

그림

크리에이티브 커먼즈 라이센스
Creative Commons License

이클립스 Package Explorer에서 SVN 아이콘 표시

Posted at 2014/04/24 15:26 // in Tips // by Daniel

Preferances -> General -> Appearance -> Label Decorations 에서 SVN 항목을 체크

http://www.okjsp.net/seq/154532

크리에이티브 커먼즈 라이센스
Creative Commons License
1 ... 4 5 6 7 8 9 10 11 12 ... 191