9front - general discussion about 9front
 help / color / mirror / Atom feed
From: Ori Bernstein <ori@eigenstate.org>
To: 9front@9front.org
Subject: Cpp: handle c99 comments by default.
Date: Mon, 17 Jun 2019 12:27:43 -0700	[thread overview]
Message-ID: <20190617122743.f698d460453a6b5f03f38da6@eigenstate.org> (raw)

This change makes the -+ flag default in cpp, and turns it into a no-op.

C99 comments have been the default in compilers for something like 20 years
now. This means we don't need to remember to turn it on when porting software,
and gets rid of cryptic errors about unterminated character constants when
someone writes something like:

	// Didn't need to...

I didn't add a way to turn the option off. All of our software works under
this change, and I can't imagine any place we care that // is a syntax error
rather than a comment.

The flag itself is retained so we don't break existing mkfiles -- but maybe
we want to remove it entirely.

diff -r 40949afe3df8 sys/src/cmd/cpp/cpp.c
--- a/sys/src/cmd/cpp/cpp.c	Mon Jun 17 13:17:16 2019 +0930
+++ b/sys/src/cmd/cpp/cpp.c	Mon Jun 17 12:19:36 2019 -0700
@@ -28,7 +28,6 @@
 	maketokenrow(3, &tr);
 	expandlex();
 	setup(argc, argv);
-	fixlex();
 	iniths();
 	genline();
 	process(&tr);
diff -r 40949afe3df8 sys/src/cmd/cpp/cpp.h
--- a/sys/src/cmd/cpp/cpp.h	Mon Jun 17 13:17:16 2019 +0930
+++ b/sys/src/cmd/cpp/cpp.h	Mon Jun 17 12:19:36 2019 -0700
@@ -86,7 +86,6 @@
 enum errtype { WARNING, ERROR, FATAL };
 
 void	expandlex(void);
-void	fixlex(void);
 void	setup(int, char **);
 #define gettokens cpp_gettokens
 int	gettokens(Tokenrow *, int);
diff -r 40949afe3df8 sys/src/cmd/cpp/lex.c
--- a/sys/src/cmd/cpp/lex.c	Mon Jun 17 13:17:16 2019 +0930
+++ b/sys/src/cmd/cpp/lex.c	Mon Jun 17 12:19:36 2019 -0700
@@ -285,14 +285,6 @@
 	}
 }
 
-void
-fixlex(void)
-{
-	/* do C++ comments? */
-	if (Cplusplus==0)
-		bigfsm['/'][COM1] = bigfsm['x'][COM1];
-}
-
 /*
  * fill in a row of tokens from input, terminated by NL or END
  * First token is put at trp->lp.
diff -r 40949afe3df8 sys/src/cmd/cpp/nlist.c
--- a/sys/src/cmd/cpp/nlist.c	Mon Jun 17 13:17:16 2019 +0930
+++ b/sys/src/cmd/cpp/nlist.c	Mon Jun 17 12:19:36 2019 -0700
@@ -8,7 +8,6 @@
 extern	int	optind;
 int	verbose;
 int	Mflag;
-int	Cplusplus;
 int	nolineinfo;
 Nlist	*kwdefined;
 char	wd[128];
@@ -142,7 +141,7 @@
 			verbose++;
 			break;
 		case '+':
-			Cplusplus++;
+			/* Ignored for compatibility */
 			break;
 		case 'i':
 			debuginclude++;
diff -r 40949afe3df8 sys/src/cmd/pcc.c
--- a/sys/src/cmd/pcc.c	Mon Jun 17 13:17:16 2019 +0930
+++ b/sys/src/cmd/pcc.c	Mon Jun 17 12:19:36 2019 -0700
@@ -65,7 +65,7 @@
 	while(argc > 0) {
 		ARGBEGIN {
 		case '+':
-			append(&cpp, smprint("-%c", ARGC()));
+			/* No-op for compatibility */
 			break;
 		case 'c':
 			cflag = 1;


-- 
Ori Bernstein <ori@eigenstate.org>


             reply	other threads:[~2019-06-17 19:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-17 19:27 Ori Bernstein [this message]
2019-06-17 22:18 ` [9front] " Steve Simon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190617122743.f698d460453a6b5f03f38da6@eigenstate.org \
    --to=ori@eigenstate.org \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).