summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2010-05-30 16:01:51 +0200
committerLubomir Rintel <lkundrak@v3.sk>2013-10-29 16:30:53 +0100
commit4dde350c4cf4e39b184e51a42cf3942e9f50adea (patch)
tree4d76048bd18653eee5fd14d00e05ee7bbdd29abf
parent40891b978c7361e132994b9ae0f7be52589189e5 (diff)
downloaddev86-4dde350c4cf4e39b184e51a42cf3942e9f50adea.tar.gz
Add support for some old K&R post-assignment operator syntax
Old C had "=+" instead of "+=" and so on. To grok it we would need to break later C including ISO and ANSI standards, potentially breaking existing code (=- would no longer be assignment and unary minus), thus this is disabled per default and enabled only with -7.
-rw-r--r--bcc/scan.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/bcc/scan.c b/bcc/scan.c
index 17f22f5..f2b9aeb 100644
--- a/bcc/scan.c
+++ b/bcc/scan.c
@@ -12,6 +12,9 @@
#include "sizes.h"
#include "table.h"
#include "type.h"
+#ifndef VERY_SMALL_MEMORY
+#include "parse.h"
+#endif
#undef EXTERN
#define EXTERN
@@ -598,6 +601,46 @@ PUBLIC void nextsym()
sym = EQOP;
gch1();
}
+/* There's no ancient switch on low memory systems */
+#ifndef VERY_SMALL_MEMORY
+ /* This is how things were in old K&R code.
+ * Note that =- and =* behave differently from ANSI C,
+ * where =- would be assignment and unary minus and
+ * =* would be assignment and pointer dereference. */
+ else if (ancient)
+ {
+ if (ch == '+')
+ {
+ sym = ADDABOP;
+ gch1();
+ }
+ else if (ch == '-')
+ {
+ sym = SUBABOP;
+ gch1();
+ }
+ else if (ch == '*')
+ {
+ sym = MULABOP;
+ gch1();
+ }
+ else if (ch == '/')
+ {
+ sym = DIVABOP;
+ gch1();
+ }
+ else if (ch == '|')
+ {
+ sym = ORABOP;
+ gch1();
+ }
+ else if (ch == '&')
+ {
+ sym = ANDABOP;
+ gch1();
+ }
+ }
+#endif
return;
case ADDOP:
if (ch == '+')