From d0a94440d928b69ce2a330f2679bd8dd1eac96fb Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 13 Feb 2013 22:33:19 +0000 Subject: [PATCH] 2013-02-13 23:30 UTC+0100 Viktor Szakats (harbour syenar.net) * contrib/hbformat/hbfmtcls.prg * contrib/hbformat/utils/hbformat.ini + allow control for how many spaces to insert (or leave as is) between comment markers and comment text. Thanks to Jose F. Gimenez for the bit-perfect patch. --- harbour/ChangeLog.txt | 7 +++++++ harbour/contrib/hbformat/hbfmtcls.prg | 5 +++-- harbour/contrib/hbformat/utils/hbformat.ini | 3 +++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/harbour/ChangeLog.txt b/harbour/ChangeLog.txt index b0e4648ec2..ca297b1bbe 100644 --- a/harbour/ChangeLog.txt +++ b/harbour/ChangeLog.txt @@ -10,6 +10,13 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2013-02-13 23:30 UTC+0100 Viktor Szakats (harbour syenar.net) + * contrib/hbformat/hbfmtcls.prg + * contrib/hbformat/utils/hbformat.ini + + allow control for how many spaces to insert (or leave + as is) between comment markers and comment text. + Thanks to Jose F. Gimenez for the bit-perfect patch. + 2013-02-13 22:53 UTC+0100 Viktor Szakats (harbour syenar.net) * utils/hbmk2/hbmk2.prg ! fixed libname suggestion in a very obscure case diff --git a/harbour/contrib/hbformat/hbfmtcls.prg b/harbour/contrib/hbformat/hbfmtcls.prg index 8aff1ebaa3..b82b18f242 100644 --- a/harbour/contrib/hbformat/hbfmtcls.prg +++ b/harbour/contrib/hbformat/hbfmtcls.prg @@ -102,6 +102,7 @@ CREATE CLASS HBFormatCode VAR nIndCont INIT 3 // Indent for continuation ( after ';' ) lines - amount of spaces VAR lCnvAst INIT .T. // If true, convert asterisk '*' to '//' VAR lCnvAmp INIT .T. // If true, convert '&&' to '//' + VAR nSpaceComment INIT 1 // Number of spaces after '//' and '/*' comments ( -1 - no change ) VAR lCnvNot INIT .T. // If true, convert .NOT. TO ! VAR nCaseCmd INIT 1 // Case of commands ( -1 - no change, 1 - upper, 2 - lower, 3 - title ) VAR nCaseBoo INIT 1 // Case of boolean operators ( -1 - no change, 1 - upper, 2 - lower, 3 - title ) @@ -283,8 +284,8 @@ METHOD Reformat( aFile ) CLASS HBFormatCode ENDIF IF nPosComment > 0 nPos := nPosComment + iif( SubStr( cLineAll, nPosComment, 1 ) == "*", 1, 2 ) - IF SubStr( cLineAll, nPos, 1 ) != " " - cLineAll := Left( cLineAll, nPos - 1 ) + " " + SubStr( cLineAll, nPos ) + IF ::nSpaceComment >= 0 + cLineAll := Left( cLineAll, nPos - 1 ) + Space( ::nSpaceComment ) + LTrim( SubStr( cLineAll, nPos ) ) ENDIF ENDIF IF ( nPos := FindNotQuoted( "/*", cLineAll ) ) != 0 .AND. ( nPosComment == 0 .OR. nPosComment > nPos ) diff --git a/harbour/contrib/hbformat/utils/hbformat.ini b/harbour/contrib/hbformat/utils/hbformat.ini index 24f80bcc08..a4dceecfdd 100644 --- a/harbour/contrib/hbformat/utils/hbformat.ini +++ b/harbour/contrib/hbformat/utils/hbformat.ini @@ -47,6 +47,9 @@ # If yes, convert '&&' to '//' #lCnvAmp = yes +# Number of spaces after /* and // comments ( -1 - no change ) +#nSpaceComment = 1 + # If yes, convert .NOT. TO ! #lCnvNot = yes