C-C++ Beautifier HOW-TOAl Dev (Alavoor Vasudevan) alavoor@yahoo.comv7.0, 5 Sep 2000 ÀÌÈ£¿¬ guru2k@kldp.orgÀÌ ¹®¼´Â C/C++ ÇÁ·Î±×·¥À» Çü½ÄÈ ÇÏ´Â °Í(¾Æ¸§´ä°Ô)À» µµ¿ï °ÍÀÌ´Ù. ±×·¡¼ ´ç½ÅÀÇ C/C++ ÇÁ·Î±×·¥ ÄÚµù Ç¥ÁØÀÌ ´õ Àб⠽±°í Á¤È®ÇÒ °ÍÀÌ´Ù. ÀÌ ¹®¼ÀÇ Á¤º¸´Â ¸ðµç ¿î¿µÃ¼Á¦¿¡¼ »ç¿ëÇÒ ¼ö ÀÖ´Ù - ¸®´ª½º, MS DOS, Windows 95/NT, OS/2, IBM OSµé, Unix like ¼Ö¶ó¸®½ºÀÇ ¸ðµç dz¹Ì, HPUX, AIX, SCO, Sinix, BSD, SCO, ±âŸ.. ±×¸®°í ±×¿Ü "C" ÄÄÆÄÀÏ·¯°¡ Áö¿øµÇ´Â ¸ðµç ¿î¿µÃ¼Á¦µé (ÀÌ°ÍÀº ÀÌ Ç༺ÀÇ °ÅÀÇ ¸ðµç ¿î¿µÃ¼Á¦¸¦ ÀǹÌÇÑ´Ù!). 1. ¼Ò°³C/C++ À̳ª ´Ù¸¥ ¾ð¾î¿¡¼ Ç¥ÁØ ÄÚµùÀº ÇÁ·Î±×·¥À» ÇÁ·Î±×·¡¸Ó¿¡ ÀÇÇØ ´õ Àб⠽±°í/ÀÌÇØÇϱ⠽±°Ô ¸¸µé±â À§Çؼ´Â ÇʼöÀÌ´Ù. ÀÌ ¸ñÀûÀ» ´Þ¼ºÇϱâ À§ÇÑ C/C++À» ¾Æ¸§´ä°Ô ÇÏ´Â (Çü½ÄÈÇÏ´Â Åø) ÀÌ ÀÖ´Ù. Äڵ带 Çü½ÄÈ ÇÏ´Â °Í(¾Æ¸§´ä°Ô)À» 2¹øÇÏ´Â °ÍÀº ÇÁ·Î±×·¡¸ÓÀÇ »ý»ê·ÂÀ» Çâ»ó½ÃŲ´Ù!! ¸®´ª½º/À¯´Ð½º¿¡´Â "indent" ¿Í "cb" ¶ó ºÒ¸®´Â ¸í·ÉÀÌ ÀÖ´Ù. "man indent" ¿Í "man cb" ¸¦ ÂüÁ¶Çضó. indent¿Í cb ÀÛ¾÷Àº ¿ÀÁ÷ "C" ÇÁ·Î±×·¥À» À§ÇÑ °ÍÀÌ´Ù. "C++" ÇÁ·Î±×·¥À» À§Çؼ´Â "bcpp" ¸¦ »ç¿ëÇ϶ó. ¹Ø¿¡ ÀÖ´Â °÷¿¡¼ ¾Æ¸§´ä°Ô ÇÏ´Â ÇÁ·Î±×·¥À» ´Ù¿î·Îµå Ç϶ó.
BCPP´Â steve@alpha.ocbbs.gen.nz ¿¡ ÀÖ´Â Steven De Toni¿¡ ÀÇÇØ ¾²¿©Á³´Ù. 2. ³»°¡ ¾î¶»°Ô ¾Æ¸§´ä°Ô ÇÏ´Â ÇÁ·Î±×·¥À» ¹ÏÀ» ¼ö Àִ°¡??!!´ç½ÅÀº ¾Æ¸§´ä°Ô ÇÏ´Â ÇÁ·Î±×·¥À» ÀÔÁõÇÏ°í ½Å·ÚÇÏ°Ô ÇÏ´Â °úÇÐÀûÀÎ ¹æ¹ýÀÌ ÇÊ¿äÇÏ´Ù°í 100% Àå´ãÇÑ´Ù. ¹æ¹ýÀ» ¼¼úÇÒ °ÍÀÌ´Ù. ¾Æ¸§´ä°Ô ÇÏ´Â ÇÁ·Î±×·¥À» "ÈǸ¢ÇÏ´Ù°í ¹Ï°í" È®½ÇÇÏ´Ù°í ¹Þ¾ÆµéÀÌ°Ô ÇÏ·Á°í ÀÌ ºÎºÐ¿¡¼´Â ¹æ¹ýÀ» ¼¼úÇÒ °ÍÀÌ´Ù. BCPP°°Àº ¾Æ¸§´ä°Ô ÇÏ´Â ÇÁ·Î±×·¥ÀÌ »ç½ÇÀÓÀ» ÀÔÁõÇϱâ À§Çؼ, indent ȤÀº cb ´Â ÀԷ¹ÞÀº ¼Ò½ºÄڵ带 Çü½ÄÈÇÑ ÈÄ ÇÇÇسª º¯°æÇÏÁö ¾Ê´Â´Ù, ´ç½ÅÀº "°ËÁõ ÇÁ·Î±×·¥" ¼Ð ½ºÅ©¸³Æ®¸¦ »ç¿ëÇϰųª ´ÙÀ½ÀÇ ±â¹ýÀ» »ç¿ëÇÒ ¼ö ÀÖ´Ù - ÄÄÆÄÀÏ·¯¸¦ ÀÌ¿ëÇؼ ÃÖÃÊÀÇ ÀԷ¹ÞÀº ¼Ò½º ÄÚµå·Î ºÎÅÍ ¿ÀºêÁ§Æ® Äڵ带 »ý¼ºÇ϶ó - g++ -c myprogram.cpp ¿©±â¼ g++ Àº GNU C++ ÄÄÆÄÀÏ·¯ÀÌ´Ù. ÀÌ°ÍÀº myprogram.o ¶ó´Â ¿ÀºêÁ§Æ® ÆÄÀÏÀ» ¸¸µé °ÍÀÌ´Ù. ÀÌ ÆÄÀÏÀ» ÀÏ´Ü ¹é¾÷½ÃŲ´Ù - mv myprogram.o myprogram_orig.o bcpp¸¦ ½ÇÇà½ÃÄѶó - bcpp myprogram.cpp ÀÌ °ÍÀº Çü½ÄÈµÈ Ãâ·Â ÇÁ·Î±×·¥ ÆÄÀÏÀÎ myprogram.cppÀ» ¸¸µé°ÍÀÌ°í ¿ø·¡ÀÇ ÆÄÀÏÀ» myprogram.cpp.orig·Î ¸¸µé °ÍÀÌ´Ù. »õ ÆÄÀÏÀ» ÄÄÆÄÀÏ Çضó - g++ -c myprogram.cpp Áö±Ý µÎ°³ÀÇ ¿ÀºêÁ§Æ® ÆÄÀÏÀ» ºñ±³Çϱâ À§Çؼ À¯´Ð½ºÀÇ "diff" ¸í·ÉÀ» »ç¿ëÇضó - diff myprogram.o myprogram_orig.o ÀÌ ÆÄÀÏ µÑ ´Ù °°À» °ÍÀ» °ÍÀÌ´Ù. bcpp´Â ¿Ïº®ÇÏ°Ô ÀÛ¾÷ÇÑ´Ù´Â °ÍÀ» °ËÁõ Çß´Ù. DOS³ª Windows 95 ¿¡¼ ´ç½ÅÀÌ ÀÚÀ¯·Î¿î Cygnus ÀÎ Cygwin ¸¦ »ç¿ëÇϱ⠿øÇÒ °ÍÀÌ´Ù. ¶ÇÇÑ ´ç½ÅÀº ÄÄÆÄÀÏ·¯ ¿¡¼ ¿ÀºêÁ§Æ® Ãâ·Â ´ë½Å¿¡ ¾î¼Àºí·¯ Ãâ·ÂÀ» »ç¿ëÇÒ ¼öµµ ÀÖ´Ù. ´ÙÀ½°ú °°ÀÌ - g++ -S myprogram.cpp ÀÌ°ÍÀº myprogram.s¸¦ ¸¸µç´Ù. °ËÁõ ÇÏ·Á¸é - diff myprogram.s myprogram_orig.s ÀÌ ½ºÅÜÀº ´ç½ÅÀÇ °ªÁø ¼Ò½º ÄÚµå´Â ¼Õ»óµÇÁö ¾Ê°í bcpp´Â ¿ÀÁ÷ ¿Ã¹Ù¸¥ Çü½ÄÈ ÀÛ¾÷¸¸ ÇÏ°í ´ç½ÅÀÇ Äڵ忡 ¾î¶² ¹æ¹ýÀ¸·Îµç Àý´ë·Î º¯°æÀ̳ª ÇÇÇظ¦ ÇÏÁö ¾Ê´Â´Ù´Â °ÍÀ» 100% º¸ÁõÇÑ´Ù. ÀÌ ¹æ¹ýÀº 'bcpp' °°Àº ¾Æ¸§´ä°Ô ÇÏ´Â ÇÁ·Î±×·¥Àº Àü¹®¾îÀÇ Æ¯¼ºÀ» Àå´ãÇÏ°í º¸ÁõÇÏ°Ô ÇÒ °ÍÀÌ´Ù. ÀÌ µÎ°³ÀÇ ½ºÅÜÀº Ç×»ó ´ç½ÅÀÌ bcpp, indent ȤÀº cb°°Àº ¾Æ¸§´ä°Ô ÇÏ´Â ÇÁ·Î±×·¥À» »ç¿ëÇϵµ·Ï °·ÂÇÏ°Ô ÃßõÇÑ´Ù. 3. ´Ù¸¥ ¾ð¾î¸¦ À§ÇÑ ¾Æ¸§´ä°Ô ÇÏ´Â ÇÁ·Î±×·¥HTML, SQL, Java, Perl, Fortran °°ÀÌ ´Ù¸¥ ¾ð¾î¸¦ À§ÇÑ ¾Æ¸§´ä°Ô ÇÏ´Â ÇÁ·Î±×·¥À» ¾ò±â À§Çؼ´Â ¾Æ·¡ÀÇ »çÀÌÆ®¿¡ ¹æ¹®Çضó.
HTMLÀ» »ç¿ëÇÏ¿© Àü½ÃÇϱâ À§ÇÑ ÄÚµåÀÇ ÇÁ¸®Á¨Å×À̼ÇÀ» ¸¸µç·Á¸é -
4. °ËÁõ ½ºÅ©¸³Æ®ÀÌ °ÍÀº ¾Æ¸§´ä°Ô ÇÏ´Â ÇÁ·Î±×·¥À» °ËÁõÇϱâ À§ÇÑ ÄܼР½ºÅ©¸³Æ®ÀÌ´Ù. ¸®´ª½º 'contrib' ½Ãµð·Ò¿¡ ÀÖ´Â "pdksh*.rpm" ÀÌ ÇÊ¿äÇÏ´Ù. ÀÌ ÆÄÀÏÀ» 'ÅؽºÆ®' ÆÄÀÏ°ú a+rx·Î ÀúÀåÇضó. ´ç½ÅÀº ÆÞ·Î ÀÌ ¼Ð ½ºÅ©¸³Æ®¸¦ ´Ù½Ã ¾µ ¼ö ÀÖ¾î¼ ´ç½ÅÀº Windows 95/NT ȤÀº MSDOS ¿¡¼ ±×°ÍÀ» ¾µ ¼ö ÀÖ´Ù. bcpp, cb ȤÀº indent¸¦ À§ÇÑ Æ÷ÀÎÆ® PRGM º¯¼ö¸¦ ¼³¸íÇضó. #!/bin/ksh # Verification program to check C++ Beautifiers 'bcpp', 'indent' or cb ############################################################ # Copyright # The copyright policy is GNU/GPL. # Author: Al Dev (Alavoor Vasudevan) alavoor@yahoo.com ############################################################ check_beautify_now() { # Remove all the temp files.... \rm -f ${TMP_FILE} \rm -f ${TMP_CPPFILE}*.* FNAME=$1 if [ ! -f ${FNAME} ]; then print "\nError: The file ${FNAME} does not exist!!. Aborting now ...." exit fi \cp -f ${FNAME} ${TMP_CPPFILE}.cpp ${COMPILER} -c ${TMP_CPPFILE}.cpp if [ ! -f ${TMP_CPPFILE}.o ]; then print "Fatal Error: Failed to compile ${FNAME}. Aborting now... " exit fi \mv -f ${TMP_CPPFILE}.o ${TMP_CPPFILE}_orig.o aa=`basename $PRGM` print "\nRunning, verifying $aa on ${FNAME}" ${PRGM} ${TMP_CPPFILE}.cpp ${COMPILER} -c ${TMP_CPPFILE}.cpp \rm -f $TMP_FILE diff ${TMP_CPPFILE}.o ${TMP_CPPFILE}_orig.o 1> $TMP_FILE 2>> $TMP_FILE result="" result=`wc -c $TMP_FILE | awk '{print $1}' ` if [ "$result" = "0" ]; then print "Success!! Beautifier $aa is working properly!!\n" else print "Fatal Error: Something wrong!! Beautifier is not working!!" exit fi # ${COMPILER} -S ${TMP_CPPFILE}.cpp # diff ${TMP_CPPFILE}.s ${TMP_CPPFILE}_orig.s # Remove all the temp files.... \rm -f ${TMP_FILE} \rm -f ${TMP_CPPFILE}*.* } ########## Main of program begins here ##################3 #PRGM=/usr/bin/bcpp #PRGM=/usr/bin/cb PRGM=/usr/bin/indent COMPILER=/usr/bin/g++ TMP_FILE=beautify.tmp TMP_CPPFILE=beautify-tmp_cppfile print -n "Enter the C++ file name <default is *.cpp> : " read ans if [ "$ans" = "" -o "$ans" = " " ]; then ans="ALL" else FILENAME=$ans fi # Remove all the temp files.... \rm -f ${TMP_FILE} \rm -f ${TMP_CPPFILE}*.* if [ "$ans" != "ALL" ]; then check_beautify_now ${FILENAME} else ls *.cpp | while read FILENAME do check_beautify_now ${FILENAME} done fi 5. °ü·Ã URL¾Æ·¡¿¡ ÀÖ´Â C, C++ °ü·Ã »çÀÌÆ®¸¦ ¹æ¹®Ç϶ó -
6. ÀÌ ¹®¼ÀÇ ´Ù¸¥ Çü½ÄÀÌ ¹®¼´Â 11°³ÀÇ ´Ù¸¥ Çü½ÄÀ¸·Î ÃâÆǵȴÙ. ÀÚ¼¼È÷ ¸»Çϸé - DVI, Postscript, Latex, Adobe Acrobat PDF, LyX, GNU-info, HTML, RTF(Rich Text Format), Plain-text, Unix man pages and SGML.
LaTeX ¹®¼´Â PDF ÆÄÀÏ·Î sgml2latex(±×¸®°í dvips)ÀÇ Ãâ·ÂÀ¸·Î Postscript ÆÄÀÏÀ» ¸¸µé°í Acrobet distill ( http://www.adobe.com )À» ´ÙÀ½ÀÇ ¸í·É¾î¸¦ ÅëÇؼ °£´ÜÈ÷ º¯Çü½Ãų ¼ö ÀÖ´Ù. bash$ man sgml2latex bash$ sgml2latex filename.sgml bash$ man dvips bash$ dvips -o filename.ps filename.dvi bash$ distill filename.ps bash$ man ghostscript bash$ man ps2pdf bash$ ps2pdf input.ps output.pdf bash$ acroread output.pdf & ȤÀº GhostscriptÀÇ ps2pdf ¸í·É¾î·Î ÇÒ ¼ö ÀÖ´Ù. ps2pdf´Â AdobeÀÇ Acrobat DistillerÀÇ ¸ðµç ±â´ÉÀ» °ÅÀÇ ¶È °°ÀÌ ¼öÇàÇÑ´Ù: PostScript ÆÄÀÏÀ» Portable Document Format(PDF) ÆÄÀÏ·Î º¯Çü½ÃŲ´Ù. ps2pdf´Â pdfwrite¶ó°í ºÒ¸®¿ì´Â Ưº°ÇÑ "Ãâ·Â ÀåÄ¡"¸¦ °ñ¶ó³»´Â Ghostscript¸¦ »ç¿ëÇÏ´Â ¸Å¿ì ÀÛÀº ¸í·É¾î ½ºÅ©¸³Æ® (¹èÄ¡ ÆÄÀÏ) µµ±¸ÀÌ´Ù. ps2pdf¸¦ »ç¿ë ÇÏ·Á¸é, pdfwrite ÀåÄ¡´Â Ghostscript°¡ ÄÄÆÄÀÏ µÇ¾úÀ» ¶§ makefile¾È¿¡ Æ÷ÇԵǾî ÀÖ¾î¾ß ÇÑ´Ù. GhostscriptÀÇ ¼³Ä¡ Ç׸ñÀÌ ÀÖ´Â ¹®¼¸¦ ºÁ¶ó. ÀÌ ¹®¼´Â ¿©±â¿¡ ÀÖ´Ù - ¶ÇÇÑ ´ÙÀ½ÀÇ ¹Ì·¯ »çÀÌÆ®¿¡¼ ÀÌ ¹®¼¸¦ ãÀ» ¼ö ÀÖ´Ù -
dvi Çü½ÄÀÇ ¹®¼¸¦ º¸±â À§Çؼ´Â, xdvi ÇÁ·Î±×·¥À» ½á¾ß ÇÑ´Ù. xdvi ÇÁ·Î±×·¥Àº ControlPanel | Applications | Publishing | TeX ¸Þ´º ¹öÆ°¿¡¼ ãÀ» ¼ö ÀÖ´Â tetex-xdvi*.rpm ÆÐÅ°Áö·Î ·¹µåÇÞ ¸®´ª½º¿¡ ÀÖ´Ù. dvi ¹®¼¸¦ Àбâ À§Çؼ´Â ¸í·ÉÀ» ½ÇÇàÇضó -
±×¸®°í ¸¶¿ì½º·Î âÀÇ Å©±â¸¦ ¹Ù²ã¶ó. xdviÀÇ ¸ÇÆäÀÌÁö¸¦ º¸¶ó.
Page Up, Page Down keys °°Àº È»ìÇ¥ Å°¸¦ ½á¶ó, ¶ÇÇÑ À§·Î,
¾Æ·¡·Î, °¡¿îµ¥·Î, ´ÙÀ½ ÆäÀÌÁö·Î, ÀÌÀü ÆäÀÌÁö ±âŸ¸¦ À§Çؼ
f, d, u, c, l, r, p, n ¹®ÀÚ Å°µµ ¾µ ¼ö ÀÖ´Ù.
Àü¹®°¡ ¸Þ´º·Î °¡·Á¸é 'x'¸¦ ´©¸£¶ó.
´ç½ÅÀº Æ÷½ºÆ®½ºÅ©¸³Æ® ÆÄÀÏÀ» 'gv' (ghostview) ¶ó´Â °í½ºÆ®½ºÅ©¸³Æ® ÇÁ·Î±×·¥Àº ghostscript.rpm ÆÐÅ°Áö ȤÀº ·¹µåÇÞ ¸®´ª½ºÀÇ gv ÇÁ·Î±×·¥ ControlPanel | Applications | Graphics ¸Þ´º ¹öÆ°¿¡ ÀÖ´Â gv*.rpm ÆÐÅ°ÁöÀÇ ÇÁ·Î±×·¥À» ½á¼ ÀÐÀ» ¼ö ÀÖ´Ù. gv ÇÁ·Î±×·¥Àº °í½ºÆ®½ºÅ©¸³Æ®¿¡ ºñÇØ ´õ Ä£ÀýÇÏ´Ù. °í½ºÆ®½ºÅ©¸³Æ®¿Í gv´Â ¶ÇÇÑ ´Ù¸¥ OS/2, Windows 95 ±×¸®°í NT °°Àº ´Ù¸¥ Ç÷§Æû¿¡¼µµ ÀÌ¿ë °¡´ÉÇÏ´Ù.
postscript ¹®¼¸¦ ÀÐÀÌ À§Çؼ´Â ´ÙÀ½ÀÇ ¸í·É¾î¸¦ »ç¿ëÇ϶ó -
´ç½ÅÀº Netscape Navigator, Microsoft Internet explorer, Redhat Baron Web browser ȤÀº ´Ù¸¥ ¾î¶² ºê¶ó¿ìÁ®¸¦ ½á¼ HTML Çü½ÄÀÇ ¹®¼¸¦ ÀÐÀ» ¼ö ÀÖ´Ù. ´ç½ÅÀº latex·Î "X-Windows" ÀÇ ¾ÕºÎºÐÀ» LyX¸¦ ½á¼ LyX¸¦ Ãâ·ÂÇؼ latex¸¦ ÀÐÀ» ¼ö ÀÖ´Ù. 7. CopyrightCopyright policy is GNU/GPL as per LDP (Linux Documentation project). LDP is a GNU/GPL project. Additional restrictions are - you must retain the author's name, email address and this copyright notice on all the copies. If you make any changes or additions to this document then you should intimate all the authors of this document. |
The universe is laughing behind your back. |