Skip to content

Commit

Permalink
2017-02-06 12:58 UTC Viktor Szakats (vszakats users.noreply.github.com)
Browse files Browse the repository at this point in the history
  * .gitattributes
    % drop list of all extensions, list exceptions only

  * bin/3rdpatch.hb
  * bin/commit.hb
  * config/lang.hb
  * config/postinst.hb
  * contrib/make.hb
  * package/mpkg.hb
  * tests/stripeol.hb
    * '!( x == y )' -> '! x == y', '!( x $ y )' -> '! x $ y'

  * bin/commit.hb
    % remove .gitattributes based logics

  * .gitignore
    % drop lines no longer needed

  * gettools.sh
    * still untested, but likely ok
  • Loading branch information
vszakats committed Feb 6, 2017
1 parent e12eb28 commit ec076bd
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 154 deletions.
56 changes: 2 additions & 54 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,52 +1,6 @@
# Default
* text=auto

# These files are text and should be normalized (convert CRLF => LF)
*.1 text
*.api text
*.asc text
*.bas text
*.c text
*.cfg text
*.ch text
*.cpp text
*.css text
*.def text
*.diff text
*.h text
*.hb text
*.hbc text
*.hbm text
*.hbp text
*.hbx text
*.html text
*.in text
*.ini text
*.js text
*.m text
*.md text
*.mk text
*.pem text
*.po text
*.prg text
*.rb text
*.rc text
*.scss text
*.spec text
*.svg text
*.txt text
*.vbs text
*.xml text
*.xpm text
*.y text
*.yml text
*.yyc text
*.yyh text

# Text files with fixed EOL requirements
*.bat text eol=crlf
*.sh text eol=lf

# Binary files
*.bmp binary
*.dbf binary
Expand All @@ -64,11 +18,5 @@
*.sqlite3 binary
*.ttf binary

# TOTEST:
#*.c text diff=cpp
#*.h text diff=cpp
#*.html text diff=html
#*.m text diff=objc
#*.rb text diff=ruby

## casematters
# Legacy files
*.bat text eol=crlf
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,4 @@ obj
*.bak

# exceptions
!libunicows.a
!unicows.lib
!lib/3rd
!config/*.exe
!/*.exe
22 changes: 22 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,28 @@
git log --pretty=medium --no-merges --date=iso --abbrev-commit HEAD~50..HEAD
See license at the end of file. */

2017-02-06 12:58 UTC Viktor Szakats (vszakats users.noreply.github.com)
* .gitattributes
% drop list of all extensions, list exceptions only

* bin/3rdpatch.hb
* bin/commit.hb
* config/lang.hb
* config/postinst.hb
* contrib/make.hb
* package/mpkg.hb
* tests/stripeol.hb
* '!( x == y )' -> '! x == y', '!( x $ y )' -> '! x $ y'

* bin/commit.hb
% remove .gitattributes based logics

* .gitignore
% drop lines no longer needed

* gettools.sh
* still untested, but likely ok

2017-02-06 10:58 UTC Viktor Szakats (vszakats users.noreply.github.com)
* package/getsrc.sh
* package/mpkg_win.sh
Expand Down
10 changes: 5 additions & 5 deletions bin/3rdpatch.hb
Original file line number Diff line number Diff line change
Expand Up @@ -656,14 +656,14 @@ STATIC FUNCTION WalkAndFind( cTop, cLookFor )

cTop := hb_DirSepAdd( cTop )

