summaryrefslogtreecommitdiff
path: root/nasm.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-06-27 15:34:32 -0700
committerH. Peter Anvin <hpa@zytor.com>2009-06-27 15:34:32 -0700
commitf7a9ecaffad2b8dea7171ebac16fe9703d1b58e1 (patch)
treeb9fbc51eb1a2bca7b0d230c6a84f447d426563c0 /nasm.c
parentd28f07f7e34e1201ebc3e62cc2cf38479908fb0b (diff)
downloadnasm-f7a9ecaffad2b8dea7171ebac16fe9703d1b58e1.tar.gz
nasm.c: clean up pass exit logic
Clean up the pass exit logic. In particular, we had a whole routine to do the same thing that the normal exit logic would do anyway if we only would actually get there. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'nasm.c')
-rw-r--r--nasm.c51
1 files changed, 25 insertions, 26 deletions
diff --git a/nasm.c b/nasm.c
index c17e52c8..55352153 100644
--- a/nasm.c
+++ b/nasm.c
@@ -150,8 +150,8 @@ static Preproc no_pp = {
#define SET_CURR_OFFS(x) (in_abs_seg?(void)(abs_offset=(x)):\
(void)(offsets=raa_write(offsets,location.segment,(x))))
-static int want_usage;
-static int terminate_after_phase;
+static bool want_usage;
+static bool terminate_after_phase;
int user_nolist = 0; /* fbk 9/2/00 */
static void nasm_fputs(const char *line, FILE * outfile)
@@ -451,7 +451,7 @@ int main(int argc, char **argv)
break;
}
- if (depend_list)
+ if (depend_list && !terminate_after_phase)
emit_dependencies(depend_list);
if (want_usage)
@@ -462,10 +462,7 @@ int main(int argc, char **argv)
eval_cleanup();
stdscan_cleanup();
- if (terminate_after_phase)
- return 1;
- else
- return 0;
+ return terminate_after_phase;
}
/*
@@ -1700,38 +1697,40 @@ static void assemble_file(char *fname, StrList **depend_ptr)
if (pass1 == 1)
preproc->cleanup(1);
- if (pass1 == 1 && terminate_after_phase) {
- fclose(ofile);
- remove(outname);
- if (want_usage)
- usage();
- exit(1);
- }
-
- if ((passn > 1 && !global_offset_changed) || pass0 == 2)
+ if ((passn > 1 && !global_offset_changed) || pass0 == 2) {
pass0++;
- else if (global_offset_changed && global_offset_changed < prev_offset_changed) {
+ } else if (global_offset_changed &&
+ global_offset_changed < prev_offset_changed) {
prev_offset_changed = global_offset_changed;
stall_count = 0;
- }
- else stall_count++;
+ } else {
+ stall_count++;
+ }
+
+ if (terminate_after_phase)
+ break;
- if((stall_count > 997) || (passn >= pass_max))
+ if ((stall_count > 997) || (passn >= pass_max)) {
/* We get here if the labels don't converge
* Example: FOO equ FOO + 1
*/
report_error(ERR_NONFATAL,
"Can't find valid values for all labels "
- "after %d passes, giving up.\n"
- " Possible cause: recursive equ's.", passn);
+ "after %d passes, giving up.", passn);
+ report_error(ERR_NONFATAL,
+ "Possible causes: recursive EQUs, macro abuse.");
+ terminate_after_phase = true;
+ break;
+ }
}
preproc->cleanup(0);
nasmlist.cleanup();
- if (opt_verbose_info) /* -On and -Ov switches */
- fprintf(stdout,
- "info:: assembly required 1+%d+1 passes\n", passn-3);
-} /* exit from assemble_file (...) */
+ if (!terminate_after_phase && opt_verbose_info) {
+ /* -On and -Ov switches */
+ fprintf(stdout, "info: assembly required 1+%d+1 passes\n", passn-3);
+ }
+}
static enum directives getkw(char **directive, char **value)
{