9front - general discussion about 9front
 help / color / mirror / Atom feed
* Cpp: handle c99 comments by default.
@ 2019-06-17 19:27 Ori Bernstein
  2019-06-17 22:18 ` [9front] " Steve Simon
  0 siblings, 1 reply; 2+ messages in thread
From: Ori Bernstein @ 2019-06-17 19:27 UTC (permalink / raw)
  To: 9front

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>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-06-17 22:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-17 19:27 Cpp: handle c99 comments by default Ori Bernstein
2019-06-17 22:18 ` [9front] " Steve Simon

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).