Re: [dev] [st] [patch] misplaced parenthesis in LEN macro
Martti Kühne, 22 April 2014 : > On Sun, Apr 20, 2014 at 9:24 PM, Rob wrote: >> Into the bikeshed I go... >> >> LEN(a + 2) doesn't mean anything anyway, as a's type decays. >> >> To do it properly there should be some kind of static assert in the >> macro that the argument is of array type. But this is a small code base >> and you'd expect that the code would be run and checked before >> committing, which renders the assert pretty useless. >> >> I think it's fine as it is, in the original C way of doing things, >> garbage in, garbage out, undefined behaviour etc etc. >> >> Rob >> > > > I may remind you there is the case where people make struct > concatenations, just because they can. Arrays of concatenated structs. > The cases where you don't even care when the preprocessor will append > a pointer or a size_t to your type. You don't even want to know. > > So, no, the parentheses are not just needed for style. > > Which we require therefore. I'm not sure I follow? struct A bunch[10]; LEN(bunch) ? Can you give an example? Rob
Re: [dev] [st] [PATCH] Fix techo handling of control and multibyte characters.
Applied with a small modification. Thanks -- Roberto E. Vargas Caballero
Re: [dev] [PATCH] [st 1/3] Use tsetdirt in tscrollup and tscrolldown.
> They are sorted by row number. ... > If you concatenate these ranges, you get orig..term.bot. For me it is a bit unclear, but I can understand that is more logical for another persons. I have applied this patch serie, but maybe could be a good idea add some comments in this functions about how dirty bit is set. Regards, -- Roberto E. Vargas Caballero
[dev] [st PATCH 1/4] Simplify tsetscroll.
--- st.c | 12 +++- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/st.c b/st.c index aba034f..ede90d5 100644 --- a/st.c +++ b/st.c @@ -1765,17 +1765,11 @@ tsetattr(int *attr, int l) { void tsetscroll(int t, int b) { - int temp; - LIMIT(t, 0, term.row-1); LIMIT(b, 0, term.row-1); - if(t > b) { - temp = t; - t = b; - b = temp; - } - term.top = t; - term.bot = b; + + term.top = MIN(t, b); + term.bot = MAX(t, b); } void -- 1.8.4
[dev] [st PATCH 2/4] Use BETWEEN macro in xsetcolorname and fix style.
--- st.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/st.c b/st.c index ede90d5..07f408c 100644 --- a/st.c +++ b/st.c @@ -2750,10 +2750,10 @@ int xsetcolorname(int x, const char *name) { XRenderColor color = { .alpha = 0x }; Colour colour; - if (x < 0 || x > LEN(colorname)) + if(!BETWEEN(x, 0, LEN(colorname))) return -1; if(!name) { - if(16 <= x && x < 16 + 216) { + if(BETWEEN(x, 16, 16 + 215)) { int r = (x - 16) / 36, g = ((x - 16) % 36) / 6, b = (x - 16) % 6; color.red = sixd_to_16bit(r); color.green = sixd_to_16bit(g); @@ -2762,7 +2762,7 @@ xsetcolorname(int x, const char *name) { return 0; /* something went wrong */ dc.col[x] = colour; return 1; - } else if (16 + 216 <= x && x < 256) { + } else if(BETWEEN(x, 16 + 216, 255)) { color.red = color.green = color.blue = 0x0808 + 0x0a0a * (x - (16 + 216)); if(!XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &color, &colour)) return 0; /* something went wrong */ -- 1.8.4
[dev] [st PATCH 3/4] Use != instead of ^ for logical values.
sel.alt is only changed by sel.alt = IS_SET(MODE_ALTSCREEN); --- st.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/st.c b/st.c index 07f408c..e61ee68 100644 --- a/st.c +++ b/st.c @@ -3449,7 +3449,7 @@ drawregion(int x1, int y1, int x2, int y2) { bool ena_sel = sel.ob.x != -1; long unicodep; - if(sel.alt ^ IS_SET(MODE_ALTSCREEN)) + if(sel.alt != IS_SET(MODE_ALTSCREEN)) ena_sel = 0; if(!(xw.state & WIN_VISIBLE)) -- 1.8.4
[dev] [st PATCH 4/4] Optimize tputtab.
Before this patch executing printf '\e[100I' or printf '\e[100Z' resulted in long delay. --- st.c | 28 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/st.c b/st.c index e61ee68..964a0ae 100644 --- a/st.c +++ b/st.c @@ -374,7 +374,7 @@ static void tmoveto(int, int); static void tmoveato(int, int); static void tnew(int, int); static void tnewline(int); -static void tputtab(bool); +static void tputtab(int); static void tputc(char *, int); static void treset(void); static int tresize(int, int); @@ -1995,8 +1995,7 @@ csihandle(void) { break; case 'I': /* CHT -- Cursor Forward Tabulation tab stops */ DEFAULT(csiescseq.arg[0], 1); - while(csiescseq.arg[0]--) - tputtab(1); + tputtab(csiescseq.arg[0]); break; case 'J': /* ED -- Clear screen */ selclear(NULL); @@ -2064,8 +2063,7 @@ csihandle(void) { break; case 'Z': /* CBT -- Cursor Backward Tabulation tab stops */ DEFAULT(csiescseq.arg[0], 1); - while(csiescseq.arg[0]--) - tputtab(0); + tputtab(-csiescseq.arg[0]); break; case 'd': /* VPA -- Move to */ DEFAULT(csiescseq.arg[0], 1); @@ -2280,19 +2278,17 @@ tdump(void) { } void -tputtab(bool forward) { +tputtab(int n) { uint x = term.c.x; - if(forward) { - if(x == term.col) - return; - for(++x; x < term.col && !term.tabs[x]; ++x) - /* nothing */ ; - } else { - if(x == 0) - return; - for(--x; x > 0 && !term.tabs[x]; --x) - /* nothing */ ; + if(n > 0) { + while(x < term.col && n--) + for(++x; x < term.col && !term.tabs[x]; ++x) + /* nothing */ ; + } else if(n < 0) { + while(x > 0 && n++) + for(--x; x > 0 && !term.tabs[x]; --x) + /* nothing */ ; } tmoveto(x, term.c.y); } -- 1.8.4
Re: [dev] [st] [PATCH] Fix techo handling of control and multibyte characters.
On Wed, Apr 23, 2014 at 08:26:32PM +0200, Roberto E. Vargas Caballero wrote: > Applied with a small modification. Thanks u suffix was here for a purpose. The patch has comment about multibyte characters. As 0x20u is unsigned, c was converted to unsigned char before comparison so multibyte characters were not considered control characters. Try enabling echo mode and typing non-ASCII characters (add some non-latin layout or use compose key or copy and paste '®').
Re: [dev][sandy][patch] minor typo correction
On Wed, Apr 23, 2014 at 7:26 AM, wrote: > Minor typo correction. > diff --git a/TODO b/TODO > index 6e01237..535a8e4 100644 > --- a/TODO > +++ b/TODO > @@ -13,7 +13,7 @@ In no particular order, at sandy.c: > At config.def.h: > - Bindings! > - Use local/system script path and all > -- Choose color-set for either black of white bg > +- Choose color-set for either black or white bg > - Define more syntaxes > - Refine syntax regexes Merged. However, I cant seem to push to git.suckless.org: $ git push origin fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. Can any suckless.org admin take a look? In the meantime find sandy at https://bitbucket.org/rafaelgg/sandy Cheers, Rafa
Re: [dev][sandy][patch] minor typo correction
Greetings. On Thu, 24 Apr 2014 06:33:00 +0200 Rafa Garcia Gallego wrote: > On Wed, Apr 23, 2014 at 7:26 AM, wrote: > > Minor typo correction. > > diff --git a/TODO b/TODO > > index 6e01237..535a8e4 100644 > > --- a/TODO > > +++ b/TODO > > @@ -13,7 +13,7 @@ In no particular order, at sandy.c: > > At config.def.h: > > - Bindings! > > - Use local/system script path and all > > -- Choose color-set for either black of white bg > > +- Choose color-set for either black or white bg > > - Define more syntaxes > > - Refine syntax regexes > > Merged. However, I cant seem to push to git.suckless.org: > > $ git push origin > fatal: Could not read from remote repository. > Please make sure you have the correct access rights > and the repository exists. > > > Can any suckless.org admin take a look? This is suckless, think further. What user are you trying to use? Do you even have ssh access? Sincerely, Christoph Lohmann
Re: [dev] [st] [PATCH] Fix techo handling of control and multibyte characters.
Hello, > u suffix was here for a purpose. The patch has comment about multibyte > characters. As 0x20u is unsigned, c was converted to unsigned char > before comparison so multibyte characters were not considered control > characters. I realized it after send the patch. I prefer use uchar instead of suffix u. I known that gcc will complaint with a warning about pointer to data with different signess, but I think we are the programmers and not gcc, so using uchar is the way. Thinking a bit more about this, I don't know why we are using -Wall, because it moves people to follow the GNU criteria, that is the more suck criteria I know (I think it is because they come from the LISP world, and they want to see your code formatted as LISP, and force you to put a lot of unneded parenthesis ;). Regards, -- Roberto E. Vargas Caballero