*** empty log message ***

*** empty log message ***

--- protocol.c
+++ protocol.c
@@ -176,7 +176,23 @@
     }

     if (currentCommand == enet_list_end (& peer -> sentReliableCommands))
-      return ENET_PROTOCOL_COMMAND_NONE;
+    {
+       for (currentCommand = enet_list_begin (& peer -> outgoingReliableCommands);
+            currentCommand != enet_list_end (& peer -> outgoingReliableCommands);
+            currentCommand = enet_list_next (currentCommand))
+       {
+          outgoingCommand = (ENetOutgoingCommand *) currentCommand;
+
+          if (outgoingCommand -> sendAttempts < 1) return ENET_PROTOCOL_COMMAND_NONE;
+
+          if (outgoingCommand -> reliableSequenceNumber == reliableSequenceNumber &&
+              outgoingCommand -> command.header.channelID == channelID)
+            break;
+       }
+
+       if (currentCommand == enet_list_end (& peer -> outgoingReliableCommands))
+         return ENET_PROTOCOL_COMMAND_NONE;
+    }

     if (channelID < peer -> channelCount)
     {


media: s5p-hdmi: add HPD GPIO to platform data

This patch extends s5p-hdmi platform data by a GPIO identifier for
Hot-Plug-Detection pin.

Signed-off-by: Tomasz Stanislawski <1d1920cd5005800d95aa92fe17b5db1b07fd95e5@samsung.com>
Acked-by: Tomasz Stanislawski <1d1920cd5005800d95aa92fe17b5db1b07fd95e5@samsung.com>
Signed-off-by: Kyungmin Park <504c23c4986a3760712724894be3105092c27331@samsung.com>
Signed-off-by: Inki Dae <bae4a7a27bbc965064e97edd6e179ac4979db440@samsung.com>

--- include/media/s5p_hdmi.h
+++ include/media/s5p_hdmi.h
@@ -20,6 +20,7 @@
  * @hdmiphy_info: template for HDMIPHY I2C device
  * @mhl_bus: controller id for MHL control bus
  * @mhl_info: template for MHL I2C device
+ * @hpd_gpio: GPIO for Hot-Plug-Detect pin
  *
  * NULL pointer for *_info fields indicates that
  * the corresponding chip is not present
@@ -29,6 +30,7 @@
 	struct i2c_board_info *hdmiphy_info;
 	int mhl_bus;
 	struct i2c_board_info *mhl_info;
+	int hpd_gpio;
 };

 #endif /* S5P_HDMI_H */


allow larger large objects to better use segment space

--- include/mimalloc-types.h
+++ include/mimalloc-types.h
@@ -93,7 +93,7 @@

 #define MI_SMALL_OBJ_SIZE_MAX             (MI_SMALL_PAGE_SIZE/4)
 #define MI_MEDIUM_OBJ_SIZE_MAX            (MI_MEDIUM_PAGE_SIZE/4)   // 128kb on 64-bit
-#define MI_LARGE_OBJ_SIZE_MAX             (MI_LARGE_PAGE_SIZE/4)    // 1Mb on 64-bit
+#define MI_LARGE_OBJ_SIZE_MAX             (MI_LARGE_PAGE_SIZE/2)    // 2Mb on 64-bit
 #define MI_LARGE_OBJ_WSIZE_MAX            (MI_LARGE_OBJ_SIZE_MAX>>MI_INTPTR_SHIFT)
 #define MI_HUGE_OBJ_SIZE_MAX              (2*MI_INTPTR_SIZE*MI_SEGMENT_SIZE)  // (must match MI_REGION_MAX_ALLOC_SIZE in memory.c)


fix slice count

fix slice count

--- include/mimalloc-types.h
+++ include/mimalloc-types.h
@@ -141,7 +141,7 @@
 #define MI_SEGMENT_ALIGN                  MI_SEGMENT_SIZE
 #define MI_SEGMENT_MASK                   (MI_SEGMENT_SIZE - 1)
 #define MI_SEGMENT_SLICE_SIZE             (MI_ZU(1)<< MI_SEGMENT_SLICE_SHIFT)
-#define MI_SLICES_PER_SEGMENT             (MI_SEGMENT_SIZE / MI_SEGMENT_SLICE_SIZE) // 128
+#define MI_SLICES_PER_SEGMENT             (MI_SEGMENT_SIZE / MI_SEGMENT_SLICE_SIZE) // 1024

 #define MI_SMALL_PAGE_SIZE                (MI_ZU(1)<<MI_SMALL_PAGE_SHIFT)
 #define MI_MEDIUM_PAGE_SIZE               (MI_ZU(1)<<MI_MEDIUM_PAGE_SHIFT)


STY: Coding style cleanups.

STY: Coding style cleanups.

git-svn-id: 003f22d385e25de9cff933a5ea4efd77cb5e7b28@6625 d6536bca-fef9-0310-8506-e4c0a848fbcf

--- scipy/interpolate/src/__fitpack.h
+++ scipy/interpolate/src/__fitpack.h
@@ -1,29 +1,31 @@
 /*
-  Python-C wrapper of FITPACK (by P. Dierckx) (in netlib known as dierckx)
-  Author: Pearu Peterson <pearu@ioc.ee>
-  June 1.-4., 1999
-  June 7. 1999
-  $Revision$
-  $Date$
+ * Python-C wrapper of FITPACK (by P. Dierckx) (in netlib known as dierckx)
+ * Author: Pearu Peterson <pearu@ioc.ee>
+ * June 1.-4., 1999
+ * June 7. 1999
+ * $Revision$
+ * $Date$
  */

 /*  module_methods:
-  {"_curfit", fitpack_curfit, METH_VARARGS, doc_curfit},
-  {"_spl_", fitpack_spl_, METH_VARARGS, doc_spl_},
-  {"_splint", fitpack_splint, METH_VARARGS, doc_splint},
-  {"_sproot", fitpack_sproot, METH_VARARGS, doc_sproot},
-  {"_spalde", fitpack_spalde, METH_VARARGS, doc_spalde},
-  {"_parcur", fitpack_parcur, METH_VARARGS, doc_parcur},
-  {"_surfit", fitpack_surfit, METH_VARARGS, doc_surfit},
-  {"_bispev", fitpack_bispev, METH_VARARGS, doc_bispev},
-  {"_insert", fitpack_insert, METH_VARARGS, doc_insert},
+ * {"_curfit", fitpack_curfit, METH_VARARGS, doc_curfit},
+ * {"_spl_", fitpack_spl_, METH_VARARGS, doc_spl_},
+ * {"_splint", fitpack_splint, METH_VARARGS, doc_splint},
+ * {"_sproot", fitpack_sproot, METH_VARARGS, doc_sproot},
+ * {"_spalde", fitpack_spalde, METH_VARARGS, doc_spalde},
+ * {"_parcur", fitpack_parcur, METH_VARARGS, doc_parcur},
+ * {"_surfit", fitpack_surfit, METH_VARARGS, doc_surfit},
+ * {"_bispev", fitpack_bispev, METH_VARARGS, doc_bispev},
+ * {"_insert", fitpack_insert, METH_VARARGS, doc_insert},
  */
+
 /* link libraries: (one item per line)
    ddierckx
  */
 /* python files: (to be imported to Multipack.py)
    fitpack.py
  */
+
 #if defined(UPPERCASE_FORTRAN)
 	#if defined(NO_APPEND_FORTRAN)
 	/* nothing to do */
@@ -74,380 +76,517 @@
 	#endif
 #endif

-void CURFIT(int*,int*,double*,double*,double*,double*,double*,int*,double*,int*,int*,double*,double*,double*,double*,int*,int*,int*);
-void PERCUR(int*,int*,double*,double*,double*,int*,double*,int*,int*,double*,double*,double*,double*,int*,int*,int*);
+void CURFIT(int*,int*,double*,double*,double*,double*,
+        double*,int*,double*,int*,int*,double*,double*,
+        double*,double*,int*,int*,int*);
+void PERCUR(int*,int*,double*,double*,double*,int*,
+        double*,int*,int*,double*,double*,double*,
+        double*,int*,int*,int*);
 void SPALDE(double*,int*,double*,int*,double*,double*,int*);
-void SPLDER(double*,int*,double*,int*,int*,double*,double*,int*,int*,double*,int*);
+void SPLDER(double*,int*,double*,int*,int*,double*,
+        double*,int*,int*,double*,int*);
 void SPLEV(double*,int*,double*,int*,double*,double*,int*,int*,int*);
 double SPLINT(double*,int*,double*,int*,double*,double*,double*);
 void SPROOT(double*,int*,double*,double*,int*,int*,int*);
-void PARCUR(int*,int*,int*,int*,double*,int*,double*,double*,double*,double*,int*,double*,int*,int*,double*,int*,double*,double*,double*,int*,int*,int*);
-void CLOCUR(int*,int*,int*,int*,double*,int*,double*,double*,int*,double*,int*,int*,double*,int*,double*,double*,double*,int*,int*,int*);
-void SURFIT(int*,int*,double*,double*,double*,double*,double*,double*,double*,double*,int*,int*,double*,int*,int*,int*,double*,int*,double*,int*,double*,double*,double*,double*,int*,double*,int*,int*,int*,int*);
-void BISPEV(double*,int*,double*,int*,double*,int*,int*,double*,int*,double*,int*,double*,double*,int*,int*,int*,int*);
-void PARDER(double*,int*,double*,int*,double*,int*,int*,int*,int*,double*,int*,double*,int*,double*,double*,int*,int*,int*,int*);
-void INSERT(int*,double*,int*,double*,int*,double*,double*,int*,double*,int*,int*);
+void PARCUR(int*,int*,int*,int*,double*,int*,double*,
+        double*,double*,double*,int*,double*,int*,int*,
+        double*,int*,double*,double*,double*,int*,int*,int*);
+void CLOCUR(int*,int*,int*,int*,double*,int*,double*,
+        double*,int*,double*,int*,int*,double*,int*,
+        double*,double*,double*,int*,int*,int*);
+void SURFIT(int*,int*,double*,double*,double*,double*,
+        double*,double*,double*,double*,int*,int*,double*,
+        int*,int*,int*,double*,int*,double*,int*,double*,
+        double*,double*,double*,int*,double*,int*,int*,int*,int*);
+void BISPEV(double*,int*,double*,int*,double*,int*,int*,
+        double*,int*,double*,int*,double*,double*,int*,
+        int*,int*,int*);
+void PARDER(double*,int*,double*,int*,double*,int*,int*,
+        int*,int*,double*,int*,double*,int*,double*,
+        double*,int*,int*,int*,int*);
+void INSERT(int*,double*,int*,double*,int*,double*,double*,
+        int*,double*,int*,int*);

 /* Note that curev, cualde need no interface. */

 static char doc_bispev[] = " [z,ier] = _bispev(tx,ty,c,kx,ky,x,y,nux,nuy)";
