[hackers] [scc] [cc1] Simplify comment() || Roberto E. Vargas Caballero

2016-06-22 Thread git
commit 18ab3f16b5df956072ca9de86967136e5dbdc330
Author: Roberto E. Vargas Caballero 
AuthorDate: Thu Jun 23 08:51:56 2016 +0200
Commit: Roberto E. Vargas Caballero 
CommitDate: Thu Jun 23 08:51:56 2016 +0200

[cc1] Simplify comment()

diff --git a/cc1/lex.c b/cc1/lex.c
index 946af62..7e51d8d 100644
--- a/cc1/lex.c
+++ b/cc1/lex.c
@@ -166,18 +166,14 @@ comment(int type)
c = -1;
 repeat:
do {
-   if (!c)
-   goto unterminated;
-   } while (!eof && (c = readchar()) != type);
+   if (!c || eof) {
+   errorp("unterminated comment");
+   return;
+   }
+   } while ((c = readchar()) != type);
 
-   if (eof)
-   goto unterminated;
if (type == '*' && (c = readchar()) != '/')
goto repeat;
-   return;
-
-unterminated:
-   errorp("unterminated comment");
 }
 
 static int



[hackers] [libzahl] update todo || Mattias Andrée

2016-06-22 Thread git
commit 7ad81d682ee7957bb87889e24138c37ed16db3d9
Author: Mattias Andrée 
AuthorDate: Wed Jun 22 20:29:31 2016 +0200
Commit: Mattias Andrée 
CommitDate: Wed Jun 22 20:29:31 2016 +0200

update todo

Signed-off-by: Mattias Andrée 

diff --git a/TODO b/TODO
index 5fe23fa..44af9a2 100644
--- a/TODO
+++ b/TODO
@@ -44,3 +44,6 @@ Add CPU-warmup loop to benchmarks.
 benchmark with worst case, average case, and best case input.
 
 zadd, zsub: benchmark both dense and sparse integers.
+
+Feedback on error handling:
+http://bbs.progrider.org/prog/read/1457215529/31,47



[hackers] [scc] [cc2] Update the value of sym->u.inst || Roberto E. Vargas Caballero

2016-06-22 Thread git
commit c12bae156bbb7ea12f7b9370d5a3e661a2a35645
Author: Roberto E. Vargas Caballero 
AuthorDate: Wed Jun 22 16:38:15 2016 +0200
Commit: Roberto E. Vargas Caballero 
CommitDate: Wed Jun 22 16:41:15 2016 +0200

[cc2] Update the value of sym->u.inst

When we call to setlabel() it means that this label is
pointing to this instruction, so we have to make the label
points to the instruction too, and not only the instruction
to the label.

diff --git a/cc2/code.c b/cc2/code.c
index 8d4bc69..8b433c9 100644
--- a/cc2/code.c
+++ b/cc2/code.c
@@ -84,6 +84,7 @@ setlabel(Symbol *sym)
return;
code(0, NULL, NULL, NULL);
pc->label = sym;
+   sym->u.inst = pc;
 }
 
 void



[hackers] [scc] [cc1] simplify readline() || Quentin Rameau

2016-06-22 Thread git
commit 8945d761a051d5bc4fcfa9fe947a9fb74f9c9641
Author: Quentin Rameau 
AuthorDate: Wed Jun 22 14:26:21 2016 +0200
Commit: Quentin Rameau 
CommitDate: Wed Jun 22 14:27:17 2016 +0200

[cc1] simplify readline()

diff --git a/cc1/lex.c b/cc1/lex.c
index 7f4a6f8..946af62 100644
--- a/cc1/lex.c
+++ b/cc1/lex.c
@@ -201,17 +201,11 @@ repeat:
peekc = 0;
if (c == '\n' || c == '\0')
break;
-   if (c != '/')
+   if (c != '/' || (peekc = readchar()) != '*' && peekc != '/')
continue;
-   if ((c = readchar()) != '*' && c != '/') {
-   peekc = c;
-   c = '/';
-   } else {
-   if (c == '/')
-   c = '\n';
-   comment(c);
-   c = ' ';
-   }
+   comment((peekc == '/') ? '\n' : peekc);
+   peekc = 0;
+   c = ' ';
}
 
if (bp == lim)



[hackers] [scc] [cc1] Do not allow comments between different files || Roberto E. Vargas Caballero

2016-06-22 Thread git
commit 983e4cd19bb2cae781d84d6e75143f9a76935536
Author: Roberto E. Vargas Caballero 
AuthorDate: Wed Jun 22 11:18:47 2016 +0200
Commit: Roberto E. Vargas Caballero 
CommitDate: Wed Jun 22 11:18:47 2016 +0200

[cc1] Do not allow comments between different files

C89 says: 'A source file shall not end in a partial
preprocessing token or comment', and C99 says:
Must a comment be contained within one #include file? (Yes.).
In the case of C99, otherwise is an UB. We think the best
option here is giving an error.

