Commit 56c94f9c authored by JP Dinger's avatar JP Dinger

Add support for last lines without newline in .hosts (untested).

(cherry picked from commit a4f7a49f)

Backported after Ken Dreyer reported the fix works as advertised. [vlc-devel]
parent e4fa6c48
...@@ -335,7 +335,7 @@ int ACL_LoadFile( vlc_acl_t *p_acl, const char *psz_path ) ...@@ -335,7 +335,7 @@ int ACL_LoadFile( vlc_acl_t *p_acl, const char *psz_path )
continue; continue;
ptr = strchr( psz_ip, '\n' ); ptr = strchr( psz_ip, '\n' );
if( ptr == NULL ) if( ptr == NULL && !feof(file) )
{ {
msg_Warn( p_acl->p_owner, "skipping overly long line in %s", msg_Warn( p_acl->p_owner, "skipping overly long line in %s",
psz_path); psz_path);
...@@ -356,16 +356,15 @@ int ACL_LoadFile( vlc_acl_t *p_acl, const char *psz_path ) ...@@ -356,16 +356,15 @@ int ACL_LoadFile( vlc_acl_t *p_acl, const char *psz_path )
continue; /* skip unusable line */ continue; /* skip unusable line */
} }
/* skips comment-only line */ /* look for first space, CR, LF, etc. or comment character */
if( *psz_ip == '#' ) for( ptr = psz_ip; ( *ptr!='#' ) && !isspace( *ptr ) && *ptr; ++ptr );
continue;
/* looks for first space, CR, LF, etc. or end-of-line comment */
/* (there is at least a linefeed) */
for( ptr = psz_ip; ( *ptr != '#' ) && !isspace( *ptr ); ptr++ );
*ptr = '\0'; *ptr = '\0';
/* skip lines without usable information */
if( ptr == psz_ip )
continue;
msg_Dbg( p_acl->p_owner, "restricted to %s", psz_ip ); msg_Dbg( p_acl->p_owner, "restricted to %s", psz_ip );
ptr = strchr( psz_ip, '/' ); ptr = strchr( psz_ip, '/' );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment