What is going on? Re-add topviewfuncs.c.

error: pathspec 'cmd/smyrna/topviewfuncs.c' did not match any file(s) known to git

--- cmd/smyrna/topviewfuncs.c
+++ cmd/smyrna/topviewfuncs.c
@@ -0,0 +1,967 @@
+/* $Id$Revision: */
+/* vim:set shiftwidth=4 ts=8: */
+
+/**********************************************************
+*      This software is part of the graphviz package      *
+*                http://www.graphviz.org/                 *
+*                                                         *
+*            Copyright (c) 1994-2004 AT&T Corp.           *
+*                and is licensed under the                *
+*            Common Public License, Version 1.0           *
+*                      by AT&T Corp.                      *
+*                                                         *
+*        Information and Software Systems Research        *
+*              AT&T Research, Florham Park NJ             *
+**********************************************************/
+
+#include "topviewfuncs.h"
+#include "cgraph.h"
+#include "smyrna_utils.h"
+#include "colorprocs.h"
+#include "draw.h"
+#include "frmobjectui.h"
+#include "xdot.h"
+#include "glutils.h"
+#include "selectionfuncs.h"
+#include "memory.h"
+#include <ctype.h>
+
+static xdot *parseXdotwithattrs(void *e)
+{
+
+    int cnt=0;
+    xdot* xDot=NULL;
+    xDot=parseXDotFOn (agget(e,"_draw_" ), OpFns,sizeof(sdot_op), xDot);
+    xDot=parseXDotFOn (agget(e,"_ldraw_" ), OpFns,sizeof(sdot_op), xDot);
+    xDot=parseXDotFOn (agget(e,"_hdraw_" ), OpFns,sizeof(sdot_op), xDot);
+    xDot=parseXDotFOn (agget(e,"_tdraw_" ), OpFns,sizeof(sdot_op), xDot);
+    xDot=parseXDotFOn (agget(e,"_hldraw_" ), OpFns,sizeof(sdot_op), xDot);
+    xDot=parseXDotFOn (agget(e,"_tldraw_" ), OpFns,sizeof(sdot_op), xDot);
+    if(xDot)
+    {
+	for (cnt=0;cnt < xDot->cnt ; cnt++)
+	{
+	    ((sdot_op*)(xDot->ops))[cnt].obj=e;
+        }
+    }
+    return xDot;
+
+}
+
+static void set_boundaries(Agraph_t * g, topview * t)
+{
+    Agnode_t *v;
+    Agsym_t* pos_attr = GN_pos(g);
+    glCompPoint pos;
+    float left, right, top, bottom;
+    int id=0;
+
+    for (v = agfstnode(g); v; v = agnxtnode(g, v))
+    {
+	pos=getPointFromStr(agxget(v, pos_attr));
+	if(id==0)
+	{
+	    left=pos.x;
+	    right=pos.x;
+	    top=pos.y;
+	    bottom=pos.y;
+	}
+	if (left > pos.x)
+	    left = pos.x;
+	if (right < pos.x)
+	    right = pos.x;
+	if (bottom > pos.y)
+	    bottom = pos.y;
+	if (top < pos.y)
+	    top = pos.y;
+	id++;
+    }
+    view->bdxLeft = left;
+    view->bdyTop = top;
+    view->bdxRight = right;
+    view->bdyBottom = bottom;
+
+    view->bdzTop = 0;
+    view->bdzBottom = 0;
+}
+
+#if UNUSED
+static float init_node_size(Agraph_t * g, topview * t)
+{
+    float vsize;
+    int percent;
+    float sz;
+    percent = atoi(agget(g, "nodesize"));
+    if (percent == 0)
+	percent = 0.000001;
+    vsize =
+	0.05 * sqrt((view->bdxRight - view->bdxLeft) *
+		    (view->bdyTop - view->bdyBottom));
+    sz =	vsize * 2  * percent / 100.0 /
+	sqrt(t->Nodecount);
+/*    if (t->init_node_size < 1)
+	t->init_node_size=1;*/
+//    t->init_zoom = view->zoom;
+    t->init_zoom = -20;
+    return  sz;
+
+}
+#endif
+
+
+static void draw_xdot(xdot* x,float base_z)
+{
+	int i;
+	sdot_op *op;
+	if (!x)
+		return;
+
+	view->Topview->global_z=base_z;
+
+	op=(sdot_op*)x->ops;
+	for (i=0; i < x->cnt; i++,op++)
+	{
+		if(op->op.drawfunc)
+			op->op.drawfunc(&op->op,0);
+	}
+
+
+}
+
+
+
+static glCompPoint getEdgeHead(Agedge_t * edge)
+{
+    return getPointFromStr(agget(aghead(edge),"pos"));
+}
+static glCompPoint getEdgeTail(Agedge_t *  edge)
+{
+    return getPointFromStr(agget(agtail(edge),"pos"));
+}
+static GLfloat getEdgeLength(Agedge_t *  edge)
+{
+    GLfloat rv=0;
+    glCompPoint A,B;
+    A=getEdgeTail(edge);
+    B=getEdgeHead(edge);
+    rv=(A.x-B.x)*(A.x-B.x) + (A.y-B.y)*(A.y-B.y) +(A.z-B.z)*(A.z-B.z);
+    rv=sqrt(rv);
+    return rv;
+}
+static void glCompColorxlate(glCompColor* c,char* str)
+{
+        gvcolor_t cl;
+	colorxlate(str, &cl, RGBA_DOUBLE);
+	c->R=cl.u.RGBA[0];
+	c->G=cl.u.RGBA[1];
+	c->B=cl.u.RGBA[2];
+	c->A=cl.u.RGBA[3];
+}
+
+/* If the "visible" attribute is not set or "", return true
+ * else evaluate as boolean
+ */
+static int visible(Agsym_t* attr, void* obj)
+{
+    char* s;
+
+    if (attr) {
+	s = agxget (obj, attr);
+	if (*s) return mapbool(s);
+	else return 1;
+    }
+    else return 1;
+}
+static int object_color(void* obj,glCompColor* c)
+{
+    gvcolor_t cl;
+    Agraph_t* g=view->g[view->activeGraph];
+    Agraph_t* objg=agraphof(obj);
+    int return_value = 1;
+    int objType;
+    float Alpha = 1;
+    char* bf;
+    Agsym_t* vis;
+
+    objType=AGTYPE(obj);
+
+    if(objType==AGEDGE) {
+	Alpha=getAttrFloat(g,objg,"defaultedgealpha",1);
+	vis = GE_visible (objg);
+    }
+    if(objType==AGNODE) {
+	Alpha=getAttrFloat(g,objg,"defaultnodealpha",1);
+	vis = GN_visible (objg);
+    }
+    if (!visible(vis,obj))
+	return 0;
+
+    /*get edge's color attribute */
+    setColorScheme (agget (obj, "colorscheme"));
+    bf=getAttrStr(g,obj,"color",NULL);
+    if((bf)&&(strlen(bf)>0))
+    {
+	colorxlate(bf, &cl, RGBA_DOUBLE);
+	c->R=cl.u.RGBA[0];
+	c->G=cl.u.RGBA[1];
+	c->B=cl.u.RGBA[2];
+	c->A=cl.u.RGBA[3];
+
+    }
+    else
+    {
+	if(objType==AGEDGE)
+	    getcolorfromschema(view->colschms, getEdgeLength(obj), view->Topview->maxedgelen,c);
+	else
+	{
+	    colorxlate(agget(g, "defaultnodecolor"),&cl, RGBA_DOUBLE);
+		c->R=cl.u.RGBA[0];
+	    c->G=cl.u.RGBA[1];
+	    c->B=cl.u.RGBA[2];
+	    c->A=cl.u.RGBA[3];
+	}
+	c->A=c->A*Alpha;
+
+    }
+    return return_value;
+}
+
+
+
+
+/*
+	draws multi edges , single edges
+	this function assumes     glBegin(GL_LINES) has been called
+*/
+static void draw_edge(glCompPoint* posT,glCompPoint* posH, GLfloat length,int deg)
+{
+    double alpha, R, ITERANGLE;
+    double X1, Y1, X2, Y2;
+
+    if (deg) {
+	R = length / 20.0;
+	if ((deg / 2) * 2 != deg)	/*odd */
+	    ITERANGLE = (deg) * 15.00 * -1;
+	else
+	    ITERANGLE = (deg) * 15.00;
+	ITERANGLE = DEG2RAD * ITERANGLE;
+
+	alpha = atan((posH->y - posT->y) / (posH->x - posT->x));
+	if (posT->x > posH->x)
+	    ITERANGLE = 180 * DEG2RAD - ITERANGLE;
+	X1 = R * cos(alpha - ITERANGLE) + posT->x;
+	Y1 = R * sin(alpha - ITERANGLE) + posT->y;
+	X2 = R * cos(alpha - (180 * DEG2RAD - ITERANGLE)) + posH->x;
+	Y2 = R * sin(alpha - (180 * DEG2RAD - ITERANGLE)) + posH->y;
+	glVertex3f(posT->x, posT->y, posT->z);
+	glVertex3f(X1, Y1, posT->z);
+	glVertex3f(X1, Y1, posT->z);
+	glVertex3f(X2, Y2, posH->z);
+	glVertex3f(X2, Y2, posH->z);
+	glVertex3f(posH->x, posH->y, posH->z);
+    } else {
+	glVertex3f(posT->x, posT->y, posT->z);
+	glVertex3f(posH->x, posH->y, posH->z);
+
+    }
+
+}
+static void renderSelectedNodes(Agraph_t * g)
+{
+    Agnode_t *v;
+    Agsym_t* data_attr = GN_labelattribute(g);
+    xdot * x;
+    glCompPoint pos;
+    Agsym_t* l_color_attr = GG_nodelabelcolor(g);
+    glCompColor c;
+    int defaultNodeShape;
+    GLfloat nodeSize;
+
+    glCompColorxlate(&c,agxget(g,l_color_attr));
+
+    defaultNodeShape=getAttrBool(g,g,"defaultnodeshape",0);
+    if(defaultNodeShape==0)
+	glBegin(GL_POINTS);
+
+    for (v = agfstnode(g); v; v = agnxtnode(g, v))
+    {
+	if(!ND_selected(v));
+	    continue;
+	x=parseXdotwithattrs(v);
+	draw_xdot(x,-1);
+	if(x)
+	    freeXDot (x);
+    }
+
+    for (v = agfstnode(g); v; v = agnxtnode(g, v))
+    {
+	if(!ND_selected(v))
+	    continue;
+	glColor4f(view->selectedNodeColor.R, view->selectedNodeColor.G,view->selectedNodeColor.B, view->selectedNodeColor.A);
+	pos = ND_A(v);
+	nodeSize = ND_size(v);
+
+	if (defaultNodeShape == 0)
+	    glVertex3f(pos.x,pos.y,pos.z+0.001);
+	else if (defaultNodeShape == 1)
+	    drawCircle(pos.x,pos.y,nodeSize,pos.z+0.001);
+    }
+    if(defaultNodeShape==0)
+	glEnd();
+    for (v = agfstnode(g); v; v = agnxtnode(g, v))
+    {
+	if(!ND_selected(v))
+	    continue;
+	if (ND_printLabel(v)==1)
+	{
+	    glColor4f(c.R, c.G,c.B, c.A);
+	    if(!data_attr)
+        	glprintfglut(view->glutfont,pos.x,pos.y,pos.z+0.002,agnameof(v));
+	    else
+		glprintfglut(view->glutfont,pos.x,pos.y,pos.z+0.002,agxget(v,data_attr));
+	}
+    }
+}
+
+
+
+static void renderNodes(Agraph_t * g)
+{
+    Agnode_t *v;
+    glCompPoint pos;
+    Agsym_t* pos_attr = GN_pos(g);
+    Agsym_t* size_attr = GN_size(g);
+    Agsym_t* selected_attr = GN_selected(g);
+    int defaultNodeShape;
+    GLfloat nodeSize;
+    glCompColor c;
+    xdot * x;
+    int ind;
+
+    defaultNodeShape=getAttrInt(g,g,"defaultnodeshape",0);
+
+    x=parseXdotwithattrs(g);
+    if (x) {
+	draw_xdot(x,-0.2);
+	freeXDot (x);
+    }
+    for (v = agfstnode(g); v; v = agnxtnode(g, v))
+    {
+	    if(!object_color(v,&c))
+		continue;
+	    x=parseXdotwithattrs(v);
+	    draw_xdot(x,-0.1);
+
+	    if(x)
+		freeXDot (x);
+    }
+
+    if(defaultNodeShape==0)
+	glBegin(GL_POINTS);
+
+    ind=0;
+
+    for (v = agfstnode(g); v; v = agnxtnode(g, v))
+    {
+	ND_TVref(v) = ind;
+	if(!object_color(v,&c))
+	{
+	    ND_visible(v) = 0;
+	    continue;
+	}
+	else
+	    ND_visible(v) = 1;
+
+	if(l_int(v, selected_attr,0))
+	{
+	    ND_selected(v) = 1;
+	}
+	glColor4f(c.R,c.G,c.B,c.A);
+	pos=getPointFromStr(agxget(v, pos_attr));
+	nodeSize=(GLfloat)l_float(v, size_attr,0);
+
+	ND_A(v) = pos;
+
+        if (nodeSize > 0)
+	    nodeSize=nodeSize*view->nodeScale;
+	else
+	    nodeSize=view->nodeScale;
+	if(defaultNodeShape==0)
+	    nodeSize=1;
+	ND_size(v) = nodeSize;
+	if (defaultNodeShape == 0)
+	    glVertex3f(pos.x,pos.y,pos.z);
+	else if (defaultNodeShape == 1)
+	    drawCircle(pos.x,pos.y,nodeSize,pos.z);
+	ind++;
+    }
+    if(defaultNodeShape==0)
+	glEnd();
+}
+
+
+static void renderSelectedEdges(Agraph_t * g)
+{
+
+    Agedge_t *e;
+    Agnode_t *v;
+    xdot * x;
+    glCompPoint posT;	/*Tail position*/
+    glCompPoint posH;	/*Head position*/
+    glCompColor c;
+    /*xdots tend to be drawn as background shapes,that is why they are being rendered before edges*/
+
+    for (v = agfstnode(g); v; v = agnxtnode(g, v))
+    {
+	for (e = agfstout(g, v); e; e = agnxtout(g, e))
+	{
+	    if(!ED_selected(e))
+		continue;
+	    if(!object_color(e,&c))
+		continue;
+
+	    x=parseXdotwithattrs(e);
+	    draw_xdot(x,0);
+	    if(x)
+		freeXDot (x);
+	}
+    }
+
+
+
+
+    glBegin(GL_LINES);
+    for (v = agfstnode(g); v; v = agnxtnode(g, v))
+    {
+	for (e = agfstout(g, v); e; e = agnxtout(g, e))
+	{
+	    if(!ED_selected(e))
+		continue;
+
+	    if(!object_color(e,&c))
+		continue;
+	    glColor4f(1,0,0,1);
+	    posT = ED_posTail(e);
+	    posH = ED_posHead(e);
+	    posT.z +=0.01;
+	    posH.z +=0.01;
+	    draw_edge(&posT,&posH,getEdgeLength(e),0);
+	}
+    }
+    glEnd();
+}
+
+/* skipWS:
+ * Skip whitespace
+ */
+static char* skipWS (char* p)
+{
+    while (isspace(*p)) p++;
+    return p;
+}
+
+/* skipNWS:
+ * Skip non-whitespace
+ */
+static char* skipNWS (char* p)
+{
+    while (*p && !isspace(*p)) p++;
+    return p;
+}
+
+/* readPoint:
+ * Parse x,y[,z] and store in pt.
+ * If z is not specified, set to 0.
+ * Return pointer to next character after reading the point.
+ * Return NULL on error.
+ */
+static char* readPoint (char* p, xdot_point* pt)
+{
+    char* endp;
+
+    pt->z = 0;
+    pt->x = strtod (p, &endp);
+    if (p == endp) {
+	return 0;
+    }
+    else
+	p = endp;
+    if (*p == ',') p++;
+    else return 0;
+
+    pt->y = strtod (p, &endp);
+    if (p == endp) {
+	return 0;
+    }
+    else
+	p = endp;
+    if ((*p == ' ') || (*p == '\0')) return p;
+    else if (*p == ',') p++;
+    else return 0;
+
+    pt->z = strtod (p, &endp);
+    if (p == endp) {
+	return 0;
+    }
+    else
+	return endp;
+}
+
+/* countPoints:
+ * count number of points in pos attribute; store in cntp;
+ * check for e and s points; store if found and increment number of
+ * points by 3 for each.
+ * return start of point list (skip over e and s points).
+ * return NULL on failure
+ */
+static char* countPoints (char* pos, int* have_sp, xdot_point* sp, int* have_ep, xdot_point* ep, int* cntp)
+{
+    int cnt = 0;
+    char* p;
+
+    pos = skipWS (pos);
+    if (*pos == 's') {
+	if ((pos = readPoint (pos+2, sp))) {
+	    *have_sp = 1;
+	    cnt += 3;
+	}
+	else
+	    return 0;
+    }
+    else
+	*have_sp = 0;
+
+    pos = skipWS (pos);
+    if (*pos == 'e') {
+	if ((pos = readPoint (pos+2, ep))) {
+	    *have_ep = 1;
+	    cnt += 3;
+	}
+	else
+	    return 0;
+    }
+    else
+	*have_ep = 0;
+
+    p = pos = skipWS (pos);
+
+    while (*p) {
+	cnt++;
+	p = skipNWS (p);
+	p = skipWS (p);
+    }
+    *cntp = cnt;
+
+    return pos;
+}
+
+/* storePoints:
+ * read comma-separated list of points
+ * and store them in ps
+ * Assumes enough storage is available.
+ * return -1 on error
+ */
+static int storePoints (char* pos, xdot_point* ps)
+{
+
+    while (*pos) {
+	if ((pos = readPoint (pos, ps))) {
+	    ps++;
+	    pos = skipWS(pos);
+	}
+	else
+	    return -1;
+    }
+    return 0;
+}
+
+/* makeXDotSpline:
+ * Generate an xdot representation of an edge's pos attribute
+ */
+static xdot* makeXDotSpline (char* pos)
+{
+    xdot_point s, e;
+    int v, have_s, have_e, cnt;
+    int sz = sizeof(sdot_op);
+    xdot* xd;
+    xdot_op* op;
+    xdot_point* pts;
+
+    if (*pos == '\0') return NULL;
+
+    pos = countPoints (pos, &have_s, &s, &have_e, &e, &cnt);
+    if (pos == 0) return NULL;
+
+    pts = N_NEW(cnt,xdot_point);
+    if (have_s) {
+	v = storePoints (pos, pts+3);
+	pts[0] = pts[1] = s;
+	pts[2] = pts[3];
+    }
+    else
+	v = storePoints (pos, pts);
+    if (v) {
+	free (pts);
+	return NULL;
+    }
+
+    if (have_e) {
+	pts[cnt-1] = pts[cnt-2] = e;
+	pts[cnt-3] = pts[cnt-4];
+    }
+
+    op = (xdot_op*)N_NEW(sz,char);
+    op->kind = xd_unfilled_bezier;
+    op->drawfunc = OpFns[xop_bezier];
+    op->u.bezier.cnt = cnt;
+    op->u.bezier.pts = pts;
+
+    xd = NEW(xdot);
+    xd->cnt = 1;
+    xd->sz = sz;
+    xd->ops = op;
+
+    return xd;
+}
+
+typedef void (*edgefn) (Agraph_t *, Agedge_t*, glCompColor);
+
+static void renderEdgesFn (Agraph_t * g, edgefn ef, int skipSelected)
+{
+    Agedge_t *e;
+    Agnode_t *v;
+    glCompColor c;
+
+    for (v = agfstnode(g); v; v = agnxtnode(g, v))
+    {
+	for (e = agfstout(g, v); e; e = agnxtout(g, e))
+	{
+	    if ((ND_visible(agtail(e))==0) || (ND_visible(aghead(e))==0))
+		continue;
+
+	    if(!object_color(e,&c))
+	    {
+		ED_visible(e) = 0;
+		continue;
+	    }
+	    else
+		ED_visible(e) = 1;
+	    if (ED_selected(e) && skipSelected)
+		continue;
+
+	    ef (g, e, c);
+	}
+    }
+}
+
+static void edge_xdot (Agraph_t* g, Agedge_t* e, glCompColor c)
+{
+    xdot * x;
+    x=parseXdotwithattrs(e);
+    draw_xdot(x,0);
+    if(x)
+	freeXDot (x);
+}
+
+static void edge_seg (Agraph_t* g, Agedge_t* e, glCompColor c)
+{
+    Agsym_t* pos_attr = GN_pos(g);
+    glCompPoint posT;	/*Tail position*/
+    glCompPoint posH;	/*Head position*/
+
+    glColor4f(c.R,c.G,c.B,1);
+    posT=getPointFromStr(agxget(agtail(e), pos_attr));
+    posH=getPointFromStr(agxget(aghead(e), pos_attr));
+    draw_edge(&posT,&posH,getEdgeLength(e),0);
+    ED_posTail(e) = posT;
+    ED_posHead(e) = posH;
+}
+
+static void edge_spline (Agraph_t* g, Agedge_t* e, glCompColor c)
+{
+    Agsym_t* pos_attr_e = GE_pos(g);
+    xdot * x;
+
+    glColor4f(c.R,c.G,c.B,1);
+    x = makeXDotSpline (agxget(e,pos_attr_e));
+    if (x) {
+	draw_xdot(x,0);
+	freeXDot (x);
+    }
+}
+
+static void renderEdges(Agraph_t * g)
+{
+    Agsym_t* pos_attr_e = GE_pos(g);
+    int drawSegs = !(pos_attr_e && view->drawSplines);
+    /*xdots tend to be drawn as background shapes,that is why they are being rendered before edges*/
+
+    renderEdgesFn (g, edge_xdot, 0);
+
+    if (drawSegs) {
+	glBegin(GL_LINES);
+	renderEdgesFn (g, edge_seg, 1);
+	glEnd();
+    }
+    else
+	renderEdgesFn (g, edge_spline, 1);
+}
+
+static void renderNodeLabels(Agraph_t * g)
+{
+    Agnode_t *v;
+    glCompPoint pos;
+    Agsym_t* data_attr = GN_labelattribute(g);
+    Agsym_t* l_color_attr = GG_nodelabelcolor(g);
+    GLfloat nodeSize;
+    glCompColor c;
+
+    glCompColorxlate(&c,agxget(g,l_color_attr));
+
+    for (v = agfstnode(g); v; v = agnxtnode(g, v))
+    {
+	 if(ND_visible(v)==0)
+	    continue;
+	 if(ND_selected(v)==1)
+	    continue;
+
+	pos = ND_A(v);
+	nodeSize = ND_size(v);
+	glColor4f(c.R,c.G,c.B,c.A);
+	if(!data_attr)
+            glprintfglut(view->glutfont,pos.x,pos.y,pos.z,agnameof(v));
+	else
+	    glprintfglut(view->glutfont,pos.x,pos.y,pos.z,agxget(v,data_attr));
+    }
+}
+
+static void renderEdgeLabels(Agraph_t * g)
+{
+    Agedge_t *e;
+    Agnode_t *v;
+    glCompPoint posT;
+    glCompPoint posH;
+    Agsym_t* data_attr = GE_labelattribute(g);
+    Agsym_t* l_color_attr = GG_edgelabelcolor(g);
+    glCompColor c;
+    GLfloat x,y,z;
+
+    glCompColorxlate(&c,agxget(g,l_color_attr));
+
+    if(!data_attr || !l_color_attr)
+	return;
+
+    for (v = agfstnode(g); v; v = agnxtnode(g, v))
+    {
+	for (e = agfstout(g, v); e; e = agnxtout(g, e))
+	{
+
+	    if (ND_visible(v)==0)
+		continue;
+
+	    posT = ED_posTail(e);
+	    posH = ED_posHead(e);
+	    glColor4f(c.R,c.G,c.B,c.A);
+	    x=posH.x+(posT.x-posH.x)/2;
+	    y=posH.y+(posT.y-posH.y)/2;
+	    z=posH.z+(posT.z-posH.z)/2;
+	    glprintfglut(view->glutfont,x,y,z,agxget(e,data_attr));
+
+	}
+    }
+}
+
+
+
+
+
+static void cacheNodes(Agraph_t * g,topview* t)
+{
+    if(t->cache.node_id!=-1)	/*clean existing cache*/
+	glDeleteLists(t->cache.node_id,1);
+    t->cache.node_id=glGenLists(1);
+    glNewList(t->cache.node_id,GL_COMPILE);
+    renderNodes(g);
+    glEndList();
+
+
+
+
+}
+static void cacheEdges(Agraph_t * g,topview* t)
+{
+    if(t->cache.edge_id!=-1)	/*clean existing cache*/
+	glDeleteLists(t->cache.edge_id,1);
+    t->cache.edge_id=glGenLists(1);
+    glNewList(t->cache.edge_id,GL_COMPILE);
+    renderEdges(g);
+    glEndList();
+
+
+}
+void cacheSelectedEdges(Agraph_t * g,topview* t)
+{
+    if(t->cache.seledge_id!=-1)	/*clean existing cache*/
+	glDeleteLists(t->cache.seledge_id,1);
+    t->cache.seledge_id=glGenLists(1);
+    glNewList(t->cache.seledge_id,GL_COMPILE);
+    renderSelectedEdges(g);
+    glEndList();
+
+
+}
+void cacheSelectedNodes(Agraph_t * g,topview* t)
+{
+    if(t->cache.selnode_id!=-1)	/*clean existing cache*/
+	glDeleteLists(t->cache.selnode_id,1);
+    t->cache.selnode_id=glGenLists(1);
+    glNewList(t->cache.selnode_id,GL_COMPILE);
+    renderSelectedNodes(g);
+    glEndList();
+}
+static void cacheNodeLabels(Agraph_t * g,topview* t)
+{
+    if(t->cache.nodelabel_id!=-1)	/*clean existing cache*/
+	glDeleteLists(t->cache.nodelabel_id,1);
+    t->cache.nodelabel_id=glGenLists(1);
+    glNewList(t->cache.nodelabel_id,GL_COMPILE);
+    renderNodeLabels(g);
+    glEndList();
+}
+static void cacheEdgeLabels(Agraph_t * g,topview* t)
+{
+    if(t->cache.edgelabel_id!=-1)	/*clean existing cache*/
+	glDeleteLists(t->cache.edgelabel_id,1);
+    t->cache.edgelabel_id=glGenLists(1);
+    glNewList(t->cache.edgelabel_id,GL_COMPILE);
+    renderEdgeLabels(g);
+    glEndList();
+}
+
+void updateSmGraph(Agraph_t * g,topview* t)
+{
+    Agnode_t *v;
+    Agedge_t *e;
+    float eLength=0;
+    float totalELength=0;
+
+    t->Nodecount=0;
+    t->Edgecount=0;
+    t->avgedgelength=0;
+    t->maxedgelen=0;
+    t->minedgelen=-1;
+
+    t->picked_node_count = 0;
+    t->picked_nodes = '\0';
+    t->picked_edge_count = 0;
+    t->picked_edges = '\0';
+    t->global_z=0;
+    t->sel.selPoly.cnt=0;
+    t->sel.selPoly.pts=NULL;
+
+    if(!t)
+	return ;
+    /*Node Loop*/
+    for (v = agfstnode(g); v; v = agnxtnode(g, v)) {
+	for (e = agfstout(g, v); e; e = agnxtout(g, e))
+	{
+	    t->Edgecount++;
+	    eLength=getEdgeLength(e);
+	    if((t->minedgelen == -1) || (t->minedgelen > eLength))
+		t->minedgelen=eLength;
+	    if(eLength > t->maxedgelen)
+		t->maxedgelen=eLength;
+	    totalELength += eLength;
+	}
+	t->Nodecount++;
+
+    }
+    aginit(g, AGNODE, "nodeRec", sizeof(nodeRec), 0);
+    aginit(g, AGEDGE, "edgeRec", sizeof(edgeRec), 0);
+
+    set_boundaries(g,t);
+    t->avgedgelength = totalELength / t->Edgecount;
+//    t->init_node_size=init_node_size(g, t);
+    view->Topview=t;
+
+
+    /*render nodes once to get set some attributes set,THIS IS A HACK, FIX IT*/
+    renderNodes(g);
+    cacheEdges(g,t);
+    cacheSelectedEdges(g,t);
+    cacheNodes(g,t);
+    cacheSelectedNodes(g,t);
+    cacheEdgeLabels(g,t);
+    cacheNodeLabels(g,t);
+}
+void initSmGraph(Agraph_t * g,topview* rv)
+{
+    rv->maxnodedegree = 1;
+
+
+
+    /*create attribute list*/
+    rv->attributes=load_attr_list(view->g[view->activeGraph]);
+    rv->filtered_attr_list=NULL;
+
+    /*set topologilca fisheye to NULL */
+    rv->fisheyeParams.h = '\0';
+
+    if (view->dfltViewType == VT_TOPFISH)
+	rv->fisheyeParams.active = 1;
+    else
+	rv->fisheyeParams.active = 0;
+    rv->cache.node_id=-1;
+    rv->cache.selnode_id=-1;
+    rv->cache.edge_id=-1;
+    rv->cache.seledge_id=-1;
+    rv->sel.selectEdges=0;
+    rv->sel.selectNodes=1;
+
+    updateSmGraph(g,rv);
+}
+
+void renderSmGraph(Agraph_t * g,topview* t)
+{
+    /*
+	we like to have blending affect where node and edge  overlap
+	to achive this depth test should be turned off.
+    */
+
+    glEnable(GL_POINT_SMOOTH);
+    glEnable(GL_DEPTH_TEST);
+    /* glDepthFunc (GL_ALWAYS); */
+    glEnable(GL_DEPTH);
+//    glDepthMask(0);
+
+    if(view->drawedges)
+    {
+	glCallList(t->cache.edge_id);
+        glCallList(t->cache.seledge_id);
+        if(view->drawedgelabels)
+	{
+	    if(view->zoom*-1 <	t->fitin_zoom /(float)view->labelnumberofnodes*-1)
+		    glCallList(t->cache.edgelabel_id);
+
+	}
+    }
+    if(view->drawnodes)
+    {
+	glPointSize(view->nodeScale*t->fitin_zoom/view->zoom);
+	glCallList(t->cache.node_id);
+        glCallList(t->cache.selnode_id);
+        if(view->drawnodelabels)
+	{
+	    if(view->zoom*-1 <	t->fitin_zoom /(float)view->labelnumberofnodes*-1)
+		glCallList(t->cache.nodelabel_id);
+	}
+    }
+
+}
+
+void freeSmGraph(Agraph_t * g,topview* t)
+{
+    return ;
+}
+
+


