From e568d2b16562797b1edd4674bc6dcb8aad7bc565 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sun, 18 May 2003 12:12:07 +0000 Subject: [PATCH] Parse DOS and *nix text files correctly. svn path=/trunk/; revision=4708 --- reactos/tools/mkhive/infcache.c | 29 ++++++++++++++++++++--------- reactos/tools/mkhive/reginf.c | 4 +++- reactos/tools/mkhive/registry.c | 14 +------------- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/reactos/tools/mkhive/infcache.c b/reactos/tools/mkhive/infcache.c index 564292232e8..6757b171fbb 100644 --- a/reactos/tools/mkhive/infcache.c +++ b/reactos/tools/mkhive/infcache.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: infcache.c,v 1.3 2003/04/17 10:41:02 chorns Exp $ +/* $Id: infcache.c,v 1.4 2003/05/18 12:12:07 ekohl Exp $ * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS hive maker * FILE: tools/mkhive/infcache.c @@ -426,7 +426,11 @@ inline static int is_eof( struct parser *parser, const CHAR *ptr ) /* check if the pointer points to an end of line */ inline static int is_eol( struct parser *parser, const CHAR *ptr ) { - return (ptr >= parser->end || *ptr == CONTROL_Z || *ptr == '\r' /*'\n'*/); +// return (ptr >= parser->end || *ptr == CONTROL_Z || *ptr == '\r' /*'\n'*/); + return (ptr >= parser->end || + *ptr == CONTROL_Z || + *ptr == '\n' || + (*ptr == '\r' && *(ptr + 1) == '\n')); } @@ -544,20 +548,24 @@ static const CHAR *line_start_state( struct parser *parser, const CHAR *pos ) { switch(*p) { -// case '\n': case '\r': - p++; + continue; + + case '\n': parser->line_pos++; close_current_line( parser ); break; + case ';': push_state( parser, LINE_START ); set_state( parser, COMMENT ); return p + 1; + case '[': parser->start = p + 1; set_state( parser, SECTION_NAME ); return p + 1; + default: if (!isspace(*p)) { @@ -711,20 +719,23 @@ static const CHAR *eol_backslash_state( struct parser *parser, const CHAR *pos ) { switch(*p) { -// case '\n': case '\r': + continue; + + case '\n': parser->line_pos++; -// parser->start = p + 1; - parser->start = p + 2; + parser->start = p + 1; set_state( parser, LEADING_SPACES ); -// return p + 1; - return p + 2; + return p + 1; + case '\\': continue; + case ';': push_state( parser, EOL_BACKSLASH ); set_state( parser, COMMENT ); return p + 1; + default: if (isspace(*p)) continue; diff --git a/reactos/tools/mkhive/reginf.c b/reactos/tools/mkhive/reginf.c index 6c7e6c2fc60..6a017dd3e46 100644 --- a/reactos/tools/mkhive/reginf.c +++ b/reactos/tools/mkhive/reginf.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: reginf.c,v 1.2 2003/04/17 10:41:02 chorns Exp $ +/* $Id: reginf.c,v 1.3 2003/05/18 12:12:07 ekohl Exp $ * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS hive maker * FILE: tools/mkhive/reginf.h @@ -382,6 +382,8 @@ registry_callback (HINF hInf, PCHAR Section, BOOL Delete) Ok = InfFindFirstLine (hInf, Section, NULL, &Context); + if (!Ok) + return FALSE; for (;Ok; Ok = InfFindNextLine (&Context, &Context)) { diff --git a/reactos/tools/mkhive/registry.c b/reactos/tools/mkhive/registry.c index 115969f3d3b..539abb9213a 100644 --- a/reactos/tools/mkhive/registry.c +++ b/reactos/tools/mkhive/registry.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: registry.c,v 1.3 2003/04/17 10:41:02 chorns Exp $ +/* $Id: registry.c,v 1.4 2003/05/18 12:12:07 ekohl Exp $ * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS hive maker * FILE: tools/mkhive/registry.c @@ -27,7 +27,6 @@ /* * TODO: * - Implement RegDeleteKey(). - * - Implement RegQueryMultipleValue(). * - Fix RegEnumValue(). */ @@ -700,15 +699,4 @@ RegGetValueCount (HKEY Key) return Key->ValueCount; } - - -#if 0 -LONG -RegQueryMultipleValue(HKEY Key, - ...) -{ - return(ERROR_SUCCESS); -} -#endif - /* EOF */