sc_closeasm(outf,!(sc_asmfile || sc_listing));
sc_closeasm(outf, 0);
int sc_compile(int argc, char *argv[]){  int entry,i,jmpcode;  int retcode;  char incfname[_MAX_PATH];  char reportname[_MAX_PATH];  FILE *binf;  void *inpfmark;  char lcl_ctrlchar;  int lcl_packstr,lcl_needsemicolon,lcl_tabsize;  /* set global variables to their initial value */  binf=NULL;  initglobals();  errorset(sRESET);  errorset(sEXPRRELEASE);  lexinit();  /* make sure that we clean up on a fatal error; do this before the first   * call to error(). */  if ((jmpcode=setjmp(errbuf))!=0)    goto cleanup;  /* allocate memory for fixed tables */  inpfname=(char *)malloc(_MAX_PATH);  litq=(cell *)malloc(litmax*sizeof(cell));  if (litq==NULL)    error(103);         /* insufficient memory */  if (!phopt_init())    error(103);         /* insufficient memory */  setopt(argc,argv,inpfname,outfname,errfname,incfname,reportname);  /* set output names that depend on the input name */  if (sc_listing)    set_extension(outfname,".lst",TRUE);  else    set_extension(outfname,".asm",TRUE);  strcpy(binfname,outfname);  set_extension(binfname,".amx",TRUE);  if (strlen(errfname)!=0)    unlink(errfname);   /* delete file on startup */  else    setcaption();  setconfig(argv[0]);   /* the path to the include files */  lcl_ctrlchar=sc_ctrlchar;  lcl_packstr=sc_packstr;  lcl_needsemicolon=sc_needsemicolon;  lcl_tabsize=sc_tabsize;  inpf=inpf_org=(FILE*)sc_opensrc(inpfname);  if (inpf==NULL)    error(100,inpfname);  freading=TRUE;  outf=(FILE*)sc_openasm(outfname); /* first write to assembler file (may be temporary) */  if (outf==NULL)    error(101,outfname);  /* immediately open the binary file, for other programs to check */  if (sc_asmfile || sc_listing) {    binf=NULL;  } else {    binf=(FILE*)sc_openbin(binfname);    if (binf==NULL)      error(101,binfname);  } /* if */  setconstants();               /* set predefined constants and tagnames */  for (i=0; i<skipinput; i++)   /* skip lines in the input file */    if (sc_readsrc(inpf,pline,sLINEMAX)!=NULL)      fline++;                  /* keep line number up to date */  skipinput=fline;  sc_status=statFIRST;  /* write starting options (from the command line or the configuration file) */  if (sc_listing) {    fprintf(outf,"#pragma ctrlchar '%c'\n",sc_ctrlchar);    fprintf(outf,"#pragma pack %s\n",sc_packstr ? "true" : "false");    fprintf(outf,"#pragma semicolon %s\n",sc_needsemicolon ? "true" : "false");    fprintf(outf,"#pragma tabsize %d\n",sc_tabsize);    setfiledirect(inpfname);  } /* if */  /* do the first pass through the file */  inpfmark=sc_getpossrc(inpf);  if (strlen(incfname)>0) {    if (strcmp(incfname,sDEF_PREFIX)==0) {      plungefile(incfname,FALSE,TRUE);  /* parse "default.inc" */    } else {      if (!plungequalifiedfile(incfname)) /* parse "prefix" include file */        error(100,incfname);            /* cannot read from ... (fatal error) */    } /* if */  } /* if */  preprocess();                         /* fetch first line */  parse();                              /* process all input */  /* second pass */  sc_status=statWRITE;                  /* set, to enable warnings */  /* write a report, if requested */  #if !defined SC_LIGHT    if (sc_makereport) {      FILE *frep=stdout;      if (strlen(reportname)>0)        frep=fopen(reportname,"wb");    /* avoid translation of \n to \r\n in DOS/Windows */      if (frep!=NULL) {        dump_referrers(&glbtab,frep,inpfname);        if (strlen(reportname)>0)          fclose(frep);      } /* if */    } /* if */  #endif  if (sc_listing)    goto cleanup;  /* ??? for re-parsing the listing file instead of the original source   * file (and doing preprocessing twice):   * - close input file, close listing file   * - re-open listing file for reading (inpf)   * - open assembler file (outf)   */  /* reset "defined" flag of all functions and global variables */  reduce_referrers(&glbtab);  delete_symbols(&glbtab,0,TRUE,FALSE);  #if !defined NO_DEFINE    delete_substtable();  #endif  resetglobals();  sc_ctrlchar=lcl_ctrlchar;  sc_packstr=lcl_packstr;  sc_needsemicolon=lcl_needsemicolon;  sc_tabsize=lcl_tabsize;  errorset(sRESET);  /* reset the source file */  inpf=inpf_org;  freading=TRUE;  sc_resetsrc(inpf,inpfmark);   /* reset file position */  fline=skipinput;              /* reset line number */  lexinit();                    /* clear internal flags of lex() */  sc_status=statWRITE;          /* allow to write --this variable was reset by resetglobals() */  writeleader();  setfile(inpfname,fnumber);  if (strlen(incfname)>0) {    if (strcmp(incfname,sDEF_PREFIX)==0)      plungefile(incfname,FALSE,TRUE);  /* parse "default.inc" (again) */    else      plungequalifiedfile(incfname);    /* parse implicit include file (again) */  } /* if */  preprocess();                         /* fetch first line */  parse();                              /* process all input */  /* inpf is already closed when readline() attempts to pop of a file */  writetrailer();                       /* write remaining stuff */  entry=testsymbols(&glbtab,0,TRUE,FALSE);  /* test for unused or undefined                                             * functions and variables */  if (!entry)    error(13);                  /* no entry point (no public functions) */cleanup:  if (inpf!=NULL)               /* main source file is not closed, do it now */    sc_closesrc(inpf);  /* write the binary file (the file is already open) */  if (!(sc_asmfile || sc_listing) && errnum==0 && jmpcode==0) {    assert(binf!=NULL);    sc_resetasm(outf);          /* flush and loop back, for reading */    assemble(binf,outf);        /* assembler file is now input */  } /* if */  if (outf!=NULL)    sc_closeasm(outf,!(sc_asmfile || sc_listing));  if (binf!=NULL)    sc_closebin(binf,errnum!=0);  if (inpfname!=NULL)    free(inpfname);  if (litq!=NULL)    free(litq);  phopt_cleanup();  stgbuffer_cleanup();  assert(jmpcode!=0 || loctab.next==NULL);/* on normal flow, local symbols                                           * should already have been deleted */  delete_symbols(&loctab,0,TRUE,TRUE);    /* delete local variables if not yet                                           * done (i.e. on a fatal error) */  delete_symbols(&glbtab,0,TRUE,TRUE);  delete_consttable(&tagname_tab);  delete_consttable(&libname_tab);  delete_aliastable();  delete_pathtable();  #if !defined NO_DEFINE    delete_substtable();  #endif  if (errnum!=0){    if (strlen(errfname)==0)      sc_printf("\n%d Error%s.\n",errnum,(errnum>1) ? "s" : "");    retcode=2;  } else if (warnnum!=0){    if (strlen(errfname)==0)      sc_printf("\n%d Warning%s.\n",warnnum,(warnnum>1) ? "s" : "");    retcode=1;  } else {    retcode=jmpcode;  } /* if */  #if defined	__WIN32__ || defined _WIN32 || defined _Windows    if (IsWindow(hwndFinish))      PostMessage(hwndFinish,RegisterWindowMessage("SCNotify"),retcode,0L);  #endif  #if defined FORTIFY    Fortify_ListAllMemory();  #endif  return retcode;}