Set up DTD related handlers in XML_ExternalEntityParserCreate.

--- expat/xmlparse/xmlparse.c
+++ expat/xmlparse/xmlparse.c
@@ -585,6 +585,10 @@
   XML_StartCdataSectionHandler oldStartCdataSectionHandler = startCdataSectionHandler;
   XML_EndCdataSectionHandler oldEndCdataSectionHandler = endCdataSectionHandler;
   XML_DefaultHandler oldDefaultHandler = defaultHandler;
+  XML_UnparsedEntityDeclHandler oldUnparsedEntityDeclHandler = unparsedEntityDeclHandler;
+  XML_NotationDeclHandler oldNotationDeclHandler = notationDeclHandler;
+  XML_ExternalParsedEntityDeclHandler oldExternalParsedEntityDeclHandler = externalParsedEntityDeclHandler;
+  XML_InternalParsedEntityDeclHandler oldInternalParsedEntityDeclHandler = internalParsedEntityDeclHandler;
   XML_StartNamespaceDeclHandler oldStartNamespaceDeclHandler = startNamespaceDeclHandler;
   XML_EndNamespaceDeclHandler oldEndNamespaceDeclHandler = endNamespaceDeclHandler;
   XML_NotStandaloneHandler oldNotStandaloneHandler = notStandaloneHandler;
