Skip to content

Commit

Permalink
cleanup ORL code
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalak committed Sep 3, 2022
1 parent 4f6dc0c commit c31cdc8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 25 deletions.
13 changes: 3 additions & 10 deletions bld/ndisasm/stand/c/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,6 @@ static long objFilePos;
static unsigned long objFileLen;


static orl_return nopCallBack( const char *str, void *cookie )
{
/* unused parameters */ (void)str; (void)cookie;

return( ORL_OKAY );
}

static orl_return scanTabCallBack( orl_sec_handle shnd, const orl_sec_offset *pstart, const orl_sec_offset *pend, void *cookie )
{
section_ptr section;
Expand Down Expand Up @@ -199,9 +192,9 @@ static return_val processDrectveSection( orl_sec_handle shnd )
if( shnd == ORL_NULL_HANDLE )
return( RC_OKAY );

cb.export_fn = nopCallBack;
cb.deflib_fn = nopCallBack;
cb.entry_fn = nopCallBack;
cb.export_fn = NULL;
cb.deflib_fn = NULL;
cb.entry_fn = NULL;
cb.scantab_fn = scanTabCallBack;

o_error = ORLNoteSecScan( shnd, &cb, NULL );
Expand Down
19 changes: 12 additions & 7 deletions bld/orl/coff/c/cofflwlv.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Open Watcom Project
*
* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved.
* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved.
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
Expand Down Expand Up @@ -495,8 +495,8 @@ static void EatWhite( const char **contents, size_t *len )
}
}

static orl_return ParseExport( const char **contents, size_t *len, orl_note_callbacks *cbs, void *cookie )
/********************************************************************************************************/
static orl_return ParseExport( const char **contents, size_t *len, callback_export_fn *export_fn, void *cookie )
/**************************************************************************************************************/
{
char *arg;
size_t l;
Expand All @@ -507,7 +507,9 @@ static orl_return ParseExport( const char **contents, size_t *len, orl_note_call
arg[l] = 0;
*len -= l;
*contents += l;
return( cbs->export_fn( arg, cookie ) );
if( export_fn == NULL )
return( ORL_OKAY );
return( export_fn( arg, cookie ) );
}


Expand All @@ -526,8 +528,11 @@ static orl_return ParseDefLibEntry( const char **contents, size_t *len,
arg[l] = 0;
*len -= l;
*contents += l;

retval = deflibentry_fn( arg, cookie );
if( deflibentry_fn == NULL ) {
retval = ORL_OKAY;
} else {
retval = deflibentry_fn( arg, cookie );
}
if( retval != ORL_OKAY || **contents != ',' )
break;
(*contents)++;
Expand All @@ -551,7 +556,7 @@ orl_return CoffParseDrectve( const char *contents, size_t len, orl_note_callback
break;
contents++; len--;
if( strnicmp( cmd, "export", 6 ) == 0 ) {
if( ParseExport( &contents, &len, cbs, cookie ) != ORL_OKAY ) {
if( ParseExport( &contents, &len, cbs->export_fn, cookie ) != ORL_OKAY ) {
break;
}
} else if( strnicmp( cmd, "defaultlib", 10 ) == 0 ) {
Expand Down
19 changes: 12 additions & 7 deletions bld/orl/elf/c/elflwlv.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Open Watcom Project
*
* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved.
* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved.
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
Expand Down Expand Up @@ -593,8 +593,8 @@ static void EatWhite( const char **contents, size_t *len )
}
}

static orl_return ParseExport( const char **contents, size_t *len, orl_note_callbacks *cbs, void *cookie )
/********************************************************************************************************/
static orl_return ParseExport( const char **contents, size_t *len, callback_export_fn *export_fn, void *cookie )
/**************************************************************************************************************/
{
char *arg;
size_t l;
Expand All @@ -605,7 +605,9 @@ static orl_return ParseExport( const char **contents, size_t *len, orl_note_call
arg[l] = 0;
*len -= l;
*contents += l;
return( cbs->export_fn( arg, cookie ) );
if( export_fn == NULL )
return( ORL_OKAY );
return( export_fn( arg, cookie ) );
}


Expand All @@ -624,8 +626,11 @@ static orl_return ParseDefLibEntry( const char **contents, size_t *len,
arg[l] = 0;
*len -= l;
*contents += l;

retval = deflibentry_fn( arg, cookie );
if( deflibentry_fn == NULL ) {
retval = ORL_OKAY;
} else {
retval = deflibentry_fn( arg, cookie );
}
if( retval != ORL_OKAY || **contents != ',' )
break;
(*contents)++;
Expand All @@ -649,7 +654,7 @@ orl_return ElfParseDrectve( const char *contents, size_t len, orl_note_callbacks
break;
contents++; len--;
if( strnicmp( cmd, "export", 6 ) == 0 ) {
if( ParseExport( &contents, &len, cbs, cookie ) != ORL_OKAY ) {
if( ParseExport( &contents, &len, cbs->export_fn, cookie ) != ORL_OKAY ) {
break;
}
} else if( strnicmp( cmd, "defaultlib", 10 ) == 0 ) {
Expand Down
3 changes: 2 additions & 1 deletion bld/wl/c/objorl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Open Watcom Project
*
* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved.
* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved.
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
Expand Down Expand Up @@ -341,6 +341,7 @@ static orl_return P1Note( orl_sec_handle sec )
cb.export_fn = ExportCallback;
cb.deflib_fn = DeflibCallback;
cb.entry_fn = EntryCallback;
cb.scantab_fn = NULL;
ORLNoteSecScan( sec, &cb, NULL );
return( ORL_OKAY );
}
Expand Down

0 comments on commit c31cdc8

Please sign in to comment.