diff --git a/cc1/lex.c b/cc1/lex.c
index 6f89352..7f4a6f8 100644
--- a/cc1/lex.c
+++ b/cc1/lex.c
@@ -167,16 +167,17 @@ comment(int type)
 repeat:
do {
if (!c)
-   delinput();
+   goto unterminated;
} while (!eof && (c = readchar()) != type);
 
-   if (eof) {
-   errorp("unterminated comment");
-   return;
-   }
-
+   if (eof)
+   goto unterminated;
if (type == '*' && (c = readchar()) != '/')
goto repeat;
+   return;
+
+unterminated:
+   errorp("unterminated comment");
 }
 
 static int
diff --git a/cc1/tests/test063.c b/cc1/tests/test063.c
index b4d7f28..1082f49 100644
--- a/cc1/tests/test063.c
+++ b/cc1/tests/test063.c
@@ -4,7 +4,7 @@
 name: TEST063
 description: Test a comment that goes beyond of the end of an included file
 error:
-test063.c:12: error: unterminated comment
+test063.h:9: error: unterminated comment
 test063.c:12: error: #endif expected
 output:
 */



Re: [hackers] [dmenu] [PATCHES] Improve code readability

2016-06-22 Thread Nick
Quoth Klemens Nanni: 
> be thrown away as well, but how is turning this lengthy and empty-bodied
> for loop into a much clearer while loop *not* an improvement in readability?

I found that to be an improvement in readability too, fwiw.



Re: [hackers] [dmenu] [PATCHES] Improve code readability

2016-06-22 Thread Klemens Nanni

On Tue, Jun 21, 2016 at 10:19:57AM +0200, Hiltjo Posthuma wrote:

I don't think it is an improvement, so will disregard it.

Certainly not performance- or featurewise and the first patch may well
be thrown away as well, but how is turning this lengthy and empty-bodied
for loop into a much clearer while loop *not* an improvement in readability?

Just being curious.

Best regards,
kl3


signature.asc
Description: PGP signature


[hackers] [scc] [cc1] Fix comments across several files || Roberto E. Vargas Caballero

2016-06-22 Thread git
commit 60560f4989f5e451ab2d1ad96bc6ebcab6337017
Author: Roberto E. Vargas Caballero 
AuthorDate: Wed Jun 22 09:07:00 2016 +0200
Commit: Roberto E. Vargas Caballero 
CommitDate: Wed Jun 22 09:07:00 2016 +0200

[cc1] Fix comments across several files

If a comment finishes before of the end of its file then
we have to continue from the previous file, and give
a message error when we arrive to the end of the base
file.

diff --git a/cc1/lex.c b/cc1/lex.c
index 84b691e..6f89352 100644
--- a/cc1/lex.c
+++ b/cc1/lex.c
@@ -127,13 +127,15 @@ newline(void)
die("error: input file '%s' too long", input->fname);
 }
 
-static char
+static int
 readchar(void)
 {
int c;
FILE *fp;
 
 repeat:
+   if (eof)
+   return 0;
fp = input->fp;
 
switch (c = getc(fp)) {
@@ -157,21 +159,24 @@ repeat:
 }
 
 static void
-comment(char type)
+comment(int type)
 {
-   if (type == '*') {
-   while (!eof) {
-   while (readchar() != '*' && !eof)
-   /* nothing */;
-   if (readchar() == '/')
-   break;
-   }
-   } else {
-   while (readchar() != '\n' && !eof)
-   /* nothing */;
+   int c;
+
+   c = -1;
+repeat:
+   do {
+   if (!c)
+   delinput();
+   } while (!eof && (c = readchar()) != type);
+
+   if (eof) {
+   errorp("unterminated comment");
+   return;
}
-   if (eof)
-   error("unterminated comment");
+
+   if (type == '*' && (c = readchar()) != '/')
+   goto repeat;
 }
 
 static int
@@ -201,6 +206,8 @@ repeat:
peekc = c;
c = '/';
} else {
+   if (c == '/')
+   c = '\n';
comment(c);
c = ' ';
}
diff --git a/cc1/tests/test063.c b/cc1/tests/test063.c
new file mode 100644
index 000..b4d7f28
--- /dev/null
+++ b/cc1/tests/test063.c
@@ -0,0 +1,12 @@
+/* See LICENSE file for copyright and license details. */
+
+/*
+name: TEST063
+description: Test a comment that goes beyond of the end of an included file
+error:
+test063.c:12: error: unterminated comment
+test063.c:12: error: #endif expected
+output:
+*/
+
+#include "test063.h"
diff --git a/cc1/tests/test063.h b/cc1/tests/test063.h
new file mode 100644
index 000..3ec5025
--- /dev/null
+++ b/cc1/tests/test063.h
@@ -0,0 +1,9 @@
+
+#ifndef TEST_H_
+#define TEST_H_
+
+/*
+ This is an unterminated comment.
+
+
+#endif