@@ -610,6 +614,10 @@
   startCdataSectionHandler = oldStartCdataSectionHandler;
   endCdataSectionHandler = oldEndCdataSectionHandler;
   defaultHandler = oldDefaultHandler;
+  unparsedEntityDeclHandler = oldUnparsedEntityDeclHandler;
+  notationDeclHandler = oldNotationDeclHandler;
+  externalParsedEntityDeclHandler = oldExternalParsedEntityDeclHandler;
+  internalParsedEntityDeclHandler = oldInternalParsedEntityDeclHandler;
   startNamespaceDeclHandler = oldStartNamespaceDeclHandler;
   endNamespaceDeclHandler = oldEndNamespaceDeclHandler;
   notStandaloneHandler = oldNotStandaloneHandler;


fpta: subtree-pull libmdbx upstream (MDBX_BAD_DBI for dropped table).

Merge commit '08508d34b3c672944904f772108c9c5715cc7d60' into devel

--- externals/libmdbx/src/mdbx.c
+++ externals/libmdbx/src/mdbx.c
@@ -7195,13 +7195,13 @@
       return rc;
     rc = mdbx_page_search(&mc2, &mc->mc_dbx->md_name, 0);
     if (unlikely(rc != MDBX_SUCCESS))
-      return rc;
+      return (rc == MDBX_NOTFOUND) ? MDBX_BAD_DBI : rc;
     {
       MDBX_val data;
       int exact = 0;
       MDBX_node *leaf = mdbx_node_search(&mc2, &mc->mc_dbx->md_name, &exact);
       if (!exact)
-        return MDBX_NOTFOUND;
+        return MDBX_BAD_DBI;
       if (unlikely((leaf->mn_flags & (F_DUPDATA | F_SUBDATA)) != F_SUBDATA))
         return MDBX_INCOMPATIBLE; /* not a named DB */
       rc = mdbx_node_read(&mc2, leaf, &data);


CCNModel: improve properties comments, remove comments from ivars.

--- Coconade/Classes/CCNModel.h
+++ Coconade/Classes/CCNModel.h
@@ -16,15 +16,8 @@
     /** Holds all hierarchies of a project with their children. */
     NSDictionary *_rootNodes;

-    /* Weakref to current hierarchy that is being edited (one of the rootNodes). */
-    CCNode *_currentRootNode;
-
-    /* Weakref to selected node in current hierarchy.  */
-    CCNode *_selectedNode;
-
-    /* SelectedRootNode & All it's Children, sorted by their Z-Order.
-     * Used to search through all nodes in current hierarchy, that is being edited.
-     */
+    CCNode *_currentRootNode; //< Weakref.
+    CCNode *_selectedNode; //< Weakref.
     NSArray *_currentNodes;
 }

@@ -47,6 +40,9 @@
  * Used to iterate over all nodes in current hierarchy.
  * Changes automatically, when currentRootNode is changed.
  *
+ * Nodes in this array are sorted by their order of arrival in scene.
+ * First node is the one that's on top.
+ *
  * Can't be nil, count is always >=1
  * (because there's always at least one root node in the project).
  */


Change to caption/creatpon sequence

Change to caption/creatpon sequence

--- InOut/window.c
+++ InOut/window.c
@@ -124,6 +124,11 @@
     char *tlim = t + CAPSIZE - 1;

     if (!csound->oparms->displays) return;    /* return if displays disabled */
+    wdptr->fdata    = fdata;            /* init remainder of data structure   */
+    wdptr->npts     = npts;
+    while (*s != '\0' && t < tlim)
+      *t++ = *s++;                      /*  (copy the caption) */
+    *t = '\0';
     if (!wdptr->windid) {   /* if no window defined for this str, create one */
       csound->csoundMakeGraphCallback_(csound, wdptr, label);
 #ifndef OLPC
@@ -131,11 +136,6 @@
         PS_MakeGraph(csound, wdptr, label); /* open PS file + write header    */
 #endif
     }
-    wdptr->fdata    = fdata;            /* init remainder of data structure   */
-    wdptr->npts     = npts;
-    while (*s != '\0' && t < tlim)
-      *t++ = *s++;                      /*  (copy the caption) */
-    *t = '\0';
     wdptr->waitflg  = waitflg;
     wdptr->polarity = (int16)NOPOL;
     wdptr->max      = FL(0.0);


Per Peter E, use 'kB' for kilobyte, not 'K'.

--- contrib/pg_test_fsync/pg_test_fsync.c
+++ contrib/pg_test_fsync/pg_test_fsync.c
@@ -175,9 +175,9 @@
 	bool		fs_warning = false;

 	if (writes_per_op == 1)
-		printf("\nCompare file sync methods using one %dK write:\n", XLOG_BLCKSZ_K);
+		printf("\nCompare file sync methods using one %dkB write:\n", XLOG_BLCKSZ_K);
 	else
-		printf("\nCompare file sync methods using two %dK writes:\n", XLOG_BLCKSZ_K);
+		printf("\nCompare file sync methods using two %dkB writes:\n", XLOG_BLCKSZ_K);
 	printf("(in wal_sync_method preference order, except fdatasync\n");
 	printf("is Linux's default)\n");

@@ -391,14 +391,14 @@
 test_open_syncs(void)
 {
 	printf("\nCompare open_sync with different write sizes:\n");
-	printf("(This is designed to compare the cost of writing 16K\n");
+	printf("(This is designed to compare the cost of writing 16kB\n");
 	printf("in different write open_sync sizes.)\n");

-	test_open_sync("16K open_sync write", 16);
-	test_open_sync(" 8K open_sync writes", 8);
-	test_open_sync(" 4K open_sync writes", 4);
-	test_open_sync(" 2K open_sync writes", 2);
-	test_open_sync(" 1K open_sync writes", 1);
+	test_open_sync("16kB open_sync write", 16);
+	test_open_sync(" 8kB open_sync writes", 8);
+	test_open_sync(" 4kB open_sync writes", 4);
+	test_open_sync(" 2kB open_sync writes", 2);
+	test_open_sync(" 1kB open_sync writes", 1);
 }

 /*
@@ -517,7 +517,7 @@
 	/*
 	 * Test a simple write without fsync
 	 */
-	printf("\nNon-Sync'ed %dK writes:\n", XLOG_BLCKSZ_K);
+	printf("\nNon-Sync'ed %dkB writes:\n", XLOG_BLCKSZ_K);
 	printf(LABEL_FORMAT, "write");
 	fflush(stdout);


Code : remove repeated write of gndHgtSigma value

--- code/estimator_23states.h
+++ code/estimator_23states.h
@@ -69,7 +69,6 @@
         dVelBiasSigma = 1e-4f;
         magEarthSigma = 3.0e-4f;
         magBodySigma  = 3.0e-4f;
-        gndHgtSigma  = 0.02f; // assume 2% terrain gradient 1-sigma

         vneSigma = 0.2f;
         vdSigma = 0.3f;


cogl-atlas-texture: Remove textures from the atlas when mipmapping is required

Mipmaps don't work very well in the current atlas because there is not
enough padding between the textures. If ensure_mipmaps is called it
will now create a new texture and migrate the atlased texture to
it. It will use the same blit mechanism as when migrating so it will
try to use an FBO for a fast blit. However if this is not possible it
will end up downloading the data for the entire atlas which is not
ideal.

--- cogl/cogl-atlas-texture.c
+++ cogl/cogl-atlas-texture.c
@@ -237,16 +237,17 @@
 }

 static void
-_cogl_atlas_texture_free (CoglAtlasTexture *atlas_tex)
-{
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
-  /* Remove the texture from the atlas */
+_cogl_atlas_texture_remove_from_atlas (CoglAtlasTexture *atlas_tex)
+{
   if (atlas_tex->in_atlas)
     {
-      CoglAtlas *atlas = ((atlas_tex->format & COGL_A_BIT) ?
-                          ctx->atlas_alpha :
-                          ctx->atlas_no_alpha);
+      CoglAtlas *atlas;
+
+      _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+
+      atlas = ((atlas_tex->format & COGL_A_BIT) ?
+               ctx->atlas_alpha :
+               ctx->atlas_no_alpha);

       cogl_atlas_remove_rectangle (atlas, &atlas_tex->rectangle);

@@ -260,7 +261,15 @@
                  cogl_atlas_get_remaining_space (atlas) * 100 /
                  (cogl_atlas_get_width (atlas) *
                   cogl_atlas_get_height (atlas)));
-    }
+
+      atlas_tex->in_atlas = FALSE;
+    }
+}
+
+static void
+_cogl_atlas_texture_free (CoglAtlasTexture *atlas_tex)
+{
+  _cogl_atlas_texture_remove_from_atlas (atlas_tex);

   cogl_handle_unref (atlas_tex->sub_texture);
 }