FOR EACH aDirEntry IN ASort( hb_vfDirectory( cTop + hb_osFileMask(), "D" ),,, {| aLeft | !( "D" $ aLeft[ F_ATTR ] ) } ) /* Files first */
IF !( "D" $ aDirEntry[ F_ATTR ] )
FOR EACH aDirEntry IN ASort( hb_vfDirectory( cTop + hb_osFileMask(), "D" ),,, {| aLeft | ! "D" $ aLeft[ F_ATTR ] } ) /* Files first */
IF ! "D" $ aDirEntry[ F_ATTR ]
IF aDirEntry[ F_NAME ] == cLookFor
cRetVal := cTop
EXIT
ENDIF
ELSEIF !( aDirEntry[ F_NAME ] == "." ) .AND. ;
!( aDirEntry[ F_NAME ] == ".." )
ELSEIF ! aDirEntry[ F_NAME ] == "." .AND. ;
! aDirEntry[ F_NAME ] == ".."
cRetVal := WalkAndFind( cTop + aDirEntry[ F_NAME ], cLookFor )
IF ! Empty( cRetVal )
EXIT
Expand Down Expand Up @@ -854,7 +854,7 @@ STATIC FUNCTION URL_GetFileName( cURL )
ENDIF

cName := aComponents[ nIdx ]
DO WHILE !( "." $ cName )
DO WHILE ! "." $ cName
cName := aComponents[ --nIdx ]
IF nIdx < 4 /* don't drain all components */
RETURN ""
Expand Down
83 changes: 17 additions & 66 deletions bin/commit.hb
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ STATIC FUNCTION MakeEntry( aChanges, cMyName, cLogName, lAllowChangeLog, cEOL )
cLog += " " + cMyName + cEOL

