#define CC_OPTION_NO_LEADING_UNDERSCORE 5
#define CC_OPTION_NO_LINEMARKERS 6
#define CC_OPTION_MASM 7
-#define CC_OPTION_MLONG64 8
-#define CC_OPTION_OUTFILE 9
-#define CC_OPTION_PEDANTIC 10
-#define CC_OPTION_PREPOCESS 11
-#define CC_OPTION_STD 12
-#define CC_OPTION_TRANDITIONAL_LINEMARKERS 13
-#define CC_OPTION_UNDEF 14
+#define CC_OPTION_MAX_ERRORS 8
+#define CC_OPTION_MLONG64 9
+#define CC_OPTION_OUTFILE 10
+#define CC_OPTION_PEDANTIC 11
+#define CC_OPTION_PREPOCESS 12
+#define CC_OPTION_STD 13
+#define CC_OPTION_TRANDITIONAL_LINEMARKERS 14
+#define CC_OPTION_UNDEF 15
static struct cc_option opts[] = {
{ "-S", CC_OPTION_COMPILE, CC_OPTION_NO_ARG },
{ "-fno-leading-underscore", CC_OPTION_NO_LEADING_UNDERSCORE, CC_OPTION_NO_ARG },
+ { "-fmax-errors", CC_OPTION_MAX_ERRORS, CC_OPTION_EQUALS_ARG },
{ "-mlong64", CC_OPTION_MLONG64, CC_OPTION_NO_ARG },
{ "-masm", CC_OPTION_MASM, CC_OPTION_EQUALS_ARG },
fprintf (stderr, " <standard>.\n");
fprintf (stderr, " Currently only C89 and C90 are\n");
fprintf (stderr, " supported.\n");
- fprintf (stderr, " -masm=<syntax> Output <systax> compatible syntax.\n");
+ fprintf (stderr, " -masm=<syntax> Output <syntax> compatible syntax.\n");
fprintf (stderr, " Defaults to MASM but also supports\n");
fprintf (stderr, " GNU AT&T, GNU INTEL and NASM.\n");
+ fprintf (stderr, " -fmax-errors=<count> Stop execution after <count> errros.\n");
fprintf (stderr, "\n");
fprintf (stderr, " -fno-leading-underscore Don't prefix symbols with an underscore.\n");
fprintf (stderr, " -mlong64 Convert long to 64-bit.\n");
}
+ case CC_OPTION_MAX_ERRORS: {
+
+ if (!(state->max_errors = atol (optarg))) {
+
+ report_at (program_name, 0, REPORT_ERROR, "invalid number for -fmax-errors=");
+ exit (EXIT_FAILURE);
+
+ }
+
+ break;
+
+ }
+
case CC_OPTION_MLONG64: {
state->long64 = 1;
#include <stdlib.h>
#include <string.h>
+#include "cc.h"
#include "ll.h"
#include "report.h"
va_start (ap, fmt);
output_message (filename, lineno, 0, type, fmt, ap);
va_end (ap);
+
+ if (errors >= state->max_errors) {
+ exit (EXIT_FAILURE);
+ }
}
char *actual_line = get_actual_line (filename, lineno);
- /*if (!(actual_line = get_actual_line (filename, lineno))) {
-
- filename = get_real_filename ();
- lineno += (get_real_line_number () - lineno);
-
- }*/
-
- if (str && caret) { idx = (caret - str) + 1; }
+ if (str && caret) {
+ idx = (caret - str) + 1;
+ }
va_start (ap, fmt);
output_message (filename, lineno, idx, type, fmt, ap);
fprintf (stderr, "^\n");
free (actual_line);
- }/* else {
-
- if (lineno > 0) {
- ident = fprintf (stderr, " %8lu | ", lineno);
- } else {
- ident = fprintf (stderr, "%*s", 12, "");
- }
-
- fprintf (stderr, "%s", str);
-
- if (str[strlen (str) - 1] != '\n') {
- fprintf (stderr, "\n");
- }
-
- len = (idx + ident) - 1;
-
- for (i = 0; i < ident; i++) {
- putc (' ', stderr);
- }
-
- for (; i < len; i++) {
- putc ('-', stderr);
- }
-
- fprintf (stderr, "^\n");
-
- }*/
+ }
+
+ }
+ if (errors >= state->max_errors) {
+ exit (EXIT_FAILURE);
}
}