@@ -332,8 +341,47 @@
 {
   CoglAtlasTexture *atlas_tex = COGL_ATLAS_TEXTURE (tex);

-  /* FIXME: If mipmaps are required then we need to migrate the
-     texture out of the atlas because it will show artifacts */
+  /* Mipmaps do not work well with the current atlas so instead we'll
+     just migrate the texture out and use a regular texture */
+  if (atlas_tex->in_atlas)
+    {
+      CoglHandle atlas_texture;
+      CoglAtlasTextureBlitData blit_data;
+
+      _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+
+      COGL_NOTE (ATLAS, "Migrating texture out of the atlas");
+
+      cogl_handle_unref (atlas_tex->sub_texture);
+
+      if ((atlas_tex->format & COGL_A_BIT))
+        atlas_texture = ctx->atlas_alpha_texture;
+      else
+        atlas_texture = ctx->atlas_no_alpha_texture;
+
+      /* Create a new texture at the right size, not including the
+         border */
+      atlas_tex->sub_texture =
+        cogl_texture_new_with_size (atlas_tex->rectangle.width - 2,
+                                    atlas_tex->rectangle.height - 2,
+                                    COGL_TEXTURE_NO_ATLAS,
+                                    atlas_tex->format);
+
+      /* Blit the data out of the atlas to the new texture. If FBOs
+         aren't available this will end up having to copy the entire
+         atlas texture */
+      _cogl_atlas_texture_blit_begin (&blit_data, atlas_tex->sub_texture,
+                                      atlas_texture);
+      _cogl_atlas_texture_blit (&blit_data,
+                                atlas_tex->rectangle.x + 1,
+                                atlas_tex->rectangle.y + 1,
+                                0, 0,
+                                atlas_tex->rectangle.width - 2,
+                                atlas_tex->rectangle.height - 2);
+      _cogl_atlas_texture_blit_end (&blit_data);
+
+      _cogl_atlas_texture_remove_from_atlas (atlas_tex);
+    }

   /* Forward on to the sub texture */
   _cogl_texture_ensure_mipmaps (atlas_tex->sub_texture);


Convert fmttest over to the new argument processing world order.

--- uip/fmttest.c
+++ uip/fmttest.c
@@ -13,29 +13,25 @@
 #include <h/utils.h>
 #include <h/scansbr.h>

-static struct swit switches[] = {
-#define	FORMSW              0
-    { "form formatfile", 0 },
-#define	FMTSW               1
-    { "format string", 5 },
-#define DUMPSW              2
-    { "dump", 0 },
-#define ADDRSW              3
-    { "address", 0 },
-#define DATESW              4
-    { "date", 0 },
-#define WIDTHSW             5
-    { "width columns", 0 },
-#define BUFSZSW             6
-    { "bufsize size-in-bytes", 0 },
-#define VERSIONSW           7
-    { "version", 0 },
-#define OTHERSW             8
-    { "-component-name component-text", 0 },
-#define	HELPSW              9
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define FMTTEST_SWITCHES \
+    X("form formatfile", 0, FORMSW) \
+    X("format string", 5, FMTSW) \
+    X("dump", 0, DUMPSW) \
+    X("address", 0, ADDRSW) \
+    X("date", 0, DATESW) \
+    X("width", 0, WIDTHSW) \
+    X("bufsize size-in-bytes", 0, BUFSZSW) \
+    X("version", 0, VERSIONSW) \
+    X("-component-name component-text", 0, OTHERSW) \
+    X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(FMTTEST);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(FMTTEST, switches);
+#undef X

 /*
  * An array containing labels used for branch instructions
@@ -48,7 +44,7 @@
 /*
  * static prototypes
  */
-static void fmt_dump (struct format *);
+static void fmt_dump (char *, struct format *);
 static void dumpone(struct format *);
 static int findlabel(struct format *);
 static void assignlabel(struct format *);
@@ -173,7 +169,7 @@
     (void) fmt_compile(nfs, &fmt, 1);

     if (dump)
-	fmt_dump(fmt);
+	fmt_dump(nfs, fmt);

     if (compargs) {
     	for (i = 0; compargs[i] != NULL; i += 2) {
@@ -200,10 +196,12 @@
 }

 static void
-fmt_dump (struct format *fmth)
+fmt_dump (char *nfs, struct format *fmth)
 {
 	int i;
 	register struct format *fmt, *addr;
+
+	printf("Instruction dump of format string: \n%s\n", nfs);

 	/* Assign labels */
 	for (fmt = fmth; fmt; ++fmt) {


defining c++ eigen function

defining c++ eigen function

--- packages/nimble/inst/include/nimble/EigenTypedefs.h
+++ packages/nimble/inst/include/nimble/EigenTypedefs.h
@@ -38,6 +38,7 @@
   return(ans);
 }

+template<class T>
 class EIGEN_EIGENCLASS : public NamedObjects, public pointedToBase {
 public:
   double nlScalar;
@@ -50,22 +51,24 @@
 };

-// idea: use makeEigenTypeLabel() to generate template class to feed to function.  argument can then be
 template<class derived1>
-nimSmartPtr<EIGEN_EIGENCLASS> EIGEN_EIGENVECS(const MatrixBase<derived1> &x) {
-	Map<MatrixXd> Eig_chol1(0,0,0);
-Map<MatrixXd> Eig_A(0,0,0);
-if(A.dim()[0] != A.dim()[1]) {
- _nimble_global_output <<"Run-time size error: expected A to be square."<<"\n"; nimble_print_to_R(_nimble_global_output);
-}
-chol1.setSize(A.dim()[0], A.dim()[0]);
-new (&Eig_chol1) Map< MatrixXd >(chol1.getPtr(),A.dim()[0],A.dim()[0]);
-new (&Eig_A) Map< MatrixXd >(A.getPtr(),A.dim()[0],A.dim()[1]);
-Eig_chol1 = EIGEN_CHOL(Eig_A);
-return(chol1);
-}
-
-  nimSmartPtr<EIGEN_EIGENCLASS> eigenClass = new EIGEN_EIGENCLASS;
+nimSmartPtr<EIGEN_EIGENCLASS>   EIGEN_EIGEN(const MatrixBase<derived1> &x, bool valuesOnly) {
+  MatrixXd xcopy = x;
+  nimSmartPtr<EIGEN_EIGENCLASS> returnClass = new EIGEN_EIGENCLASS;
+  Map<MatrixXd> Eig_eigVals(0,0,0);
+  new (&Eig_eigVals) Map< MatrixXd >((*returnClass).values.getPtr(),x.dim()[0],1);
+  EigenSolver<MatrixXd> solver = EigenSolver<MatrixXd>(xcopy, valuesOnly);
+  Eig_eigVals = solver.eigenvectors().real();
+  if(!valuesOnly){
+	Map<MatrixXd> Eig_eigVecs(0,0,0);
+	new (&Eig_eigVecs) Map< MatrixXd >((*returnClass).vectors.getPtr(),x.dim()[0],x.dim()[0]);
+	Eig_eigVecs = solver.eigenvalues().real();
+  }
+  return(returnClass);
+};
+
+/* template<class derived1>
+MatrixXd EIGEN_EIGENVECS(const MatrixBase<derived1> &x) {
   MatrixXd xcopy = x;
   MatrixXd ans = EigenSolver<MatrixXd>(xcopy, true).eigenvectors().real();
   return(ans);
@@ -76,7 +79,7 @@
   MatrixXd xcopy = x;
   VectorXd ans = EigenSolver<MatrixXd>(xcopy, false).eigenvalues().real();
   return(ans);
-}
+} */

 template<class derived1>
 VectorXd EIGEN_SVDD(const MatrixBase<derived1> &x) {


Removed stray debugging printf.

Removed stray debugging printf.

git-svn-id: e50b6a1ce0e75e718bdfc9056f740679c20291aa@305 e2bd861d-eb25-0410-b326-f6ed22b6b98c

--- test/screen-review-test.c
+++ test/screen-review-test.c
@@ -530,8 +530,6 @@
 		text_chunk->text_bounds.height = y2 - text_chunk->text_bounds.y;
 		text_chunk->start_offset = start;
 		text_chunk->end_offset = end;
-		fprintf (stderr, "text at offset %d, %s, %d, %d\n",
-			 offset, s, start, end);
 		AccessibleText_unref (text);
 	} else {
 		if (role == SPI_ROLE_PUSH_BUTTON ||
@@ -710,8 +708,8 @@

 /*
  * Note: this routine shouldn't have to do as much as it currently does,
- *       but at the moment it works around a pango?/gail? bug which
- *       causes WORD boundary type queries to return incorrect strings.
+ *       but at the moment it works around another bug (probably one in this
+ *       code).
  */
 static char *
 string_strip_newlines (char *s, long offset, long *start_offset, long *end_offset)
@@ -786,7 +784,7 @@
 		do {
 		    s = AccessibleText_getTextAtOffset (text,
 							start,
-						SPI_TEXT_BOUNDARY_WORD_START,
+						SPI_TEXT_BOUNDARY_WORD_END,
 							&word_start,
 							&word_end);
 		    range_end = word_end;


Removed inappropriate log message with offending content :)

git-svn-id: fbb392d5347ebc45c06187f72dfd8bab02595dbf@569956 13f79535-47bb-0310-9956-ffa450edef68

--- src/core/description/msg.c
+++ src/core/description/msg.c
@@ -107,7 +107,6 @@
         {
             axis2_phase_t *phase = NULL;
             phase = axutil_array_list_get(msg->flow, env, i);
-            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "dam_phase_name:%s", axis2_phase_get_name(phase, env));
             if(phase)
                 axis2_phase_free(phase, env);
         }


Fixing alignment issue with Arenas.

Fixing alignment issue with Arenas.

--- src/core/lib/gprpp/arena.h
+++ src/core/lib/gprpp/arena.h
@@ -96,7 +96,8 @@
   //   where we wish to create an arena and then perform an immediate
   //   allocation.
   explicit Arena(size_t initial_size, size_t initial_alloc = 0)
-      : total_used_(initial_alloc), initial_zone_size_(initial_size) {}
+      : total_used_(GPR_ROUND_UP_TO_ALIGNMENT_SIZE(initial_alloc)),
+        initial_zone_size_(initial_size) {}

   ~Arena();


Remove errant header

Remove errant header

--- src/core/lib/support/env.h
+++ src/core/lib/support/env.h
@@ -36,8 +36,6 @@

 #include <stdio.h>

-#include <grpc/slice.h>
-
 #ifdef __cplusplus
 extern "C" {
 #endif


Implement r1506 also in the test case. This fixes issue #74.

* test/server/test_server.c:
  (test_server_run): Use select() on Windows with apr 1.4.

--- test/server/test_server.c
+++ test/server/test_server.c
@@ -219,7 +219,13 @@
     const apr_pollfd_t *desc;

     /* create a new pollset */
-    status = apr_pollset_create(&pollset, 32, pool, 0);
+#ifdef BROKEN_WSAPOLL
+    (void) apr_pollset_create_ex(&pollset, 32, pool, 0,
+                                 APR_POLLSET_SELECT);
+#else
+    (void) apr_pollset_create(&pollset, 32, pool, 0);
+#endif
+
     if (status != APR_SUCCESS)
         return status;


core: Added padding for public structures in grl-media-audio

--- src/data/grl-media-audio.h
+++ src/data/grl-media-audio.h
@@ -30,7 +30,7 @@
 #define _GRL_MEDIA_AUDIO_H_

 #include <grl-media.h>
-
+#include <grl-definitions.h>

 G_BEGIN_DECLS

@@ -72,11 +72,17 @@
 struct _GrlMediaAudioClass
 {
   GrlMediaClass parent_class;
+
+  /*< private >*/
+  gpointer _grl_reserved[GRL_PADDING];
 };

 struct _GrlMediaAudio
 {
   GrlMedia parent;
+
+  /*< private >*/
+  gpointer _grl_reserved[GRL_PADDING_SMALL];
 };

 void grl_media_audio_set_artist (GrlMediaAudio *data, const gchar *artist);


test: fix cwd_and_chdir test on Unix

test: fix cwd_and_chdir test on Unix

There is no need to check for a trailing slash, uv_cwd ensures it.

PR-URL: https://github.com/libuv/libuv/pull/63
Reviewed-By: Bert Belder <9f2ff180696da386c1be31b4507155616db25dc6@gmail.com>
Reviewed-By: Ben Noordhuis <59bd0a3ff43b32849b319e645d4798d8a5d1e889@bnoordhuis.nl>

--- test/test-cwd-and-chdir.c
+++ test/test-cwd-and-chdir.c
@@ -31,27 +31,11 @@
   char buffer_new[PATHMAX];
   size_t size1;
   size_t size2;
-  char* last_slash;
   int err;

   size1 = sizeof buffer_orig;
   err = uv_cwd(buffer_orig, &size1);
   ASSERT(err == 0);
-
-  /* Remove trailing slash unless at a root directory. */
-#ifdef _WIN32
-  last_slash = strrchr(buffer_orig, '\\');
-  ASSERT(last_slash);
-  if (last_slash > buffer_orig && *(last_slash - 1) != ':') {
-    *last_slash = '\0';
-  }
-#else /* Unix */
-  last_slash = strrchr(buffer_orig, '/');
-  ASSERT(last_slash);
-  if (last_slash != buffer_orig) {
-    *last_slash = '\0';
-  }
-#endif

   err = uv_chdir(buffer_orig);
   ASSERT(err == 0);


changed to size_t from uint

changed to size_t from uint

git-svn-id: 1af002208e930b4d920e7c2b948d1e98a012c795@5037 a9d63959-f2ad-4865-b262-bf0e56cfafb6

--- people/include/pcl/people/conversions/conversions.h
+++ people/include/pcl/people/conversions/conversions.h
@@ -62,7 +62,7 @@
     cloud_out.width = width;
     cloud_out.height = height;

-    for(unsigned int i = 0; i < cloud_in.points.size(); i++)
+    for(size_t i = 0; i < cloud_in.points.size(); i++)
     {
       PointXYZRGBL p;
       p.x = cloud_in.points[i].x; p.y = cloud_in.points[i].y; p.z = cloud_in.points[i].z;
@@ -92,7 +92,7 @@
     cloud_out.width = width;
     cloud_out.height = height;

-    for(unsigned int i = 0; i < cloud_in.points.size(); i++)
+    for(size_t i = 0; i < cloud_in.points.size(); i++)
     {
       PointXYZL p;
       p.x = cloud_in.points[i].x; p.y = cloud_in.points[i].y; p.z = cloud_in.points[i].z;
@@ -118,7 +118,7 @@
     cloud_out.width = width;
     cloud_out.height = height;

-    for(unsigned int i = 0; i < cloud_in.points.size(); i++)
+    for(size_t i = 0; i < cloud_in.points.size(); i++)
     {
       PointXYZRGBL p;
       p.x = cloud_in.points[i].x; p.y = cloud_in.points[i].y; p.z = cloud_in.points[i].z;
@@ -151,7 +151,7 @@
     cloud_out.width = width;
     cloud_out.height = height;

-    for(unsigned int i = 0; i < cloud_in.points.size(); i++)
+    for(size_t i = 0; i < cloud_in.points.size(); i++)
     {
       PointXYZRGBL p;
       p.x = cloud_in.points[i].x; p.y = cloud_in.points[i].y; p.z = cloud_in.points[i].z;


usb: Create usb_send_in_buffer_0() to handle EP 0

Don't call usb_send_in_buffer() when using Endpoint 0.  This helps pave the
way for ping-pong buffering, since EP 0 will potentially have a different
buffer descriptor layout than the other endpoints.

--- usb/src/usb.c
+++ usb/src/usb.c
@@ -402,6 +402,23 @@
 	bds[0].ep_in.STAT.BDnSTAT = 0;
 	SET_BDN(bds[0].ep_in, BDNSTAT_UOWN|BDNSTAT_DTS|BDNSTAT_DTSEN, 0);
 }
+
+static void usb_send_in_buffer_0(size_t len)
+{
+	if (!usb_in_endpoint_halted(0)) {
+		uint8_t pid;
+		pid = !bds[0].ep_in.STAT.DTS;
+		bds[0].ep_in.STAT.BDnSTAT = 0;
+
+		if (pid)
+			SET_BDN(bds[0].ep_in,
+				BDNSTAT_UOWN|BDNSTAT_DTS|BDNSTAT_DTSEN, len);
+		else
+			SET_BDN(bds[0].ep_in,
+				BDNSTAT_UOWN|BDNSTAT_DTSEN, len);
+	}
+}
+

 /* Start Control Return
  *
@@ -816,10 +833,10 @@
 		    returning_short)
 			control_need_zlp = 1;

-		usb_send_in_buffer(0, bytes_to_send);
+		usb_send_in_buffer_0(bytes_to_send);
 	}
 	else if (control_need_zlp) {
-		usb_send_in_buffer(0, 0);
+		usb_send_in_buffer_0(0);
 		control_need_zlp = 0;
 		reset_ep0_data_stage();
 	}


cfgmap.c: Removed one missed @internal.

cfgmap.c: Removed one missed @internal.

--- util/cfgmap.c
+++ util/cfgmap.c
@@ -109,7 +109,6 @@

 /**
  * Translate field setter to cfgmap setter.
- * @internal
  *
  * @sa ib_field_set_fn_t.
  */


Fix return code from ectool

Fix return code from ectool

lbplay and burn_my_ec didn't have this problem.

BUG=chrome-os-partner:11402
TEST=ectool lightbar init && echo $?
Should echo 0

Change-Id: I7e9585555cc285ff02502fd4e6bb80e41c889e9d
Signed-off-by: Randall Spangler <62698fdbb84d1779579ee80c3f39fac22017e5bc@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27527
Reviewed-by: Bill Richardson <129945214b1d548d8e49b6c29c43094f8c78057f@chromium.org>

--- util/ectool.c
+++ util/ectool.c
@@ -380,7 +380,7 @@
 int cmd_reboot_ec(int argc, char *argv[])
 {
 	struct ec_params_reboot_ec p;
-	int i;
+	int rv, i;

 	if (argc < 2) {
 		/*
@@ -388,7 +388,8 @@
 		 * That reboots the AP as well, so unlikely we'll be around
 		 * to see a return code from this...
 		 */
-		return ec_command(EC_CMD_REBOOT, 0, NULL, 0, NULL, 0);
+		rv = ec_command(EC_CMD_REBOOT, 0, NULL, 0, NULL, 0);
+		return (rv < 0 ? rv : 0);
 	}

 	/* Parse command */
@@ -420,7 +421,8 @@
 		}
 	}

-	return ec_command(EC_CMD_REBOOT_EC, 0, &p, sizeof(p), NULL, 0);
+	rv = ec_command(EC_CMD_REBOOT_EC, 0, &p, sizeof(p), NULL, 0);
+	return (rv < 0 ? rv : 0);
 }

@@ -547,6 +549,7 @@
 {
 	struct ec_params_flash_erase p;
 	char *e;
+	int rv;

 	if (argc < 3) {
 		fprintf(stderr, "Usage: %s <offset> <size>\n", argv[0]);
@@ -564,8 +567,9 @@
 	}

 	printf("Erasing %d bytes at offset %d...\n", p.size, p.offset);
-	if (ec_command(EC_CMD_FLASH_ERASE, 0, &p, sizeof(p), NULL, 0) < 0)
-		return -1;
+	rv = ec_command(EC_CMD_FLASH_ERASE, 0, &p, sizeof(p), NULL, 0);
+	if (rv < 0)
+		return rv;

 	printf("done.\n");
 	return 0;
@@ -936,12 +940,12 @@
 static int lb_do_cmd(enum lightbar_command cmd,
 		     struct ec_params_lightbar_cmd *ptr)
 {
-	int r;
+	int rv;
 	ptr->in.cmd = cmd;
-	r = ec_command(EC_CMD_LIGHTBAR_CMD, 0,
-		       ptr, lb_command_paramcount[cmd].insize,
-		       ptr, lb_command_paramcount[cmd].outsize);
-	return r;
+	rv = ec_command(EC_CMD_LIGHTBAR_CMD, 0,
+			ptr, lb_command_paramcount[cmd].insize,
+			ptr, lb_command_paramcount[cmd].outsize);
+	return (rv < 0 ? rv : 0);
 }

 static void lb_show_msg_names(void)
@@ -1050,20 +1054,20 @@

 static int cmd_vboot(int argc, char **argv)
 {
-	int r;
+	int rv;
 	uint8_t v;
 	char *e;
 	struct ec_params_vboot_cmd param;

 	if (argc == 1) {			/* no args = get */
 		param.in.cmd = VBOOT_CMD_GET_FLAGS;
-		r = ec_command(EC_CMD_VBOOT_CMD, 0,
-			       &param,
-			       vb_command_paramcount[param.in.cmd].insize,
-			       &param,
-			       vb_command_paramcount[param.in.cmd].outsize);
-		if (r < 0)
-			return r;
+		rv = ec_command(EC_CMD_VBOOT_CMD, 0,
+				&param,
+				vb_command_paramcount[param.in.cmd].insize,
+				&param,
+				vb_command_paramcount[param.in.cmd].outsize);
+		if (rv < 0)
+			return rv;

 		v = param.out.get_flags.val;
 		printf("0x%02x image=%s\n", v,
@@ -1081,12 +1085,12 @@

 	param.in.cmd = VBOOT_CMD_SET_FLAGS;
 	param.in.set_flags.val = v;
-	r = ec_command(EC_CMD_VBOOT_CMD, 0,
-		       &param,
-		       vb_command_paramcount[param.in.cmd].insize,
-		       &param,
-		       vb_command_paramcount[param.in.cmd].outsize);
-	return r;
+	rv = ec_command(EC_CMD_VBOOT_CMD, 0,
+			&param,
+			vb_command_paramcount[param.in.cmd].insize,
+			&param,
+			vb_command_paramcount[param.in.cmd].outsize);
+	return (rv < 0 ? rv : 0);
 }

 int cmd_usb_charge_set_mode(int argc, char *argv[])
@@ -1670,8 +1674,7 @@

 int cmd_charge_force_idle(int argc, char *argv[])
 {
-	int rv = ec_command(EC_CMD_CHARGE_FORCE_IDLE,
-			    0, NULL, 0, NULL, 0);
+	int rv = ec_command(EC_CMD_CHARGE_FORCE_IDLE, 0, NULL, 0, NULL, 0);
 	if (rv < 0) {
 		fprintf(stderr, "Is AC connected?\n");
 		return rv;
@@ -1699,8 +1702,7 @@
 	}
 	strcpy(p.name, argv[1]);

-	rv = ec_command(EC_CMD_GPIO_GET, 0,
-			&p, sizeof(p), &r, sizeof(r));
+	rv = ec_command(EC_CMD_GPIO_GET, 0, &p, sizeof(p), &r, sizeof(r));
 	if (rv < 0)
 		return rv;

@@ -1732,8 +1734,7 @@
 		return -1;
 	}

-	rv = ec_command(EC_CMD_GPIO_SET, 0,
-			&p, sizeof(p), NULL, 0);
+	rv = ec_command(EC_CMD_GPIO_SET, 0, &p, sizeof(p), NULL, 0);
 	if (rv < 0)
 		return rv;

@@ -1867,13 +1868,15 @@
 	struct ec_params_vboot_hash p;
 	struct ec_response_vboot_hash r;
 	char *e;
+	int rv;

 	if (argc < 2) {
 		/* Get hash status */
 		p.cmd = EC_VBOOT_HASH_GET;
-		if (ec_command(EC_CMD_VBOOT_HASH, 0,
-			       &p, sizeof(p), &r, sizeof(r)) < 0)
-			return -1;
+		rv = ec_command(EC_CMD_VBOOT_HASH, 0,
+				&p, sizeof(p), &r, sizeof(r));
+		if (rv < 0)
+			return rv;

 		return ec_hash_print(&r);
 	}
@@ -1881,10 +1884,9 @@
 	if (argc == 2 && !strcasecmp(argv[1], "abort")) {
 		/* Abort hash calculation */
 		p.cmd = EC_VBOOT_HASH_ABORT;
-		if (ec_command(EC_CMD_VBOOT_HASH, 0,
-			       &p, sizeof(p), &r, sizeof(r)) < 0)
-			return -1;
-		return 0;
+		rv = ec_command(EC_CMD_VBOOT_HASH, 0,
+				&p, sizeof(p), &r, sizeof(r));
+		return (rv < 0 ? rv : 0);
 	}

 	/* The only other commands are start and recalc */
@@ -1928,8 +1930,9 @@
 		p.nonce_size = 0;

 	printf("Hashing %d bytes at offset %d...\n", p.size, p.offset);
-	if (ec_command(EC_CMD_VBOOT_HASH, 0, &p, sizeof(p), &r, sizeof(r)) < 0)
-		return -1;
+	rv = ec_command(EC_CMD_VBOOT_HASH, 0, &p, sizeof(p), &r, sizeof(r));
+	if (rv < 0)
+		return rv;

 	/* Start command doesn't wait for hashing to finish */
 	if (p.cmd == EC_VBOOT_HASH_START)


added comment

added comment

--- util/lpanal.c
+++ util/lpanal.c
@@ -825,6 +825,8 @@

    /* Transfer signal in x array */
     for (xp=thislp->x; xp-thislp->x < thislp->WINDIN;++xp,++sig) {
+      /* VL 24.06.21 - adding a little noise to allow pole analysis
+         to be carried out with silences */
       *xp = (double) *sig + (thislp->storePoles ? noise(0.0001) : 0.);
     }


Put a mutex around thread_exited_list, sometimes threads finish while processing quitting threads which does weird stuff

--- util/thread.c
+++ util/thread.c
@@ -7,28 +7,34 @@
 bedrock_pipe thread_notify_pipe;

 static bedrock_list thread_exited_list = LIST_INIT;
+static bedrock_mutex thread_mutex;

 static void do_exit_threads(void bedrock_attribute_unused *unused)
 {
-	bedrock_node *node, *node2;
-
-	LIST_FOREACH_SAFE(&thread_exited_list, node, node2)
-	{
-		struct bedrock_thread *thread = node->data;
+	bedrock_mutex_lock(&thread_mutex);
+
+	while (thread_exited_list.count)
+	{
+		struct bedrock_thread *thread = thread_exited_list.head->data;
+
+		bedrock_mutex_unlock(&thread_mutex);
 		bedrock_thread_join(thread);
-	}
-
-	bedrock_assert(thread_exited_list.count == 0, ;);
+		bedrock_mutex_lock(&thread_mutex);
+	}
+
+	bedrock_mutex_unlock(&thread_mutex);
 }

 void bedrock_threadengine_start()
 {
 	bedrock_pipe_open(&thread_notify_pipe, "thread exit pipe", do_exit_threads, NULL);
+	bedrock_mutex_init(&thread_mutex, "thread mutex");
 }

 void bedrock_threadengine_stop()
 {
 	bedrock_pipe_close(&thread_notify_pipe);
+	bedrock_mutex_destroy(&thread_mutex);
 }

 static void *thread_entry(void *data)
@@ -67,16 +73,22 @@

 bool bedrock_thread_want_exit(struct bedrock_thread *thread)
 {
-	return bedrock_list_has_data(&thread_exited_list, thread);
+	bool b;
+	bedrock_mutex_lock(&thread_mutex);
+	b = bedrock_list_has_data(&thread_exited_list, thread);
+	bedrock_mutex_unlock(&thread_mutex);
+	return b;
 }

 void bedrock_thread_set_exit(struct bedrock_thread *thread)
 {
-	if (bedrock_thread_want_exit(thread) == false)
+	bedrock_mutex_lock(&thread_mutex);
+	if (bedrock_list_has_data(&thread_exited_list, thread) == false)
 	{
 		bedrock_list_add(&thread_exited_list, thread);
 		bedrock_pipe_notify(&thread_notify_pipe);
 	}
+	bedrock_mutex_unlock(&thread_mutex);
 }

 void bedrock_thread_join(struct bedrock_thread *thread)
@@ -92,7 +104,9 @@
 		thread->at_exit(thread->data);

 	bedrock_list_del(&thread_list, thread);
+	bedrock_mutex_lock(&thread_mutex);
 	bedrock_list_del(&thread_exited_list, thread);
+	bedrock_mutex_unlock(&thread_mutex);

 	bedrock_free(thread);
 }


Use LPTMR to trigger TSI for Teensy-LC

Use LPTMR to trigger TSI for Teensy-LC

--- utility/tsi.h
+++ utility/tsi.h
@@ -16,7 +16,7 @@
     bool state = false;
 } tsi_mask_t;
 /********************************************************************/
-#if defined(__MK20DX128__) || defined(__MK20DX256__)
+#if defined(KINETISK)
 static const uint8_t tsi_pins[] = {
     //0    1    2    3    4    5    6    7    8    9
     9,  10, 255, 255, 255, 255, 255, 255, 255, 255,
@@ -24,7 +24,7 @@
     255, 255,  14,  15, 255,  12, 255, 255, 255, 255,
     255, 255,  11,   5
 };
-#elif defined(__MKL26Z64__)
+#elif defined(KINETISL)
 static const uint8_t tsi_pins[] = {
     //0    1    2    3    4    5    6    7    8    9
     9,  10, 255,   2,   3, 255, 255, 255, 255, 255,
@@ -62,8 +62,13 @@

     static inline
     void tsiISR( void ) {
-        if( !(SIM_SCGC5 & SIM_SCGC5_TSI) ) return;
+        if( !( SIM_SCGC5 & SIM_SCGC5_TSI ) ) return;
         TSI0_GENCS = TSI_GENCS_OUTRGF | TSI_GENCS_EOSF;
+#if defined(KINETISL)
+        LPTMR0_CSR = LPTMR_CSR_TCF;
+        SIM_SCGC5 &= ~SIM_SCGC5_LPTIMER;
+#endif
+        wakeupSource = 35;
     }
     /*******************************************************************************
      *
@@ -77,55 +82,64 @@
     static inline
     void tsi_set( tsi_mask_t *mask ) {
         if ( mask->state == false ) return;
-        if ( enable_periph_irq ) attachInterruptVector( IRQ_TSI, tsiISR );
         uint8_t pin = mask->pin;
+        if ( pin >= NUM_DIGITAL_PINS ) return;
         uint16_t threshold = mask->threshold;
+        if ( enable_periph_irq ) {
+            attachInterruptVector( IRQ_TSI, tsiISR );
+            NVIC_ENABLE_IRQ( IRQ_TSI );
+        }

         uint32_t ch;

         ch = tsi_pins[pin];
         if ( ch == 255 ) return;
-        //if ( tsi_pins[pin] == 255 ) return;

+        *portConfigRegister( pin ) = PORT_PCR_MUX( 0 );
         SIM_SCGC5 |= SIM_SCGC5_TSI;

         TSI0_GENCS = 0;
-#if defined(__MK20DX128__) || defined(__MK20DX256__)
+#if defined(KINETISK)
         TSI0_THRESHOLD = threshold;
-
-        TSI0_SCANC = ((TSI_SCANC_EXTCHRG(2)) |
-                      (TSI_SCANC_REFCHRG(3)) |
-                      (TSI_SCANC_AMPSC(1))   |
-                      (TSI_SCANC_AMCLKS(0)));
-
-        TSI0_PEN = TSI_PEN_LPSP(ch);
-        //TSI0_PEN = TSI_PEN_LPSP(tsi_pins[pin]);
-#elif defined(__MKL26Z64__)
-        TSI0_TSHD = threshold;
-        TSI0_DATA = TSI_DATA_TSICH(ch);
+        TSI0_SCANC =  (
+                      ( TSI_SCANC_EXTCHRG( 2 ) ) |
+                      ( TSI_SCANC_REFCHRG( 3 ) ) |
+                      ( TSI_SCANC_AMPSC( 1 ) )   |
+                      ( TSI_SCANC_AMCLKS( 0 ) )
+                      );
+        TSI0_PEN = TSI_PEN_LPSP( ch );
+        TSI0_GENCS = (
+                      ( TSI_GENCS_NSCN( 9 ) )     |
+                      ( TSI_GENCS_PS( 2 ) )       |
+                      ( TSI_GENCS_STPE )          |
+                      ( TSI_GENCS_LPSCNITV( 7 ) ) |
+                      ( TSI_GENCS_TSIIE )         |
+                      ( TSI_GENCS_OUTRGF )        |
+                      ( TSI_GENCS_EOSF )          |
+                      ( TSI_GENCS_TSIEN )
+                      );
+#elif defined(KINETISL)
+        TSI0_TSHD = ( threshold << 16) & 0xFFFF0000;
+        TSI0_DATA = TSI_DATA_TSICH( ch );
+        TSI0_GENCS = (
+                      ( TSI_GENCS_NSCN( 9 ) )    |
+                      ( TSI_GENCS_PS( 2 ) )      |
+                      ( TSI_GENCS_STPE )         |
+                      ( TSI_GENCS_REFCHRG( 4 ) ) |
+                      ( TSI_GENCS_EXTCHRG( 3 ) ) |
+                      ( TSI_GENCS_TSIIEN )       |
+                      ( TSI_GENCS_DVOLT( 0 ) )   |
+                      //TSI_GENCS_ESOR             |
+                      ( TSI_GENCS_STM )          |
+                      ( TSI_GENCS_OUTRGF )       |
+                      ( TSI_GENCS_EOSF )         |
+                      ( TSI_GENCS_TSIEN )
+                      );
+        SIM_SCGC5 |= SIM_SCGC5_LPTIMER;
+        LPTMR0_CMR = 1;
+        LPTMR0_CSR = LPTMR_CSR_TEN | LPTMR_CSR_TCF;
 #endif
-        TSI0_GENCS = (
-                       (TSI_GENCS_NSCN(9))      |
-                       (TSI_GENCS_PS(2))        |
-                       (TSI_GENCS_STPE)         |
-#if defined(__MK20DX128__) || defined(__MK20DX256__)
-                       (TSI_GENCS_LPSCNITV(7))  |
-                       (TSI_GENCS_TSIIE)        |
-#elif defined(__MKL26Z64__)
-                       TSI_GENCS_REFCHRG(4)     |
-                       TSI_GENCS_EXTCHRG(3)     |
-                       TSI_GENCS_TSIIEN         |
-                       TSI_GENCS_ESOR           |
-                       TSI_GENCS_STM            |
-#endif
-                       (TSI_GENCS_OUTRGF)       |
-                       (TSI_GENCS_EOSF)         |
-                       (TSI_GENCS_TSIEN));
-
-        // Wait for any in-progress scans to complete
-        while (TSI0_GENCS & TSI_GENCS_SCNIP) yield();
-
-        if ( enable_periph_irq ) NVIC_ENABLE_IRQ( IRQ_TSI );
+
     }
     /*******************************************************************************
      *
@@ -139,7 +153,10 @@
     static inline
     void tsi_disable( tsi_mask_t *mask ) {
         if ( mask->state == false ) return;
-        if ( enable_periph_irq ) detachInterruptVector( IRQ_TSI );
+        if ( enable_periph_irq ) {
+            NVIC_DISABLE_IRQ( IRQ_TSI );
+            detachInterruptVector( IRQ_TSI );
+        }
         TSI0_GENCS = TSI_GENCS_OUTRGF | TSI_GENCS_EOSF;
         TSI0_GENCS &= ~TSI_GENCS_TSIEN;
         SIM_SCGC5 &= ~SIM_SCGC5_TSI;


First go at SWAP* capacity validation checks.

--- src/algorithms/local_search/swap_star_utils.h
+++ src/algorithms/local_search/swap_star_utils.h
@@ -168,12 +168,131 @@
       const auto current_delta = source_delta + target_delta;

       if (current_delta < best_delta) {
-        best_delta = current_delta;
-        choice = {-current_delta,
-                  s_rank,
-                  t_rank,
-                  (use_k_prime_for_min) ? k_prime->rank : s_rank,
-                  (use_k_for_min) ? k->rank : t_rank};
+        const auto insertion_in_source =
+          (use_k_prime_for_min) ? k_prime->rank : s_rank;
+        const auto insertion_in_target = (use_k_for_min) ? k->rank : t_rank;
+
+        std::vector<Index> source_range;
+        Index first_rank;
+        Index last_rank;
+        if (s_rank == insertion_in_source) {
+          source_range.push_back(target.route[t_rank]);
+          first_rank = s_rank;
+          last_rank = s_rank + 1;
+        } else {
+          if (s_rank < insertion_in_source) {
+            std::copy(source.route.begin() + s_rank + 1,
+                      source.route.begin() + insertion_in_source,
+                      std::back_inserter(source_range));
+            source_range.push_back(target.route[t_rank]);
+            first_rank = s_rank;
+            last_rank = insertion_in_source;
+          } else {
+            source_range.push_back(target.route[t_rank]);
+            std::copy(source.route.begin() + insertion_in_source,
+                      source.route.begin() + s_rank,
+                      std::back_inserter(source_range));
+            first_rank = insertion_in_source;
+            last_rank = s_rank + 1;
+          }
+        }
+
+        auto source_pickup =
+          std::accumulate(source_range.begin(),
+                          source_range.end(),
+                          input.zero_amount(),
+                          [&](auto sum, const auto i) {
+                            return sum + input.jobs[i].pickup;
+                          });
+        auto source_delivery =
+          std::accumulate(source_range.begin(),
+                          source_range.end(),
+                          input.zero_amount(),
+                          [&](auto sum, const auto i) {
+                            return sum + input.jobs[i].delivery;
+                          });
+
+        bool source_valid =
+          source.is_valid_addition_for_capacity_margins(input,
+                                                        source_pickup,
+                                                        source_delivery,
+                                                        first_rank,
+                                                        last_rank);
+
+        source_valid =
+          source_valid &&
+          source.is_valid_addition_for_capacity_inclusion(input,
+                                                          source_delivery,
+                                                          source_range.begin(),
+                                                          source_range.end(),
+                                                          first_rank,
+                                                          last_rank);
+
+        if (source_valid) {
+          std::vector<Index> target_range;
+          if (t_rank == insertion_in_target) {
+            target_range.push_back(source.route[s_rank]);
+            first_rank = t_rank;
+            last_rank = t_rank + 1;
+          } else {
+            if (t_rank < insertion_in_target) {
+              std::copy(target.route.begin() + t_rank + 1,
+                        target.route.begin() + insertion_in_target,
+                        std::back_inserter(target_range));
+              target_range.push_back(source.route[s_rank]);
+              first_rank = t_rank;
+              last_rank = insertion_in_target;
+            } else {
+              target_range.push_back(source.route[s_rank]);
+              std::copy(target.route.begin() + insertion_in_target,
+                        target.route.begin() + t_rank,
+                        std::back_inserter(target_range));
+              first_rank = insertion_in_target;
+              last_rank = t_rank + 1;
+            }
+          }
+
+          auto target_pickup =
+            std::accumulate(target_range.begin(),
+                            target_range.end(),
+                            input.zero_amount(),
+                            [&](auto sum, const auto i) {
+                              return sum + input.jobs[i].pickup;
+                            });
+          auto target_delivery =
+            std::accumulate(target_range.begin(),
+                            target_range.end(),
+                            input.zero_amount(),
+                            [&](auto sum, const auto i) {
+                              return sum + input.jobs[i].delivery;
+                            });
+
+          bool target_valid =
+            target.is_valid_addition_for_capacity_margins(input,
+                                                          target_pickup,
+                                                          target_delivery,
+                                                          first_rank,
+                                                          last_rank);
+
+          target_valid =
+            target_valid &&
+            target
+              .is_valid_addition_for_capacity_inclusion(input,
+                                                        target_delivery,
+                                                        target_range.begin(),
+                                                        target_range.end(),
+                                                        first_rank,
+                                                        last_rank);
+
+          if (target_valid) {
+            best_delta = current_delta;
+            choice = {-current_delta,
+                      s_rank,
+                      t_rank,
+                      insertion_in_source,
+                      insertion_in_target};
+          }
+        }
       }
     }
   }


HAWQ-318. Infinite loop when adjusting resource request in one resource queue track

--- src/backend/resourcemanager/resqueuemanager.c
+++ src/backend/resourcemanager/resqueuemanager.c
@@ -5225,7 +5225,7 @@
 			}

 			/* Add request to the resource queue and return. */
-			addQueryResourceRequestToQueue(shadowtrack, newconn);
+			addQueryResourceRequestToQueue(quetrack, newconn);
 		}
 		else
 		{


1998-07-14  Ben Elliston  <bje@cygnus.com>

	* condvar.c (pthread_condattr_init): Add `_cond' to function name.

--- condvar.c
+++ condvar.c
@@ -8,7 +8,7 @@
 #include "pthread.h"

 int
-pthread_cond_init(pthread_condattr_t *attr)
+pthread_condattr_init(pthread_condattr_t *attr)
 {
   if (attr == NULL)
     {


Allow pin pulldown

Allow pin pulldown

--- firmware/BlynkApiSparkCore.h
+++ firmware/BlynkApiSparkCore.h
@@ -106,6 +106,8 @@
                     pinMode(pin, OUTPUT);
                 } else if (!strcmp(it.asStr(), "pu")) {
                     pinMode(pin, INPUT_PULLUP);
+                } else if (!strcmp(it.asStr(), "pd")) {
+                    pinMode(pin, INPUT_PULLDOWN);
                 } else {
 #ifdef BLYNK_DEBUG
                     BLYNK_LOG("Invalid pinMode %u -> %s", pin, it.asStr());


vboot_ui_menu: honour power button press in RECOVERY_NO_GOOD_SCREEN

Curretly power button press is ignored in RECOVERY_NO_GOOD_SCREEN,
Allow user to power off system from RECOVERY_NO_GOOD_SCREEN.

BUG=None
Branch=None
Test=verify that the system powers of from NO_GOOD screen.

Change-Id: I768cd5a448c4493a4d9de756b2047c19cdf961ef
Signed-off-by: Rizwan Qureshi <ab2e774007702691ca75a812098fe180965af20d@intel.com>
Signed-off-by: Rizwan Qureshi <ab2e774007702691ca75a812098fe180965af20d@intel.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/812304
Reviewed-by: Randall Spangler <62698fdbb84d1779579ee80c3f39fac22017e5bc@chromium.org>
Reviewed-by: Wai-Hong Tam <04b587fdf5845741a0c5a8b9cd59ca72d73ef8fc@google.com>
Reviewed-by: Shelley Chen <ab7b8cc85923339aed379eb1c5cc4dccfd2eb3d7@chromium.org>

--- firmware/lib/vboot_ui_menu.c
+++ firmware/lib/vboot_ui_menu.c
@@ -1115,7 +1115,8 @@
 				 * there), power button will turn off
 				 * device.
 				 */
-				if (current_menu == VB_MENU_RECOVERY_INSERT) {
+				if (current_menu == VB_MENU_RECOVERY_INSERT ||
+					current_menu == VB_MENU_RECOVERY_NO_GOOD) {
 					ret = VBERROR_SHUTDOWN_REQUESTED;
 				} else {
 					/*


poppy: Converting all // comments to /* */

Also, ensuring comments start with capital letter.

BUG=chrome-os-partner:61275
BRANCH=None
TEST=None.  No functionality change.

Change-Id: I961236e2b6d95cf0281cd4e3313f465bf12ead9f
Signed-off-by: Shelley Chen <ab7b8cc85923339aed379eb1c5cc4dccfd2eb3d7@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/434250
Reviewed-by: Randall Spangler <62698fdbb84d1779579ee80c3f39fac22017e5bc@chromium.org>

--- firmware/lib/vboot_ui_menu.c
+++ firmware/lib/vboot_ui_menu.c
@@ -61,7 +61,7 @@
 	else if (0 != RollbackKernelLock(0))
 		VB2_DEBUG("Error locking kernel versions on legacy boot.\n");
 	else
-		VbExLegacy();	/* will not return if successful */
+		VbExLegacy();	/* Will not return if successful */

 	/* If legacy boot fails, beep and return to calling UI loop. */
 	VbExBeep(120, 400);
@@ -218,7 +218,7 @@
 	VB_TO_DEV_COUNT,
 } VB_TO_DEV_MENU;

-// currently we're only supporting
+// TODO: currently we're only supporting
 // english.  Will need to somehow find mapping
 // from language to localization index.
 typedef enum _VB_LANGUAGES_MENU {
@@ -340,7 +340,6 @@
 // printouts.
 VbError_t vb2_print_current_menu()
 {
-	// create menu string
 	char m_str[1024];
 	const char *selected = "==> ";
 	const char *deselected = "    ";
@@ -353,9 +352,9 @@
 	vb2_get_current_menu_size(current_menu, &m, &size);
 	VB2_DEBUG("vb2_print_current_menu:\n");

+	/* Create menu string */
 	for (i = 0; i < size; i++) {
 		if (current_menu_idx == i) {
-			// add selection to indicate current selection
 			strncat(m_str, selected, strlen(selected));
 		} else {
 			strncat(m_str, deselected, strlen(deselected));
@@ -412,24 +411,24 @@
 			}

 			/*
-			 * 1. select dev menu
-			 * 2. default to dev boot device
+			 * 1. Select dev menu
+			 * 2. Default to dev boot device
 			 */
 			vb2_set_menu_items(VB_MENU_DEV, next_menu_idx);
 			break;
 		case VB_WARN_DBG_INFO:
-			/* show debug info */
+			/* Show debug info */
 			break;
 		case VB_WARN_ENABLE_VER:
 			/*
-			 * 1. enable boot verification
-			 * 2. default to the power off option
+			 * 1. Enable boot verification
+			 * 2. Default to the power off option
 			 */
 			vb2_set_menu_items(VB_MENU_TO_NORM,
 					   VB_TO_NORM_POWER_OFF);
 			break;
 		case VB_WARN_POWER_OFF:
-			/* power off machine */
+			/* Power off machine */
 			ret =  VBERROR_SHUTDOWN_REQUESTED;
 			break;
 		case VB_WARN_LANGUAGE:
@@ -439,34 +438,34 @@
 					   VB_LANGUAGES_EN_US);
 			break;
 		default:
-			/* invalid menu item.  Don't update anything. */
+			/* Invalid menu item.  Don't update anything. */
 			break;
 		}
 		break;
 	case VB_MENU_DEV:
 		switch(current_menu_idx) {
 		case VB_DEV_NETWORK:
-			/* boot network image */
+			/* Boot network image */
 			break;
 		case VB_DEV_LEGACY:
-			/* boot legacy BIOS */
+			/* Boot legacy BIOS */
 			break;
 		case VB_DEV_USB:
-			/* boot USB image */
+			/* Boot USB image */
 			break;
 		case VB_DEV_DISK:
-			/* boot developer image */
+			/* Boot developer image */
 			break;
 		case VB_DEV_CANCEL:
 			/*
-			 * 1. cancel (go back to developer warning menu)
-			 * 2. default to power off option.
+			 * 1. Cancel (go back to developer warning menu)
+			 * 2. Default to power off option.
 			 */
 			vb2_set_menu_items(VB_MENU_DEV_WARNING,
 					   VB_WARN_POWER_OFF);
 			break;
 		case VB_DEV_POWER_OFF:
-			/* power off */
+			/* Power off */
 			ret = VBERROR_SHUTDOWN_REQUESTED;
 			break;
 		case VB_DEV_LANGUAGE:
@@ -475,25 +474,25 @@
 					   VB_LANGUAGES_EN_US);
 			break;
 		default:
-			/* invalid menu item.  don't update anything. */
+			/* Invalid menu item.  Don't update anything. */
 			break;
 		}
 		break;
 	case VB_MENU_TO_NORM:
 		switch(current_menu_idx) {
 		case VB_TO_NORM_CONFIRM:
-			/* confirm enabling verified boot */
+			/* Confirm enabling verified boot */
 			break;
 		case VB_TO_NORM_CANCEL:
 			/*
-			 * 1. cancel (go back to developer warning menu)
-			 * 2. default to power off
+			 * 1. Cancel (go back to developer warning menu)
+			 * 2. Default to power off
 			 */
 			vb2_set_menu_items(VB_MENU_DEV_WARNING,
 					   VB_WARN_POWER_OFF);
 			break;
 		case VB_TO_NORM_POWER_OFF:
-			/* power off */
+			/* Power off */
 			ret = VBERROR_SHUTDOWN_REQUESTED;
 			break;
 		case VB_TO_NORM_LANGUAGE:
@@ -502,7 +501,7 @@
 					   VB_LANGUAGES_EN_US);
 			break;
 		default:
-			/* invalid menu item.  don't update anything */
+			/* Invalid menu item.  Don't update anything */
 			break;
 		}
 		break;
@@ -510,8 +509,8 @@
 		switch(current_menu_idx) {
 		case VB_RECOVERY_TO_DEV:
 			/*
-			 * 1. switch to TO_DEV menu
-			 * 2. default to power off option
+			 * 1. Switch to TO_DEV menu
+			 * 2. Default to power off option
 			 */
 			vb2_set_menu_items(VB_MENU_TO_DEV,
 					   VB_TO_DEV_POWER_OFF);
@@ -526,14 +525,14 @@
 					   VB_LANGUAGES_EN_US);
 			break;
 		default:
-			/* invalid menu item.  don't update anything */
+			/* Invalid menu item.  Don't update anything */
 			break;
 		}
 		break;
 	case VB_MENU_TO_DEV:
 		switch(current_menu_idx) {
 		case VB_TO_DEV_CONFIRM:
-			/* confirm enabling dev mode */
+			/* Confirm enabling dev mode */
 			break;
 		case VB_TO_DEV_CANCEL:
 			vb2_set_menu_items(VB_MENU_RECOVERY,
@@ -547,7 +546,7 @@
 					   VB_LANGUAGES_EN_US);
 			break;
 		default:
-			/* invalid menu item.  don't update anything. */
+			/* Invalid menu item.  Don't update anything. */
 			break;
 		}
 		break;
@@ -555,10 +554,9 @@
 		switch(current_menu_idx) {
 		default:
 			/*
-			 * Assume that we selected a language.
-			 * Go to previous menu.
-			 * Purposely bypassing vb2_set_menu_items()
-			 * here because need to do in different order.
+			 * Assume that we selected a language.  Go to previous
+			 * menu.  Purposely bypassing vb2_set_menu_items() here
+			 * because need to do in different order.
 			 */
 			current_menu = prev_menu;
 			current_menu_idx = 0;
@@ -661,7 +659,7 @@
 	}

 	/* Show the dev mode warning screen */
-	/* TODO: change this to blank screen? */
+	//TODO: change this to blank screen?
 	VbDisplayScreen(ctx, cparams, VB_SCREEN_DEVELOPER_WARNING, 0);
 	vb2_print_current_menu();

@@ -682,7 +680,7 @@
 		key = VbExKeyboardRead();
 		switch (key) {
 		case 0:
-			/* nothing pressed */
+			/* Nothing pressed */
 			break;
 		case '\r':
 			/* Only disable virtual dev switch if allowed by GBB */
@@ -692,7 +690,7 @@
 		case VB_KEY_UP:
 			vb2_get_current_menu_size(current_menu,
 						  NULL, &menu_size);
-			// do not wrap selection index
+			/* Do not wrap selection index */
 			if (current_menu_idx > 0)
 				current_menu_idx--;
 			vb2_print_current_menu();
@@ -701,43 +699,44 @@
 		case VB_KEY_DOWN:
 			vb2_get_current_menu_size(current_menu,
 						  NULL, &menu_size);
-			// do no wrap selection index
+			/* Do no wrap selection index */
 			if (current_menu_idx < menu_size-1)
 				current_menu_idx++;
 			vb2_print_current_menu();
 			break;
 		case VB_BUTTON_POWER:
 		case VB_KEY_RIGHT:
-		        // temporarily using this as a stand in for power button
-		        // until get power button bypassed
 			selected = 1;

 			ret = vb2_update_menu();
-			// unfortunately, we need the blanking to get rid of
-			// artifacts from previous menu printing.
+			/*
+			 * Unfortunately, we need the blanking to get rid of
+			 * artifacts from previous menu printing.
+			 */
 			VbDisplayScreen(ctx, cparams, VB_SCREEN_BLANK, 0);
 			VbDisplayScreen(ctx, cparams,
 					VB_SCREEN_DEVELOPER_WARNING, 0);
 			vb2_print_current_menu();

-			// probably shutting down
+			/* Probably shutting down */
 			if (ret != VBERROR_SUCCESS) {
 			  VB2_DEBUG("VbBootDeveloperMenu() - shutting down!\n");
 			  return ret;
 			}

-			// nothing selected, skip everything else.
+			/* Nothing selected, skip everything else */
 			if (selected == 0)
 				break;

-			// below is all the selection actions
-			// Display debug information = tab on most chromebooks
+			/* All the actions associated with selection */
+
+			/* Display debug information */
 			if (current_menu == VB_MENU_DEV_WARNING &&
 			    current_menu_idx == VB_WARN_DBG_INFO) {
 				VbDisplayDebugInfo(ctx, cparams);
 			}

-			// Ctrl+L = legacy mode
+			/* Boot Legacy mode */
 			if (current_menu == VB_MENU_DEV &&
 			    current_menu_idx == VB_DEV_LEGACY) {
 				VB2_DEBUG("VbBootDeveloperMenu() - "
@@ -746,7 +745,7 @@
 				VbTryLegacyMenu(allow_legacy);
 			}

-			// Ctrl+U = try USB boot, or beep if failure
+			/* USB boot, or beep if failure */
 			if (current_menu == VB_MENU_DEV &&
 			    current_menu_idx == VB_DEV_USB) {
 				VB2_DEBUG("VbBootDeveloperMenu() - "
@@ -763,8 +762,10 @@
 					VbExSleepMs(120);
 					VbExBeep(120, 400);
 				} else {
-					// Clear the screen to show we get the
-					// Ctrl+U key press.
+					/*
+					 * Clear the screen to show we get the
+					 * Ctrl+U key press.
+					 */
 					VbDisplayScreen(ctx,
 						cparams, VB_SCREEN_BLANK, 0);
 					if (VBERROR_SUCCESS ==
@@ -772,8 +773,10 @@
 						VbAudioClose(audio);
 						return VBERROR_SUCCESS;
 					} else {
-						// Show dev mode warning screen
-						// again
+						/*
+						 * Show dev mode warning screen
+						 * again
+						 */
 						VbDisplayScreen(ctx,
 							cparams,
 							VB_SCREEN_DEVELOPER_WARNING,
@@ -782,7 +785,7 @@
 				}
 			}

-			/* Ctrl+D = dismiss warning; advance to timeout */
+			/* Boot developer mode: advance to timeout */
 			if (current_menu == VB_MENU_DEV &&
 			    current_menu_idx == VB_DEV_DISK) {
 				VB2_DEBUG("VbBootDeveloperMenu() - "
@@ -791,14 +794,16 @@
 				goto fallout;
 			}

-			/* enabling verified boot */
+			/* Enabling verified boot */
 			if (current_menu == VB_MENU_TO_NORM &&
 			    current_menu_idx == VB_TO_NORM_CONFIRM) {
-				// See if we should disable virtual dev-mode
-				// switch.
+				/*
+				 * See if we should disable virtual dev-mode
+				 * switch.
+				 */
 				VB2_DEBUG("%s shared->flags=0x%x\n",
 					  __func__, shared->flags);
-				// Ignore space in VbUserConfirmsMenu()...
+				/* Ignore space in VbUserConfirmsMenu()... */
 			        VB2_DEBUG("%s() - leaving dev-mode.\n",
 					  __func__);
 				vb2_nv_set(ctx, VB2_NV_DISABLE_DEV_REQUEST,
@@ -909,7 +914,8 @@

 	/* Loop and wait for a recovery image */
 	VB2_DEBUG("VbBootRecoveryMenu() waiting for a recovery image\n");
-	// initialize menu to recovery menu.
+
+	/* Initialize menu to recovery menu. */
 	current_menu = VB_MENU_RECOVERY;
 	prev_menu = VB_MENU_RECOVERY;
 	current_menu_idx = VB_RECOVERY_POWER_OFF;
@@ -967,17 +973,17 @@
 				break;
 			case VB_BUTTON_POWER:
 			case VB_KEY_RIGHT:
-				// temporarily using this as a stand in for
-				// power button until get power button bypassed
 				VB2_DEBUG("VbBootRecoveryMenu() - pressed key VB_KEY_RIGHT (SELECT)\n");
 				selected = 1;

 				ret = vb2_update_menu();
 				if (current_menu != VB_MENU_RECOVERY ||
 				     current_menu_idx != VB_RECOVERY_DBG_INFO) {
-					// unfortunately we need this screen
-					// blanking to clear previous menus
-					// printed.
+					/*
+					 * Unfortunately we need this screen
+					 * blanking to clear previous menus
+					 * printed.
+					 */
 					VbDisplayScreen(ctx, cparams, VB_SCREEN_BLANK, 0);
 					VbDisplayScreen(ctx, cparams, VBERROR_NO_DISK_FOUND == retval ?
 							VB_SCREEN_RECOVERY_INSERT :
@@ -986,13 +992,13 @@
 					vb2_print_current_menu();
 				}

-				// probably shutting down
+				/* Probably shutting down */
 				if (ret != VBERROR_SUCCESS) {
 					VB2_DEBUG("VbBootRecoveryMenu() - update_menu - shutting down!\n");
 					return ret;
 				}

-				// nothing selected, skip everything else.
+				/* Nothing selected, skip everything else. */
 				if (selected == 0)
 					break;


attribute_macros

error: pathspec 'common/attribute_macros.h' did not match any file(s) known to git

--- common/attribute_macros.h
+++ common/attribute_macros.h
@@ -0,0 +1,46 @@
+#ifndef ETL_COMMON_ATTRIBUTE_MACROS_H_
+#define ETL_COMMON_ATTRIBUTE_MACROS_H_
+
+/*
+ * These are shorthand for GCC's attribute syntax.  (The ETL_INLINE macro
+ * also includes a keyword needed to make the attribute work.)
+ */
+
+/*
+ * Function attributes.  Place before return type in declaration.
+ */
+
+// Function does not return.
+#define ETL_NORETURN __attribute__((noreturn))
+
+// Function should omit normal prologue/epilogue.
+#define ETL_NAKED __attribute__((naked))
+
+// Function body should *really* not be generated outline.
+// This overrides conservative heuristics at -Os.
+#define ETL_INLINE inline __attribute__((always_inline))
+
+
+/*
+ * Data attributes.
+ */
+
+// Lay out data as specified.  May hurt efficiency.
+#define ETL_PACKED __attribute__((packed))
+
+// Ensure object starts at multiple of n bytes.
+#define ETL_ALIGNED(n) __attribute__((aligned(n)))
+
+
+/*
+ * Multi-purpose attributes
+ */
+
+// Put object in specified linker section.
+#define ETL_SECTION(s) __attribute__((section(s)))
+
+// Consider object to be 'used' during linker GC.
+#define ETL_USED __attribute__((used))
+
+
+#endif  // ETL_COMMON_ATTRIBUTE_MACROS_H_


Handle app-less instances better

Handle app-less instances better

FlatpakInstance was not dealing well with sandboxes
that don't have an application. In this case, the
metadata does not have an Application group, but
a Runtime group instead.

Closes: #2482
Approved by: matthiasclasen

--- common/flatpak-instance.c
+++ common/flatpak-instance.c
@@ -128,6 +128,8 @@
  *
  * Gets the application ID of the application running in the instance.
  *
+ * Note that this may return %NULL for sandboxes that don't have an application.
+ *
  * Returns: the application ID
  *
  * Since: 1.1
@@ -392,10 +394,18 @@

   if (priv->info)
     {
-      priv->app = g_key_file_get_string (priv->info,
-          FLATPAK_METADATA_GROUP_APPLICATION, FLATPAK_METADATA_KEY_NAME, NULL);
-      priv->runtime = g_key_file_get_string (priv->info,
-          FLATPAK_METADATA_GROUP_APPLICATION, FLATPAK_METADATA_KEY_RUNTIME, NULL);
+      if (g_key_file_has_group (priv->info, FLATPAK_METADATA_GROUP_APPLICATION))
+        {
+          priv->app = g_key_file_get_string (priv->info,
+              FLATPAK_METADATA_GROUP_APPLICATION, FLATPAK_METADATA_KEY_NAME, NULL);
+          priv->runtime = g_key_file_get_string (priv->info,
+              FLATPAK_METADATA_GROUP_APPLICATION, FLATPAK_METADATA_KEY_RUNTIME, NULL);
+        }
+      else
+        {
+          priv->runtime = g_key_file_get_string (priv->info,
+              FLATPAK_METADATA_GROUP_RUNTIME, FLATPAK_METADATA_KEY_RUNTIME, NULL);
+        }

       priv->arch = g_key_file_get_string (priv->info,
           FLATPAK_METADATA_GROUP_INSTANCE, FLATPAK_METADATA_KEY_ARCH, NULL);


semantic: use int32_t for scope values (instead of uint32_t)

--- bootstrap/libnanyc/details/semantic/semantic-analysis.h
+++ bootstrap/libnanyc/details/semantic/semantic-analysis.h
@@ -38,13 +38,13 @@
 struct OnScopeFailHandlers final {
 	struct Handler {
 		Handler() = default;
-		Handler(uint32_t lvid, uint32_t label, uint32_t scope)
+		Handler(uint32_t lvid, uint32_t label, int32_t scope)
 			: lvid(lvid)
 			, label(label)
 			, scope(scope) {
 		}

-		void reset(uint32_t newlvid, uint32_t newlabel, uint32_t newscope) {
+		void reset(uint32_t newlvid, uint32_t newlabel, int32_t newscope) {
 			lvid  = newlvid;
 			label = newlabel;
 			used  = false;
@@ -66,7 +66,7 @@
 		uint32_t lvid = 0;
 		uint32_t label = 0;
 		bool used = false;
-		uint32_t scope = 0;
+		int32_t scope = 0;
 	};

 	auto& any() { return m_any; }
@@ -107,7 +107,7 @@
 		return find(atom) != nullptr;
 	}

-	auto& add(const Atom* atom, uint32_t lvid, uint32_t label, uint32_t scope) {
+	auto& add(const Atom* atom, uint32_t lvid, uint32_t label, int32_t scope) {
 		m_handlers.emplace_back(atom, Handler(lvid, label, scope));
 		return std::get<Handler>(m_handlers.back());
 	}
@@ -126,7 +126,7 @@
 			and std::get<const Atom*>(m_handlers.back()) == atom;
 	}

-	uint32_t scope() const {
+	int32_t scope() const {
 		assert(not empty());
 		auto& handler = (not m_any.empty()) ?  m_any : std::get<Handler>(m_handlers[0]);
 		return handler.scope;


Use "SetLastError" to flag errors to caller while loading.

--- MemoryModule.c
+++ MemoryModule.c
@@ -253,9 +253,7 @@
 			FARPROC *funcRef;
 			HCUSTOMMODULE handle = module->loadLibrary((LPCSTR) (codeBase + importDesc->Name), module->userdata);
 			if (handle == NULL) {
-#if DEBUG_OUTPUT
-				OutputLastError("Can't load library");
-#endif
+				SetLastError(ERROR_MOD_NOT_FOUND);
 				result = 0;
 				break;
 			}
@@ -263,6 +261,7 @@
 			tmp = (HCUSTOMMODULE *) realloc(module->modules, (module->numModules+1)*(sizeof(HCUSTOMMODULE)));
 			if (tmp == NULL) {
 				module->freeLibrary(handle, module->userdata);
+				SetLastError(ERROR_OUTOFMEMORY);
 				result = 0;
 				break;
 			}
@@ -292,6 +291,7 @@

 			if (!result) {
 				module->freeLibrary(handle, module->userdata);
+				SetLastError(ERROR_PROC_NOT_FOUND);
 				break;
 			}
 		}
@@ -341,17 +341,13 @@

 	dos_header = (PIMAGE_DOS_HEADER)data;
 	if (dos_header->e_magic != IMAGE_DOS_SIGNATURE) {
-#if DEBUG_OUTPUT
-		OutputDebugString("Not a valid executable file.\n");
-#endif
+		SetLastError(ERROR_BAD_EXE_FORMAT);
 		return NULL;
 	}

 	old_header = (PIMAGE_NT_HEADERS)&((const unsigned char *)(data))[dos_header->e_lfanew];
 	if (old_header->Signature != IMAGE_NT_SIGNATURE) {
-#if DEBUG_OUTPUT
-		OutputDebugString("No PE header found.\n");
-#endif
+		SetLastError(ERROR_BAD_EXE_FORMAT);
 		return NULL;
 	}

@@ -370,18 +366,14 @@
             MEM_RESERVE | MEM_COMMIT,
             PAGE_READWRITE);
 		if (code == NULL) {
-#if DEBUG_OUTPUT
-			OutputLastError("Can't reserve memory");
-#endif
+			SetLastError(ERROR_OUTOFMEMORY);
 			return NULL;
 		}
 	}

 	result = (PMEMORYMODULE)HeapAlloc(GetProcessHeap(), 0, sizeof(MEMORYMODULE));
 	if (result == NULL) {
-#if DEBUG_OUTPUT
-		OutputLastError("Can't reserve memory");
-#endif
+		SetLastError(ERROR_OUTOFMEMORY);
 		VirtualFree(code, 0, MEM_RELEASE);
 		return NULL;
 	}
@@ -432,9 +424,7 @@
 		// notify library about attaching to process
 		successfull = (*DllEntry)((HINSTANCE)code, DLL_PROCESS_ATTACH, 0);
 		if (!successfull) {
-#if DEBUG_OUTPUT
-			OutputDebugString("Can't attach library.\n");
-#endif
+			SetLastError(ERROR_DLL_INIT_FAILED);
 			goto error;
 		}
 		result->initialized = 1;


Patch #672053: Return a result from Py_Main, instead of exiting.

--- Modules/main.c
+++ Modules/main.c
@@ -88,7 +88,7 @@
 ";

-static void
+static int
 usage(int exitcode, char* program)
 {
 	FILE *f = exitcode ? stderr : stdout;
@@ -105,14 +105,14 @@
 #if defined(__VMS)
 	if (exitcode == 0) {
 		/* suppress 'error' message */
-		exit(1);
+		return 1;
 	}
 	else {
 		/* STS$M_INHIB_MSG + SS$_ABORT */
-		exit(0x1000002c);
+		return 0x1000002c;
 	}
 #else
-	exit(exitcode);
+	return exitcode;
 #endif
 	/*NOTREACHED*/
 }
@@ -194,7 +194,7 @@
 			fprintf(stderr,
 				"-Q option should be `-Qold', "
 				"`-Qwarn', `-Qwarnall', or `-Qnew' only\n");
-			usage(2, argv[0]);
+			return usage(2, argv[0]);
 			/* NOTREACHED */

 		case 'i':
@@ -255,18 +255,18 @@
 		/* This space reserved for other options */

 		default:
-			usage(2, argv[0]);
+			return usage(2, argv[0]);
 			/*NOTREACHED*/

 		}
 	}

 	if (help)
-		usage(0, argv[0]);
+		return usage(0, argv[0]);

 	if (version) {
 		fprintf(stderr, "Python %s\n", PY_VERSION);
-		exit(0);
+		return 0;
 	}

 	if (!saw_inspect_flag &&
@@ -291,7 +291,7 @@
 			if ((fp = fopen(filename, "r")) == NULL) {
 				fprintf(stderr, "%s: can't open file '%s'\n",
 					argv[0], filename);
-				exit(2);
+				return 2;
 			}
 			else if (skipfirstline) {
 				int ch;


a better name for myinit/myfini

a better name for myinit/myfini

--- compiled/xalt_obfuscate.h
+++ compiled/xalt_obfuscate.h
@@ -1,39 +1,43 @@
 #ifndef XALT_OBFUSCATE
 #define XALT_OBFUSCATE

-#define PASTE(a,b)  PaStE2(a,b)
-#define PaStE2(a,b) a##b
+#define PASTE2(a,b)    PaStE2(a,b)
+#define PaStE2(a,b)    a##b
+#define PASTE3(a,b,c)  PaStE3(a,b,c)
+#define PaStE3(a,b,c)  a##b##c

 #ifndef HIDE
 #define HIDE _xalt_1_5
 #endif

+#define MY_NAME            PASTE3("_",STATE,HIDE)
+
 // Functions
-#define abspath            PASTE(__XALT_abspath,HIDE)
-#define build_uuid_str     PASTE(__XALT_build_uuid_str,HIDE)
-#define compute_value      PASTE(__XALT_compute_value,HIDE)
-#define hostname           PASTE(__XALT_hostname,HIDE)
-#define myfini             PASTE(__XALT_myfini,STATE)
-#define myinit             PASTE(__XALT_myinit,STATE)
-#define reject             PASTE(__XALT_reject,HIDE)
-#define xalt_fgets_alloc   PASTE(__XALT_fgets_alloc,HIDE)
-#define xalt_quotestring   PASTE(__XALT_quotestring,HIDE)
-#define xalt_syshost       PASTE(__XALT_syshost,HIDE)
-#define xalt_unquotestring PASTE(__XALT_unquotestring,HIDE)
+#define abspath            PASTE2(__XALT_abspath,HIDE)
+#define build_uuid_str     PASTE2(__XALT_build_uuid_str,HIDE)
+#define compute_value      PASTE2(__XALT_compute_value,HIDE)
+#define hostname           PASTE2(__XALT_hostname,HIDE)
+#define myfini             PASTE2(__XALT_myfini,MY_NAME)
+#define myinit             PASTE2(__XALT_myinit,MY_NAME)
+#define reject             PASTE2(__XALT_reject,HIDE)
+#define xalt_fgets_alloc   PASTE2(__XALT_fgets_alloc,HIDE)
+#define xalt_quotestring   PASTE2(__XALT_quotestring,HIDE)
+#define xalt_syshost       PASTE2(__XALT_syshost,HIDE)
+#define xalt_unquotestring PASTE2(__XALT_unquotestring,HIDE)

 // Data

-#define acceptPathA        PASTE(__XALT_acceptPathA,HIDE)
-#define ignorePathA        PASTE(__XALT_ignorePathA,HIDE)
-#define hostnameA          PASTE(__XALT_hostnameA,HIDE)
-#define acceptEnvA         PASTE(__XALT_acceptEnvA,HIDE)
-#define ignoreEnvA         PASTE(__XALT_ignoreEnvA,HIDE)
+#define acceptPathA        PASTE2(__XALT_acceptPathA,HIDE)
+#define ignorePathA        PASTE2(__XALT_ignorePathA,HIDE)
+#define hostnameA          PASTE2(__XALT_hostnameA,HIDE)
+#define acceptEnvA         PASTE2(__XALT_acceptEnvA,HIDE)
+#define ignoreEnvA         PASTE2(__XALT_ignoreEnvA,HIDE)

-#define acceptPathSz       PASTE(__XALT_acceptPathSz,HIDE)
-#define ignorePathSz       PASTE(__XALT_ignorePathSz,HIDE)
-#define hostnameSz         PASTE(__XALT_hostnameSz,HIDE)
-#define acceptEnvSz        PASTE(__XALT_acceptEnvSz,HIDE)
-#define ignoreEnvSz        PASTE(__XALT_ignoreEnvSz,HIDE)
+#define acceptPathSz       PASTE2(__XALT_acceptPathSz,HIDE)
+#define ignorePathSz       PASTE2(__XALT_ignorePathSz,HIDE)
+#define hostnameSz         PASTE2(__XALT_hostnameSz,HIDE)
+#define acceptEnvSz        PASTE2(__XALT_acceptEnvSz,HIDE)
+#define ignoreEnvSz        PASTE2(__XALT_ignoreEnvSz,HIDE)


[java] Don't generate parentheses around foo.length()

--- compiler/generator_java.c
+++ compiler/generator_java.c
@@ -282,11 +282,11 @@
         case c_lenof: /* Same as sizeof() for Java. */
         case c_sizeof:
             g->V[0] = p->name;
-            w(g, "(~V0.length())");
+            w(g, "~V0.length()");
             break;
         case c_len: /* Same as size() for Java. */
         case c_size:
-            w(g, "(current.length())");
+            w(g, "current.length()");
             break;
     }
 }
@@ -821,7 +821,7 @@
     writef(g, "~{~M~n ~B0 = this;~N"
              "~Mcurrent = new StringBuffer(~V0.toString());~N"
              "~Mcursor = 0;~N"
-             "~Mlimit = (current.length());~N", p);
+             "~Mlimit = current.length();~N", p);
     generate(g, p->left);
     if (!g->unreachable) {
         write_margin(g);


Fixed compilation error.

Fixed compilation error.

--- NULLC/Parser.h
+++ NULLC/Parser.h
@@ -21,7 +21,9 @@
 	ALLOW_GENERIC_BASE = 1 << 2, // used for parsing of external generic type member function definitions so that a function can be applied to all generic type instances
 	ALLOW_EXTENDED_TYPEOF = 1 << 3, // used to allow extended typeof expressions immediately after class name
 	ALLOW_NUMERIC_RESULT = 1 << 4, // used to allow extended typeof expressions that result in a numeric result instead of type
-	ALLOW_AUTO_RETURN_TYPE = 1 << 5 // used to allow extended typeof expressions that result in a numeric result instead of type
+	ALLOW_AUTO_RETURN_TYPE = 1 << 5, // used to allow extended typeof expressions that result in a numeric result instead of type
+
+	DISALLOW_EXPLICIT = 1 << 6, // explicit keyword should not be skipped
 };
 bool ParseSelectType(Lexeme** str, unsigned flag = ALLOW_ARRAY | ALLOW_EXTENDED_TYPEOF, TypeInfo* instanceType = NULL, bool* instanceFailure = NULL);
 void ParseTypePostExpressions(Lexeme** str, bool allowArray, bool notType, bool allowAutoReturnType = false, bool allowGenericType = false, TypeInfo* instanceType = NULL, bool* instanceFailure = NULL);


COMMON - fixed a few bugs in the command line parser

--- src/commandLineParser/cxa_commandLineParser.c
+++ src/commandLineParser/cxa_commandLineParser.c
@@ -170,8 +170,8 @@
 				return false;
 			}
 			// get the argument value
-			cxa_stringUtils_parseResult_t argVal = cxa_stringUtils_parseString(passedOpt);
-			if( argVal.dataType != expectedOpt->expectedArgType )
+			cxa_stringUtils_parseResult_t argVal;
+			if( !cxa_stringUtils_parseString(argv[i], &argVal) || (argVal.dataType != expectedOpt->expectedArgType) )
 			{
 				fprintf(stderr, "Error: Cannot parse expected %s argument from string [%s]" CXA_LINE_ENDING, cxa_stringUtils_getStringForDataType(argVal.dataType), passedOpt);
 				return false;
@@ -191,7 +191,7 @@
 				continue;
 			}

-			// if we made it ehre, things get a little tricky...
+			// if we made it here, things get a little tricky...
 			char* nextStr = argv[i];
 			if( cxa_stringUtils_startsWith(nextStr, "--") || cxa_stringUtils_startsWith(nextStr, "-") )
 			{
@@ -203,8 +203,8 @@
 			else
 			{
 				// the next string is not an option...therefore it should be an argument
-				cxa_stringUtils_parseResult_t argVal = cxa_stringUtils_parseString(passedOpt);
-				if( argVal.dataType != expectedOpt->expectedArgType )
+				cxa_stringUtils_parseResult_t argVal;
+				if( !cxa_stringUtils_parseString(passedOpt, &argVal) || (argVal.dataType != expectedOpt->expectedArgType) )
 				{
 					fprintf(stderr, "Error: Cannot parse expected %s argument from string [%s]" CXA_LINE_ENDING, cxa_stringUtils_getStringForDataType(argVal.dataType), passedOpt);
 					return false;


Avoid leaking file descriptors and object references in the python bindings,
by releasing the python object from the pool cleanup handler. Also call
the python close function when the stream is explicitly closed.

* subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c
  (close_handler_pyio): Forward close to the python code, but don't decrement
    reference to python object yet.

  (svn_swig_py_stream_destroy): New function.
  (svn_swig_py_make_stream): Install svn_swig_py_stream_destroy as cleanup
    handler.

Patch by: Nick Piper <nick.piper{_AT_}logica.com>
          (tweaked by me)

--- subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c
+++ subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c
@@ -2117,10 +2117,27 @@
 close_handler_pyio(void *baton)
 {
   PyObject *py_io = baton;
+  PyObject *result;
+  svn_error_t *err = NULL;
+
+  svn_swig_py_acquire_py_lock();
+  if ((result = PyObject_CallMethod(py_io, (char *)"close", NULL)) == NULL)
+    {
+      err = callback_exception_error();
+    }
+  Py_XDECREF(result);
+  svn_swig_py_release_py_lock();
+
+  return err;
+}
+
+static apr_status_t
+svn_swig_py_stream_destroy(void *py_io)
+{
   svn_swig_py_acquire_py_lock();
   Py_DECREF(py_io);
   svn_swig_py_release_py_lock();
-  return SVN_NO_ERROR;
+  return APR_SUCCESS;
 }

 svn_stream_t *
@@ -2132,6 +2149,8 @@
   svn_stream_set_read(stream, read_handler_pyio);
   svn_stream_set_write(stream, write_handler_pyio);
   svn_stream_set_close(stream, close_handler_pyio);
+  apr_pool_cleanup_register(pool, py_io, svn_swig_py_stream_destroy,
+                            apr_pool_cleanup_null);
   Py_INCREF(py_io);

   return stream;