aboutsummaryrefslogtreecommitdiff
path: root/contrib/gcc/tradcpp.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/gcc/tradcpp.c')
-rw-r--r--contrib/gcc/tradcpp.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/contrib/gcc/tradcpp.c b/contrib/gcc/tradcpp.c
index 11c5fd3c5c07..f6bc24aeaa05 100644
--- a/contrib/gcc/tradcpp.c
+++ b/contrib/gcc/tradcpp.c
@@ -86,6 +86,13 @@ int inhibit_warnings = 0;
/* Non-0 means don't output the preprocessed program. */
int inhibit_output = 0;
+/* Nonzero means chars are signed. */
+#if DEFAULT_SIGNED_CHAR
+int flag_signed_char = 1;
+#else
+int flag_signed_char = 0;
+#endif
+
/* Nonzero means warn if slash-star appears in a comment. */
int warn_comments;
@@ -423,6 +430,7 @@ static void grow_outbuf PARAMS ((FILE_BUF *, int));
static int handle_directive PARAMS ((FILE_BUF *, FILE_BUF *));
static void process_include PARAMS ((struct file_name_list *,
const U_CHAR *, int, int, FILE_BUF *));
+static void fixup_newlines PARAMS ((FILE_BUF *));
static void finclude PARAMS ((int, const char *,
struct file_name_list *, FILE_BUF *));
static void init_dependency_output PARAMS ((void));
@@ -627,6 +635,10 @@ main (argc, argv)
user_label_prefix = "_";
else if (!strcmp (argv[i], "-fno-leading-underscore"))
user_label_prefix = "";
+ else if (!strcmp (argv[i], "-fsigned-char"))
+ flag_signed_char = 1;
+ else if (!strcmp (argv[i], "-funsigned-char"))
+ flag_signed_char = 0;
break;
case 'M':
@@ -937,6 +949,7 @@ main (argc, argv)
}
fp->bufp = fp->buf;
fp->if_stack = if_stack;
+ fixup_newlines (fp);
/* Make sure data ends with a newline. And put a null after it. */
@@ -2579,6 +2592,42 @@ process_include (stackp, fbeg, flen, system_header_p, op)
}
}
+/* Replace all CR NL, NL CR and CR sequences with NL. */
+
+static void
+fixup_newlines (FILE_BUF *fp)
+{
+ U_CHAR *p, *q, *end;
+
+ if (fp->length <= 0)
+ return;
+
+ end = fp->buf + fp->length;
+ *end = '\r';
+ p = (U_CHAR *) strchr ((const char *) fp->buf, '\r');
+ *end = '\0';
+ if (p == end)
+ return;
+
+ if (p > fp->buf && p[-1] == '\n')
+ p--;
+ q = p;
+ while (p < end)
+ switch (*p)
+ {
+ default:
+ *q++ = *p++;
+ break;
+ case '\n':
+ case '\r':
+ p += 1 + (p[0] + p[1] == '\n' + '\r');
+ *q++ = '\n';
+ break;
+ }
+
+ fp->length = q - fp->buf;
+}
+
/* Process the contents of include file FNAME, already open on descriptor F,
with output to OP. */
@@ -2653,6 +2702,7 @@ finclude (f, fname, nhd, op)
fp->length = st_size;
}
close (f);
+ fixup_newlines (fp);
/* Make sure data ends with a newline. And put a null after it. */
@@ -5105,6 +5155,9 @@ initialize_builtins ()
#endif
install_value ("__REGISTER_PREFIX__", REGISTER_PREFIX);
install_value ("__USER_LABEL_PREFIX__", user_label_prefix);
+
+ if (flag_signed_char == 0)
+ install_value ("__CHAR_UNSIGNED__", "1");
}
#undef DSC
#undef install_spec