Re: [dev] [st] [patch] misplaced parenthesis in LEN macro

2014-04-20 Thread Rob
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[] =

Re: [dev] [st] [patch] move MODBIT to Macros section

2014-04-20 Thread Roberto E. Vargas Caballero
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

Re: [dev] [st] [patch] misplaced parenthesis in LEN macro

2014-04-20 Thread FRIGN
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

Re: [dev] [st] [patch] misplaced parenthesis in LEN macro

2014-04-20 Thread sin
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

Re: [dev] [st] [patch] misplaced parenthesis in LEN macro

2014-04-20 Thread sin
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

Re: [dev] [st] [patch] misplaced parenthesis in LEN macro

2014-04-20 Thread Roberto E. Vargas Caballero
> #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

Re: [dev] [st] [patch] move MODBIT to Macros section

2014-04-20 Thread 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

Re: [dev] [PATCH] remove confusing SERRNO macro

2014-04-20 Thread 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

Re: [dev] [st] [patch] misplaced parenthesis in LEN macro

2014-04-20 Thread sin
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

Re: [dev] [st] [patch] misplaced parenthesis in LEN macro

2014-04-20 Thread Balazs Kezes
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

Re: [dev] [PATCH] [st 1/3] Use tsetdirt in tscrollup and tscrolldown.

2014-04-20 Thread noname
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

[dev] [PATCH] [st 2/3] Do not set dirty flag twice in tscrollup and tscrolldown.

2014-04-20 Thread noname
--- 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)

[dev] [PATCH] [st 3/3] Style fixes in tscrollup.

2014-04-20 Thread noname
--- 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

[dev] [PATCH] [st 1/3] Use tsetdirt in tscrollup and tscrolldown.

2014-04-20 Thread noname
--- 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

Re: [dev] [st] [patch] misplaced parenthesis in LEN macro

2014-04-20 Thread FRIGN
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

Re: [dev] [st] [patch] misplaced parenthesis in LEN macro

2014-04-20 Thread FRIGN
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

Re: [dev] [st] [patch] misplaced parenthesis in LEN macro

2014-04-20 Thread noname
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]

Re: [dev] [st] [patch] misplaced parenthesis in LEN macro

2014-04-20 Thread Alexander Huemer
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

Re: [dev] [st] [patch] misplaced parenthesis in LEN macro

2014-04-20 Thread noname
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

[dev] [PATCH] remove confusing SERRNO macro

2014-04-20 Thread Markus Teich
--- 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

Re: [dev] [st] [patch] remove unnecessary line continuations

2014-04-20 Thread Christoph Lohmann
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

Re: [dev] [st] [patch] remove unnecessary line continuations

2014-04-20 Thread noname
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_

Re: [dev] [st] [patch] use SERRNO instead of strerror(errno)

2014-04-20 Thread noname
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) {

[dev] [st] [patch] move MODBIT to Macros section

2014-04-20 Thread noname
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) (