Skip to content

Commit

Permalink
cc: do code for handling module name more transparent
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalak committed Oct 6, 2024
1 parent b54cd36 commit eebc084
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
20 changes: 8 additions & 12 deletions bld/cc/c/ccmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ static char *createFileName( const char *template, const char *ext, bool forceex
{
pgroup2 pg;
bool use_defaults;
const char *module_name;

use_defaults = ( template == NULL );
if( use_defaults )
Expand All @@ -222,13 +223,14 @@ static char *createFileName( const char *template, const char *ext, bool forceex
pg.drive = "";
pg.dir = "";
}
if( pg.fname[0] == '\0' || pg.fname[0] == '*' ) {
pg.fname = ModuleName;
}
if( !forceext && pg.ext[0] != '\0' && !use_defaults ) {
ext = pg.ext;
}
_makepath( FNameBuf, pg.drive, pg.dir, pg.fname, ext );
module_name = pg.fname;
if( module_name[0] == '\0' || module_name[0] == '*' ) {
module_name = FEModuleName();
}
_makepath( FNameBuf, pg.drive, pg.dir, module_name, ext );
return( FNameBuf );
}

Expand Down Expand Up @@ -350,21 +352,15 @@ static void MakePgmName( void )
WholeFName = CMemAlloc( sizeof( STDIN_NAME ) );
strcpy( WholeFName, STDIN_NAME );
pg.fname = WholeFName;
len = sizeof( STDIN_NAME );
} else {
_splitpath2( WholeFName, pg.buffer, &pg.drive, &pg.dir, &pg.fname, &pg.ext );
if( pg.ext[0] == '\0' ) { // no extension
len = strlen( WholeFName );
WholeFName = CMemRealloc( WholeFName, len + ( 1 + sizeof( C_EXT ) ) + 1 );
WholeFName = CMemRealloc( WholeFName, len + 1 + ( sizeof( C_EXT ) - 1 ) + 1 );
strcat( WholeFName + len, "." C_EXT );
}
len = strlen( pg.fname ) + 1;
}
SrcFName = CMemAlloc( len );
strcpy( SrcFName, pg.fname );
if( ModuleName == NULL ) {
ModuleName = SrcFName;
}
SrcFName = CMemStrDup( pg.fname );
}

static void CantOpenFile( const char *name )
Expand Down
6 changes: 2 additions & 4 deletions bld/cc/c/cfeinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -1137,11 +1137,9 @@ CGPOINTER FEAuxInfo( CGPOINTER req_handle, aux_class request )
#endif
#endif
case FEINF_SOURCE_NAME:
if( SrcFName == ModuleName ) {
return( (CGPOINTER)FNameFullPath( FNames ) );
} else {
if( ModuleName != NULL && ModuleName[0] != '\0' )
return( (CGPOINTER)ModuleName );
}
return( (CGPOINTER)FNameFullPath( FNames ) );
case FEINF_CALL_CLASS:
return( (CGPOINTER)getCallClass( req_handle ) );
case FEINF_CALL_CLASS_TARGET:
Expand Down
10 changes: 7 additions & 3 deletions bld/cc/c/cinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@ void SetSegs( void )
user_seg *useg;
textsegment *tseg;
char *name;
const char *module_name;
align_type optsize_segalign;

CompFlags.low_on_memory_printed = false;
Expand All @@ -644,9 +645,10 @@ void SetSegs( void )
if( CompFlags.far_strings ) {
FarStringSegId = SegmentNum++;
}
name = CMemAlloc( strlen( ModuleName ) + 10 + sizeof( "_DATA" ) );
module_name = FEModuleName();
name = CMemAlloc( strlen( module_name ) + 10 + sizeof( "_DATA" ) );
for( segid = FIRST_PRIVATE_SEGMENT; segid < SegmentNum; ++segid ) {
sprintf( name, "%s%d_DATA", ModuleName, segid );
sprintf( name, "%s%d_DATA", module_name, segid );
BEDefSeg( segid, INIT | PRIVATE, name, SegAlign( 16 ) );
}
CMemFree( name );
Expand Down Expand Up @@ -845,7 +847,9 @@ void FEMessage( fe_msg femsg, CGPOINTER parm )
const char *FEModuleName( void )
/******************************/
{
return( (const char *)ModuleName );
if( ModuleName != NULL && ModuleName[0] != '\0' )
return( ModuleName );
return( SrcFName );
}


Expand Down

0 comments on commit eebc084

Please sign in to comment.