[hackers][vis][PATCH] Don't use an offset of 1 for the 'L' command by default
--- This was the easiest way to fix this that I could think of (without duplicating most of the 'return' line). vis-motions.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vis-motions.c b/vis-motions.c index 9bd95b9..f00d525 100644 --- a/vis-motions.c +++ b/vis-motions.c @@ -99,7 +99,10 @@ static size_t view_lines_middle(Vis *vis, View *view) { static size_t view_lines_bottom(Vis *vis, View *view) { int h = view_height_get(vis->win->view); - return view_screenline_goto(vis->win->view, h - vis->action.count); + int offset = 0; + if (vis->action.count > 1) + offset = vis->action.count; + return view_screenline_goto(vis->win->view, h - offset); } static size_t window_changelist_next(Vis *vis, Win *win, size_t pos) { -- 2.5.0
[hackers] [scc] Add initializer struct || Roberto E. Vargas Caballero
commit 671acae249562120edaec2fb6ff24411ef9be84c Author: Roberto E. Vargas CaballeroAuthorDate: Sun Jan 17 20:47:02 2016 +0100 Commit: Roberto E. Vargas Caballero CommitDate: Sun Jan 17 20:47:02 2016 +0100 Add initializer struct This struct is needed for the designated initializers, because we have to process the full designation before of emitting something. diff --git a/cc1/init.c b/cc1/init.c index f56e47f..b2ae095 100644 --- a/cc1/init.c +++ b/cc1/init.c @@ -11,6 +11,12 @@ struct designator { struct designator *next; }; +struct inititlizer { + Node *expr; + struct designator *dp; + struct inititalizer *next; +}; + static TINT arydesig(Type *tp) { @@ -56,7 +62,7 @@ fielddesig(Type *tp) static struct designator * designation(Type *tp) { - struct designator *des = NULL, *d; + struct designator *dp, *d, *head; TINT (*fun)(Type *); for (;;) { @@ -64,37 +70,38 @@ designation(Type *tp) case '[': fun = arydesig; break; case '.': fun = fielddesig; break; default: - if (des) + if (head) expect('='); - return des; + return head; } d = xmalloc(sizeof(*d)); d->next = NULL; - if (!des) { - des = d; + if (!head) { + head = dp = d; } else { - des->next = d; - des = d; + dp->next = d; + dp = d; } - des->pos = (*fun)(tp); + dp->pos = (*fun)(tp); } } -static void +static struct designator * initlist(Symbol *sym, Type *tp) { - struct designator *des; + struct designator *dp; + struct inititlizer *ip; int toomany = 0; TINT n; Type *newtp; for (n = 0; ; ++n) { - if ((des = designation(tp)) == NULL) { - des = xmalloc(sizeof(*des)); - des->pos = n; + if ((dp = designation(tp)) == NULL) { + dp = xmalloc(sizeof(*dp)); + dp->pos = n; } else { - n = des->pos; + n = dp->pos; } switch (tp->op) { case ARY: @@ -128,7 +135,10 @@ initlist(Symbol *sym, Type *tp) } break; } - initializer(sym, newtp, n); + if (accept('{')) + return initlist(sym, tp); + ip->expr = assign(NULL); + if (!accept(',')) break; } @@ -138,10 +148,9 @@ initlist(Symbol *sym, Type *tp) tp->n.elem = n + 1; tp->defined = 1; } + return dp; } -extern Node *assign(Node *np); - void initializer(Symbol *sym, Type *tp, int nelem) { @@ -153,20 +162,13 @@ initializer(Symbol *sym, Type *tp, int nelem) switch (yytoken) { case '{': - initlist(sym, tp); /* FIXME: This code is not complete */ + initlist(sym, tp); return; case '=': np = assign(varnode(sym)); break; } - /* FIXME: old code used in the recursive call -* if (!sym) -* return; -* if (nelem >= 0) -* return; -*/ - if (flags & ISDEFINED) { errorp("redeclaration of '%s'", sym->name); } else if ((flags & (ISGLOBAL|ISLOCAL|ISPRIVATE)) != 0) {
[hackers] [scc] Reduce indentation in initlist() || Roberto E. Vargas Caballero
commit a1254513235f39ea3816072cf50c0a46f6155e67 Author: Roberto E. Vargas CaballeroAuthorDate: Sun Jan 17 20:53:55 2016 +0100 Commit: Roberto E. Vargas Caballero CommitDate: Sun Jan 17 21:07:13 2016 +0100 Reduce indentation in initlist() diff --git a/cc1/init.c b/cc1/init.c index b2ae095..651a65a 100644 --- a/cc1/init.c +++ b/cc1/init.c @@ -105,34 +105,34 @@ initlist(Symbol *sym, Type *tp) } switch (tp->op) { case ARY: - if (tp->defined && n >= tp->n.elem) { - if (!toomany) - warn("excess elements in array initializer"); - toomany = 1; - sym = NULL; - } newtp = tp->type; + if (!tp->defined || n < tp->n.elem) + break; + if (!toomany) + warn("excess elements in array initializer"); + toomany = 1; + sym = NULL; break; case STRUCT: - if (n >= tp->n.elem) { - if (!toomany) - warn("excess elements in struct initializer"); - toomany = 1; - sym = NULL; - } else { + if (n < tp->n.elem) { sym = tp->p.fields[n]; newtp = sym->type; + break; } + if (!toomany) + warn("excess elements in struct initializer"); + toomany = 1; + sym = NULL; break; default: newtp = tp; warn("braces around scalar initializer"); - if (n > 0) { - if (!toomany) - warn("excess elements in scalar initializer"); - toomany = 1; - sym = NULL; - } + if (n <= 0) + break; + if (!toomany) + warn("excess elements in scalar initializer"); + toomany = 1; + sym = NULL; break; } if (accept('{'))
[hackers] [scc] Move initializer code to a new file || Roberto E. Vargas Caballero
commit 38c240c4f09858a4ce71d70ee7fe16e7df7c9bff Author: Roberto E. Vargas CaballeroAuthorDate: Sun Jan 17 11:59:04 2016 +0100 Commit: Roberto E. Vargas Caballero CommitDate: Sun Jan 17 14:09:34 2016 +0100 Move initializer code to a new file This code is going to be too long, and it is not totally related to expressions, so it is better to create a new file. diff --git a/cc1/Makefile b/cc1/Makefile index 30b459b..01dd816 100644 --- a/cc1/Makefile +++ b/cc1/Makefile @@ -3,7 +3,7 @@ include ../config.mk OBJS = types.o decl.o lex.o error.o symbol.o main.o expr.o \ - code.o stmt.o cpp.o fold.o + code.o stmt.o cpp.o fold.o init.o all: cc1 diff --git a/cc1/cc1.h b/cc1/cc1.h index 73a76fb..47710b7 100644 --- a/cc1/cc1.h +++ b/cc1/cc1.h @@ -374,13 +374,14 @@ extern Node *castcode(Node *np, Type *newtp); extern TUINT ones(int nbytes); /* expr.c */ -extern Node *expr(void), *negate(Node *np), *constexpr(void); +extern Node *decay(Node *), *negate(Node *np), *assign(Node *np);; extern Node *convert(Node *np, Type *tp1, char iscast); -extern Node *iconstexpr(void), *condexpr(void); +extern Node *iconstexpr(void), *condexpr(void), *expr(void); extern bool isnodecmp(int op); extern int negop(int op); extern bool cmpnode(Node *np, TUINT val); -extern Node *decay(Node *np); + +/* init.c */ extern void initializer(Symbol *sym, Type *tp, int nelem); /* cpp.c */ diff --git a/cc1/decl.c b/cc1/decl.c index c1fcdac..e2fbae7 100644 --- a/cc1/decl.c +++ b/cc1/decl.c @@ -779,7 +779,7 @@ identifier(struct decl *dcl) if (sym->token == IDEN && sym->type->op != FTN) emit(ODECL, sym); - if (accept('=')) + if (yytoken == '=') initializer(sym, sym->type, -1); if (!(sym->flags & (ISGLOBAL|ISEXTERN)) && tp->op != FTN) sym->flags |= ISDEFINED; diff --git a/cc1/expr.c b/cc1/expr.c index 36eef5f..262f261 100644 --- a/cc1/expr.c +++ b/cc1/expr.c @@ -629,8 +629,6 @@ primary(void) return np; } -static Node *assign(void); - static Node * arguments(Node *np) { @@ -659,7 +657,7 @@ arguments(Node *np) toomany = 0; do { - arg = decay(assign()); + arg = decay(assign(NULL)); argtype = *targs; if (argtype == ellipsistype) { n = 0; @@ -1007,16 +1005,22 @@ ternary(void) return cond; } -static Node * -assign(void) +Node * +assign(Node *np) { - Node *np, *(*fun)(char , Node *, Node *); + Node *(*fun)(char , Node *, Node *); char op; - np = ternary(); + if (np) { + op = OINIT; + } else { + op = OASSIGN; + np = ternary(); + } + for (;;) { switch (yytoken) { - case '=':op = OASSIGN; fun = assignop; break; + case '=': /* op = op; */; fun = assignop; break; case MUL_EQ: op = OA_MUL; fun = arithmetic; break; case DIV_EQ: op = OA_DIV; fun = arithmetic; break; case MOD_EQ: op = OA_MOD; fun = integerop; break; @@ -1031,7 +1035,7 @@ assign(void) } chklvalue(np); next(); - np = (fun)(op, np, assign()); + np = (fun)(op, np, assign(NULL)); } } @@ -1069,9 +1073,9 @@ expr(void) { Node *lp, *rp; - lp = assign(); + lp = assign(NULL); while (accept(',')) { - rp = assign(); + rp = assign(NULL); lp = node(OCOMMA, rp->type, lp, rp); } @@ -1088,176 +1092,3 @@ condexpr(void) warn("conditional expression is constant"); return np; } - -struct designator { - TINT pos; - struct designator *next; -}; - -static TINT -arydesig(Type *tp) -{ - TINT npos; - Node *np; - - if (tp->op != ARY) - errorp("array index in non-array initializer"); - next(); - np = iconstexpr(); - npos = np->sym->u.i; - freetree(np); - expect(']'); - return npos; -} - -static TINT -fielddesig(Type *tp) -{ - TINT npos; - int ons; - Symbol *sym, **p; - - if (!tp->aggreg) - errorp("field name not in record or union initializer"); - ons = namespace; - namespace = tp->ns; - next(); - namespace = ons; - if (yytoken != IDEN) - unexpected(); - sym = yylval.sym; - if ((sym->flags & ISDECLARED) == 0) { - errorp(" unknown field '%s' specified in initializer", - sym->name); - return 0; - } - for (p = tp->p.fields; *p != sym; ++p) - /* nothing */; - return p - tp->p.fields; -} - -static struct designator * -designation(Type *tp) -{ - struct designator *des = NULL, *d; - TINT
[hackers] [scc] Pass pointer to the initializer struct to the designations || Roberto E. Vargas Caballero
commit 5d74dc264ed9a012ad74016ed02b2cd9d96d75b1 Author: Roberto E. Vargas CaballeroAuthorDate: Sun Jan 17 21:40:17 2016 +0100 Commit: Roberto E. Vargas Caballero CommitDate: Sun Jan 17 21:40:17 2016 +0100 Pass pointer to the initializer struct to the designations We need the state of the current initialization in the full initializer, and in this cases the best approach is to pass a struct to all the functions with the data that they need. diff --git a/cc1/init.c b/cc1/init.c index 651a65a..668f830 100644 --- a/cc1/init.c +++ b/cc1/init.c @@ -6,24 +6,26 @@ #include "../inc/sizes.h" #include "cc1.h" +typedef struct inititlizer Init; + struct designator { TINT pos; + Node *expr; struct designator *next; }; struct inititlizer { - Node *expr; - struct designator *dp; - struct inititalizer *next; + Type *type; + struct designator *head; }; static TINT -arydesig(Type *tp) +arydesig(Init *ip) { TINT npos; Node *np; - if (tp->op != ARY) + if (ip->type->op != ARY) errorp("array index in non-array initializer"); next(); np = iconstexpr(); @@ -34,11 +36,12 @@ arydesig(Type *tp) } static TINT -fielddesig(Type *tp) +fielddesig(Init *ip) { TINT npos; int ons; Symbol *sym, **p; + Type *tp = ip->type; if (!tp->aggreg) errorp("field name not in record or union initializer"); @@ -59,50 +62,38 @@ fielddesig(Type *tp) return p - tp->p.fields; } -static struct designator * -designation(Type *tp) +static Init * +designation(Init *ip) { - struct designator *dp, *d, *head; - TINT (*fun)(Type *); + struct designator *dp; + TINT (*fun)(Init *); - for (;;) { - switch (yytoken) { - case '[': fun = arydesig; break; - case '.': fun = fielddesig; break; - default: - if (head) - expect('='); - return head; - } - d = xmalloc(sizeof(*d)); - d->next = NULL; - - if (!head) { - head = dp = d; - } else { - dp->next = d; - dp = d; - } - dp->pos = (*fun)(tp); + dp = xmalloc(sizeof(*dp)); + dp->next = ip->head; + ip->head = dp; + + switch (yytoken) { + case '[': fun = arydesig; break; + case '.': fun = fielddesig; break; + default: return ip; } + + dp->pos = (*fun)(ip); + expect('='); + return ip; } -static struct designator * +static Node * initlist(Symbol *sym, Type *tp) { - struct designator *dp; struct inititlizer *ip; int toomany = 0; TINT n; Type *newtp; + /* TODO: catch the case of empty list */ for (n = 0; ; ++n) { - if ((dp = designation(tp)) == NULL) { - dp = xmalloc(sizeof(*dp)); - dp->pos = n; - } else { - n = dp->pos; - } + designation(ip); switch (tp->op) { case ARY: newtp = tp->type; @@ -137,7 +128,7 @@ initlist(Symbol *sym, Type *tp) } if (accept('{')) return initlist(sym, tp); - ip->expr = assign(NULL); + ip->head->expr = assign(NULL); if (!accept(',')) break; @@ -148,7 +139,7 @@ initlist(Symbol *sym, Type *tp) tp->n.elem = n + 1; tp->defined = 1; } - return dp; + return NULL; } void
[hackers][vis][PATCH] Don't use an offset of 1 for the 'L' command by default
--- This was the easiest way to fix this that I could think of (without duplicating most of the 'return' line). vis-motions.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vis-motions.c b/vis-motions.c index 9bd95b9..f00d525 100644 --- a/vis-motions.c +++ b/vis-motions.c @@ -99,7 +99,10 @@ static size_t view_lines_middle(Vis *vis, View *view) { static size_t view_lines_bottom(Vis *vis, View *view) { int h = view_height_get(vis->win->view); - return view_screenline_goto(vis->win->view, h - vis->action.count); + int offset = 0; + if (vis->action.count > 1) + offset = vis->action.count; + return view_screenline_goto(vis->win->view, h - offset); } static size_t window_changelist_next(Vis *vis, Win *win, size_t pos) { -- 2.5.0
[hackers] [farbfeld] Add ICC-color-profile handling to jpg2ff || FRIGN
commit 93204899d4a27d2ecefe7fe7f0902f94cab72268 Author: FRIGNAuthorDate: Sun Jan 17 21:03:19 2016 +0100 Commit: FRIGN CommitDate: Sun Jan 17 21:03:19 2016 +0100 Add ICC-color-profile handling to jpg2ff And fix a bug in the transforms that was introduced yesterday. The only thing remaining for jpg is handling EXIF-embedded color profiles, but the EXIF format sucks so bad. diff --git a/jpg2ff.c b/jpg2ff.c index aec6dd0..c1a0f92 100644 --- a/jpg2ff.c +++ b/jpg2ff.c @@ -20,7 +20,6 @@ static cmsCIExyYTRIPLE primaries = { { 0.0366, 0.0001, 0.86 }, /* blue */ }; - METHODDEF(void) jpeg_error(j_common_ptr cinfo) { @@ -32,10 +31,11 @@ jpeg_error(j_common_ptr cinfo) int main(int argc, char *argv[]) { - cmsHPROFILE in_profile, out_profile; + cmsHPROFILE in_profile = NULL, out_profile; cmsHTRANSFORM transform; cmsToneCurve *gamma18, *out_curves[3]; struct jpeg_decompress_struct cinfo; + jpeg_saved_marker_ptr marker; struct jpeg_error_mgr jerr; uint32_t width, height, val_be; uint16_t *ff_row; @@ -54,6 +54,10 @@ main(int argc, char *argv[]) jerr.error_exit = jpeg_error; jpeg_create_decompress(); + + jpeg_save_markers(, JPEG_APP0 + 1, 0x); /* exif data */ + jpeg_save_markers(, JPEG_APP0 + 2, 0x); /* icc data */ + jpeg_stdio_src(, stdin); jpeg_read_header(, TRUE); @@ -64,6 +68,23 @@ main(int argc, char *argv[]) cinfo.output_components = 3; /* color components per pixel */ cinfo.out_color_space = JCS_RGB; /* input color space */ + /* extract metadata */ + marker = cinfo.marker_list; + for(; marker; marker = marker->next) { + if (!marker->data || !marker->data_length) + continue; + if (marker->marker == JPEG_APP0 + 1) { + /* exif data marker */ + /* todo: Should we handle icc data from exif? */ + } else if (marker->marker == JPEG_APP0 + 2) { + /* icc data marker */ + if (!(in_profile = cmsOpenProfileFromMem( + marker->data + 14, + marker->data_length - 14))) + goto lcmserr; + } + } + jpeg_start_decompress(); jpeg_row_len = width * cinfo.output_components; @@ -77,7 +98,7 @@ main(int argc, char *argv[]) } /* icc profile (output ProPhoto RGB) */ - if (!(in_profile = cmsCreate_sRGBProfile())) + if (!in_profile && !(in_profile = cmsCreate_sRGBProfile())) goto lcmserr; if (!(gamma18 = cmsBuildGamma(NULL, 1.8))) goto lcmserr; @@ -112,7 +133,7 @@ main(int argc, char *argv[]) ff_row[dx+3] = 65535; } - cmsDoTransform(transform, ff_row, ff_row, ff_row_len); + cmsDoTransform(transform, ff_row, ff_row, ff_row_len / 4); for (i = 0; i < ff_row_len; i++) { /* re-add alpha */
[hackers] [farbfeld] Fix gcc-optimization bug in png2ff || FRIGN
commit 42ace91b3ddba2fa40e0362ce7aba814aa7dd79c Author: FRIGNAuthorDate: Sun Jan 17 21:01:50 2016 +0100 Commit: FRIGN CommitDate: Sun Jan 17 21:01:50 2016 +0100 Fix gcc-optimization bug in png2ff For some reason, those strange png_char_pp-passes were optimized away in some way, yielding in icc_len = 0. I now explicitly use the pointers to indicate to the compiler that we pass by reference. Fuck those png types... diff --git a/png2ff.c b/png2ff.c index aea7a50..97bcdce 100644 --- a/png2ff.c +++ b/png2ff.c @@ -35,8 +35,8 @@ main(int argc, char *argv[]) cmsToneCurve *gamma18, *out_curves[3]; png_structp png_struct_p; png_infop png_info_p; - png_bytepp png_row_p, icc_data = NULL; - png_charpp icc_name = NULL; + png_bytep *png_row_p, icc_data; + png_charp icc_name; uint32_t width, height, icc_len, outrowlen, tmp32, r, i; uint16_t *inrow, *outrow; int icc_compression; @@ -72,8 +72,8 @@ main(int argc, char *argv[]) /* icc profile (output ProPhoto RGB) */ if (png_get_valid(png_struct_p, png_info_p, PNG_INFO_iCCP)) { - png_get_iCCP(png_struct_p, png_info_p, icc_name, -_compression, icc_data, _len); + png_get_iCCP(png_struct_p, png_info_p, _name, +_compression, _data, _len); if (!(in_profile = cmsOpenProfileFromMem(icc_data, icc_len))) goto lcmserr;
[hackers] [scc] Support empty compound initializers || Roberto E. Vargas Caballero
commit c79ab0b02b6d74f4fa1b19e82201df136b8ae2e6 Author: Roberto E. Vargas CaballeroAuthorDate: Sun Jan 17 21:46:49 2016 +0100 Commit: Roberto E. Vargas Caballero CommitDate: Sun Jan 17 21:48:28 2016 +0100 Support empty compound initializers diff --git a/cc1/init.c b/cc1/init.c index 668f830..8265ef2 100644 --- a/cc1/init.c +++ b/cc1/init.c @@ -16,6 +16,7 @@ struct designator { struct inititlizer { Type *type; + TUINT curpos; struct designator *head; }; @@ -91,8 +92,12 @@ initlist(Symbol *sym, Type *tp) TINT n; Type *newtp; - /* TODO: catch the case of empty list */ - for (n = 0; ; ++n) { + ip = xmalloc(sizeof(*ip)); + ip->head = NULL; + if (accept('}')) + return NULL; + + for (ip->curpos = 0; ; ++ip->curpos) { designation(ip); switch (tp->op) { case ARY:
Re: [hackers] [farbfeld] Mandate "ProPhoto RGB" color space for farbfeld and handle ICC profiles || FRIGN
On Sun, 17 Jan 2016 10:10:19 + Dimitris Papastamoswrote: > Commit message reads like a diary. That's because it is a diary. :P -- FRIGN
[hackers] [scc] Remove inttypes inclusion || Roberto E. Vargas Caballero
commit ba98fe9738f78620b50c8351d46c95f923052dd7 Author: Roberto E. Vargas CaballeroAuthorDate: Sun Jan 17 09:08:36 2016 +0100 Commit: Roberto E. Vargas Caballero CommitDate: Sun Jan 17 09:08:36 2016 +0100 Remove inttypes inclusion This type is no longher needed. diff --git a/cc1/code.c b/cc1/code.c index e62619f..d72e5f1 100644 --- a/cc1/code.c +++ b/cc1/code.c @@ -1,5 +1,4 @@ -#include #include #include #include diff --git a/cc1/cpp.c b/cc1/cpp.c index 18bcd3c..e0574e1 100644 --- a/cc1/cpp.c +++ b/cc1/cpp.c @@ -1,6 +1,5 @@ #include -#include #include #include #include @@ -680,7 +679,7 @@ bool cpp(void) { static struct { - uint8_t token; + unsigned char token; void (*fun)(void); } *bp, clauses [] = { {DEFINE, define}, diff --git a/cc1/decl.c b/cc1/decl.c index 7032733..c1fcdac 100644 --- a/cc1/decl.c +++ b/cc1/decl.c @@ -1,5 +1,4 @@ -#include #include #include #include diff --git a/cc1/error.c b/cc1/error.c index 64a4e8a..f6aaa0f 100644 --- a/cc1/error.c +++ b/cc1/error.c @@ -2,7 +2,6 @@ #include #include #include -#include #include "../inc/cc.h" #include "cc1.h" diff --git a/cc1/expr.c b/cc1/expr.c index 9702950..36eef5f 100644 --- a/cc1/expr.c +++ b/cc1/expr.c @@ -1,4 +1,3 @@ -#include #include #include #include diff --git a/cc1/lex.c b/cc1/lex.c index 1155cfd..04cbaf6 100644 --- a/cc1/lex.c +++ b/cc1/lex.c @@ -1,7 +1,6 @@ #include #include -#include #include #include #include diff --git a/cc1/main.c b/cc1/main.c index ff2616b..8b1be01 100644 --- a/cc1/main.c +++ b/cc1/main.c @@ -1,5 +1,4 @@ -#include #include #include #include diff --git a/cc1/stmt.c b/cc1/stmt.c index 65a0a15..9aa801c 100644 --- a/cc1/stmt.c +++ b/cc1/stmt.c @@ -1,6 +1,5 @@ #include -#include #include #include diff --git a/cc1/symbol.c b/cc1/symbol.c index 47795c3..e48453e 100644 --- a/cc1/symbol.c +++ b/cc1/symbol.c @@ -1,5 +1,4 @@ -#include #include #include #include