FOR EACH cLine IN aChanges
IF lAllowChangeLog .OR. !( SubStr( cLine, 5 ) == hb_FNameNameExt( cLogName ) )
IF lAllowChangeLog .OR. ! SubStr( cLine, 5 ) == hb_FNameNameExt( cLogName )
cLog += cLine + cEOL
ENDIF
NEXT
Expand Down Expand Up @@ -452,7 +452,7 @@ STATIC FUNCTION DoctorChanges( cVCS, aChanges, aFiles )
ENDSWITCH
IF ! cStart == ""
AAdd( aNew, " " + cStart + " " + StrTran( SubStr( cLine, 8 + 1 ), "\", "/" ) )
IF !( cStart == "-" )
IF ! cStart == "-"
AAdd( aFiles, SubStr( cLine, 8 + 1 ) )
ENDIF
ENDIF
Expand Down Expand Up @@ -482,7 +482,7 @@ STATIC FUNCTION DoctorChanges( cVCS, aChanges, aFiles )
ENDSWITCH
IF ! cStart == ""
AAdd( aNew, " " + cStart + " " + StrTran( SubStr( cLine, 3 + 1 ), "\", "/" ) )
IF !( cStart == "-" )
IF ! cStart == "-"
cFile := SubStr( cLine, 3 + 1 )
IF ( tmp := At( " -> ", cFile ) ) > 0
cFile := SubStr( cFile, tmp + Len( " -> " ) )
Expand Down Expand Up @@ -664,9 +664,6 @@ STATIC FUNCTION CheckFile( cName, /* @ */ aErr, lApplyFixes, cLocalRoot, lRebase
"*.svg", ;
"*.vbs" }

LOCAL aAnyIdent := { ;
hb_osFileMask() }

LOCAL aCanHaveSpaceAtEol := { ;
"*.dif", ;
"*.md" }
Expand All @@ -691,9 +688,6 @@ STATIC FUNCTION CheckFile( cName, /* @ */ aErr, lApplyFixes, cLocalRoot, lRebase
"src/codepage/*", ;
"src/lang/*" }

LOCAL hFlags
LOCAL aCanHaveIdent
LOCAL hAllowedExt := LoadGitattributes( cLocalRoot + ".gitattributes", @aCanHaveIdent, @hFlags )
LOCAL nLines

/* TODO: extend as you go */
Expand All @@ -713,15 +707,11 @@ STATIC FUNCTION CheckFile( cName, /* @ */ aErr, lApplyFixes, cLocalRoot, lRebase

/* filename checks */

IF hb_FNameExt( cName ) == ""
IF ! FNameExc( cName, aCanHaveNoExtension )
AAdd( aErr, "filename: missing extension" )
ENDIF
ELSEIF ! Empty( hAllowedExt ) .AND. ! hb_FNameExt( cName ) $ hAllowedExt
AAdd( aErr, "filename: unrecognized extension. Either change it or update .gitattributes." )
IF hb_FNameExt( cName ) == "" .AND. ! FNameExc( cName, aCanHaveNoExtension )
AAdd( aErr, "filename: missing extension" )
ENDIF

IF "casematters" $ hFLags .AND. !( cName == Lower( cName ) ) .AND. ! FNameExc( cName, aCanBeUpper )
IF ! cName == Lower( cName ) .AND. ! FNameExc( cName, aCanBeUpper )
AAdd( aErr, "filename: non-lowercase" )
ENDIF

Expand All @@ -740,7 +730,7 @@ STATIC FUNCTION CheckFile( cName, /* @ */ aErr, lApplyFixes, cLocalRoot, lRebase
lReBuild := .F.

/* TOFIX: Harbour repo specific */
IF !( hb_DirSepToOS( "/3rd/" ) $ cName ) .OR. ;
IF ! hb_DirSepToOS( "/3rd/" ) $ cName .OR. ;
hb_FNameName( cName ) == "Makefile" .OR. ;
hb_FNameExt( cName ) == ".hbc" .OR. ;
hb_FNameExt( cName ) == ".hbp"
Expand Down Expand Up @@ -774,14 +764,14 @@ STATIC FUNCTION CheckFile( cName, /* @ */ aErr, lApplyFixes, cLocalRoot, lRebase
ENDIF
ENDIF

IF FNameExc( cName, aForcedCRLF ) .AND. !( cEOL == Chr( 13 ) + Chr( 10 ) )
IF FNameExc( cName, aForcedCRLF ) .AND. ! cEOL == Chr( 13 ) + Chr( 10 )
AAdd( aErr, "content: must use CRLF EOL for file type" )
IF lApplyFixes
cFile := StrTran( StrTran( cFile, Chr( 13 ) ), Chr( 10 ), cEOL := Chr( 13 ) + Chr( 10 ) )
ENDIF
ENDIF

IF FNameExc( cName, aForcedLF ) .AND. !( cEOL == Chr( 10 ) )
IF FNameExc( cName, aForcedLF ) .AND. ! cEOL == Chr( 10 )
AAdd( aErr, "content: must use LF EOL for file type" )
IF lApplyFixes
cFile := StrTran( cFile, Chr( 13 ) )
Expand All @@ -801,7 +791,7 @@ STATIC FUNCTION CheckFile( cName, /* @ */ aErr, lApplyFixes, cLocalRoot, lRebase
cFile := RemoveEndingWhitespace( cFile, iif( cEOL == "", hb_eol(), cEOL ), lRemoveEndingWhitespace )
ENDIF

IF !( hb_BRight( cFile, Len( Chr( 10 ) ) ) == Chr( 10 ) )
IF ! hb_BRight( cFile, Len( Chr( 10 ) ) ) == Chr( 10 )
AAdd( aErr, "content: has no EOL at EOF" )
IF lApplyFixes
cFile += iif( cEOL == "", hb_eol(), cEOL )
Expand Down Expand Up @@ -831,13 +821,8 @@ STATIC FUNCTION CheckFile( cName, /* @ */ aErr, lApplyFixes, cLocalRoot, lRebase
ENDIF
ENDIF

IF ! FNameExc( cName, aAnyIdent ) .AND. ;
( tmp := ( ( "$" + "Id" ) $ cFile ) ) != FNameExc( cName, aCanHaveIdent )
IF tmp
AAdd( aErr, "content: has " + "$" + "Id" )
ELSE
AAdd( aErr, "content: missing " + "$" + "Id" )
ENDIF
IF "$" + "Id" $ cFile
AAdd( aErr, "content: has " + "$" + "Id" )
ENDIF

/* TOFIX: Harbour repo specific */
Expand Down Expand Up @@ -876,7 +861,7 @@ STATIC FUNCTION CheckFile( cName, /* @ */ aErr, lApplyFixes, cLocalRoot, lRebase
RETURN Empty( aErr )

STATIC FUNCTION IsBinary( cFile )
RETURN Chr( 0 ) $ cFile .OR. !( Chr( 10 ) $ cFile )
RETURN Chr( 0 ) $ cFile .OR. ! Chr( 10 ) $ cFile

STATIC FUNCTION RTrimEOL( cFile )

Expand Down Expand Up @@ -971,9 +956,9 @@ STATIC FUNCTION StripCStrings( cFile )

DO WHILE ( tmp := hb_BAt( '"', cFile, nPos ) ) > 0
/* TOFIX: imprecise escaped char detection */
IF ( !( hb_BSubStr( cFile, tmp - 1, 1 ) == "\" ) .OR. ;
IF ( ! hb_BSubStr( cFile, tmp - 1, 1 ) == "\" .OR. ;
hb_BSubStr( cFile, tmp - 2, 2 ) == "\\" ) .AND. ;
!( hb_BSubStr( cFile, tmp - 1, 1 ) + hb_BSubStr( cFile, tmp + 1, 1 ) == "''" )
! hb_BSubStr( cFile, tmp - 1, 1 ) + hb_BSubStr( cFile, tmp + 1, 1 ) == "''"
AAdd( aHits, tmp )
ENDIF
nPos := tmp + 1
Expand Down Expand Up @@ -1104,8 +1089,8 @@ STATIC FUNCTION LoadGitignore( cFileName )
iif( Left( cLine, 1 ) $ "?*/!", "", "*/" ) + ;
cLine + ;
iif( Right( cLine, 1 ) == "/", "*", ;
iif( hb_FNameExt( cLine ) == "" .AND. !( Right( cLine, 2 ) == "*/" ), "/*", "" ) ) )
IF !( ATail( t_aIgnore ) == cLine )
iif( hb_FNameExt( cLine ) == "" .AND. ! Right( cLine, 2 ) == "*/", "/*", "" ) ) )
IF ! ATail( t_aIgnore ) == cLine
IF hb_LeftEq( ATail( t_aIgnore ), "*/" )
AAdd( t_aIgnore, SubStr( ATail( t_aIgnore ), 3 ) )
ENDIF
Expand All @@ -1117,40 +1102,6 @@ STATIC FUNCTION LoadGitignore( cFileName )

RETURN t_aIgnore

STATIC FUNCTION LoadGitattributes( cFileName, /* @ */ aIdent, /* @ */ hFlags )

THREAD STATIC t_hExt
THREAD STATIC t_aIdent
THREAD STATIC t_hFlags

LOCAL cLine
LOCAL tmp

IF t_hExt == NIL
t_hExt := { => }
t_aIdent := {}
t_hFlags := { => }
FOR EACH cLine IN hb_ATokens( hb_MemoRead( cFileName ), .T. )
IF hb_LeftEq( cLine, "*." )
cLine := SubStr( cLine, 2 )
IF ( tmp := At( " ", cLine ) ) > 0
t_hExt[ RTrim( Left( cLine, tmp - 1 ) ) ] := NIL
ENDIF
ENDIF
IF ( tmp := At( " ", cLine ) ) > 0 .AND. "ident" $ SubStr( cLine, tmp + 1 )
AAdd( t_aIdent, RTrim( Left( cLine, tmp - 1 ) ) )
ENDIF
IF hb_LeftEq( cLine, "## " )
t_hFlags[ Lower( SubStr( cLine, 4 ) ) ] := NIL
ENDIF
NEXT
ENDIF

aIdent := t_aIdent
hFlags := t_hFlags

RETURN t_hExt

STATIC FUNCTION my_DirScan( cMask )
RETURN my_DirScanWorker( cMask, {} )

Expand Down
2 changes: 1 addition & 1 deletion config/lang.hb
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ STATIC FUNCTION StrUnspace( cString )

cChar := SubStr( cString, tmp, 1 )

IF !( cChar == " " ) .OR. !( cCharPrev == " " )
IF ! cChar == " " .OR. ! cCharPrev == " "
cResult += cChar
ENDIF

Expand Down
Loading

0 comments on commit ec076bd

Please sign in to comment.