summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorRobert de Bath <rdebath@poboxes.com>2002-08-30 20:22:10 +0200
committerLubomir Rintel <lkundrak@v3.sk>2013-10-23 23:48:48 +0200
commit67ef77f9e0744e524188c01fe314b609edd53456 (patch)
tree8a29acbf686764a050b4960a579e2a6d71f43ae2 /cpp
parent26ade8d624457b7164502ed9c190ca3f146bda0c (diff)
downloaddev86-67ef77f9e0744e524188c01fe314b609edd53456.tar.gz
Import Dev86src-0.16.9.tar.gzv0.16.9
Diffstat (limited to 'cpp')
-rwxr-xr-xcpp/cbin0 -> 6204 bytes
-rw-r--r--cpp/c.c28
-rw-r--r--cpp/cpp.c27
-rw-r--r--cpp/main.c17
4 files changed, 52 insertions, 20 deletions
diff --git a/cpp/c b/cpp/c
new file mode 100755
index 0000000..869f927
--- /dev/null
+++ b/cpp/c
Binary files differ
diff --git a/cpp/c.c b/cpp/c.c
index 89f3120..03b3ee3 100644
--- a/cpp/c.c
+++ b/cpp/c.c
@@ -7,29 +7,33 @@
#define strong_alias(Y,X) asm("export _" "X", "_" "X" " = _" "Y" )
#endif
-#if __STDC__
-#define comb(x,y) x ## y
-#warning Using Ansi combine
-#elif __BCC__
-#define comb(x,y) x/**/y
-#warning Using bcc combine
-#else
-#define comb(x,y) x/**/y
-#warning Using K&R combine
+#if 1
+# if __STDC__
+# define comb(x,y) x ## y
+# warning Using Ansi combine
+# elif __BCC__
+# define comb(x,y) x/**/y
+# warning Using bcc combine
+# else
+# define comb(x,y) x/**/y
+# warning Using K&R combine
+# endif
#endif
-#define signed unsigned
-#define unsigned signed
+#define o define
+#o signed unsigned
+#o unsigned signed
#ifdef signed
typedef signed char t_sc;
typedef comb(un,signed) char t_uc;
-#endif
char c;
t_sc sc;
t_uc uc;
+#endif
+#pragma full optimise
strong_alias(main,zulu);
main()
{
diff --git a/cpp/cpp.c b/cpp/cpp.c
index 030535e..231760b 100644
--- a/cpp/cpp.c
+++ b/cpp/cpp.c
@@ -23,17 +23,18 @@
* c_lineno Current line number in file being parsed.
*
* alltok Control flag for the kind of tokens you want (C or generic)
- * dislect Control flag to change the preprocessor for Ansi C.
+ * dialect Control flag to change the preprocessor for Ansi C.
*
* TODO:
* #asm -> asm("...") translation.
* ?: in #if expressions
- * __DATE__ and __TIME__ macros.
- * Add #line directive.
- * Poss: Seperate current directory for #include from errors (#line).
- * Poss: C99 Variable macro args.
+ * Complete #line directive.
* \n in "\n" in a stringized argument.
* Comments in stringized arguments should be deleted.
+ *
+ * Poss: Seperate current directory for #include from errors (#line).
+ * (For editors that hunt down source files)
+ * Poss: C99 Variable macro args.
*/
#define KEEP_SPACE 0
@@ -83,7 +84,7 @@ static int if_count = 0;
static int if_false = 0;
static int if_has_else = 0;
static int if_hidden = 0;
-static int if_stack = 0;
+static unsigned int if_stack = 0;
struct arg_store {
char * name;
@@ -276,7 +277,7 @@ Try_again:
if( cc < WORDSIZE-1 ) *p++ = ch; /* Clip to WORDSIZE */
*p = '\0'; cc++;
ch = chget();
- if (ch == 1) ch = chget();
+ if (ch == SYN) ch = chget();
}
break_break:
/* Numbers */
@@ -671,7 +672,10 @@ do_preproc()
cwarn(curword);
} else if( strcmp(curword, "pragma") == 0 ) {
do_proc_copy_hashline(); pgetc();
- /* Ignore #pragma */
+ /* Ignore #pragma ? */
+ } else if( strcmp(curword, "line") == 0 ) {
+ do_proc_copy_hashline(); pgetc();
+ /* Ignore #line for now. */
} else if( strcmp(curword, "asm") == 0 ) {
alltok |= 0x100;
return do_proc_copy_hashline();
@@ -905,6 +909,13 @@ do_proc_if(type)
int type;
{
int ch = 0;
+ if(if_false && if_hidden)
+ {
+ if( type != 3 ) if_hidden++;
+ do_proc_tail();
+ return 0;
+ }
+
if( type == 3 )
{
if( if_count == 0 )
diff --git a/cpp/main.c b/cpp/main.c
index 0cbdaa3..dfe0e5c 100644
--- a/cpp/main.c
+++ b/cpp/main.c
@@ -7,6 +7,7 @@
#include <ctype.h>
#include <string.h>
#include <malloc.h>
+#include <time.h>
#include "cc.h"
@@ -138,6 +139,22 @@ static char Usage[] = "Usage: cpp -E -0 -Dxxx -Uxxx -Ixxx infile -o outfile";
if (!curfile)
cfatal(Usage);
+ /* Define date and time macros. */
+ if (dialect != DI_KNR) {
+ time_t now;
+ char * timep;
+ char buf[128];
+ time(&now);
+ timep = ctime(&now);
+
+ /* Yes, well */
+ sprintf(buf, "__TIME__=\"%.8s\"", timep + 11);
+ define_macro(buf);
+ /* US order; Seems to be mandated by standard. */
+ sprintf(buf, "__DATE__=\"%.3s %.2s %.4s\"", timep + 4, timep + 8, timep + 20);
+ define_macro(buf);
+ }
+
if (outfile) ofd = fopen(outfile, "w");
else ofd = stdout;
if (!ofd)