-static PyObject *fitpack_bispev(PyObject *dummy, PyObject *args) {
-  int nx,ny,kx,ky,mx,my,lwrk,*iwrk,kwrk,ier,lwa,nux,nuy;
-  npy_intp mxy;
-  double *tx,*ty,*c,*x,*y,*z,*wrk,*wa = NULL;
-  PyArrayObject *ap_x = NULL,*ap_y = NULL,*ap_z = NULL,*ap_tx = NULL,\
-    *ap_ty = NULL,*ap_c = NULL;
-  PyObject *x_py = NULL,*y_py = NULL,*c_py = NULL,*tx_py = NULL,*ty_py = NULL;
-  if (!PyArg_ParseTuple(args, "OOOiiOOii",&tx_py,&ty_py,&c_py,&kx,&ky,
-			&x_py,&y_py,&nux,&nuy))
+static PyObject *
+fitpack_bispev(PyObject *dummy, PyObject *args)
+{
+    int nx, ny, kx, ky, mx, my, lwrk, *iwrk, kwrk, ier, lwa, nux, nuy;
+    npy_intp mxy;
+    double *tx, *ty, *c, *x, *y, *z, *wrk, *wa = NULL;
+    PyArrayObject *ap_x = NULL, *ap_y = NULL, *ap_z = NULL, *ap_tx = NULL;
+    PyArrayObject *ap_ty = NULL, *ap_c = NULL;
+    PyObject *x_py = NULL, *y_py = NULL, *c_py = NULL, *tx_py = NULL, *ty_py = NULL;
+
+    if (!PyArg_ParseTuple(args, "OOOiiOOii",&tx_py,&ty_py,&c_py,&kx,&ky,
+                &x_py,&y_py,&nux,&nuy)) {
+        return NULL;
+    }
+    ap_x = (PyArrayObject *)PyArray_ContiguousFromObject(x_py, PyArray_DOUBLE, 0, 1);
+    ap_y = (PyArrayObject *)PyArray_ContiguousFromObject(y_py, PyArray_DOUBLE, 0, 1);
+    ap_c = (PyArrayObject *)PyArray_ContiguousFromObject(c_py, PyArray_DOUBLE, 0, 1);
+    ap_tx = (PyArrayObject *)PyArray_ContiguousFromObject(tx_py, PyArray_DOUBLE, 0, 1);
+    ap_ty = (PyArrayObject *)PyArray_ContiguousFromObject(ty_py, PyArray_DOUBLE, 0, 1);
+    if (ap_x == NULL
+            || ap_y == NULL
+            || ap_c == NULL
+            || ap_tx == NULL
+            || ap_ty == NULL) {
+        goto fail;
+    }
+    x = (double *) ap_x->data;
+    y = (double *) ap_y->data;
+    c = (double *) ap_c->data;
+    tx = (double *) ap_tx->data;
+    ty = (double *) ap_ty->data;
+    nx = ap_tx->dimensions[0];
+    ny = ap_ty->dimensions[0];
+    mx = ap_x->dimensions[0];
+    my = ap_y->dimensions[0];
+    mxy = mx*my;
+    ap_z = (PyArrayObject *)PyArray_SimpleNew(1,&mxy,PyArray_DOUBLE);
+    z = (double *) ap_z->data;
+    if (nux || nuy) {
+        lwrk = mx*(kx + 1 - nux) + my*(ky + 1 - nuy) + (nx - kx - 1)*(ny - ky - 1);
+    }
+    else {
+        lwrk = mx*(kx + 1) + my*(ky + 1);
+    }
+    kwrk = mx + my;
+    lwa = lwrk + kwrk;
+    if ((wa = (double *)malloc(lwa*sizeof(double))) == NULL) {
+        PyErr_NoMemory();
+        goto fail;
+    }
+    wrk = wa;
+    iwrk = (int *)(wrk + lwrk);
+    if (nux || nuy) {
+        PARDER(tx, &nx, ty, &ny, c, &kx, &ky, &nux, &nuy, x, &mx, y, &my, z,
+                wrk, &lwrk, iwrk, &kwrk, &ier);
+    }
+    else {
+        BISPEV(tx, &nx, ty, &ny, c, &kx, &ky, x, &mx, y, &my, z, wrk, &lwrk,
+                iwrk, &kwrk, &ier);
+    }
+
+    if (wa) {
+        free(wa);
+    }
+    Py_DECREF(ap_x);
+    Py_DECREF(ap_y);
+    Py_DECREF(ap_c);
+    Py_DECREF(ap_tx);
+    Py_DECREF(ap_ty);
+    return Py_BuildValue("Ni",PyArray_Return(ap_z),ier);
+
+fail:
+    if (wa) {
+        free(wa);
+    }
+    Py_XDECREF(ap_x);
+    Py_XDECREF(ap_y);
+    Py_XDECREF(ap_z);
+    Py_XDECREF(ap_c);
+    Py_XDECREF(ap_tx);
+    Py_XDECREF(ap_ty);
     return NULL;
-  ap_x = (PyArrayObject *)PyArray_ContiguousFromObject(x_py, PyArray_DOUBLE, 0, 1);
-  ap_y = (PyArrayObject *)PyArray_ContiguousFromObject(y_py, PyArray_DOUBLE, 0, 1);
-  ap_c = (PyArrayObject *)PyArray_ContiguousFromObject(c_py, PyArray_DOUBLE, 0, 1);
-  ap_tx = (PyArrayObject *)PyArray_ContiguousFromObject(tx_py, PyArray_DOUBLE, 0, 1);
-  ap_ty = (PyArrayObject *)PyArray_ContiguousFromObject(ty_py, PyArray_DOUBLE, 0, 1);
-  if (ap_x == NULL || ap_y == NULL || ap_c == NULL || ap_tx == NULL \
-      || ap_ty == NULL) goto fail;
-  x = (double *) ap_x->data;
-  y = (double *) ap_y->data;
-  c = (double *) ap_c->data;
-  tx = (double *) ap_tx->data;
-  ty = (double *) ap_ty->data;
-  nx = ap_tx->dimensions[0];
-  ny = ap_ty->dimensions[0];
-  mx = ap_x->dimensions[0];
-  my = ap_y->dimensions[0];
-  mxy = mx*my;
-  ap_z = (PyArrayObject *)PyArray_SimpleNew(1,&mxy,PyArray_DOUBLE);
-  z = (double *) ap_z->data;
-  if (nux || nuy)
-    lwrk = mx*(kx+1-nux)+my*(ky+1-nuy)+(nx-kx-1)*(ny-ky-1);
-  else
-    lwrk = mx*(kx+1)+my*(ky+1);
-  kwrk = mx+my;
-  lwa = lwrk+kwrk;
-  if ((wa = (double *)malloc(lwa*sizeof(double)))==NULL) {
-    PyErr_NoMemory();
-    goto fail;
-  }
-  wrk = wa;
-  iwrk = (int *)(wrk+lwrk);
-  if (nux || nuy)
-    PARDER(tx,&nx,ty,&ny,c,&kx,&ky,&nux,&nuy,x,&mx,y,&my,z,wrk,&lwrk,iwrk,&kwrk,&ier);
-  else
-    BISPEV(tx,&nx,ty,&ny,c,&kx,&ky,x,&mx,y,&my,z,wrk,&lwrk,iwrk,&kwrk,&ier);
-
-  if (wa) free(wa);
-  Py_DECREF(ap_x);
-  Py_DECREF(ap_y);
-  Py_DECREF(ap_c);
-  Py_DECREF(ap_tx);
-  Py_DECREF(ap_ty);
-  return Py_BuildValue("Ni",PyArray_Return(ap_z),ier);
-  fail:
-  if (wa) free(wa);
-  Py_XDECREF(ap_x);
-  Py_XDECREF(ap_y);
-  Py_XDECREF(ap_z);
-  Py_XDECREF(ap_c);
-  Py_XDECREF(ap_tx);
-  Py_XDECREF(ap_ty);
-  return NULL;
 }

-static char doc_surfit[] = " [tx,ty,c,o] = _surfit(x,y,z,w,xb,xe,yb,ye,kx,ky,iopt,s,eps,tx,ty,nxest,nyest,wrk,lwrk1,lwrk2)";
-static PyObject *fitpack_surfit(PyObject *dummy, PyObject *args) {
-  int iopt,m,kx,ky,nxest,nyest,lwrk1,lwrk2,*iwrk,kwrk,ier,lwa,nxo,nyo,\
-    i,lcest,nmax;
-  npy_intp nx, ny, lc;
-  double *x,*y,*z,*w,xb,xe,yb,ye,s,*tx,*ty,*c,fp,*wrk1,*wrk2,*wa = NULL,eps;
-  PyArrayObject *ap_x = NULL,*ap_y = NULL,*ap_z,*ap_w = NULL,\
-    *ap_tx = NULL,*ap_ty = NULL,*ap_c = NULL;
-  PyArrayObject *ap_wrk = NULL;
-  PyObject *x_py = NULL,*y_py = NULL,*z_py = NULL,*w_py = NULL,\
-    *tx_py = NULL,*ty_py = NULL;
-  PyObject *wrk_py=NULL;
-  nx=ny=ier=nxo=nyo=0;
-  if (!PyArg_ParseTuple(args, "OOOOddddiiiddOOiiOii",\
-			&x_py,&y_py,&z_py,&w_py,&xb,&xe,\
-			&yb,&ye,&kx,&ky,&iopt,&s,&eps,&tx_py,&ty_py,&nxest,&nyest,\
-			&wrk_py,&lwrk1,&lwrk2)) return NULL;
-  ap_x = (PyArrayObject *)PyArray_ContiguousFromObject(x_py, PyArray_DOUBLE, 0, 1);
-  ap_y = (PyArrayObject *)PyArray_ContiguousFromObject(y_py, PyArray_DOUBLE, 0, 1);
-  ap_z = (PyArrayObject *)PyArray_ContiguousFromObject(z_py, PyArray_DOUBLE, 0, 1);
-  ap_w = (PyArrayObject *)PyArray_ContiguousFromObject(w_py, PyArray_DOUBLE, 0, 1);
-  ap_wrk=(PyArrayObject *)PyArray_ContiguousFromObject(wrk_py, PyArray_DOUBLE, 0, 1);
-  /*ap_iwrk=(PyArrayObject *)PyArray_ContiguousFromObject(iwrk_py, PyArray_INT, 0, 1);*/
-  if (ap_x == NULL || ap_y == NULL || ap_z == NULL || ap_w == NULL \
-      || ap_wrk == NULL) goto fail;
-  x = (double *) ap_x->data;
-  y = (double *) ap_y->data;
-  z = (double *) ap_z->data;
-  w = (double *) ap_w->data;
-  m = ap_x->dimensions[0];
-  nmax=nxest;
-  if (nmax<nyest) nmax=nyest;
-  lcest=(nxest-kx-1)*(nyest-ky-1);
-  kwrk=m+(nxest-2*kx-1)*(nyest-2*ky-1);
-  lwa = 2*nmax+lcest+lwrk1+lwrk2+kwrk;
-  if ((wa = (double *)malloc(lwa*sizeof(double)))==NULL) {
-    PyErr_NoMemory();
-    goto fail;
-  }
-  tx = wa;
-  ty = tx + nmax;
-  c = ty + nmax;
-  wrk1 = c + lcest;
-  iwrk = (int *)(wrk1 + lwrk1);
-  wrk2 = (double *)(iwrk+kwrk);
-  if (iopt) {
-    ap_tx=(PyArrayObject *)PyArray_ContiguousFromObject(tx_py, PyArray_DOUBLE, 0, 1);
-    ap_ty=(PyArrayObject *)PyArray_ContiguousFromObject(ty_py, PyArray_DOUBLE, 0, 1);
-    if (ap_tx == NULL || ap_ty == NULL) goto fail;
-    nx = nxo = ap_tx->dimensions[0];
-    ny = nyo = ap_ty->dimensions[0];
-    memcpy(tx,ap_tx->data,nx*sizeof(double));
-    memcpy(ty,ap_ty->data,ny*sizeof(double));
-  }
-  if (iopt==1) {
-    lc = (nx-kx-1)*(ny-ky-1);
-    memcpy(wrk1,ap_wrk->data,lc*sizeof(double));
-    /*memcpy(iwrk,ap_iwrk->data,n*sizeof(int));*/
-  }
-  SURFIT(&iopt,&m,x,y,z,w,&xb,&xe,&yb,&ye,&kx,&ky,&s,&nxest,&nyest,&nmax,&eps,&nx,tx,&ny,ty,c,&fp,wrk1,&lwrk1,wrk2,&lwrk2,iwrk,&kwrk,&ier);
-  i=0;
-  while ((ier>10) && (i++<5)) {
-    lwrk2=ier;
-    if ((wrk2 = (double *)malloc(lwrk2*sizeof(double)))==NULL) {
-      PyErr_NoMemory();
-      goto fail;
-    }
-    SURFIT(&iopt,&m,x,y,z,w,&xb,&xe,&yb,&ye,&kx,&ky,&s,&nxest,&nyest,&nmax,&eps,&nx,tx,&ny,ty,c,&fp,wrk1,&lwrk1,wrk2,&lwrk2,iwrk,&kwrk,&ier);
-    if (wrk2) free(wrk2);
-  }
-  if (ier==10) {
-	  PyErr_SetString(PyExc_ValueError, "Invalid inputs.");
-	  goto fail;
-  }
-  lc = (nx-kx-1)*(ny-ky-1);
-  Py_XDECREF(ap_tx);
-  Py_XDECREF(ap_ty);
-  ap_tx = (PyArrayObject *)PyArray_SimpleNew(1,&nx,PyArray_DOUBLE);
-  ap_ty = (PyArrayObject *)PyArray_SimpleNew(1,&ny,PyArray_DOUBLE);
-  ap_c = (PyArrayObject *)PyArray_SimpleNew(1,&lc,PyArray_DOUBLE);
-  if (ap_tx == NULL || ap_ty == NULL || ap_c == NULL) goto fail;
-  if ((iopt==0)||(nx>nxo)||(ny>nyo)) {
+static char doc_surfit[] = " [tx,ty,c,o] = _surfit(x, y, z, w, xb, xe, yb, ye,"\
+      " kx,ky,iopt,s,eps,tx,ty,nxest,nyest,wrk,lwrk1,lwrk2)";
+static PyObject *
+fitpack_surfit(PyObject *dummy, PyObject *args)
+{
+    int iopt, m, kx, ky, nxest, nyest, lwrk1, lwrk2, *iwrk, kwrk, ier;
+    int lwa, nxo, nyo, i, lcest, nmax;
+    npy_intp nx, ny, lc;
+    double *x, *y, *z, *w, xb, xe, yb, ye, s, *tx, *ty, *c, fp;
+    double *wrk1, *wrk2, *wa = NULL, eps;
+    PyArrayObject *ap_x = NULL, *ap_y = NULL, *ap_z, *ap_w = NULL;
+    PyArrayObject *ap_tx = NULL,*ap_ty = NULL,*ap_c = NULL, *ap_wrk = NULL;
+    PyObject *x_py = NULL, *y_py = NULL, *z_py = NULL, *w_py = NULL;
+    PyObject *tx_py = NULL, *ty_py = NULL, *wrk_py = NULL;
+
+    nx = ny = ier = nxo = nyo = 0;
+    if (!PyArg_ParseTuple(args, "OOOOddddiiiddOOiiOii",
+                &x_py, &y_py, &z_py, &w_py, &xb, &xe, &yb, &ye,
+                &kx, &ky, &iopt, &s, &eps, &tx_py, &ty_py, &nxest,
+                &nyest, &wrk_py, &lwrk1, &lwrk2)) {
+        return NULL;
+    }
+    ap_x = (PyArrayObject *)PyArray_ContiguousFromObject(x_py, PyArray_DOUBLE, 0, 1);
+    ap_y = (PyArrayObject *)PyArray_ContiguousFromObject(y_py, PyArray_DOUBLE, 0, 1);
+    ap_z = (PyArrayObject *)PyArray_ContiguousFromObject(z_py, PyArray_DOUBLE, 0, 1);
+    ap_w = (PyArrayObject *)PyArray_ContiguousFromObject(w_py, PyArray_DOUBLE, 0, 1);
+    ap_wrk=(PyArrayObject *)PyArray_ContiguousFromObject(wrk_py, PyArray_DOUBLE, 0, 1);
+    /*ap_iwrk=(PyArrayObject *)PyArray_ContiguousFromObject(iwrk_py, PyArray_INT, 0, 1);*/
+    if (ap_x == NULL
+            || ap_y == NULL
+            || ap_z == NULL
+            || ap_w == NULL
+            || ap_wrk == NULL) {
+        goto fail;
+    }
+    x = (double *) ap_x->data;
+    y = (double *) ap_y->data;
+    z = (double *) ap_z->data;
+    w = (double *) ap_w->data;
+    m = ap_x->dimensions[0];
+    nmax = nxest;
+    if (nmax < nyest) {
+        nmax = nyest;
+    }
+    lcest = (nxest - kx - 1)*(nyest - ky - 1);
+    kwrk = m + (nxest - 2*kx - 1)*(nyest - 2*ky - 1);
+    lwa = 2*nmax + lcest + lwrk1 + lwrk2 + kwrk;
+    if ((wa = (double *)malloc(lwa*sizeof(double))) == NULL) {
+        PyErr_NoMemory();
+        goto fail;
+    }
+    tx = wa;
+    ty = tx + nmax;
+    c = ty + nmax;
+    wrk1 = c + lcest;
+    iwrk = (int *)(wrk1 + lwrk1);
+    wrk2 = (double *)(iwrk + kwrk);
+    if (iopt) {
+        ap_tx = (PyArrayObject *)PyArray_ContiguousFromObject(tx_py, PyArray_DOUBLE, 0, 1);
+        ap_ty = (PyArrayObject *)PyArray_ContiguousFromObject(ty_py, PyArray_DOUBLE, 0, 1);
+        if (ap_tx == NULL || ap_ty == NULL) {
+            goto fail;
+        }
+        nx = nxo = ap_tx->dimensions[0];
+        ny = nyo = ap_ty->dimensions[0];
+        memcpy(tx,ap_tx->data,nx*sizeof(double));
+        memcpy(ty,ap_ty->data,ny*sizeof(double));
+    }
+    if (iopt==1) {
+        lc = (nx - kx - 1)*(ny - ky - 1);
+        memcpy(wrk1, ap_wrk->data, lc*sizeof(double));
+        /*memcpy(iwrk,ap_iwrk->data,n*sizeof(int));*/
+    }
+    SURFIT(&iopt, &m, x, y, z, w, &xb, &xe, &yb, &ye, &kx, &ky,
+            &s, &nxest, &nyest, &nmax, &eps, &nx, tx, &ny, ty,
+            c, &fp, wrk1, &lwrk1, wrk2, &lwrk2, iwrk, &kwrk, &ier);
+    i = 0;
+    while ((ier > 10) && (i++ < 5)) {
+        lwrk2 = ier;
+        if ((wrk2 = (double *)malloc(lwrk2*sizeof(double))) == NULL) {
+            PyErr_NoMemory();
+            goto fail;
+        }
+        SURFIT(&iopt, &m, x, y, z, w, &xb, &xe, &yb, &ye, &kx, &ky,
+                &s, &nxest, &nyest, &nmax, &eps, &nx, tx, &ny, ty,
+                c, &fp, wrk1, &lwrk1, wrk2, &lwrk2, iwrk, &kwrk, &ier);
+        if (wrk2) {
+            free(wrk2);
+        }
+    }
+    if (ier == 10) {
+        PyErr_SetString(PyExc_ValueError, "Invalid inputs.");
+        goto fail;
+    }
+    lc = (nx - kx - 1)*(ny - ky - 1);
+    Py_XDECREF(ap_tx);
+    Py_XDECREF(ap_ty);
+    ap_tx = (PyArrayObject *)PyArray_SimpleNew(1, &nx, PyArray_DOUBLE);
+    ap_ty = (PyArrayObject *)PyArray_SimpleNew(1, &ny, PyArray_DOUBLE);
+    ap_c = (PyArrayObject *)PyArray_SimpleNew(1, &lc, PyArray_DOUBLE);
+    if (ap_tx == NULL
+            || ap_ty == NULL
+            || ap_c == NULL) {
+        goto fail;
+    }
+    if ((iopt == 0)||(nx > nxo)||(ny > nyo)) {
+        Py_XDECREF(ap_wrk);
+        ap_wrk = (PyArrayObject *)PyArray_SimpleNew(1, &lc, PyArray_DOUBLE);
+        if (ap_wrk == NULL) {
+            goto fail;
+        }
+        /*ap_iwrk = (PyArrayObject *)PyArray_SimpleNew(1,&n,PyArray_INT);*/
+    }
+    if (ap_wrk->dimensions[0] < lc) {
+        Py_XDECREF(ap_wrk);
+        ap_wrk = (PyArrayObject *)PyArray_SimpleNew(1, &lc, PyArray_DOUBLE);
+        if (ap_wrk == NULL) {
+            goto fail;
+        }
+    }
+    memcpy(ap_tx->data, tx, nx*sizeof(double));
+    memcpy(ap_ty->data, ty, ny*sizeof(double));
+    memcpy(ap_c->data, c, lc*sizeof(double));
+    memcpy(ap_wrk->data, wrk1, lc*sizeof(double));
+    /*memcpy(ap_iwrk->data,iwrk,n*sizeof(int));*/
+    if (wa) {
+        free(wa);
+    }
+    Py_DECREF(ap_x);
+    Py_DECREF(ap_y);
+    Py_DECREF(ap_z);
+    Py_DECREF(ap_w);
+    return Py_BuildValue("NNN{s:N,s:i,s:d}",PyArray_Return(ap_tx),
+            PyArray_Return(ap_ty),PyArray_Return(ap_c),
+            "wrk",PyArray_Return(ap_wrk),
+            "ier",ier,"fp",fp);
+
+fail:
+    if (wa) {
+        free(wa);
+    }
+    Py_XDECREF(ap_x);
+    Py_XDECREF(ap_y);
+    Py_XDECREF(ap_z);
+    Py_XDECREF(ap_w);
+    Py_XDECREF(ap_tx);
+    Py_XDECREF(ap_ty);
     Py_XDECREF(ap_wrk);
-    ap_wrk = (PyArrayObject *)PyArray_SimpleNew(1,&lc,PyArray_DOUBLE);
-    if (ap_wrk == NULL) goto fail;
-    /*ap_iwrk = (PyArrayObject *)PyArray_SimpleNew(1,&n,PyArray_INT);*/
-  }
-  if(ap_wrk->dimensions[0]<lc) {
-    Py_XDECREF(ap_wrk);
-    ap_wrk = (PyArrayObject *)PyArray_SimpleNew(1,&lc,PyArray_DOUBLE);
-    if (ap_wrk == NULL) goto fail;
-  }
-  memcpy(ap_tx->data,tx,nx*sizeof(double));
-  memcpy(ap_ty->data,ty,ny*sizeof(double));
-  memcpy(ap_c->data,c,lc*sizeof(double));
-  memcpy(ap_wrk->data,wrk1,lc*sizeof(double));
-  /*memcpy(ap_iwrk->data,iwrk,n*sizeof(int));*/
-  if (wa) free(wa);
-  Py_DECREF(ap_x);
-  Py_DECREF(ap_y);
-  Py_DECREF(ap_z);
-  Py_DECREF(ap_w);
-  return Py_BuildValue("NNN{s:N,s:i,s:d}",PyArray_Return(ap_tx),\
-		       PyArray_Return(ap_ty),PyArray_Return(ap_c),\
-		       "wrk",PyArray_Return(ap_wrk),\
-		       "ier",ier,"fp",fp);
-  fail:
-  if (wa) free(wa);
-  Py_XDECREF(ap_x);
-  Py_XDECREF(ap_y);
-  Py_XDECREF(ap_z);
-  Py_XDECREF(ap_w);
-  Py_XDECREF(ap_tx);
-  Py_XDECREF(ap_ty);
-  Py_XDECREF(ap_wrk);
-  /*Py_XDECREF(ap_iwrk);*/
-  if (!PyErr_Occurred()) {
-	  PyErr_SetString(PyExc_ValueError, "An error occurred.");
-  }
-  return NULL;
+    /*Py_XDECREF(ap_iwrk);*/
+    if (!PyErr_Occurred()) {
+        PyErr_SetString(PyExc_ValueError,
+                "An error occurred.");
+    }
+    return NULL;
 }

 static char doc_parcur[] = " [t,c,o] = _parcur(x,w,u,ub,ue,k,iopt,ipar,s,t,nest,wrk,iwrk,per)";
-static PyObject *fitpack_parcur(PyObject *dummy, PyObject *args) {
-  int k,iopt,ipar,nest,*iwrk,idim,m,mx,no=0,nc,ier,lwa,lwrk,i,per;
-  npy_intp n=0, lc;
-  double *x,*w,*u,*c,*t,*wrk,*wa=NULL,ub,ue,fp,s;
-  PyObject *x_py = NULL,*u_py = NULL,*w_py = NULL,*t_py = NULL;
-  PyObject *wrk_py=NULL,*iwrk_py=NULL;
-  PyArrayObject *ap_x = NULL,*ap_u = NULL,*ap_w = NULL,*ap_t = NULL,*ap_c = NULL;
-  PyArrayObject *ap_wrk = NULL,*ap_iwrk = NULL;
-  if (!PyArg_ParseTuple(args, "OOOddiiidOiOOi",&x_py,&w_py,&u_py,&ub,&ue,\
-			&k,&iopt,&ipar,&s,&t_py,&nest,&wrk_py,&iwrk_py,&per)) return NULL;
-  ap_x = (PyArrayObject *)PyArray_ContiguousFromObject(x_py, PyArray_DOUBLE, 0, 1);
-  ap_u = (PyArrayObject *)PyArray_ContiguousFromObject(u_py, PyArray_DOUBLE, 0, 1);
-  ap_w = (PyArrayObject *)PyArray_ContiguousFromObject(w_py, PyArray_DOUBLE, 0, 1);
-  ap_wrk=(PyArrayObject *)PyArray_ContiguousFromObject(wrk_py, PyArray_DOUBLE, 0, 1);
-  ap_iwrk=(PyArrayObject *)PyArray_ContiguousFromObject(iwrk_py, PyArray_INT, 0, 1);
-  if (ap_x == NULL || ap_u == NULL || ap_w == NULL || ap_wrk == NULL || ap_iwrk == NULL) goto fail;
-  x = (double *) ap_x->data;
-  u = (double *) ap_u->data;
-  w = (double *) ap_w->data;
-  m = ap_w->dimensions[0];
-  mx = ap_x->dimensions[0];
-  idim = mx/m;
-  if (per)
-    lwrk=m*(k+1)+nest*(7+idim+5*k);
-  else
-    lwrk=m*(k+1)+nest*(6+idim+3*k);
-  nc=idim*nest;
-  lwa = nc+2*nest+lwrk;
-  if ((wa = (double *)malloc(lwa*sizeof(double)))==NULL) {
-    PyErr_NoMemory();
-    goto fail;
-  }
-  t = wa;
-  c = t + nest;
-  wrk = c + nc;
-  iwrk = (int *)(wrk + lwrk);
-  if (iopt) {
-    ap_t=(PyArrayObject *)PyArray_ContiguousFromObject(t_py, PyArray_DOUBLE, 0, 1);
-    if (ap_t == NULL) goto fail;
-    n = no = ap_t->dimensions[0];
-    memcpy(t,ap_t->data,n*sizeof(double));
-  }
-  if (iopt==1) {
-    memcpy(wrk,ap_wrk->data,n*sizeof(double));
-    memcpy(iwrk,ap_iwrk->data,n*sizeof(int));
-  }
-  if (per)
-    CLOCUR(&iopt,&ipar,&idim,&m,u,&mx,x,w,&k,&s,&nest,&n,t,&nc,\
-	   c,&fp,wrk,&lwrk,iwrk,&ier);
-  else
-    PARCUR(&iopt,&ipar,&idim,&m,u,&mx,x,w,&ub,&ue,&k,&s,&nest,&n,t,&nc,\
-	   c,&fp,wrk,&lwrk,iwrk,&ier);
-  if (ier==10) goto fail;
-  if (ier>0 && n==0) n=1;
-  lc = (n-k-1)*idim;
-  ap_t = (PyArrayObject *)PyArray_SimpleNew(1,&n,PyArray_DOUBLE);
-  ap_c = (PyArrayObject *)PyArray_SimpleNew(1,&lc,PyArray_DOUBLE);
-  if (ap_t == NULL || ap_c == NULL) goto fail;
-  if ((iopt==0)||(n>no)) {
-    ap_wrk = (PyArrayObject *)PyArray_SimpleNew(1,&n,PyArray_DOUBLE);
-    ap_iwrk = (PyArrayObject *)PyArray_SimpleNew(1,&n,PyArray_INT);
-    if (ap_wrk == NULL || ap_iwrk == NULL) goto fail;
-  }
-  memcpy(ap_t->data,t,n*sizeof(double));
-  for (i=0;i<idim;i++)
-    memcpy((double *) ap_c->data+i*(n-k-1),c+i*n,(n-k-1)*sizeof(double));
-  memcpy(ap_wrk->data,wrk,n*sizeof(double));
-  memcpy(ap_iwrk->data,iwrk,n*sizeof(int));
-  if (wa) free(wa);
-  Py_DECREF(ap_x);
-  Py_DECREF(ap_w);
-  return Py_BuildValue("NN{s:N,s:d,s:d,s:N,s:N,s:i,s:d}",PyArray_Return(ap_t),PyArray_Return(ap_c),"u",PyArray_Return(ap_u),"ub",ub,"ue",ue,"wrk",PyArray_Return(ap_wrk),"iwrk",PyArray_Return(ap_iwrk),"ier",ier,"fp",fp);
-  fail:
-  if (wa) free(wa);
-  Py_XDECREF(ap_x);
-  Py_XDECREF(ap_u);
-  Py_XDECREF(ap_w);
-  Py_XDECREF(ap_t);
-  Py_XDECREF(ap_wrk);
-  Py_XDECREF(ap_iwrk);
-  return NULL;
-}
-
-static char doc_curfit[] = " [t,c,o] = _curfit(x,y,w,xb,xe,k,iopt,s,t,nest,wrk,iwrk,per)";
-static PyObject *fitpack_curfit(PyObject *dummy, PyObject *args) {
-  int iopt,m,k,nest,lwrk,*iwrk,ier,lwa,no=0,per;
-  npy_intp n, lc;
-  double *x,*y,*w,xb,xe,s,*t,*c,fp,*wrk,*wa = NULL;
-  PyArrayObject *ap_x = NULL,*ap_y = NULL,*ap_w = NULL,*ap_t = NULL,*ap_c = NULL;
-  PyArrayObject *ap_wrk = NULL,*ap_iwrk = NULL;
-  PyObject *x_py = NULL,*y_py = NULL,*w_py = NULL,*t_py = NULL;
-  PyObject *wrk_py=NULL,*iwrk_py=NULL;
-  if (!PyArg_ParseTuple(args, "OOOddiidOiOOi",&x_py,&y_py,&w_py,&xb,&xe,\
-			&k,&iopt,&s,&t_py,&nest,&wrk_py,&iwrk_py,&per)) return NULL;
-  ap_x = (PyArrayObject *)PyArray_ContiguousFromObject(x_py, PyArray_DOUBLE, 0, 1);
-  ap_y = (PyArrayObject *)PyArray_ContiguousFromObject(y_py, PyArray_DOUBLE, 0, 1);
-  ap_w = (PyArrayObject *)PyArray_ContiguousFromObject(w_py, PyArray_DOUBLE, 0, 1);
-  ap_wrk=(PyArrayObject *)PyArray_ContiguousFromObject(wrk_py, PyArray_DOUBLE, 0, 1);
-  ap_iwrk=(PyArrayObject *)PyArray_ContiguousFromObject(iwrk_py, PyArray_INT, 0, 1);
-  if (ap_x == NULL || ap_y == NULL || ap_w == NULL || ap_wrk == NULL || ap_iwrk == NULL) goto fail;
-  x = (double *) ap_x->data;
-  y = (double *) ap_y->data;
-  w = (double *) ap_w->data;
-  m = ap_x->dimensions[0];
-  if (per) lwrk = m*(k+1) + nest*(8+5*k);
-  else lwrk = m*(k+1) + nest*(7+3*k);
-  lwa = 3*nest+lwrk;
-  if ((wa = (double *)malloc(lwa*sizeof(double)))==NULL) {
-    PyErr_NoMemory();
-    goto fail;
-  }
-  t = wa;
-  c = t + nest;
-  wrk = c + nest;
-  iwrk = (int *)(wrk + lwrk);
-  if (iopt) {
-    ap_t=(PyArrayObject *)PyArray_ContiguousFromObject(t_py, PyArray_DOUBLE, 0, 1);
-    if (ap_t == NULL) goto fail;
-    n = no = ap_t->dimensions[0];
-    memcpy(t,ap_t->data,n*sizeof(double));
-  }
-  if (iopt==1) {
-    memcpy(wrk,ap_wrk->data,n*sizeof(double));
-    memcpy(iwrk,ap_iwrk->data,n*sizeof(int));
-  }
-  if (per)
-    PERCUR(&iopt,&m,x,y,w,&k,&s,&nest,&n,t,c,&fp,wrk,&lwrk,iwrk,&ier);
-  else
-    CURFIT(&iopt,&m,x,y,w,&xb,&xe,&k,&s,&nest,&n,t,c,&fp,wrk,&lwrk,iwrk,&ier);
-  if (ier==10) {
-	  PyErr_SetString(PyExc_ValueError, "Invalid inputs.");
-	  goto fail;
-  }
-  lc = n-k-1;
-  if (!iopt) {
-	  ap_t = (PyArrayObject *)PyArray_SimpleNew(1,&n,PyArray_DOUBLE);
-	  if (ap_t == NULL) goto fail;
-  }
-  ap_c = (PyArrayObject *)PyArray_SimpleNew(1,&lc,PyArray_DOUBLE);
-  if (ap_c == NULL) goto fail;
-  if ((iopt==0)||(n>no)) {
+static PyObject *
+fitpack_parcur(PyObject *dummy, PyObject *args)
+{
+    int k, iopt, ipar, nest, *iwrk, idim, m, mx, no=0, nc, ier, lwa, lwrk, i, per;
+    npy_intp n=0,  lc;
+    double *x, *w, *u, *c, *t, *wrk, *wa=NULL, ub, ue, fp, s;
+    PyObject *x_py = NULL, *u_py = NULL, *w_py = NULL, *t_py = NULL;
+    PyObject *wrk_py=NULL, *iwrk_py=NULL;
+    PyArrayObject *ap_x = NULL, *ap_u = NULL, *ap_w = NULL, *ap_t = NULL, *ap_c = NULL;
+    PyArrayObject *ap_wrk = NULL, *ap_iwrk = NULL;
+
+    if (!PyArg_ParseTuple(args,  "OOOddiiidOiOOi", &x_py, &w_py, &u_py, &ub, &ue,
+                &k, &iopt, &ipar, &s, &t_py, &nest, &wrk_py, &iwrk_py, &per)) {
+        return NULL;
+    }
+    ap_x = (PyArrayObject *)PyArray_ContiguousFromObject(x_py, PyArray_DOUBLE, 0, 1);
+    ap_u = (PyArrayObject *)PyArray_ContiguousFromObject(u_py, PyArray_DOUBLE, 0, 1);
+    ap_w = (PyArrayObject *)PyArray_ContiguousFromObject(w_py, PyArray_DOUBLE, 0, 1);
+    ap_wrk=(PyArrayObject *)PyArray_ContiguousFromObject(wrk_py, PyArray_DOUBLE, 0, 1);
+    ap_iwrk=(PyArrayObject *)PyArray_ContiguousFromObject(iwrk_py, PyArray_INT, 0, 1);
+    if (ap_x == NULL
+            || ap_u == NULL
+            || ap_w == NULL
+            || ap_wrk == NULL
+            || ap_iwrk == NULL) {
+        goto fail;
+    }
+    x = (double *) ap_x->data;
+    u = (double *) ap_u->data;
+    w = (double *) ap_w->data;
+    m = ap_w->dimensions[0];
+    mx = ap_x->dimensions[0];
+    idim = mx/m;
+    if (per) {
+        lwrk = m*(k + 1) + nest*(7 + idim + 5*k);
+    }
+    else {
+        lwrk = m*(k + 1) + nest*(6 + idim + 3*k);
+    }
+    nc = idim*nest;
+    lwa = nc + 2*nest + lwrk;
+    if ((wa = (double *)malloc(lwa*sizeof(double))) == NULL) {
+        PyErr_NoMemory();
+        goto fail;
+    }
+    t = wa;
+    c = t + nest;
+    wrk = c + nc;
+    iwrk = (int *)(wrk + lwrk);
+    if (iopt) {
+        ap_t=(PyArrayObject *)PyArray_ContiguousFromObject(t_py, PyArray_DOUBLE, 0, 1);
+        if (ap_t == NULL) {
+            goto fail;
+        }
+        n = no = ap_t->dimensions[0];
+        memcpy(t, ap_t->data, n*sizeof(double));
+    }
+    if (iopt == 1) {
+        memcpy(wrk, ap_wrk->data, n*sizeof(double));
+        memcpy(iwrk, ap_iwrk->data, n*sizeof(int));
+    }
+    if (per) {
+        CLOCUR(&iopt, &ipar, &idim, &m, u, &mx, x, w, &k, &s, &nest,
+                &n, t, &nc, c, &fp, wrk, &lwrk, iwrk, &ier);
+    }
+    else {
+        PARCUR(&iopt, &ipar, &idim, &m, u, &mx, x, w, &ub, &ue, &k,
+                &s, &nest, &n, t, &nc, c, &fp, wrk, &lwrk, iwrk, &ier);
+    }
+    if (ier == 10) {
+        goto fail;
+    }
+    if (ier > 0 && n == 0) {
+        n = 1;
+    }
+    lc = (n - k - 1)*idim;
+    ap_t = (PyArrayObject *)PyArray_SimpleNew(1, &n, PyArray_DOUBLE);
+    ap_c = (PyArrayObject *)PyArray_SimpleNew(1, &lc, PyArray_DOUBLE);
+    if (ap_t == NULL || ap_c == NULL) {
+        goto fail;
+    }
+    if (iopt == 0|| n > no) {
+        ap_wrk = (PyArrayObject *)PyArray_SimpleNew(1, &n, PyArray_DOUBLE);
+        ap_iwrk = (PyArrayObject *)PyArray_SimpleNew(1, &n, PyArray_INT);
+        if (ap_wrk == NULL || ap_iwrk == NULL) {
+            goto fail;
+        }
+    }
+    memcpy(ap_t->data, t, n*sizeof(double));
+    for (i = 0; i < idim; i++)
+        memcpy((double *)ap_c->data + i*(n - k - 1), c + i*n, (n - k - 1)*sizeof(double));
+    memcpy(ap_wrk->data, wrk, n*sizeof(double));
+    memcpy(ap_iwrk->data, iwrk, n*sizeof(int));
+    if (wa) {
+        free(wa);
+    }
+    Py_DECREF(ap_x);
+    Py_DECREF(ap_w);
+    return Py_BuildValue("NN{s:N,s:d,s:d,s:N,s:N,s:i,s:d}", PyArray_Return(ap_t),
+            PyArray_Return(ap_c), "u", PyArray_Return(ap_u), "ub", ub, "ue", ue,
+            "wrk", PyArray_Return(ap_wrk), "iwrk", PyArray_Return(ap_iwrk),
+            "ier", ier, "fp",fp);
+fail:
+    if (wa) {
+        free(wa);
+    }
+    Py_XDECREF(ap_x);
+    Py_XDECREF(ap_u);
+    Py_XDECREF(ap_w);
+    Py_XDECREF(ap_t);
     Py_XDECREF(ap_wrk);
     Py_XDECREF(ap_iwrk);
-    ap_wrk = (PyArrayObject *)PyArray_SimpleNew(1,&n,PyArray_DOUBLE);
-    ap_iwrk = (PyArrayObject *)PyArray_SimpleNew(1,&n,PyArray_INT);
-    if (ap_wrk == NULL || ap_iwrk == NULL) goto fail;
-  }
-  memcpy(ap_t->data,t,n*sizeof(double));
-  memcpy(ap_c->data,c,lc*sizeof(double));
-  memcpy(ap_wrk->data,wrk,n*sizeof(double));
-  memcpy(ap_iwrk->data,iwrk,n*sizeof(int));
-  if (wa) free(wa);
-  Py_DECREF(ap_x);
-  Py_DECREF(ap_y);
-  Py_DECREF(ap_w);
-  return Py_BuildValue("NN{s:N,s:N,s:i,s:d}",PyArray_Return(ap_t),PyArray_Return(ap_c),"wrk",PyArray_Return(ap_wrk),"iwrk",PyArray_Return(ap_iwrk),"ier",ier,"fp",fp);
-  fail:
-  if (wa) free(wa);
-  Py_XDECREF(ap_x);
-  Py_XDECREF(ap_y);
-  Py_XDECREF(ap_w);
-  Py_XDECREF(ap_t);
-  Py_XDECREF(ap_wrk);
-  Py_XDECREF(ap_iwrk);
-  return NULL;
+    return NULL;
 }

+static char doc_curfit[] = " [t,c,o] = _curfit(x,y,w,xb,xe,k,iopt,s,t,nest,wrk,iwrk,per)";
+static PyObject *
+fitpack_curfit(PyObject *dummy, PyObject *args)
+{
+    int iopt, m, k, nest, lwrk, *iwrk, ier, lwa, no=0, per;
+    npy_intp n, lc;
+    double *x, *y, *w, xb, xe, s, *t, *c, fp, *wrk, *wa = NULL;
+    PyArrayObject *ap_x = NULL, *ap_y = NULL, *ap_w = NULL, *ap_t = NULL, *ap_c = NULL;
+    PyArrayObject *ap_wrk = NULL, *ap_iwrk = NULL;
+    PyObject *x_py = NULL, *y_py = NULL, *w_py = NULL, *t_py = NULL;
+    PyObject *wrk_py=NULL, *iwrk_py=NULL;
+
+    if (!PyArg_ParseTuple(args, "OOOddiidOiOOi", &x_py, &y_py, &w_py, &xb, &xe,
+                &k, &iopt, &s, &t_py, &nest, &wrk_py, &iwrk_py, &per)) {
+        return NULL;
+    }
+    ap_x = (PyArrayObject *)PyArray_ContiguousFromObject(x_py, PyArray_DOUBLE, 0, 1);
+    ap_y = (PyArrayObject *)PyArray_ContiguousFromObject(y_py, PyArray_DOUBLE, 0, 1);
+    ap_w = (PyArrayObject *)PyArray_ContiguousFromObject(w_py, PyArray_DOUBLE, 0, 1);
+    ap_wrk = (PyArrayObject *)PyArray_ContiguousFromObject(wrk_py, PyArray_DOUBLE, 0, 1);
+    ap_iwrk = (PyArrayObject *)PyArray_ContiguousFromObject(iwrk_py, PyArray_INT, 0, 1);
+    if (ap_x == NULL
+            || ap_y == NULL
+            || ap_w == NULL
+            || ap_wrk == NULL
+            || ap_iwrk == NULL) {
+        goto fail;
+    }
+    x = (double *) ap_x->data;
+    y = (double *) ap_y->data;
+    w = (double *) ap_w->data;
+    m = ap_x->dimensions[0];
+    if (per) {
+        lwrk = m*(k + 1) + nest*(8 + 5*k);
+    }
+    else {
+        lwrk = m*(k + 1) + nest*(7 + 3*k);
+    }
+    lwa = 3*nest + lwrk;
+    if ((wa = (double *)malloc(lwa*sizeof(double))) == NULL) {
+        PyErr_NoMemory();
+        goto fail;
+    }
+    t = wa;
+    c = t + nest;
+    wrk = c + nest;
+    iwrk = (int *)(wrk + lwrk);
+    if (iopt) {
+        ap_t = (PyArrayObject *)PyArray_ContiguousFromObject(t_py, PyArray_DOUBLE, 0, 1);
+        if (ap_t == NULL) {
+            goto fail;
+        }
+        n = no = ap_t->dimensions[0];
+        memcpy(t, ap_t->data, n*sizeof(double));
+    }
+    if (iopt == 1) {
+        memcpy(wrk, ap_wrk->data, n*sizeof(double));
+        memcpy(iwrk, ap_iwrk->data, n*sizeof(int));
+    }
+    if (per)
+        PERCUR(&iopt, &m, x, y, w, &k, &s, &nest, &n, t, c, &fp, wrk,
+                &lwrk, iwrk, &ier);
+    else {
+        CURFIT(&iopt, &m, x, y, w, &xb, &xe, &k, &s, &nest, &n, t, c,
+                &fp, wrk, &lwrk, iwrk, &ier);
+    }
+    if (ier == 10) {
+        PyErr_SetString(PyExc_ValueError, "Invalid inputs.");
+        goto fail;
+    }
+    lc = n - k - 1;
+    if (!iopt) {
+        ap_t = (PyArrayObject *)PyArray_SimpleNew(1, &n, PyArray_DOUBLE);
+        if (ap_t == NULL) {
+            goto fail;
+        }
+    }
+    ap_c = (PyArrayObject *)PyArray_SimpleNew(1, &lc, PyArray_DOUBLE);
+    if (ap_c == NULL) {
+        goto fail;
+    }
+    if (iopt == 0 || n > no) {
+        Py_XDECREF(ap_wrk);
+        Py_XDECREF(ap_iwrk);
+        ap_wrk = (PyArrayObject *)PyArray_SimpleNew(1, &n, PyArray_DOUBLE);
+        ap_iwrk = (PyArrayObject *)PyArray_SimpleNew(1, &n, PyArray_INT);
+        if (ap_wrk == NULL || ap_iwrk == NULL) {
+            goto fail;
+        }
+    }
+    memcpy(ap_t->data, t, n*sizeof(double));
+    memcpy(ap_c->data, c, lc*sizeof(double));
+    memcpy(ap_wrk->data, wrk, n*sizeof(double));
+    memcpy(ap_iwrk->data, iwrk, n*sizeof(int));
+    if (wa) {
+        free(wa);
+    }
+    Py_DECREF(ap_x);
+    Py_DECREF(ap_y);
+    Py_DECREF(ap_w);
+    return Py_BuildValue("NN{s:N,s:N,s:i,s:d}", PyArray_Return(ap_t),
+            PyArray_Return(ap_c), "wrk", PyArray_Return(ap_wrk),
+            "iwrk", PyArray_Return(ap_iwrk), "ier", ier, "fp", fp);
+
+fail:
+    if (wa) {
+        free(wa);
+    }
+    Py_XDECREF(ap_x);
+    Py_XDECREF(ap_y);
+    Py_XDECREF(ap_w);
+    Py_XDECREF(ap_t);
+    Py_XDECREF(ap_wrk);
+    Py_XDECREF(ap_iwrk);
+    return NULL;
+}
+
 static char doc_spl_[] = " [y,ier] = _spl_(x,nu,t,c,k,e)";
-static PyObject *fitpack_spl_(PyObject *dummy, PyObject *args)
+static PyObject *
+fitpack_spl_(PyObject *dummy, PyObject *args)
 {
     int n, nu, ier, k, e=0;
     npy_intp m;
@@ -503,7 +642,8 @@
 }

 static char doc_splint[] = " [aint,wrk] = _splint(t,c,k,a,b)";
-static PyObject *fitpack_splint(PyObject *dummy, PyObject *args)
+static PyObject *
+fitpack_splint(PyObject *dummy, PyObject *args)
 {
     int k;
     npy_intp n;
@@ -540,7 +680,8 @@
 }

 static char doc_sproot[] = " [z,ier] = _sproot(t,c,k,mest)";
-static PyObject *fitpack_sproot(PyObject *dummy, PyObject *args)
+static PyObject *
+fitpack_sproot(PyObject *dummy, PyObject *args)
 {
     int n, k, mest, ier;
     npy_intp m;
@@ -590,7 +731,8 @@
 }

 static char doc_spalde[] = " [d,ier] = _spalde(t,c,k,x)";
-static PyObject *fitpack_spalde(PyObject *dummy, PyObject *args)
+static PyObject *
+fitpack_spalde(PyObject *dummy, PyObject *args)
 {
     int n, k, ier;
     npy_intp k1;
@@ -627,7 +769,8 @@
 }

 static char doc_insert[] = " [tt,cc,ier] = _insert(iopt,t,c,k,x,m)";
-static PyObject *fitpack_insert(PyObject *dummy, PyObject*args)
+static PyObject *
+fitpack_insert(PyObject *dummy, PyObject*args)
 {
     int iopt, n, nn, k, ier, m;
     npy_intp nest;
@@ -738,130 +881,151 @@
 }

-/* Given a set of (N+1) samples:  A default set of knots is constructed
-   using the samples xk plus 2*(K-1) additional knots where
-   K = max(order,1) and the knots are chosen so that distances
-   are symmetric around the first and last samples: x_0 and x_N.
-
-   There should be a vector of N+K coefficients for the spline
-   curve in coef.  These coefficients form the curve as
-
-   s(x) = sum(c_j B_{j,K}(x), j=-K..N-1)
-
-   The spline function is evaluated at all points xx.
-   The approximation interval is from xk[0] to xk[-1]
-   Any xx outside that interval is set automatically to 0.0
+/*
+ * Given a set of (N+1) samples:  A default set of knots is constructed
+ * using the samples xk plus 2*(K-1) additional knots where
+ * K = max(order,1) and the knots are chosen so that distances
+ * are symmetric around the first and last samples: x_0 and x_N.
+ *
+ * There should be a vector of N+K coefficients for the spline
+ * curve in coef.  These coefficients form the curve as
+ *
+ * s(x) = sum(c_j B_{j,K}(x), j=-K..N-1)
+ *
+ * The spline function is evaluated at all points xx.
+ * The approximation interval is from xk[0] to xk[-1]
+ * Any xx outside that interval is set automatically to 0.0
  */
-
-
 static char doc_bspleval[] = "y = _bspleval(xx,xk,coef,k,{deriv (0)})\n"
-    "\n"
-    "The spline is defined by the approximation interval xk[0] to xk[-1],\n"
-    "the length of xk (N+1), the order of the spline, k, and \n"
-    "the number of coeficients N+k.  The coefficients range from xk_{-K}\n"
-    "to xk_{N-1} inclusive and are all the coefficients needed to define\n"
-    "an arbitrary spline of order k, on the given approximation interval\n"
-    "\n"
-    "Extra knot points are internally added using knot-point symmetry \n"
-    "around xk[0] and xk[-1]";
-
-static PyObject *_bspleval(PyObject *dummy, PyObject *args) {
-    int k,kk,N,i,ell,dk,deriv=0;
-    PyObject *xx_py=NULL, *coef_py=NULL, *x_i_py=NULL;
-    PyArrayObject *xx=NULL, *coef=NULL, *x_i=NULL, *yy=NULL;
+"\n"
+"The spline is defined by the approximation interval xk[0] to xk[-1],\n"
+"the length of xk (N+1), the order of the spline, k, and \n"
+"the number of coeficients N+k.  The coefficients range from xk_{-K}\n"
+"to xk_{N-1} inclusive and are all the coefficients needed to define\n"
+"an arbitrary spline of order k, on the given approximation interval\n"
+"\n"
+"Extra knot points are internally added using knot-point symmetry \n"
+"around xk[0] and xk[-1]";
+
+static PyObject *
+_bspleval(PyObject *dummy, PyObject *args)
+{
+    int k, kk, N, i, ell, dk, deriv = 0;
+    PyObject *xx_py = NULL, *coef_py = NULL, *x_i_py = NULL;
+    PyArrayObject *xx = NULL, *coef = NULL, *x_i = NULL, *yy = NULL;
     PyArrayIterObject *xx_iter;
-    double *t=NULL, *h=NULL, *ptr;
+    double *t = NULL, *h = NULL, *ptr;
     double x0, xN, xN1, arg, sp, cval;
-    if (!PyArg_ParseTuple(args, "OOOi|i", &xx_py, &x_i_py, &coef_py, &k, &deriv))
-        return NULL;
+
+    if (!PyArg_ParseTuple(args, "OOOi|i", &xx_py, &x_i_py, &coef_py, &k, &deriv)) {
+        return NULL;
+    }
     if (k < 0) {
-        PyErr_Format(PyExc_ValueError, "order (%d) must be >=0", k);
+        PyErr_Format(PyExc_ValueError,
+                "order (%d) must be >=0", k);
         return NULL;
     }
     if (deriv > k) {
-        PyErr_Format(PyExc_ValueError, "derivative (%d) must be <= order (%d)",
-                     deriv, k);
+        PyErr_Format(PyExc_ValueError,
+                "derivative (%d) must be <= order (%d)", deriv, k);
         return NULL;
     }
     kk = k;
-    if (k==0) kk = 1;
+    if (k == 0) {
+        kk = 1;
+    }
     dk = (k == 0 ? 0 : 1);
     x_i = (PyArrayObject *)PyArray_FROMANY(x_i_py, NPY_DOUBLE, 1, 1, NPY_ALIGNED);
     coef = (PyArrayObject *)PyArray_FROMANY(coef_py, NPY_DOUBLE, 1, 1, NPY_ALIGNED);
     xx = (PyArrayObject *)PyArray_FROMANY(xx_py, NPY_DOUBLE, 0, 0, NPY_ALIGNED);
-    if (x_i == NULL || coef == NULL || xx == NULL) goto fail;
-
-    N = PyArray_DIM(x_i,0)-1;
-
-    if (PyArray_DIM(coef,0) < (N+k)) {
-        PyErr_Format(PyExc_ValueError, "too few coefficients (have %d need at least %d)",
-                     PyArray_DIM(coef,0), N+k);
+    if (x_i == NULL || coef == NULL || xx == NULL) {
+        goto fail;
+    }
+
+    N = PyArray_DIM(x_i, 0) - 1;
+    if (PyArray_DIM(coef, 0) < N + k) {
+        PyErr_Format(PyExc_ValueError,
+                "too few coefficients (have %d need at least %d)",
+                PyArray_DIM(coef, 0), N + k);
         goto fail;
     }

     /* create output values */
     yy = (PyArrayObject *)PyArray_EMPTY(xx->nd, xx->dimensions, NPY_DOUBLE, 0);
-    if (yy == NULL) goto fail;
-    /* create dummy knot array with new knots inserted at the end
-       selected as mirror symmetric versions of the old knots
+    if (yy == NULL) {
+        goto fail;
+    }
+    /*
+     * create dummy knot array with new knots inserted at the end
+     * selected as mirror symmetric versions of the old knots
      */
-    t = (double *)malloc(sizeof(double)*(N+2*kk-1));
-    if (t==NULL) {
+    t = (double *)malloc(sizeof(double)*(N + 2*kk - 1));
+    if (t == NULL) {
         PyErr_NoMemory();
         goto fail;
     }
     x0 = *((double *)PyArray_DATA(x_i));
     xN = *((double *)PyArray_DATA(x_i) + N);
-    for (i=0; i<kk-1; i++) { /* fill in ends if kk > 1*/
-        t[i] = 2*x0 - *((double *)(PyArray_GETPTR1(x_i,kk-1-i)));
-        t[kk+N+i] = 2*xN - *((double *)(PyArray_GETPTR1(x_i,N-1-i)));
-    }
-    ptr = t + (kk-1);
-    for (i=0; i<=N; i++) {
+    for (i = 0; i < kk - 1; i++) { /* fill in ends if kk > 1*/
+        t[i] = 2*x0 - *((double *)(PyArray_GETPTR1(x_i, kk - 1 - i)));
+        t[kk+N+i] = 2*xN - *((double *)(PyArray_GETPTR1(x_i, N - 1 - i)));
+    }
+    ptr = t + (kk - 1);
+    for (i = 0; i <= N; i++) {
         *ptr++ = *((double *)(PyArray_GETPTR1(x_i, i)));
     }

-    /* Create work array to hold computed non-zero values for
-       the spline for a value of x.
-    */
+    /*
+     * Create work array to hold computed non-zero values for
+     * the spline for a value of x.
+     */
     h = (double *)malloc(sizeof(double)*(2*kk+1));
-    if (h==NULL) {
+    if (h == NULL) {
         PyErr_NoMemory();
         goto fail;
     }

     /* Determine the spline for each value of x */
     xx_iter = (PyArrayIterObject *)PyArray_IterNew((PyObject *)xx);
-    if (xx_iter == NULL) goto fail;
+    if (xx_iter == NULL) {
+        goto fail;
+    }
     ptr = PyArray_DATA(yy);

     while(PyArray_ITER_NOTDONE(xx_iter)) {
         arg = *((double *)PyArray_ITER_DATA(xx_iter));
         if ((arg < x0) || (arg > xN)) {
-            /* If we are outside the interpolation region,
-               fill with zeros
-            */
+            /*
+             * If we are outside the interpolation region,
+             * fill with zeros
+             */
             *ptr++ = 0.0;
         }
         else {
-            /* Find the interval that arg lies between in the set of knots
-               t[ell] <= arg < t[ell+1] (last-knot use the previous interval) */
+            /*
+             * Find the interval that arg lies between in the set of knots
+             * t[ell] <= arg < t[ell+1] (last-knot use the previous interval)
+             */
             xN1 = *((double *)PyArray_DATA(x_i) + N-1);
             if (arg >= xN1) {
                 ell = N + kk - 2;
             }
             else {
-                ell = kk-1;
-                while ((arg > t[ell])) ell++;
-                if (arg != t[ell]) ell--;
+                ell = kk - 1;
+                while ((arg > t[ell])) {
+                    ell++;
+                }
+                if (arg != t[ell]) {
+                    ell--;
+                }
             }

             _deBoor_D(t, arg, k, ell, deriv, h);

             sp = 0.0;
-            for (i=0; i<=k; i++) {
-                cval = *((double *)(PyArray_GETPTR1(coef, ell-i+dk)));
-                sp += cval*h[k-i];
+            for (i = 0; i <= k; i++) {
+                cval = *((double *)(PyArray_GETPTR1(coef, ell - i + dk)));
+                sp += cval * h[k - i];
             }
             *ptr++ = sp;
         }
@@ -875,44 +1039,49 @@
     free(h);
     return PyArray_Return(yy);

- fail:
+fail:
     Py_XDECREF(xx);
     Py_XDECREF(coef);
     Py_XDECREF(x_i);
     Py_XDECREF(yy);
-    if (t != NULL) free(t);
-    if (h != NULL) free(h);
+    if (t != NULL) {
+        free(t);
+    }
+    if (h != NULL) {
+        free(h);
+    }
     return NULL;
 }

-/* Given a set of (N+1) sample positions:
-   Construct the diagonals of the (N+1) x (N+K) matrix that is needed to find
-   the coefficients of a spline fit of order K.
-       Note that K>=2 because for K=0,1, the coefficients are just the
-       sample values themselves.
-
-   The equation that expresses the constraints is
-
-     s(x_i) = sum(c_j B_{j,K}(x_i), j=-K..N-1) = w_i   for i=0..N
-
-   This is equivalent to
-
-     w = B*c   where c.T = [c_{-K}, c{-K+1}, ..., c_{N-1}] and
-                     w.T = [w_{0}, w_{1}, ..., w_{N}]
-
-   Therefore B is an (N+1) times (N+K) matrix with entries
-
-   B_{j,K}(x_i)  for column j=-K..N-1
-                 and row i=0..N
-
-   This routine takes the N+1 sample positions and the order k and
-      constructs the banded constraint matrix B (with k non-zero diagonals)
-
-   The returned array is (N+1) times (N+K) ready to be either used
-   to compute a minimally Kth-order derivative discontinuous spline
-   or to be expanded with an additional K-1 constraints to be used in
-   an exact spline specification.
+/*
+ * Given a set of (N+1) sample positions:
+ * Construct the diagonals of the (N+1) x (N+K) matrix that is needed to find
+ * the coefficients of a spline fit of order K.
+ * Note that K>=2 because for K=0,1, the coefficients are just the
+ * sample values themselves.
+ *
+ * The equation that expresses the constraints is
+ *
+ * s(x_i) = sum(c_j B_{j,K}(x_i), j=-K..N-1) = w_i   for i=0..N
+ *
+ * This is equivalent to
+ *
+ * w = B*c   where c.T = [c_{-K}, c{-K+1}, ..., c_{N-1}] and
+ * w.T = [w_{0}, w_{1}, ..., w_{N}]
+ *
+ * Therefore B is an (N+1) times (N+K) matrix with entries
+ *
+ * B_{j,K}(x_i)  for column j=-K..N-1
+ * and row i=0..N
+ *
+ * This routine takes the N+1 sample positions and the order k and
+ * constructs the banded constraint matrix B (with k non-zero diagonals)
+ *
+ * The returned array is (N+1) times (N+K) ready to be either used
+ * to compute a minimally Kth-order derivative discontinuous spline
+ * or to be expanded with an additional K-1 constraints to be used in
+ * an exact spline specification.
  */
 static char doc_bsplmat[] = "B = _bsplmat(order,xk)\n"
 "Construct the constraint matrix for spline fitting of order k\n"
@@ -921,15 +1090,18 @@
 "If xk is an integer (N+1), then the result is equivalent to\n"
 "xk=arange(N+1)+x0 for any value of x0.   This produces the\n"
 "integer-spaced, or cardinal spline matrix a bit faster.";
-static PyObject *_bsplmat(PyObject *dummy, PyObject *args) {
-    int k,N,i,numbytes,j, equal;
+static PyObject *
+_bsplmat(PyObject *dummy, PyObject *args) {
+    int k, N, i, numbytes, j, equal;
     npy_intp dims[2];
-    PyObject *x_i_py=NULL;
-    PyArrayObject *x_i=NULL, *BB=NULL;
-    double *t=NULL, *h=NULL, *ptr;
+    PyObject *x_i_py = NULL;
+    PyArrayObject *x_i = NULL, *BB = NULL;
+    double *t = NULL, *h = NULL, *ptr;
     double x0, xN, arg;
-    if (!PyArg_ParseTuple(args, "iO", &k, &x_i_py))
-        return NULL;
+
+    if (!PyArg_ParseTuple(args, "iO", &k, &x_i_py)) {
+        return NULL;
+    }
     if (k < 2) {
         PyErr_Format(PyExc_ValueError, "order (%d) must be >=2", k);
         return NULL;
@@ -940,119 +1112,139 @@
     if (N == -1 && PyErr_Occurred()) {
         PyErr_Clear();
         N = PyInt_AsLong(x_i_py);
-        if (N==-1 && PyErr_Occurred()) goto fail;
+        if (N == -1 && PyErr_Occurred()) {
+            goto fail;
+        }
         equal = 1;
     }
     N -= 1;

     /* create output matrix */
-    dims[0] = N+1;
-    dims[1] = N+k;
+    dims[0] = N + 1;
+    dims[1] = N + k;
     BB = (PyArrayObject *)PyArray_ZEROS(2, dims, NPY_DOUBLE, 0);
-    if (BB == NULL) goto fail;
-
-    t = (double *)malloc(sizeof(double)*(N+2*k-1));
-    if (t==NULL) {
+    if (BB == NULL) {
+        goto fail;
+    }
+
+    t = (double *)malloc(sizeof(double)*(N + 2*k - 1));
+    if (t == NULL) {
         PyErr_NoMemory();
         goto fail;
     }

-    /* Create work array to hold computed non-zero values for
-       the spline for a value of x.
-    */
-    h = (double *)malloc(sizeof(double)*(2*k+1));
-    if (h==NULL) {
+    /*
+     * Create work array to hold computed non-zero values for
+     * the spline for a value of x.
+     */
+    h = (double *)malloc(sizeof(double)*(2*k + 1));
+    if (h == NULL) {
         PyErr_NoMemory();
         goto fail;
     }

     numbytes = k*sizeof(double);

-    if (equal) { /* points equally spaced by 1 */
-        /* we run deBoor's algorithm one time with artificially created knots
-           Then, we keep copying the result to every row */
+    if (equal) {
+        /*
+         * points equally spaced by 1
+         * we run deBoor's algorithm one time with artificially created knots
+         * Then, we keep copying the result to every row
+         */

         /* Create knots at equally-spaced locations from -(K-1) to N+K-1 */
         ptr = t;
-        for (i=-k+1; i<N+k; i++) *ptr++ = i;
-        j = k-1;
+        for (i = -k + 1; i < N + k; i++) {
+            *ptr++ = i;
+        }
+        j = k - 1;
         _deBoor_D(t, 0, k, k-1, 0, h);
         ptr = PyArray_DATA(BB);
         N = N+1;
-        for (i=0; i<N; i++) {
+        for (i = 0; i < N; i++) {
             memcpy(ptr, h, numbytes);
-            ptr += (N+k);
+            ptr += N + k;
         }
         goto finish;
     }

     /* Not-equally spaced */
     x_i = (PyArrayObject *)PyArray_FROMANY(x_i_py, NPY_DOUBLE, 1, 1, NPY_ALIGNED);
-    if (x_i == NULL) return NULL;
-
-    /* create dummy knot array with new knots inserted at the end
-       selected as mirror symmetric versions of the old knots
+    if (x_i == NULL) {
+        return NULL;
+    }
+    /*
+     * create dummy knot array with new knots inserted at the end
+     * selected as mirror symmetric versions of the old knots
      */
     x0 = *((double *)PyArray_DATA(x_i));
     xN = *((double *)PyArray_DATA(x_i) + N);
-    for (i=0; i<k-1; i++) { /* fill in ends if k > 1*/
-        t[i] = 2*x0 - *((double *)(PyArray_GETPTR1(x_i,k-1-i)));
-        t[k+N+i] = 2*xN - *((double *)(PyArray_GETPTR1(x_i,N-1-i)));
-    }
-    ptr = t + (k-1);
-    for (i=0; i<=N; i++) {
+    for (i = 0; i < k - 1; i++) {
+        /* fill in ends if k > 1*/
+        t[i] = 2*x0 - *((double *)(PyArray_GETPTR1(x_i, k - 1 - i)));
+        t[k+N+i] = 2*xN - *((double *)(PyArray_GETPTR1(x_i, N - 1 - i)));
+    }
+    ptr = t + (k - 1);
+    for (i = 0; i <= N; i++) {
         *ptr++ = *((double *)(PyArray_GETPTR1(x_i, i)));
     }

-    /* Determine the K+1 non-zero values of the spline and place them in the
-       correct location in the matrix for each row (along the diagonals).
-       In fact, the last member is always zero so only K non-zero values
-       are present.
-    */
+    /*
+     * Determine the K+1 non-zero values of the spline and place them in the
+     * correct location in the matrix for each row (along the diagonals).
+     * In fact, the last member is always zero so only K non-zero values
+     * are present.
+     */
     ptr = PyArray_DATA(BB);
-    for (i=0,j=k-1; i<N; i++,j++) {
+    for (i = 0, j = k - 1; i < N; i++, j++) {
         arg = *((double *)PyArray_DATA(x_i) + i);
         _deBoor_D(t, arg, k, j, 0, h);
         memcpy(ptr, h, numbytes);
-        ptr += (N+k+1);  /* advance to next row shifted over one */
+        /* advance to next row shifted over one */
+        ptr += (N + k + 1);
     }
     /* Last row is different the first coefficient is zero.*/
-    _deBoor_D(t, xN, k, j-1, 0, h);
-    memcpy(ptr, h+1, numbytes);
-
- finish:
+    _deBoor_D(t, xN, k, j - 1, 0, h);
+    memcpy(ptr, h + 1, numbytes);
+
+finish:
     Py_XDECREF(x_i);
     free(t);
     free(h);
     return (PyObject *)BB;

- fail:
+fail:
     Py_XDECREF(x_i);
     Py_XDECREF(BB);
-    if (t != NULL) free(t);
-    if (h != NULL) free(h);
+    if (t != NULL) {
+        free(t);
+    }
+    if (h != NULL) {
+        free(h);
+    }
     return NULL;
 }

-/* Given a set of (N+1) sample positions:
-   Construct the (N-1) x (N+K) error matrix J_{ij} such that
-
-   for i=1..N-1,
-
-   e_i = sum(J_{ij}c_{j},j=-K..N-1)
-
-   is the discontinuity of the Kth derivative at the point i in the spline.
-
-   This routine takes the N+1 sample positions and the order k and
-      constructs the banded matrix J
-
-   The returned array is (N+1) times (N+K) ready to be either used
-   to compute a minimally Kth-order derivative discontinuous spline
-   or to be expanded with an additional K-1 constraints to be used in
-   an exact reconstruction approach.
+/*
+ * Given a set of (N+1) sample positions:
+ * Construct the (N-1) x (N+K) error matrix J_{ij} such that
+ *
+ * for i=1..N-1,
+ *
+ * e_i = sum(J_{ij}c_{j},j=-K..N-1)
+ *
+ * is the discontinuity of the Kth derivative at the point i in the spline.
+ *
+ * This routine takes the N+1 sample positions and the order k and
+ * constructs the banded matrix J
+ *
+ * The returned array is (N+1) times (N+K) ready to be either used
+ * to compute a minimally Kth-order derivative discontinuous spline
+ * or to be expanded with an additional K-1 constraints to be used in
+ * an exact reconstruction approach.
  */
 static char doc_bspldismat[] = "B = _bspldismat(order,xk)\n"
 "Construct the kth derivative discontinuity jump constraint matrix \n"
@@ -1062,15 +1254,19 @@
 "xk=arange(N+1)+x0 for any value of x0.   This produces the\n"
 "integer-spaced matrix a bit faster.  If xk is a 2-tuple (N+1,dx)\n"
 "then it produces the result as if the sample distance were dx";
-static PyObject *_bspldismat(PyObject *dummy, PyObject *args) {
-    int k,N,i,j, equal, m;
+static PyObject *
+_bspldismat(PyObject *dummy, PyObject *args)
+{
+    int k, N, i, j, equal, m;
     npy_intp dims[2];
-    PyObject *x_i_py=NULL;
-    PyArrayObject *x_i=NULL, *BB=NULL;
-    double *t=NULL, *h=NULL, *ptr, *dptr;
+    PyObject *x_i_py = NULL;
+    PyArrayObject *x_i = NULL, *BB = NULL;
+    double *t = NULL, *h = NULL, *ptr, *dptr;
     double x0, xN, dx;
-    if (!PyArg_ParseTuple(args, "iO", &k, &x_i_py))
-        return NULL;
+
+    if (!PyArg_ParseTuple(args, "iO", &k, &x_i_py)) {
+        return NULL;
+    }
     if (k < 2) {
         PyErr_Format(PyExc_ValueError, "order (%d) must be >=2", k);
         return NULL;
@@ -1078,7 +1274,7 @@

     equal = 0;
     N = PySequence_Length(x_i_py);
-    if (N==2 || (N == -1 && PyErr_Occurred())) {
+    if (N == 2 || (N == -1 && PyErr_Occurred())) {
         PyErr_Clear();
         if (PyTuple_Check(x_i_py)) {
             /* x_i_py = (N+1, dx) */
@@ -1087,7 +1283,9 @@
         }
         else {
             N = PyInt_AsLong(x_i_py);
-            if (N==-1 && PyErr_Occurred()) goto fail;
+            if (N == -1 && PyErr_Occurred()) {
+                goto fail;
+            }
             dx = 1.0;
         }
         equal = 1;
@@ -1099,59 +1297,70 @@
         return NULL;
     }
     /* create output matrix */
-    dims[0] = N-1;
-    dims[1] = N+k;
+    dims[0] = N - 1;
+    dims[1] = N + k;
     BB = (PyArrayObject *)PyArray_ZEROS(2, dims, NPY_DOUBLE, 0);
-    if (BB == NULL) goto fail;
-
+    if (BB == NULL) {
+        goto fail;
+    }
     t = (double *)malloc(sizeof(double)*(N+2*k-1));
-    if (t==NULL) {
+    if (t == NULL) {
         PyErr_NoMemory();
         goto fail;
     }

-    /* Create work array to hold computed non-zero values for
-       the spline for a value of x.
-    */
-    h = (double *)malloc(sizeof(double)*(2*k+1));
-    if (h==NULL) {
+    /*
+     * Create work array to hold computed non-zero values for
+     * the spline for a value of x.
+     */
+    h = (double *)malloc(sizeof(double)*(2*k + 1));
+    if (h == NULL) {
         PyErr_NoMemory();
         goto fail;
     }

-    if (equal) { /* points equally spaced by 1 */
-        /* we run deBoor's full derivative algorithm twice, subtract the results
-           offset by one and then copy the result one time with artificially created knots
-           Then, we keep copying the result to every row */
+    if (equal) {
+        /*
+         * points equally spaced by 1
+         * we run deBoor's full derivative algorithm twice, subtract the results
+         * offset by one and then copy the result one time with artificially created knots
+         * Then, we keep copying the result to every row
+         */

         /* Create knots at equally-spaced locations from -(K-1) to N+K-1 */
         double *tmp, factor;
         int numbytes;
-        numbytes = (k+2)*sizeof(double);
+        numbytes = (k + 2)*sizeof(double);
         tmp = malloc(numbytes);
-        if (tmp==NULL) {
+        if (tmp == NULL) {
             PyErr_NoMemory();
             goto fail;
         }
         ptr = t;
-        for (i=-k+1; i<N+k; i++) *ptr++ = i;
-        j = k-1;
+        for (i = -k + 1; i < N + k; i++) {
+            *ptr++ = i;
+        }
+        j = k - 1;
         _deBoor_D(t, 0, k, k-1, k, h);
         ptr = tmp;
-        for (m=0; m<=k; m++) *ptr++ = -h[m];
+        for (m = 0; m <= k; m++) {
+            *ptr++ = -h[m];
+        }
         _deBoor_D(t, 0, k, k, k, h);
-        ptr = tmp+1;
-        for (m=0; m<=k; m++) *ptr++ += h[m];
+        ptr = tmp + 1;
+        for (m = 0; m <= k; m++) {
+            *ptr++ += h[m];
+        }
         if (dx != 1.0) {
             factor = pow(dx, (double)k);
-            for (m=0; m<(k+2); m++) {
+            for (m = 0; m < k + 2; m++) {
                 tmp[m] /= factor;
             }
         }
         ptr = PyArray_DATA(BB);
-        for (i=0; i<(N-1); i++) {
+        for (i = 0; i < N - 1; i++) {
             memcpy(ptr, tmp, numbytes);
-            ptr += (N+k+1);
+            ptr += N + k + 1;
         }
         free(tmp);
         goto finish;
@@ -1159,61 +1368,77 @@

     /* Not-equally spaced */
     x_i = (PyArrayObject *)PyArray_FROMANY(x_i_py, NPY_DOUBLE, 1, 1, NPY_ALIGNED);
-    if (x_i == NULL) return NULL;
-
-    /* create dummy knot array with new knots inserted at the end
-       selected as mirror symmetric versions of the old knots
+    if (x_i == NULL) {
+        return NULL;
+    }
+    /*
+     * create dummy knot array with new knots inserted at the end
+     * selected as mirror symmetric versions of the old knots
      */
     x0 = *((double *)PyArray_DATA(x_i));
     xN = *((double *)PyArray_DATA(x_i) + N);
-    for (i=0; i<k-1; i++) { /* fill in ends if k > 1*/
-        t[i] = 2*x0 - *((double *)(PyArray_GETPTR1(x_i,k-1-i)));
-        t[k+N+i] = 2*xN - *((double *)(PyArray_GETPTR1(x_i,N-1-i)));
-    }
-    ptr = t + (k-1);
-    for (i=0; i<=N; i++) {
+    for (i = 0; i < k - 1; i++) {
+        /* fill in ends if k > 1*/
+        t[i] = 2*x0 - *((double *)(PyArray_GETPTR1(x_i, k - 1 - i)));
+        t[k+N+i] = 2*xN - *((double *)(PyArray_GETPTR1(x_i, N - 1 - i)));
+    }
+    ptr = t + (k - 1);
+    for (i = 0; i <= N; i++) {
         *ptr++ = *((double *)(PyArray_GETPTR1(x_i, i)));
     }

-    /* Determine the K+1 non-zero values of the discontinuity jump matrix
-       and place them in the correct location in the matrix for each row
-       (along the diagonals).
-
-       The matrix is
-
-       J_{ij} = b^{(k)}_{j,k}(x^{+}_i) - b^{(k)}_{j,k}(x^{-}_i)
-
-    */
+    /*
+     * Determine the K+1 non-zero values of the discontinuity jump matrix
+     * and place them in the correct location in the matrix for each row
+     * (along the diagonals).
+     *
+     * The matrix is
+     *
+     * J_{ij} = b^{(k)}_{j,k}(x^{+}_i) - b^{(k)}_{j,k}(x^{-}_i)
+     */
     ptr = PyArray_DATA(BB);
     dptr = ptr;
-    for (i=0,j=k-1; i<N-1; i++,j++) {
+    for (i = 0, j = k - 1; i < N - 1; i++, j++) {
         _deBoor_D(t, 0, k, j, k, h);
         /* We need to copy over but negate the terms */
-        for (m=0; m<=k; m++) *ptr++ = -h[m];
-        /* If we are past the first row, then we need to also add the current
-           values result to the previous row */
-        if (i>0) {
-            for (m=0; m<=k; m++) *dptr++ += h[m];
+        for (m = 0; m <= k; m++) {
+            *ptr++ = -h[m];
+        }
+        /*
+         * If we are past the first row, then we need to also add the current
+         * values result to the previous row
+         */
+        if (i > 0) {
+            for (m = 0; m <= k; m++) {
+                *dptr++ += h[m];
+            }
         }
         /* store location of last start position plus one.*/
         dptr = ptr - k;
-        ptr += N;  /* advance to next row shifted over one */
+        /* advance to next row shifted over one */
+        ptr += N;
     }
     /* We need to finish the result for the last row. */
     _deBoor_D(t, 0, k, j, k, h);
-    for (m=0; m<=k; m++) *dptr++ += h[m];
-
- finish:
+    for (m = 0; m <= k; m++) {
+        *dptr++ += h[m];
+    }
+
+finish:
     Py_XDECREF(x_i);
     free(t);
     free(h);
     return (PyObject *)BB;

- fail:
+fail:
     Py_XDECREF(x_i);
     Py_XDECREF(BB);
-    if (t != NULL) free(t);
-    if (h != NULL) free(h);
+    if (t != NULL) {
+        free(t);
+    }
+    if (h != NULL) {
+        free(h);
+    }
     return NULL;
 }


export up to 64 node addresses

export up to 64 node addresses

--- src/kad.c
+++ src/kad.c
@@ -384,8 +384,8 @@
 }

 int kad_export_nodes( IP addr_array[], int *num ) {
-	IP4 addr4[32];
-	IP6 addr6[32];
+	IP4 addr4[64];
+	IP6 addr6[64];
 	int num4;
 	int num6;
 	int i, count;


Fixed stb_vorbis.c compilation in FreeBSD.

--- src/siege/internal/stb/stb_vorbis.c
+++ src/siege/internal/stb/stb_vorbis.c
@@ -546,7 +546,7 @@
 #include <string.h>
 #include <assert.h>
 #include <math.h>
-#if !(defined(__APPLE__) || defined(MACOSX) || defined(macintosh) || defined(Macintosh))
+#if !(defined(__APPLE__) || defined(MACOSX) || defined(macintosh) || defined(Macintosh) || defined(__FreeBSD__))
 #include <malloc.h>
 #endif
 #else


initialize socket with -1

initialize socket with -1

--- src/kad.c
+++ src/kad.c
@@ -25,7 +25,7 @@

 /* Next time to do DHT maintenance */
 static time_t g_dht_maintenance = 0;
-static int g_dht_socket = 0;
+static int g_dht_socket = -1;

 void dht_lock_init( void ) {
 #ifdef PTHREAD


Increase MAX_INFO_STRING to 256 to avoid errors with long info strings such as:

07.02.0005 PostgreSQL 7.3 on i386-redhat-linux-gnu, compiled by GCC i386-redhat-linux-gcc (GCC) 3.2.1 20021207 (Red Hat Linux 8.0 3.2.1-2)

See https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=80394 for more details.

--- psqlodbc.h
+++ psqlodbc.h
@@ -5,7 +5,7 @@
  *
  * Comments:		See "notice.txt" for copyright and license information.
  *
- * $Id: psqlodbc.h,v 1.73 2002/12/16 15:01:34 hinoue Exp $
+ * $Id: psqlodbc.h,v 1.74 2003/01/02 11:45:41 dpage Exp $
  *
  */

@@ -165,7 +165,7 @@
 #define KEYS_TABLE					"dd_fkey"

 /*	Info limits */
-#define MAX_INFO_STRING				128
+#define MAX_INFO_STRING				256
 #define MAX_KEYPARTS				20
 #define MAX_KEYLEN					512 /* max key of the form
 										 * "date+outlet+invoice" */


Deserialized key should be the correct size.

--- src/key.h
+++ src/key.h
@@ -176,6 +176,10 @@
     void Unserialize(Stream &s)
     {
         unsigned int len = ::ReadCompactSize(s);
+        if (len != BIP32_EXTKEY_SIZE)
+        {
+            throw std::runtime_error("Invalid extended key size\n");
+        }
         unsigned char code[BIP32_EXTKEY_SIZE];
         s.read((char *)&code[0], len);
         Decode(code);


zkey: Enhance error message on key store open

Print a meaningful reason when the keystore can not be
accessed, e.g. because the user is not allowed to access
the keystore directory.

Signed-off-by: Ingo Franzki <fa8d39f13ae2429c04f0388a0ea18c43b0cb5bf2@linux.ibm.com>
Signed-off-by: Jan Höppner <96138615ab4af0813785fa10d283f3d37eca3b78@linux.ibm.com>

--- zkey/keystore.c
+++ zkey/keystore.c
@@ -1359,7 +1359,7 @@
 	util_assert(directory != NULL, "Internal error: directory is NULL");

 	if (stat(directory, &sb) != 0) {
-		warnx("'%s' does not exist", directory);
+		warnx("Can not access '%s': %s", directory, strerror(errno));
 		return NULL;
 	}
 	if (!(sb.st_mode & S_IFDIR)) {


Check that the reduced discriminant is strictly positive in truncated conjugate gradient

--- src/lcg.c
+++ src/lcg.c
@@ -38,11 +38,6 @@
 #include <math.h>

 #include "optimpack-linalg.h"
-
-/* FIXME: what about negative BETA?
- * FIXME: detect exact convergence...
- * FIXME: check if Q and Z can be the same array
- */

 #define COPY(n, x, y)    OPK_COPY(n, x, 1, y, 1)
 #define AXPY(n, a, x, y) OPK_AXPY(n, a, x, 1, y, 1)
@@ -295,12 +290,12 @@
       pq = DOT(n, p, q);
       if (pq > zero) {
         alpha = rho[1]/pq; /* optimal step size */
+        rho[2] = alpha; /* memorize optimal step size */
         if (alpha == zero) {
           /* If alpha too small, then algorithm has converged. */
           *state = OPK_CG_FINISH;
           return;
         }
-        /* FIXME: use Z if not NULL as a scratch array to save computations */
         sum = zero;
         for (i = 0; i < n; ++i) {
           tmp = x[i] + alpha*p[i];
@@ -312,7 +307,6 @@
           AXPY(n,  alpha, p, x);
           AXPY(n, -alpha, q, r);
           rho[0] = rho[1];
-          rho[2] = alpha; /* memorize optimal step size */
           rho[4] = xn;
           *state = (xn < delta ? OPK_CG_NEWX : OPK_CG_TRUNCATED);
           return;
@@ -321,16 +315,17 @@

       /* Operator A is not positive definite (P'.A.P < 0) or optimal step
          leads us ouside the trust region.  In these cases, we take a
-         truncated step X + ALPHA*P along P so that |X + ALPHA*P| = DELTA
-         with ALPHA >= 0.  This amounts to find the positive root of:
-         A*ALPHA^2 + 2*B*ALPHA + C with: A = |P|^2, B = X'.P, and
-         C = |X|^2 - DELTA^2. */
+         truncated step X + ALPHA*P along P so that |X + ALPHA*P| = DELTA with
+         ALPHA >= 0.  This amounts to find the positive root of: A*ALPHA^2 +
+         2*B*ALPHA + C with: A = |P|^2, B = X'.P, and C = |X|^2 - DELTA^2.
+         Note that the reduced discriminant is D = B*B - A*C which expands to
+         D = (DELTA^2 - |X|^2*sin(THETA)^2)*|P|^2 with THETA the angle between
+         X and P, as DELTA > |X|, then D > 0 must hold. */
       a = DOT(n, p, p);
       if (a <= zero) {
-        /* FIXME: This can only occurs if P = 0 (and thus A = 0).  It is
-           probably due to rounding errors and the algorithm should be
-           restarted. */
-        *state = OPK_CG_ERROR;
+        /* This can only occurs if P = 0 (and thus A = 0).  It is probably due
+           to rounding errors and the algorithm should be restarted. */
+        *state = OPK_CG_FINISH;
         return;
       }
       b = DOT(n, x, p);
@@ -352,21 +347,17 @@
       /* Compute the reduced discriminant. */
       d = b*b - a*c;
       if (d > zero) {
-        /* The polynomial has two real roots of opposite signs (because
-           C/A < 0 by construction), ALPHA is the positive one.  Compute
-           this root avoiding numerical errors (by adding numbers of
-           same sign). */
+        /* The polynomial has two real roots of opposite signs (because C/A <
+           0 by construction), ALPHA is the positive one.  Compute this root
+           avoiding numerical errors (by adding numbers of same sign). */
         e = SQRT(d);
         if (b >= zero) {
           alpha = -c/(e + b);
         } else {
           alpha = (e - b)/a;
         }
-      } else if (d == zero && b >= zero) {
-        /* A single positive root. */
-        alpha = -b/a;
       } else {
-        /* No real positive roots.  There must be something wrong... */
+        /* D > 0 must hold.  There must be something wrong... */
         *state = OPK_CG_ERROR;
         return;
       }


zkey: Fix convert command to use an associated APQN of a key

The zkey convert command must select an CCA adapter out of the
list of associated APQNs (if any) to perform the key conversion.

Signed-off-by: Ingo Franzki <fa8d39f13ae2429c04f0388a0ea18c43b0cb5bf2@linux.ibm.com>
Signed-off-by: Jan Höppner <96138615ab4af0813785fa10d283f3d37eca3b78@linux.ibm.com>

--- zkey/keystore.c
+++ zkey/keystore.c
@@ -4050,7 +4050,7 @@
 	if (rc)
 		goto out;

-	rc = select_cca_adapter_by_mkvp(cca, mkvp, NULL,
+	rc = select_cca_adapter_by_mkvp(cca, mkvp, apqns,
 					FLAG_SEL_CCA_MATCH_CUR_MKVP,
 					keystore->verbose);
 	if (rc == -ENOTSUP) {


Formatting update to surface header.

Formatting update to surface header.

--- include/openmc/surface.h
+++ include/openmc/surface.h
@@ -149,8 +149,8 @@
   //! Get the BoundingBox for this surface.
   virtual BoundingBox bounding_box(bool /*pos_side*/) const { return {}; }

-  protected:
-     virtual void to_hdf5_inner(hid_t group_id) const = 0;
+protected:
+  virtual void to_hdf5_inner(hid_t group_id) const = 0;
 };

 class CSGSurface : public Surface


lex.c: refactorinfg

lex.c: refactorinfg

--- src/lex.c
+++ src/lex.c
@@ -47,19 +47,19 @@
         (x >= WS_LOW && x <= WS_HIGH)) ? 1 : 0;
 }

-static int simple_transition (int literal, char **input, int tok, int *ret)
+static int trans (int literal, char **input, int tok, int state, int *ret)
 {
-    int state;
+    int endstate;

     if (literal) {
-        state = STATE_LITERAL;
+        endstate = STATE_LITERAL;
     } else {
-        state = STATE_END;
-        *ret = tok;
+        endstate = state;
+        if (ret) *ret = tok;
         *input += 1;
     }

-    return state;
+    return endstate;
 }

 void lex_init (void)
@@ -88,11 +88,8 @@
                     *input += 1;

                 } else if (**input == CHARC_OPEN_SYM) {
-                    state = STATE_END;
-                    ret = CHARC_OPEN;
-                    literal = 1;
-                    *input += 1;
-
+                    state = trans(literal, input, CHARC_OPEN, STATE_END, &ret);
+                    if (!literal) literal = 1;
                 } else if (**input == CHARC_CLOSE_SYM) {
                     state = STATE_END;
                     ret = CHARC_CLOSE;
@@ -100,30 +97,27 @@
                     *input += 1;

                 } else if (**input == REP_OPEN_SYM) {
-                   state = STATE_REP;
-                   *input += 1;
-
+                    state = trans(literal, input, 0, STATE_REP, NULL);
                 } else if (**input == REP_CLOSE_SYM) {
-                    return RVM_BADREP;
-
+                    state = trans(literal, input, RVM_BADREP, STATE_END, &ret);
                 } else if (**input == LPAREN_SYM) {
-                    state = simple_transition(literal, input, LPAREN, &ret);
+                    state = trans(literal, input, LPAREN, STATE_END, &ret);
                 } else if (**input == RPAREN_SYM) {
-                    state = simple_transition(literal, input, RPAREN, &ret);
+                    state = trans(literal, input, RPAREN, STATE_END, &ret);
                 } else if (**input == ONE_SYM) {
-                    state = simple_transition(literal, input, ONE, &ret);
+                    state = trans(literal, input, ONE, STATE_END, &ret);
                 } else if (**input == ONEZERO_SYM) {
-                    state = simple_transition(literal, input, ONEZERO, &ret);
+                    state = trans(literal, input, ONEZERO, STATE_END, &ret);
                 } else if (**input == ZERO_SYM) {
-                    state = simple_transition(literal, input, ZERO, &ret);
+                    state = trans(literal, input, ZERO, STATE_END, &ret);
                 } else if (**input == ANY_SYM) {
-                    state = simple_transition(literal, input, ANY, &ret);
+                    state = trans(literal, input, ANY, STATE_END, &ret);
                 } else if (**input == SOL_SYM) {
-                    state = simple_transition(literal, input, SOL, &ret);
+                    state = trans(literal, input, SOL, STATE_END, &ret);
                 } else if (**input == EOL_SYM) {
-                    state = simple_transition(literal, input, EOL, &ret);
+                    state = trans(literal, input, EOL, STATE_END, &ret);
                 } else if (**input == ALT_SYM) {
-                    state = simple_transition(literal, input, ALT, &ret);
+                    state = trans(literal, input, ALT, STATE_END, &ret);
                 } else if (isprintable(**input)) {
                     state = STATE_LITERAL;
                 } else {


Remove outdated comment about CSSPrimitiveValue being DOM-exposed

CSSPrimitiveValue is no longer exposed to JavaScript, so the comment
about it being exposed makes no sense.

Review URL: https://codereview.chromium.org/812183002

git-svn-id: bf5cd6ccde378db821296732a091cfbcf5285fbd@187418 bbb929c8-8fbe-4397-9dbb-9b2b20218538

--- Source/core/css/CSSPrimitiveValue.h
+++ Source/core/css/CSSPrimitiveValue.h
@@ -66,8 +66,7 @@

 // CSSPrimitiveValues are immutable. This class has manual ref-counting
 // of unioned types and does not have the code necessary
-// to handle any kind of mutations. All DOM-exposed "setters" just throw
-// exceptions.
+// to handle any kind of mutations.
 class CSSPrimitiveValue : public CSSValue {
 public:
     enum UnitType {


Stream: increase default value for proxy_protocol_timeout to 30s.

--- src/stream/ngx_stream_core_module.c
+++ src/stream/ngx_stream_core_module.c
@@ -249,7 +249,7 @@
     }

     ngx_conf_merge_msec_value(conf->proxy_protocol_timeout,
-                              prev->proxy_protocol_timeout, 5000);
+                              prev->proxy_protocol_timeout, 30000);

     ngx_conf_merge_value(conf->tcp_nodelay, prev->tcp_nodelay, 1);


deprecate engine from public header files

Reviewed-by: Richard Levitte <5fb523282dd7956571c80524edc2dccfa0bd8234@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/12226)

--- include/openssl/engine.h
+++ include/openssl/engine.h
@@ -314,17 +314,17 @@
  */

 /* Get the first/last "ENGINE" type available. */
-ENGINE *ENGINE_get_first(void);
-ENGINE *ENGINE_get_last(void);
+DEPRECATEDIN_3_0(ENGINE *ENGINE_get_first(void))
+DEPRECATEDIN_3_0(ENGINE *ENGINE_get_last(void))
 /* Iterate to the next/previous "ENGINE" type (NULL = end of the list). */
-ENGINE *ENGINE_get_next(ENGINE *e);
-ENGINE *ENGINE_get_prev(ENGINE *e);
+DEPRECATEDIN_3_0(ENGINE *ENGINE_get_next(ENGINE *e))
+DEPRECATEDIN_3_0(ENGINE *ENGINE_get_prev(ENGINE *e))
 /* Add another "ENGINE" type into the array. */
-int ENGINE_add(ENGINE *e);
+DEPRECATEDIN_3_0(int ENGINE_add(ENGINE *e))
 /* Remove an existing "ENGINE" type from the array. */
-int ENGINE_remove(ENGINE *e);
+DEPRECATEDIN_3_0(int ENGINE_remove(ENGINE *e))
 /* Retrieve an engine from the list by its unique "id" value. */
-ENGINE *ENGINE_by_id(const char *id);
+DEPRECATEDIN_3_0(ENGINE *ENGINE_by_id(const char *id))

 #  ifndef OPENSSL_NO_DEPRECATED_1_1_0
 #   define ENGINE_load_openssl() \
@@ -344,14 +344,14 @@
 #   define ENGINE_load_rdrand() \
         OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_RDRAND, NULL)
 #  endif
-void ENGINE_load_builtin_engines(void);
+DEPRECATEDIN_3_0(void ENGINE_load_builtin_engines(void))

 /*
  * Get and set global flags (ENGINE_TABLE_FLAG_***) for the implementation
  * "registry" handling.
  */
-unsigned int ENGINE_get_table_flags(void);
-void ENGINE_set_table_flags(unsigned int flags);
+DEPRECATEDIN_3_0(unsigned int ENGINE_get_table_flags(void))
+DEPRECATEDIN_3_0(void ENGINE_set_table_flags(unsigned int flags))

 /*- Manage registration of ENGINEs per "table". For each type, there are 3
  * functions;
@@ -361,41 +361,41 @@
  * Cleanup is automatically registered from each table when required.
  */

-int ENGINE_register_RSA(ENGINE *e);
-void ENGINE_unregister_RSA(ENGINE *e);
-void ENGINE_register_all_RSA(void);
-
-int ENGINE_register_DSA(ENGINE *e);
-void ENGINE_unregister_DSA(ENGINE *e);
-void ENGINE_register_all_DSA(void);
-
-int ENGINE_register_EC(ENGINE *e);
-void ENGINE_unregister_EC(ENGINE *e);
-void ENGINE_register_all_EC(void);
-
-int ENGINE_register_DH(ENGINE *e);
-void ENGINE_unregister_DH(ENGINE *e);
-void ENGINE_register_all_DH(void);
-
-int ENGINE_register_RAND(ENGINE *e);
-void ENGINE_unregister_RAND(ENGINE *e);
-void ENGINE_register_all_RAND(void);
-
-int ENGINE_register_ciphers(ENGINE *e);
-void ENGINE_unregister_ciphers(ENGINE *e);
-void ENGINE_register_all_ciphers(void);
-
-int ENGINE_register_digests(ENGINE *e);
-void ENGINE_unregister_digests(ENGINE *e);
-void ENGINE_register_all_digests(void);
-
-int ENGINE_register_pkey_meths(ENGINE *e);
-void ENGINE_unregister_pkey_meths(ENGINE *e);
-void ENGINE_register_all_pkey_meths(void);
-
-int ENGINE_register_pkey_asn1_meths(ENGINE *e);
-void ENGINE_unregister_pkey_asn1_meths(ENGINE *e);
-void ENGINE_register_all_pkey_asn1_meths(void);
+DEPRECATEDIN_3_0(int ENGINE_register_RSA(ENGINE *e))
+DEPRECATEDIN_3_0(void ENGINE_unregister_RSA(ENGINE *e))
+DEPRECATEDIN_3_0(void ENGINE_register_all_RSA(void))
+
+DEPRECATEDIN_3_0(int ENGINE_register_DSA(ENGINE *e))
+DEPRECATEDIN_3_0(void ENGINE_unregister_DSA(ENGINE *e))
+DEPRECATEDIN_3_0(void ENGINE_register_all_DSA(void))
+
+DEPRECATEDIN_3_0(int ENGINE_register_EC(ENGINE *e))
+DEPRECATEDIN_3_0(void ENGINE_unregister_EC(ENGINE *e))
+DEPRECATEDIN_3_0(void ENGINE_register_all_EC(void))
+
+DEPRECATEDIN_3_0(int ENGINE_register_DH(ENGINE *e))
+DEPRECATEDIN_3_0(void ENGINE_unregister_DH(ENGINE *e))
+DEPRECATEDIN_3_0(void ENGINE_register_all_DH(void))
+
+DEPRECATEDIN_3_0(int ENGINE_register_RAND(ENGINE *e))
+DEPRECATEDIN_3_0(void ENGINE_unregister_RAND(ENGINE *e))
+DEPRECATEDIN_3_0(void ENGINE_register_all_RAND(void))
+
+DEPRECATEDIN_3_0(int ENGINE_register_ciphers(ENGINE *e))
+DEPRECATEDIN_3_0(void ENGINE_unregister_ciphers(ENGINE *e))
+DEPRECATEDIN_3_0(void ENGINE_register_all_ciphers(void))
+
+DEPRECATEDIN_3_0(int ENGINE_register_digests(ENGINE *e))
+DEPRECATEDIN_3_0(void ENGINE_unregister_digests(ENGINE *e))
+DEPRECATEDIN_3_0(void ENGINE_register_all_digests(void))
+
+DEPRECATEDIN_3_0(int ENGINE_register_pkey_meths(ENGINE *e))
+DEPRECATEDIN_3_0(void ENGINE_unregister_pkey_meths(ENGINE *e))
+DEPRECATEDIN_3_0(void ENGINE_register_all_pkey_meths(void))
+
+DEPRECATEDIN_3_0(int ENGINE_register_pkey_asn1_meths(ENGINE *e))
+DEPRECATEDIN_3_0(void ENGINE_unregister_pkey_asn1_meths(ENGINE *e))
+DEPRECATEDIN_3_0(void ENGINE_register_all_pkey_asn1_meths(void))

 /*
  * These functions register all support from the above categories. Note, use
@@ -403,8 +403,8 @@
  * may not need. If you only need a subset of functionality, consider using
  * more selective initialisation.
  */
-int ENGINE_register_complete(ENGINE *e);
-int ENGINE_register_all_complete(void);
+DEPRECATEDIN_3_0(int ENGINE_register_complete(ENGINE *e))
+DEPRECATEDIN_3_0(int ENGINE_register_all_complete(void))

 /*
  * Send parameterised control commands to the engine. The possibilities to
@@ -416,7 +416,8 @@
  * commands that require an operational ENGINE, and only use functional
  * references in such situations.
  */
-int ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void));
+DEPRECATEDIN_3_0(int ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p,
+                                 void (*f) (void)))

 /*
  * This function tests if an ENGINE-specific command is usable as a
@@ -424,7 +425,7 @@
  * ENGINE_ctrl_cmd_string(). If this returns zero, it is not available to
  * ENGINE_ctrl_cmd_string(), only ENGINE_ctrl().
  */
-int ENGINE_cmd_is_executable(ENGINE *e, int cmd);
+DEPRECATEDIN_3_0(int ENGINE_cmd_is_executable(ENGINE *e, int cmd))

 /*
  * This function works like ENGINE_ctrl() with the exception of taking a
@@ -432,8 +433,9 @@
  * commands. See the comment on ENGINE_ctrl_cmd_string() for an explanation
  * on how to use the cmd_name and cmd_optional.
  */
-int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name,
-                    long i, void *p, void (*f) (void), int cmd_optional);
+DEPRECATEDIN_3_0(int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name,
+                                     long i, void *p, void (*f) (void),
+                                     int cmd_optional))

 /*
  * This function passes a command-name and argument to an ENGINE. The
@@ -457,8 +459,8 @@
  * applications can work consistently with the same configuration for the
  * same ENGINE-enabled devices, across applications.
  */
-int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg,
-                           int cmd_optional);
+DEPRECATEDIN_3_0(int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name,
+                                            const char *arg, int cmd_optional))

 /*
  * These functions are useful for manufacturing new ENGINE structures. They
@@ -468,37 +470,43 @@
  * These are also here so that the ENGINE structure doesn't have to be
  * exposed and break binary compatibility!
  */
-ENGINE *ENGINE_new(void);
-int ENGINE_free(ENGINE *e);
-int ENGINE_up_ref(ENGINE *e);
-int ENGINE_set_id(ENGINE *e, const char *id);
-int ENGINE_set_name(ENGINE *e, const char *name);
-int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth);
-int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth);
-int ENGINE_set_EC(ENGINE *e, const EC_KEY_METHOD *ecdsa_meth);
-int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth);
-int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth);
-int ENGINE_set_destroy_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR destroy_f);
-int ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f);
-int ENGINE_set_finish_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR finish_f);
-int ENGINE_set_ctrl_function(ENGINE *e, ENGINE_CTRL_FUNC_PTR ctrl_f);
-int ENGINE_set_load_privkey_function(ENGINE *e,
-                                     ENGINE_LOAD_KEY_PTR loadpriv_f);
-int ENGINE_set_load_pubkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpub_f);
-int ENGINE_set_load_ssl_client_cert_function(ENGINE *e,
-                                             ENGINE_SSL_CLIENT_CERT_PTR
-                                             loadssl_f);
-int ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f);
-int ENGINE_set_digests(ENGINE *e, ENGINE_DIGESTS_PTR f);
-int ENGINE_set_pkey_meths(ENGINE *e, ENGINE_PKEY_METHS_PTR f);
-int ENGINE_set_pkey_asn1_meths(ENGINE *e, ENGINE_PKEY_ASN1_METHS_PTR f);
-int ENGINE_set_flags(ENGINE *e, int flags);
-int ENGINE_set_cmd_defns(ENGINE *e, const ENGINE_CMD_DEFN *defns);
+DEPRECATEDIN_3_0(ENGINE *ENGINE_new(void))
+DEPRECATEDIN_3_0(int ENGINE_free(ENGINE *e))
+DEPRECATEDIN_3_0(int ENGINE_up_ref(ENGINE *e))
+DEPRECATEDIN_3_0(int ENGINE_set_id(ENGINE *e, const char *id))
+DEPRECATEDIN_3_0(int ENGINE_set_name(ENGINE *e, const char *name))
+DEPRECATEDIN_3_0(int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth))
+DEPRECATEDIN_3_0(int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth))
+DEPRECATEDIN_3_0(int ENGINE_set_EC(ENGINE *e, const EC_KEY_METHOD *ecdsa_meth))
+DEPRECATEDIN_3_0(int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth))
+DEPRECATEDIN_3_0(int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth))
+DEPRECATEDIN_3_0(int ENGINE_set_destroy_function
+                    (ENGINE *e,ENGINE_GEN_INT_FUNC_PTR destroy_f))
+DEPRECATEDIN_3_0(int ENGINE_set_init_function
+                    (ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f))
+DEPRECATEDIN_3_0(int ENGINE_set_finish_function
+                    (ENGINE *e, ENGINE_GEN_INT_FUNC_PTR finish_f))
+DEPRECATEDIN_3_0(int ENGINE_set_ctrl_function
+                    (ENGINE *e, ENGINE_CTRL_FUNC_PTR ctrl_f))
+DEPRECATEDIN_3_0(int ENGINE_set_load_privkey_function
+                    (ENGINE *e, ENGINE_LOAD_KEY_PTR loadpriv_f))
+DEPRECATEDIN_3_0(int ENGINE_set_load_pubkey_function
+                    (ENGINE *e, ENGINE_LOAD_KEY_PTR loadpub_f))
+DEPRECATEDIN_3_0(int ENGINE_set_load_ssl_client_cert_function
+                    (ENGINE *e, ENGINE_SSL_CLIENT_CERT_PTR loadssl_f))
+DEPRECATEDIN_3_0(int ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f))
+DEPRECATEDIN_3_0(int ENGINE_set_digests(ENGINE *e, ENGINE_DIGESTS_PTR f))
+DEPRECATEDIN_3_0(int ENGINE_set_pkey_meths(ENGINE *e, ENGINE_PKEY_METHS_PTR f))
+DEPRECATEDIN_3_0(int ENGINE_set_pkey_asn1_meths(ENGINE *e,
+                                                ENGINE_PKEY_ASN1_METHS_PTR f))
+DEPRECATEDIN_3_0(int ENGINE_set_flags(ENGINE *e, int flags))
+DEPRECATEDIN_3_0(int ENGINE_set_cmd_defns(ENGINE *e,
+                                          const ENGINE_CMD_DEFN *defns))
 /* These functions allow control over any per-structure ENGINE data. */
 #  define ENGINE_get_ex_new_index(l, p, newf, dupf, freef) \
     CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_ENGINE, l, p, newf, dupf, freef)
-int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg);
-void *ENGINE_get_ex_data(const ENGINE *e, int idx);
+DEPRECATEDIN_3_0(int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg))
+DEPRECATEDIN_3_0(void *ENGINE_get_ex_data(const ENGINE *e, int idx))

 #  ifndef OPENSSL_NO_DEPRECATED_1_1_0
 /*
@@ -514,37 +522,44 @@
  * which you obtained. Using the result for functional purposes if you only
  * obtained a structural reference may be problematic!
  */
-const char *ENGINE_get_id(const ENGINE *e);
-const char *ENGINE_get_name(const ENGINE *e);
-const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e);
-const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e);
-const EC_KEY_METHOD *ENGINE_get_EC(const ENGINE *e);
-const DH_METHOD *ENGINE_get_DH(const ENGINE *e);
-const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e);
-ENGINE_GEN_INT_FUNC_PTR ENGINE_get_destroy_function(const ENGINE *e);
-ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(const ENGINE *e);
-ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(const ENGINE *e);
-ENGINE_CTRL_FUNC_PTR ENGINE_get_ctrl_function(const ENGINE *e);
-ENGINE_LOAD_KEY_PTR ENGINE_get_load_privkey_function(const ENGINE *e);
-ENGINE_LOAD_KEY_PTR ENGINE_get_load_pubkey_function(const ENGINE *e);
-ENGINE_SSL_CLIENT_CERT_PTR ENGINE_get_ssl_client_cert_function(const ENGINE
-                                                               *e);
-ENGINE_CIPHERS_PTR ENGINE_get_ciphers(const ENGINE *e);
-ENGINE_DIGESTS_PTR ENGINE_get_digests(const ENGINE *e);
-ENGINE_PKEY_METHS_PTR ENGINE_get_pkey_meths(const ENGINE *e);
-ENGINE_PKEY_ASN1_METHS_PTR ENGINE_get_pkey_asn1_meths(const ENGINE *e);
-const EVP_CIPHER *ENGINE_get_cipher(ENGINE *e, int nid);
-const EVP_MD *ENGINE_get_digest(ENGINE *e, int nid);
-const EVP_PKEY_METHOD *ENGINE_get_pkey_meth(ENGINE *e, int nid);
-const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth(ENGINE *e, int nid);
-const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth_str(ENGINE *e,
-                                                          const char *str,
-                                                          int len);
-const EVP_PKEY_ASN1_METHOD *ENGINE_pkey_asn1_find_str(ENGINE **pe,
-                                                      const char *str,
-                                                      int len);
-const ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *e);
-int ENGINE_get_flags(const ENGINE *e);
+DEPRECATEDIN_3_0(const char *ENGINE_get_id(const ENGINE *e))
+DEPRECATEDIN_3_0(const char *ENGINE_get_name(const ENGINE *e))
+DEPRECATEDIN_3_0(const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e))
+DEPRECATEDIN_3_0(const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e))
+DEPRECATEDIN_3_0(const EC_KEY_METHOD *ENGINE_get_EC(const ENGINE *e))
+DEPRECATEDIN_3_0(const DH_METHOD *ENGINE_get_DH(const ENGINE *e))
+DEPRECATEDIN_3_0(const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e))
+DEPRECATEDIN_3_0(ENGINE_GEN_INT_FUNC_PTR ENGINE_get_destroy_function
+                    (const ENGINE *e))
+DEPRECATEDIN_3_0(ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function
+                    (const ENGINE *e))
+DEPRECATEDIN_3_0(ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function
+                    (const ENGINE *e))
+DEPRECATEDIN_3_0(ENGINE_CTRL_FUNC_PTR ENGINE_get_ctrl_function
+                    (const ENGINE *e))
+DEPRECATEDIN_3_0(ENGINE_LOAD_KEY_PTR ENGINE_get_load_privkey_function
+                    (const ENGINE *e))
+DEPRECATEDIN_3_0(ENGINE_LOAD_KEY_PTR ENGINE_get_load_pubkey_function
+                    (const ENGINE *e))
+DEPRECATEDIN_3_0(ENGINE_SSL_CLIENT_CERT_PTR ENGINE_get_ssl_client_cert_function
+                    (const ENGINE *e))
+DEPRECATEDIN_3_0(ENGINE_CIPHERS_PTR ENGINE_get_ciphers(const ENGINE *e))
+DEPRECATEDIN_3_0(ENGINE_DIGESTS_PTR ENGINE_get_digests(const ENGINE *e))
+DEPRECATEDIN_3_0(ENGINE_PKEY_METHS_PTR ENGINE_get_pkey_meths(const ENGINE *e))
+DEPRECATEDIN_3_0(ENGINE_PKEY_ASN1_METHS_PTR ENGINE_get_pkey_asn1_meths
+                    (const ENGINE *e))
+DEPRECATEDIN_3_0(const EVP_CIPHER *ENGINE_get_cipher(ENGINE *e, int nid))
+DEPRECATEDIN_3_0(const EVP_MD *ENGINE_get_digest(ENGINE *e, int nid))
+DEPRECATEDIN_3_0(const EVP_PKEY_METHOD *ENGINE_get_pkey_meth
+                    (ENGINE *e, int nid))
+DEPRECATEDIN_3_0(const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth
+                    (ENGINE *e, int nid))
+DEPRECATEDIN_3_0(const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth_str
+                    (ENGINE *e, const char *str, int len))
+DEPRECATEDIN_3_0(const EVP_PKEY_ASN1_METHOD *ENGINE_pkey_asn1_find_str
+                    (ENGINE **pe, const char *str, int len))
+DEPRECATEDIN_3_0(const ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *e))
+DEPRECATEDIN_3_0(int ENGINE_get_flags(const ENGINE *e))

 /*
  * FUNCTIONAL functions. These functions deal with ENGINE structures that
@@ -564,27 +579,29 @@
  * already in use). This will fail if the engine is not currently operational
  * and cannot initialise.
  */
-int ENGINE_init(ENGINE *e);
+DEPRECATEDIN_3_0(int ENGINE_init(ENGINE *e))
 /*
  * Free a functional reference to a engine type. This does not require a
  * corresponding call to ENGINE_free as it also releases a structural
  * reference.
  */
-int ENGINE_finish(ENGINE *e);
+DEPRECATEDIN_3_0(int ENGINE_finish(ENGINE *e))

 /*
  * The following functions handle keys that are stored in some secondary
  * location, handled by the engine.  The storage may be on a card or
  * whatever.
  */
-EVP_PKEY *ENGINE_load_private_key(ENGINE *e, const char *key_id,
-                                  UI_METHOD *ui_method, void *callback_data);
-EVP_PKEY *ENGINE_load_public_key(ENGINE *e, const char *key_id,
-                                 UI_METHOD *ui_method, void *callback_data);
-int ENGINE_load_ssl_client_cert(ENGINE *e, SSL *s,
-                                STACK_OF(X509_NAME) *ca_dn, X509 **pcert,
-                                EVP_PKEY **ppkey, STACK_OF(X509) **pother,
-                                UI_METHOD *ui_method, void *callback_data);
+DEPRECATEDIN_3_0(EVP_PKEY *ENGINE_load_private_key
+                    (ENGINE *e, const char *key_id, UI_METHOD *ui_method,
+                     void *callback_data))
+DEPRECATEDIN_3_0(EVP_PKEY *ENGINE_load_public_key
+                    (ENGINE *e, const char *key_id, UI_METHOD *ui_method,
+                     void *callback_data))
+DEPRECATEDIN_3_0(int ENGINE_load_ssl_client_cert
+                    (ENGINE *e, SSL *s, STACK_OF(X509_NAME) *ca_dn,
+                     X509 **pcert, EVP_PKEY **ppkey, STACK_OF(X509) **pother,
+                     UI_METHOD *ui_method, void *callback_data))

 /*
  * This returns a pointer for the current ENGINE structure that is (by
@@ -592,20 +609,20 @@
  * incremented reference, so it should be free'd (ENGINE_finish) before it is
  * discarded.
  */
-ENGINE *ENGINE_get_default_RSA(void);
+DEPRECATEDIN_3_0(ENGINE *ENGINE_get_default_RSA(void))
 /* Same for the other "methods" */
-ENGINE *ENGINE_get_default_DSA(void);
-ENGINE *ENGINE_get_default_EC(void);
-ENGINE *ENGINE_get_default_DH(void);
-ENGINE *ENGINE_get_default_RAND(void);
+DEPRECATEDIN_3_0(ENGINE *ENGINE_get_default_DSA(void))
+DEPRECATEDIN_3_0(ENGINE *ENGINE_get_default_EC(void))
+DEPRECATEDIN_3_0(ENGINE *ENGINE_get_default_DH(void))
+DEPRECATEDIN_3_0(ENGINE *ENGINE_get_default_RAND(void))
 /*
  * These functions can be used to get a functional reference to perform
  * ciphering or digesting corresponding to "nid".
  */
-ENGINE *ENGINE_get_cipher_engine(int nid);
-ENGINE *ENGINE_get_digest_engine(int nid);
-ENGINE *ENGINE_get_pkey_meth_engine(int nid);
-ENGINE *ENGINE_get_pkey_asn1_meth_engine(int nid);
+DEPRECATEDIN_3_0(ENGINE *ENGINE_get_cipher_engine(int nid))
+DEPRECATEDIN_3_0(ENGINE *ENGINE_get_digest_engine(int nid))
+DEPRECATEDIN_3_0(ENGINE *ENGINE_get_pkey_meth_engine(int nid))
+DEPRECATEDIN_3_0(ENGINE *ENGINE_get_pkey_asn1_meth_engine(int nid))

 /*
  * This sets a new default ENGINE structure for performing RSA operations. If
@@ -613,17 +630,17 @@
  * its reference count up'd so the caller should still free their own
  * reference 'e'.
  */
-int ENGINE_set_default_RSA(ENGINE *e);
-int ENGINE_set_default_string(ENGINE *e, const char *def_list);
+DEPRECATEDIN_3_0(int ENGINE_set_default_RSA(ENGINE *e))
+DEPRECATEDIN_3_0(int ENGINE_set_default_string(ENGINE *e, const char *def_list))
 /* Same for the other "methods" */
-int ENGINE_set_default_DSA(ENGINE *e);
-int ENGINE_set_default_EC(ENGINE *e);
-int ENGINE_set_default_DH(ENGINE *e);
-int ENGINE_set_default_RAND(ENGINE *e);
-int ENGINE_set_default_ciphers(ENGINE *e);
-int ENGINE_set_default_digests(ENGINE *e);
-int ENGINE_set_default_pkey_meths(ENGINE *e);
-int ENGINE_set_default_pkey_asn1_meths(ENGINE *e);
+DEPRECATEDIN_3_0(int ENGINE_set_default_DSA(ENGINE *e))
+DEPRECATEDIN_3_0(int ENGINE_set_default_EC(ENGINE *e))
+DEPRECATEDIN_3_0(int ENGINE_set_default_DH(ENGINE *e))
+DEPRECATEDIN_3_0(int ENGINE_set_default_RAND(ENGINE *e))
+DEPRECATEDIN_3_0(int ENGINE_set_default_ciphers(ENGINE *e))
+DEPRECATEDIN_3_0(int ENGINE_set_default_digests(ENGINE *e))
+DEPRECATEDIN_3_0(int ENGINE_set_default_pkey_meths(ENGINE *e))
+DEPRECATEDIN_3_0(int ENGINE_set_default_pkey_asn1_meths(ENGINE *e))

 /*
  * The combination "set" - the flags are bitwise "OR"d from the
@@ -632,9 +649,9 @@
  * application requires only specific functionality, consider using more
  * selective functions.
  */
-int ENGINE_set_default(ENGINE *e, unsigned int flags);
-
-void ENGINE_add_conf_module(void);
+DEPRECATEDIN_3_0(int ENGINE_set_default(ENGINE *e, unsigned int flags))
+
+DEPRECATEDIN_3_0(void ENGINE_add_conf_module(void))

 /* Deprecated functions ... */
 /* int ENGINE_clear_defaults(void); */
@@ -746,7 +763,7 @@
 void *ENGINE_get_static_state(void);

 #  if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
-DEPRECATEDIN_1_1_0(void ENGINE_setup_bsd_cryptodev(void))
+DEPRECATEDIN_3_0(DEPRECATEDIN_1_1_0(void ENGINE_setup_bsd_cryptodev(void)))
 #  endif


BUGFIX referencing NULL pointer when generating path for log message

--- src/log.c
+++ src/log.c
@@ -295,6 +295,7 @@
 {
     int i;
     struct lys_node_list *slist;
+    struct lys_node *sparent;
     struct lyd_node *dlist, *diter;
     const char *name, *prefix = NULL;
     size_t len;
@@ -308,8 +309,8 @@
             break;
         case LY_VLOG_LYS:
             name = ((struct lys_node *)elem)->name;
-            if (!((struct lys_node *)elem)->parent ||
-                    lys_node_module((struct lys_node *)elem) != lys_node_module(lys_parent((struct lys_node *)elem))) {
+            if (!(sparent = lys_parent((struct lys_node *)elem)) ||
+                    lys_node_module((struct lys_node *)elem) != lys_node_module(sparent)) {
                 prefix = lys_node_module((struct lys_node *)elem)->name;
             } else {
                 prefix = NULL;