On 20/04/14, sin wrote:
On Sun, Apr 20, 2014 at 02:43:53PM +0200, FRIGN wrote:
On Sun, 20 Apr 2014 13:53:33 +0200
#define LEN(a) (sizeof a / sizeof *a)
is the right way to do it.
You are missing the parentheses there.
Your macro provides the wrong answer for something like:
int a[] =
On Sun, Apr 20, 2014 at 01:08:09PM +0400, non...@inventati.org wrote:
> Patch moves MODBIT to macros section and uses it in tselcs.
Reading this patch, I remember a know bug in st related to tselcs.
After patch 7a4eefe (Add support for multiple charset definitions)
Benno Kroeck noticed me that alo
On Sun, 20 Apr 2014 20:13:02 +0100
sin wrote:
> You are missing the parentheses there.
>
> Your macro provides the wrong answer for something like:
>
> int a[] = { 1, 2, 3, 4, 5 };
> printf("%zu\n", LEN(a + 2));
Ah, that's right!
Thanks for noting this.
Cheers
FRIGN
--
FRIGN
On Sun, Apr 20, 2014 at 02:43:53PM +0200, FRIGN wrote:
> On Sun, 20 Apr 2014 13:53:33 +0200
> Alexander Huemer wrote:
>
> > > […]
> > > -#define LEN(a) (sizeof(a) / sizeof(a[0]))
> > > +#define LEN(a) (sizeof(a) / sizeof(a)[0])
> > > […]
> >
> > Why parenthesis anyway? a[0] is an express
On Sun, Apr 20, 2014 at 08:58:23PM +0200, Roberto E. Vargas Caballero wrote:
> > #define LEN(x) (sizeof (x) / sizeof *(x))
>
> I am used to read the other form, but I thing it is only a question
> of personal taste, and since the other form was sent before your suggestion
> I'll apply it.
Yes, pe
> #define LEN(x) (sizeof (x) / sizeof *(x))
I am used to read the other form, but I thing it is only a question
of personal taste, and since the other form was sent before your suggestion
I'll apply it.
Regards,
--
Roberto E. Vargas Caballero
> Patch moves MODBIT to macros section and uses it in tselcs.
Good catch, I'll apply the patch.
--
Roberto E. Vargas Caballero
> I found the SERRNO Macro slightly confusing, since you have to look it up, if
> you don't know it already. A web search showed it does not seem to be any kind
> of standard. Also there was no reason in the commit log when it was introduced
> in 2009. As you can see it also leads to new patches, w
On Sun, Apr 20, 2014 at 04:07:12PM +0400, non...@inventati.org wrote:
> On Sun, Apr 20, 2014 at 01:53:33PM +0200, Alexander Huemer wrote:
> > Hi,
> >
> > On Sun, Apr 20, 2014 at 03:41:40PM +0400, non...@inventati.org wrote:
> > > […]
> > > -#define LEN(a) (sizeof(a) / sizeof(a[0]))
> > > +#def
On 2014-04-20 14:43 +0200, FRIGN wrote:
> However, I don't see any error in the way it was done before noname
> suggested changing it.
It's a common practice in C macros to enclose each argument instance
with parentheses to avoid most pitfalls. This particular case will most
probably be fine witho
tscrollup and tscrolldown do not use tsetdirt, but their code is
equivalent to
tsetdirt(orig, term.bot-n);
tsetdirt(orig+n, term.bot);
tclearregion also marks cleared lines as dirty.
In tscrolldown it sets lines from term.bot-n+1 to term.bot dirty, and in
tscrollup it sets lines f
---
st.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/st.c b/st.c
index e625237..fecf1c2 100644
--- a/st.c
+++ b/st.c
@@ -1400,9 +1400,8 @@ tscrolldown(int orig, int n) {
LIMIT(n, 0, term.bot-orig+1);
- tclearregion(0, term.bot-n+1, term.col-1, term.bot)
---
st.c | 7 ---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/st.c b/st.c
index fecf1c2..185c615 100644
--- a/st.c
+++ b/st.c
@@ -1416,15 +1416,16 @@ void
tscrollup(int orig, int n) {
int i;
Line temp;
+
LIMIT(n, 0, term.bot-orig+1);
tclearr
---
st.c | 10 --
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/st.c b/st.c
index df660ff..e625237 100644
--- a/st.c
+++ b/st.c
@@ -1401,14 +1401,13 @@ tscrolldown(int orig, int n) {
LIMIT(n, 0, term.bot-orig+1);
tclearregion(0, term.bot-n+1, term.col-1, t
On Sun, Apr 20, 2014 at 03:41:40PM +0400
non...@inventati.org wrote:
> […]
> -#define LEN(a) (sizeof(a) / sizeof(a[0]))
> +#define LEN(a) (sizeof(a) / sizeof(a)[0])
> […]
Btw:
1) Use git format-patch instead of generating normal diffs
2) Don't just send your diffs in without saying anythi
On Sun, 20 Apr 2014 13:53:33 +0200
Alexander Huemer wrote:
> > […]
> > -#define LEN(a) (sizeof(a) / sizeof(a[0]))
> > +#define LEN(a) (sizeof(a) / sizeof(a)[0])
> > […]
>
> Why parenthesis anyway? a[0] is an expression, not a type, and there is
> nothing to group here. sizeof is not a f
On Sun, Apr 20, 2014 at 01:53:33PM +0200, Alexander Huemer wrote:
> Hi,
>
> On Sun, Apr 20, 2014 at 03:41:40PM +0400, non...@inventati.org wrote:
> > […]
> > -#define LEN(a) (sizeof(a) / sizeof(a[0]))
> > +#define LEN(a) (sizeof(a) / sizeof(a)[0])
> > […]
>
> Why parenthesis anyway? a[0]
Hi,
On Sun, Apr 20, 2014 at 03:41:40PM +0400, non...@inventati.org wrote:
> […]
> -#define LEN(a) (sizeof(a) / sizeof(a[0]))
> +#define LEN(a) (sizeof(a) / sizeof(a)[0])
> […]
Why parenthesis anyway? a[0] is an expression, not a type, and there is
nothing to group here. sizeof is not a f
diff --git a/st.c b/st.c
index df660ff..fbbdc34 100644
--- a/st.c
+++ b/st.c
@@ -68,7 +68,7 @@ char *argv0;
#define SERRNO strerror(errno)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) < (b) ? (b) : (a))
-#define LEN(a) (sizeof(a) / sizeof(a[0]))
+#define LEN(a) (si
---
Hello,
I found the SERRNO Macro slightly confusing, since you have to look it up, if
you don't know it already. A web search showed it does not seem to be any kind
of standard. Also there was no reason in the commit log when it was introduced
in 2009. As you can see it also leads to new patc
Greetings.
On Sun, 20 Apr 2014 12:36:56 +0200 non...@inventati.org wrote:
> Patch attached.
You are changing style. Won’t be applied.
Sincerely,
Christoph Lohmann
Patch attached.
diff --git a/st.c b/st.c
index df660ff..5cc5da7 100644
--- a/st.c
+++ b/st.c
@@ -132,7 +132,7 @@ enum term_mode {
MODE_MOUSEMANY = 262144,
MODE_BRCKTPASTE = 524288,
MODE_PRINT = 1048576,
- MODE_MOUSE = MODE_MOUSEBTN|MODE_MOUSEMOTION|MODE_
Replaced strerror(errno) with SERRNO where possible.
diff --git a/st.c b/st.c
index 8237d78..f9ac1f7 100644
--- a/st.c
+++ b/st.c
@@ -1226,7 +1226,7 @@ ttynew(void) {
open(opt_io, O_WRONLY | O_CREAT, 0666);
if(iofd < 0) {
Patch moves MODBIT to macros section and uses it in tselcs.
diff --git a/st.c b/st.c
index df660ff..8237d78 100644
--- a/st.c
+++ b/st.c
@@ -64,7 +64,7 @@ char *argv0;
#define REDRAW_TIMEOUT (80*1000) /* 80 ms */
-/* macros */
+/* Macros */
#define SERRNO strerror(errno)
#define MIN(a, b) (
24 matches
Mail list logo