diff -Naur --exclude=Makefile wfdb-10.5.23/MANIFEST wfdb-10.5.24/MANIFEST
--- wfdb-10.5.23/MANIFEST	2014-03-08 18:03:25.000000000 -0500
+++ wfdb-10.5.24/MANIFEST	2015-05-28 15:55:11.000000000 -0400
@@ -142,7 +142,6 @@
 checkpkg/Makefile
 checkpkg/Makefile.top
 checkpkg/Makefile.tpl
-checkpkg/mitdb
 conf
 conf/archname
 conf/collect.sh
diff -Naur --exclude=Makefile wfdb-10.5.23/Makefile.tpl wfdb-10.5.24/Makefile.tpl
--- wfdb-10.5.23/Makefile.tpl	2014-03-09 09:35:41.000000000 -0400
+++ wfdb-10.5.24/Makefile.tpl	2015-05-28 15:55:11.000000000 -0400
@@ -1,10 +1,10 @@
 # file: Makefile.tpl		G. Moody	 24 May 2000
-#				Last revised:   9 March 2014
+#				Last revised:   26 August 2014
 # This section of the Makefile should not need to be changed.
 
 # 'make' or 'make all': compile the WFDB applications without installing them
 all:		config.cache
-	$(MAKE) WFDBROOT=`pwd`/build install check
+	$(MAKE) WFDBROOT=`pwd`/build LIBDIR=`pwd`/build/lib install check
 
 # 'make install': compile and install the WFDB software package
 install:	config.cache
@@ -124,13 +124,13 @@
 	cd lib; $(SETPERMISSIONS) *.h
 	cd ..; export COPYFILE_DISABLE=true; \
 	  tar --create --file $(PACKAGE).tar.gz --verbose --gzip \
-          '--exclude=$(PACKAGE)/*CVS' $(PACKAGE) 2>&1 | \
+          '--exclude=.git*' $(PACKAGE) 2>&1 | \
 	  sed "s+^a ++" | sed s+${PACKAGE}/++ | \
           tee $(PACKAGE)-MANIFEST
 	cd ..; tar --create --file $(PACKAGE)-no-docs.tar.gz \
 	  --verbose --gzip \
           '--exclude=$(PACKAGE)/*doc' \
-	  '--exclude=$(PACKAGE)/*CVS' $(PACKAGE)
+	  '--exclude=.git*' $(PACKAGE)
 	./check-manifest $(PACKAGE)
 
 # 'make bin-tarball': make a gzipped tar archive of the WFDB software package
diff -Naur --exclude=Makefile wfdb-10.5.23/NEWS wfdb-10.5.24/NEWS
--- wfdb-10.5.23/NEWS	2014-03-13 14:09:53.000000000 -0400
+++ wfdb-10.5.24/NEWS	2015-05-28 15:55:11.000000000 -0400
@@ -1,3 +1,39 @@
+10.5.24 (28 May 2015):
+	A security flaw was found in the 'pnwlogin' script used to access
+	PhysioNetWorks projects, owing to a combination of bugs in WFDB and
+	libcurl.  Previous versions of the WFDB library would unconditionally
+	set the username and password for every HTTP or HTTPS request, which
+	caused them to be sent over the network unencrypted.  This bug has now
+	been fixed; note, however, that the old version of 'pnwlogin' is now
+	blocked at the server side, and the new version of 'pnwlogin' is (by
+	design) incompatible with older, insecure versions of the WFDB library.
+	In order to use 'pnwlogin', be sure that you are using the latest
+	version of the library (both 32-bit and 64-bit, if necessary.)
+
+	On most platforms, the WFDB library will now be installed in
+	/usr/local/lib by default, or /usr/local/lib32 if you are building a
+	32-bit library on an x86_64 system.  You can specify the --libdir option
+	to 'configure' to change the installation directory if you wish.
+
+	The 'wfdb-config' program used by external packages to compile and link
+	programs with the WFDB library was broken in version 10.5.23, in that if
+	libcurl was used, it would output the string "`curl-config --libs`",
+	rather than actually invoking curl-config.  This has now been fixed for
+	the case of a static WFDB library.  In the case of a dynamic WFDB
+	library, the curl flags were unnecessary in the first place, so they are
+	now omitted.
+
+	On MinGW, error messages will now be printed to standard error, rather
+	than being displayed in a popup message box.
+
+	When using libcurl, the environment variable CURL_CA_BUNDLE can be set
+	to the name of a file containing the trusted root certificate
+	authorities.  (Note that this does not currently work with the 'winssl'
+	version of libcurl, which uses the system certificate database instead.)
+
+	If the environment variable WFDB_NET_DEBUG is set, detailed information
+	about HTTP transfers will be printed to standard error.
+
 10.5.23 (13 March 2014):
 
 	Changes in 'configure', 'Makefile.tpl', 'conf/linux.def', and
diff -Naur --exclude=Makefile wfdb-10.5.23/app/gqrs.c wfdb-10.5.24/app/gqrs.c
--- wfdb-10.5.23/app/gqrs.c	2013-07-21 13:02:54.000000000 -0400
+++ wfdb-10.5.24/app/gqrs.c	2015-05-28 15:55:11.000000000 -0400
@@ -122,7 +122,7 @@
 main(int argc, char **argv)
 {
     char *p;
-    int gvmode = 0, i, isiglist = 0, j, nisig, s;
+    int gvmode = 0, i, isiglist = 0, j, nisig;
     WFDB_Anninfo a;
 
     pname = prog_name(argv[0]);
@@ -246,8 +246,8 @@
 	int i = findsig(argv[sig]);
 	if (i < 0) {
 	    (void)fprintf(stderr,
-			  "%s: (warning) no signal %d in record %s\n",
-			  pname, s, record);
+			  "%s: (warning) no signal %s in record %s\n",
+			  pname, argv[sig], record);
 	    cleanup(4);
 	}
 	sig = i;
diff -Naur --exclude=Makefile wfdb-10.5.23/app/pnwlogin wfdb-10.5.24/app/pnwlogin
--- wfdb-10.5.23/app/pnwlogin	2012-08-12 16:23:07.000000000 -0400
+++ wfdb-10.5.24/app/pnwlogin	2015-05-28 15:55:11.000000000 -0400
@@ -1,6 +1,7 @@
 #! /bin/bash
 
 # file: pnwlogin	G. Moody	12 August 2012
+#			Last revised:   30 July 2014
 #
 # Log in to PhysioNetWorks
 #
@@ -20,10 +21,12 @@
 stty echo
 echo
 
-export PNWUSER PNWPASS
+WFDBPASSWORD="https://physionet.org/ $PNWUSER:$PNWPASS"
+export WFDBPASSWORD
+unset PNWPASS # in case it was previously exported
 ( WFDB=https://physionet.org/users
   export WFDB
-  wfdbcat $PNWUSER/index.shtml >.pnwhome 2>/dev/null )
+  wfdbcat "$PNWUSER/?pnwlogin=10.5.24" >.pnwhome 2>/dev/null )
 
 if [ ! -s .pnwhome ]
 then
@@ -39,7 +42,7 @@
 rm -f .pnwhome
 if [ -z "${WFDB+xxx}" ]
 then
-    WFDB=". /usr/database http://physionet.org/physiobank/database"
+    WFDB=". /usr/local/database http://physionet.org/physiobank/database"
 fi
 WFDB="$WFDB https://physionet.org/works/\
  https://physionet.org/users/$PNWUSER/works/"
diff -Naur --exclude=Makefile wfdb-10.5.23/app/wfdb-config.c wfdb-10.5.24/app/wfdb-config.c
--- wfdb-10.5.23/app/wfdb-config.c	2009-05-03 15:08:07.000000000 -0400
+++ wfdb-10.5.24/app/wfdb-config.c	2015-05-28 15:55:11.000000000 -0400
@@ -1,5 +1,5 @@
 /* file: wfdb-config.c	G. Moody	27 April 2002
-			Last revised:	 3 May 2009	wfdblib 10.4.20
+			Last revised:	14 August 2014	wfdblib 10.5.24
 
 -------------------------------------------------------------------------------
 wfdb-config: Print WFDB library version and linking information
@@ -32,6 +32,18 @@
 
 #include <wfdb/wfdb.h>
 
+/* Expand command substitutions in VAR; needed if libcurl is included
+   in LDFLAGS, so that we invoke the curl-config program rather than
+   simply printing "`curl-config --libs`". */
+static void expand_var(const char *var)
+{
+    char *buffer;
+    SUALLOC(buffer, strlen(var) + 6, 1);
+    sprintf(buffer, "echo %s", var);
+    system(buffer);
+    SFREE(buffer);
+}
+
 char *pname;
 
 main(int argc, char **argv)
@@ -50,9 +62,9 @@
 	if (strcmp(argv[i], "--version") == 0)
 	    printf("%s\n", wfdbversion());
 	else if (strcmp(argv[i], "--libs") == 0)
-	    printf("%s\n", wfdbldflags());
+	    expand_var(wfdbldflags());
 	else if (strcmp(argv[i], "--cflags") == 0)
-	    printf("%s\n", wfdbcflags());
+	    expand_var(wfdbcflags());
 	else
 	    help();
     }
diff -Naur --exclude=Makefile wfdb-10.5.23/check-manifest wfdb-10.5.24/check-manifest
--- wfdb-10.5.23/check-manifest	2010-07-27 17:17:18.000000000 -0400
+++ wfdb-10.5.24/check-manifest	2015-05-28 15:55:11.000000000 -0400
@@ -1,11 +1,11 @@
 #!/bin/sh
 # file: check-manifest		G. Moody	14 December 2001
-#				Last revised:     27 July 2010
+#				Last revised:    26 August 2014
 # Verify tarball contents
 
 PACKAGE=$1
 sort -f <MANIFEST | grep . | grep -v ${PACKAGE} >../expected-MANIFEST
-sort -f <../${PACKAGE}-MANIFEST | grep . | sed 's+/$++' | \
+sed 's+/$++' <../${PACKAGE}-MANIFEST | sort -f | grep . | \
  grep -v ${PACKAGE} >../sort.$$
 mv ../sort.$$ ../${PACKAGE}-MANIFEST
 if diff ../expected-MANIFEST ../${PACKAGE}-MANIFEST
diff -Naur --exclude=Makefile wfdb-10.5.23/checkpkg/expected/lcheck_cal wfdb-10.5.24/checkpkg/expected/lcheck_cal
--- wfdb-10.5.23/checkpkg/expected/lcheck_cal	2012-08-09 23:51:34.000000000 -0400
+++ wfdb-10.5.24/checkpkg/expected/lcheck_cal	2015-05-28 15:55:11.000000000 -0400
@@ -37,7 +37,6 @@
 I	- 2 square 1 mV
 V	- 2 square 1 mV
 PLETH	- - undefined 1 mV
-P	- - undefined 100 mmHg
 Atip	- - undefined 1 mV
 HVA	- - undefined 5 mV
 Vtip	- - undefined 10 mV
@@ -46,7 +45,10 @@
 Abdomen	- - undefined 200 uV
 FECG	- - undefined 1 mV
 Direct	- - undefined 200 uV
+FHR	0 - undefined 20 bpm
+UC	- - undefined 50 nd
 CS	- - undefined 1 mV
+PCG	- - undefined 10000 mV
 F	- - undefined 100 uV
 C	- - undefined 100 uV
 A	- - undefined 100 uV
@@ -54,6 +56,7 @@
 P	- - undefined 100 uV
 O	- - undefined 100 uV
 I	- - undefined 100 uV
+P	- - undefined 100 mmHg
 record	- - undefined 1 mV
 record	- - undefined 10 V
 record	- - undefined 100 mmHg
diff -Naur --exclude=Makefile wfdb-10.5.23/conf/cygwin-slib.def wfdb-10.5.24/conf/cygwin-slib.def
--- wfdb-10.5.23/conf/cygwin-slib.def	2010-05-13 11:04:38.000000000 -0400
+++ wfdb-10.5.24/conf/cygwin-slib.def	2015-05-28 15:55:13.000000000 -0400
@@ -1,5 +1,5 @@
 # file: cygwin-slib.def	I. Henry and G. Moody	19 November 2002
-#				Last revised:	  13 May 2010
+#				Last revised:	 6 August 2014
 
 # This section contains settings suitable for generating a DLL (shared library)
 # under MS Windows using the free Cygwin/gcc ANSI C compiler, available from
@@ -53,7 +53,7 @@
 
 # LDFLAGS is appended to the C compiler command line to specify loading the
 # WFDB library.
-LDFLAGS = -L$(LIBDIR) -lwfdb $(LL)
+LDFLAGS = -L$(LIBDIR) -lwfdb
 
 # CC is the name of your C compiler.
 CC = gcc
diff -Naur --exclude=Makefile wfdb-10.5.23/conf/darwin-slib.def wfdb-10.5.24/conf/darwin-slib.def
--- wfdb-10.5.23/conf/darwin-slib.def	2010-07-27 15:02:57.000000000 -0400
+++ wfdb-10.5.24/conf/darwin-slib.def	2015-05-28 15:55:13.000000000 -0400
@@ -1,5 +1,5 @@
 # file: darwin-slib.def	I. Henry and G. Moody	14 November 2002
-#				Last revised:	  27 July 2010
+#				Last revised:	17 September 2014
 # Based on 'freebsd-slib.def'.
 
 # This section contains settings suitable for generating a shared library under
@@ -52,7 +52,7 @@
 
 # LDFLAGS is appended to the C compiler command line to specify loading the
 # WFDB library.
-LDFLAGS = -L$(LIBDIR) -lwfdb $(LL)
+LDFLAGS = -L$(LIBDIR) -lwfdb
 
 # CC is the name of your C compiler.
 CC = gcc
@@ -68,7 +68,7 @@
 
 # CFLAGS is the set of C compiler options used when compiling the shared
 # library.  CFLAGS should always include CCDEFS.
-CFLAGS = $(MFLAGS) -fPIC -fno-common -g -O $(CCDEFS) $(LC) -I$(INCDIR) -arch i386 -arch x86_64 -arch ppc
+CFLAGS = $(MFLAGS) -fPIC -fno-common -g -O $(CCDEFS) $(LC) -I$(INCDIR)
 
 # WFDBLIB_BASENAME is the name, without version numbers, of the alternate
 # library.  WFDBLIB_SONAME is the shared object name ("soname") of the
@@ -93,15 +93,14 @@
 # components have been compiled separately;  the list of *.o files that
 # make up the library will be appended to BUILDLIB.
 BUILDLIB = gcc $(MFLAGS) -dynamiclib \
- -arch i386 -arch x86_64 -arch ppc \
  -install_name $(LIBDIR)/$(WFDBLIB_SONAME) \
  -compatibility_version $(MAJOR).$(MINOR) \
  -current_version $(MAJOR).$(MINOR).$(RELEASE) \
- $(LL) -o $(WFDBLIB)
+ -o $(WFDBLIB)
 
 # BUILDLIB_LDFLAGS is a list of arguments appended to BUILDLIB following
 # the list of *.o files (for most platforms, BUILDLIB_LDFLAGS is empty).
-BUILDLIB_LDFLAGS =
+BUILDLIB_LDFLAGS = $(LL)
 
 # PRINT is the name of the program used to produce listings (including any
 # options for the desired formatting).
diff -Naur --exclude=Makefile wfdb-10.5.23/conf/darwin.def wfdb-10.5.24/conf/darwin.def
--- wfdb-10.5.23/conf/darwin.def	2010-07-27 15:02:30.000000000 -0400
+++ wfdb-10.5.24/conf/darwin.def	2015-05-28 15:55:13.000000000 -0400
@@ -1,5 +1,5 @@
 # file: darwin.def	G. Moody and I. Henry	14 November 2002
-#				Last revised: 	  27 July 2010
+#				Last revised: 	17 September 2014
 # 'make' definitions for compiling the WFDB Software Package under Darwin
 #
 # Based on 'freebsd.def'.
@@ -74,7 +74,7 @@
 
 # CFLAGS is the set of C compiler options.  CFLAGS should always include
 # CCDEFS.
-CFLAGS = $(MFLAGS) -g -O $(CCDEFS) $(LC) -I$(INCDIR) -arch i386 -arch x86_64 -arch ppc
+CFLAGS = $(MFLAGS) -g -O $(CCDEFS) $(LC) -I$(INCDIR)
 
 # LDFLAGS is appended to the C compiler command line to specify loading the
 # WFDB library.
@@ -145,8 +145,12 @@
 # XLIBDIR is the directory in which the X11 libraries are found.
 XLIBDIR = $(XHOME)/lib
 
+# WMFLAGS is the set of architecture-dependend compiler options to use
+# when compiling WAVE.
+WMFLAGS =
+
 # WCFLAGS is the set of C compiler options to use when compiling WAVE.
-WCFLAGS = $(CFLAGS) -I$(OWINCDIR) -I$(XINCDIR) -arch i386
+WCFLAGS = $(WMFLAGS) -g -O $(CCDEFS) $(LC) -I$(INCDIR) -I$(OWINCDIR) -I$(XINCDIR)
 
 # HELPOBJ can be set to "help.o" if you wish to recompile the XView spot help
 # functions in "wave/help.c" (recommended under Linux).
diff -Naur --exclude=Makefile wfdb-10.5.23/conf/freebsd-slib.def wfdb-10.5.24/conf/freebsd-slib.def
--- wfdb-10.5.23/conf/freebsd-slib.def	2010-05-13 11:03:38.000000000 -0400
+++ wfdb-10.5.24/conf/freebsd-slib.def	2015-05-28 15:55:13.000000000 -0400
@@ -1,5 +1,5 @@
 # file: freebsd-slib.def	G. Moody	5 March 2002
-#				Last revised:   13 May 2010
+#				Last revised:  13 August 2014
 # Based on 'linux-slib.def'.
 
 # This section contains settings suitable for generating an ELF-format shared
@@ -50,9 +50,14 @@
 # library.
 LIBDIR = $(WFDBROOT)/lib
 
+# RPATHFLAGS is a set of C compiler options that cause the program to
+# search for shared libraries in a non-standard location at run-time.
+# These options are not needed or useful when using a static library.
+RPATHFLAGS = -Wl,-rpath,$(LIBDIR)
+
 # LDFLAGS is appended to the C compiler command line to specify loading the
 # WFDB library.
-LDFLAGS = -L$(LIBDIR) -lwfdb $(LL)
+LDFLAGS = -L$(LIBDIR) -lwfdb $(RPATHFLAGS)
 
 # CC is the name of your C compiler.
 CC = gcc
@@ -91,12 +96,12 @@
 # BUILDLIB is the command that creates the shared WFDB library once its
 # components have been compiled separately;  the list of *.o files that
 # make up the library will be appended to BUILDLIB.
-BUILDLIB = gcc $(MFLAGS) -shared -Wl,-soname,$(WFDBLIB_SONAME) $(LL) \
+BUILDLIB = $(CC) $(MFLAGS) -shared -Wl,-soname,$(WFDBLIB_SONAME) \
  -o $(WFDBLIB)
 
 # BUILDLIB_LDFLAGS is a list of arguments appended to BUILDLIB following
 # the list of *.o files (for most platforms, BUILDLIB_LDFLAGS is empty).
-BUILDLIB_LDFLAGS =
+BUILDLIB_LDFLAGS = $(LL)
 
 # LDCONFIG is the name of the program needed to refresh the system's cached
 # index of shared libraries.
diff -Naur --exclude=Makefile wfdb-10.5.23/conf/freebsd.def wfdb-10.5.24/conf/freebsd.def
--- wfdb-10.5.23/conf/freebsd.def	2010-05-13 11:03:56.000000000 -0400
+++ wfdb-10.5.24/conf/freebsd.def	2015-05-28 15:55:13.000000000 -0400
@@ -1,5 +1,5 @@
 # file: freebsd.def		G. Moody	5 March 2002
-#				Last revised:   13 May 2010
+#				Last revised:  13 August 2014
 # 'make' definitions for compiling the WFDB Software Package under FreeBSD
 #
 # Based on 'linux.def', with edits for FreeBSD thanks to Giuseppe Pagnoni.
@@ -88,9 +88,14 @@
 # CCDEFS.
 CFLAGS = $(MFLAGS) -g -O $(CCDEFS) $(LC) -I$(INCDIR)
 
+# RPATHFLAGS is a set of C compiler options that cause the program to
+# search for shared libraries in a non-standard location at run-time.
+# These options are not needed or useful when using a static library.
+RPATHFLAGS = -Wl,-rpath,$(LIBDIR)
+
 # LDFLAGS is appended to the C compiler command line to specify loading the
 # WFDB library.
-LDFLAGS = -L$(LIBDIR) -lwfdb $(LDLIBWWW) $(LDLIBCURL)
+LDFLAGS = -L$(LIBDIR) -lwfdb $(LL)
 
 # WFDBLIB is the name of the standard WFDB library.  In order to access it via
 # `-lwfdb', WFDBLIB should be `libwfdb.a'.
diff -Naur --exclude=Makefile wfdb-10.5.23/conf/generic-slib.def wfdb-10.5.24/conf/generic-slib.def
--- wfdb-10.5.23/conf/generic-slib.def	2010-05-13 11:03:00.000000000 -0400
+++ wfdb-10.5.24/conf/generic-slib.def	2015-05-28 15:55:13.000000000 -0400
@@ -1,5 +1,5 @@
 # file: generic-slib.def	G. Moody	31 May 2000
-#				Last revised:   13 May 2010
+#				Last revised:  13 August 2014
 # This section contains settings suitable for compiling a shared version of the
 # WFDB library under versions of UNIX that are not otherwise recognized by
 # 'configure'.  Not all versions of UNIX support shared libraries, so you may
@@ -56,9 +56,14 @@
 # library.
 LIBDIR = $(WFDBROOT)/lib
 
+# RPATHFLAGS is a set of C compiler options that cause the program to
+# search for shared libraries in a non-standard location at run-time.
+# These options are not needed or useful when using a static library.
+RPATHFLAGS = -Wl,-rpath -Wl,$(LIBDIR)
+
 # LDFLAGS is appended to the C compiler command line to specify loading the
 # WFDB library.
-LDFLAGS = -L$(LIBDIR) -lwfdb $(LL)
+LDFLAGS = -L$(LIBDIR) -lwfdb $(RPATHFLAGS) $(LL)
 
 # CC is the name of your C compiler.
 CC = gcc
@@ -112,12 +117,12 @@
 # make up the library will be appended to BUILDLIB.  This command varies
 # considerably depending on the operating system;  the setting here works
 # if gcc and the GNU binutils are installed.
-BUILDLIB = gcc $(MFLAGS) -shared -Wl,-soname,$(SWFDBLIB_SONAME) $(LL) \
+BUILDLIB = gcc $(MFLAGS) -shared -Wl,-soname,$(SWFDBLIB_SONAME) \
  -o $(SWFDBLIB)
 
 # BUILDLIB_LDFLAGS is a list of arguments appended to BUILDLIB following
 # the list of *.o files (for most platforms, BUILDLIB_LDFLAGS is empty).
-BUILDLIB_LDFLAGS =
+BUILDLIB_LDFLAGS = $(LL)
 
 # PRINT is the name of the program used to produce listings (including any
 # options for the desired formatting).
diff -Naur --exclude=Makefile wfdb-10.5.23/conf/generic.def wfdb-10.5.24/conf/generic.def
--- wfdb-10.5.23/conf/generic.def	2010-05-13 11:03:13.000000000 -0400
+++ wfdb-10.5.24/conf/generic.def	2015-05-28 15:55:13.000000000 -0400
@@ -1,5 +1,5 @@
 # file: generic.def		G. Moody	31 May 2000
-#				Last revised:   13 May 2010
+#				Last revised:  13 August 2014
 # This file contains default 'make' definitions for compiling the WFDB Software
 # Package under versions of UNIX that are not otherwise recognized by
 # 'configure'.
@@ -114,6 +114,11 @@
 # `gcc' users may comment out the previous line, and uncomment the next one.
 CFLAGS = $(MFLAGS) -g -O $(CCDEFS) $(LC) -I$(INCDIR)
 
+# RPATHFLAGS is a set of C compiler options that cause the program to
+# search for shared libraries in a non-standard location at run-time.
+# These options are not needed or useful when using a static library.
+RPATHFLAGS = -Wl,-rpath -Wl,$(LIBDIR)
+
 # LDFLAGS is appended to the C compiler command line to specify loading the
 # WFDB library.
 LDFLAGS = -L$(LIBDIR) -lwfdb $(LL)
diff -Naur --exclude=Makefile wfdb-10.5.23/conf/hpux-slib.def wfdb-10.5.24/conf/hpux-slib.def
--- wfdb-10.5.23/conf/hpux-slib.def	2010-05-13 11:02:09.000000000 -0400
+++ wfdb-10.5.24/conf/hpux-slib.def	2015-05-28 15:55:13.000000000 -0400
@@ -1,5 +1,5 @@
 # file: hpux-slib.def	G. Moody	31 May 2000
-#			Last revised:   13 May 2010
+#			Last revised:  13 August 2014
 # This section contains settings suitable for generating a shared library under
 # HP-UX.
 
@@ -52,9 +52,14 @@
 # library.
 LIBDIR = $(WFDBROOT)/lib
 
+# RPATHFLAGS is a set of C compiler options that cause the program to
+# search for shared libraries in a non-standard location at run-time.
+# These options are not needed or useful when using a static library.
+RPATHFLAGS = -Wl,+b -Wl,$(LIBDIR)
+
 # LDFLAGS is appended to the C compiler command line to specify loading the
 # WFDB library.
-LDFLAGS = -L$(LIBDIR) -lwfdb $(LL)
+LDFLAGS = -L$(LIBDIR) -lwfdb $(RPATHFLAGS) $(LL)
 
 # CC is the name of your C compiler.
 CC = gcc
diff -Naur --exclude=Makefile wfdb-10.5.23/conf/hpux.def wfdb-10.5.24/conf/hpux.def
--- wfdb-10.5.23/conf/hpux.def	2010-05-13 11:02:39.000000000 -0400
+++ wfdb-10.5.24/conf/hpux.def	2015-05-28 15:55:13.000000000 -0400
@@ -1,5 +1,5 @@
 # file: hpux.def		G. Moody	31 May 2000
-#				Last revised:   13 May 2010
+#				Last revised:  13 August 2014
 # 'make' definitions for compiling the WFDB library under HP-UX
 
 # Choose a value for WFDBROOT to determine where the WFDB Software Package will
@@ -89,6 +89,11 @@
 # `gcc' users may comment out the previous line, and uncomment the next one.
 CFLAGS = $(MFLAGS) -g -O $(CCDEFS) $(LC) -I$(INCDIR)
 
+# RPATHFLAGS is a set of C compiler options that cause the program to
+# search for shared libraries in a non-standard location at run-time.
+# These options are not needed or useful when using a static library.
+RPATHFLAGS = -Wl,+b -Wl,$(LIBDIR)
+
 # LDFLAGS is appended to the C compiler command line to specify loading the
 # WFDB library.
 LDFLAGS = -L$(LIBDIR) -lwfdb $(LL)
diff -Naur --exclude=Makefile wfdb-10.5.23/conf/linux-slib.def wfdb-10.5.24/conf/linux-slib.def
--- wfdb-10.5.23/conf/linux-slib.def	2014-03-13 15:17:02.000000000 -0400
+++ wfdb-10.5.24/conf/linux-slib.def	2015-05-28 15:55:13.000000000 -0400
@@ -1,5 +1,5 @@
 # file: linux-slib.def		G. Moody	31 May 2000
-#                               Last revised:  13 March 2014
+#                               Last revised:  13 August 2014
 # This section contains settings suitable for generating an ELF-format shared
 # library under Linux.
 
@@ -48,9 +48,14 @@
 # library.
 LIBDIR = $(WFDBROOT)/lib
 
+# RPATHFLAGS is a set of C compiler options that cause the program to
+# search for shared libraries in a non-standard location at run-time.
+# These options are not needed or useful when using a static library.
+RPATHFLAGS = -Wl,--enable-new-dtags,-rpath,$(LIBDIR)
+
 # LDFLAGS is appended to the C compiler command line to specify loading the
 # WFDB library.
-LDFLAGS = -lwfdb $(LL)
+LDFLAGS = -L$(LIBDIR) -lwfdb $(RPATHFLAGS)
 
 # CC is the name of your C compiler.
 CC = gcc
@@ -65,15 +70,6 @@
 # is usually empty.  See the gcc manual for information about gcc's -m options.
 MFLAGS =
 
-# CWLOPT is a set of options for CC to pass to the linker.  Recent versions of
-# gcc/ld do not load shared libraries named on the command line if they are
-# needed only by other shared libraries, unless these options include
-# '-Wl,--no-as-needed';  this is needed to force loading of libcurl or libwww
-# with WFDB applications if the WFDB library was compiled with NETFILES support.
-# Older versions of gcc/ld do not recognize this option, however;  remove it
-# here and in linux-slib.def if your CC doesn't support it.
-CWLOPT = -Wl,--no-as-needed,-rpath,$(LIBDIR)
-
 # CFLAGS is the set of C compiler options used when compiling the shared
 # library.  CFLAGS should always include CCDEFS.
 CFLAGS = $(MFLAGS) -fpic -g -O $(CCDEFS) $(LC) -I$(INCDIR)
diff -Naur --exclude=Makefile wfdb-10.5.23/conf/linux.def wfdb-10.5.24/conf/linux.def
--- wfdb-10.5.23/conf/linux.def	2014-03-13 15:27:29.000000000 -0400
+++ wfdb-10.5.24/conf/linux.def	2015-05-28 15:55:13.000000000 -0400
@@ -1,5 +1,5 @@
 # file: linux.def		G. Moody	31 May 2000
-#				Last revised:  13 March 2014
+#				Last revised:  13 August 2014
 # 'make' definitions for compiling the WFDB Software Package under Linux
 
 # Choose a value for WFDBROOT to determine where the WFDB Software Package will
@@ -71,18 +71,14 @@
 # is usually empty.  See the gcc manual for information about gcc's -m options.
 MFLAGS =
 
-# CWLOPT is a set of options for CC to pass to the linker.  Recent versions of
-# gcc/ld do not load shared libraries named on the command line if they are
-# needed only by other shared libraries, unless these options include
-# '-Wl,--no-as-needed';  this is needed to force loading of libcurl or libwww
-# with WFDB applications if the WFDB library was compiled with NETFILES support.
-# Older versions of gcc/ld do not recognize this option, however;  remove it
-# here and in linux-slib.def if your CC doesn't support it.
-CWLOPT = -Wl,--no-as-needed,-rpath,$(LIBDIR)
-
 # CFLAGS is the set of C compiler options.  CFLAGS should always include
 # CCDEFS.
-CFLAGS = $(MFLAGS) -g -O $(CCDEFS) $(LC) -I$(INCDIR) $(CWLOPT)
+CFLAGS = $(MFLAGS) -g -O $(CCDEFS) $(LC) -I$(INCDIR)
+
+# RPATHFLAGS is a set of C compiler options that cause the program to
+# search for shared libraries in a non-standard location at run-time.
+# These options are not needed or useful when using a static library.
+RPATHFLAGS = -Wl,--enable-new-dtags,-rpath,$(LIBDIR)
 
 # LDFLAGS is appended to the C compiler command line to specify loading the
 # WFDB library.
diff -Naur --exclude=Makefile wfdb-10.5.23/conf/mingw-slib.def wfdb-10.5.24/conf/mingw-slib.def
--- wfdb-10.5.23/conf/mingw-slib.def	2013-11-19 09:14:26.000000000 -0500
+++ wfdb-10.5.24/conf/mingw-slib.def	2015-05-28 15:55:13.000000000 -0400
@@ -1,5 +1,5 @@
 # file: mingw-slib.def		I. Henry and G. Moody	    11 February 2005
-#				Last revised:		    19 November 2013
+#				Last revised:		    18 August 2014
 #
 # This section contains settings suitable for generating a DLL (shared library)
 # under MS Windows using the free gcc ANSI C compiler.
@@ -49,6 +49,10 @@
 # library.  Under Windows, this is the same as BINDIR (above).
 LIBDIR = $(WFDBROOT)/bin
 
+# LDFLAGS is appended to the C compiler command line to specify loading the
+# WFDB library.
+LDFLAGS = -L$(LIBDIR) -lwfdb
+
 # CC is the name of your C compiler ('configure' will modify this).
 CC = gcc NOCYGWIN
 
@@ -128,6 +132,7 @@
 lib-post-install:
 	cd $(LIBDIR); ln -sf $(WFDBLIB) $(WFDBLIB_BASENAME)
 	cd $(LIBDIR); ln -sf $(WFDBLIB) $(WFDBLIB_SONAME)
+	mkdir -p $(BINDIR); $(SETDPERMISSIONS) $(BINDIR)
 	cp $(WFDBLIB_DLLNAME) $(BINDIR)
 
 lib-post-uninstall:
diff -Naur --exclude=Makefile wfdb-10.5.23/conf/solaris-slib.def wfdb-10.5.24/conf/solaris-slib.def
--- wfdb-10.5.23/conf/solaris-slib.def	2010-05-13 10:59:49.000000000 -0400
+++ wfdb-10.5.24/conf/solaris-slib.def	2015-05-28 15:55:13.000000000 -0400
@@ -1,5 +1,5 @@
 # file: solaris-slib.def	G. Moody	31 May 2000
-#				Last revised:   13 May 2010
+#				Last revised:  13 August 2014
 # This section contains settings suitable for generating a shared library under
 # Solaris.
 
@@ -48,9 +48,14 @@
 # library.
 LIBDIR = $(WFDBROOT)/lib
 
+# RPATHFLAGS is a set of C compiler options that cause the program to
+# search for shared libraries in a non-standard location at run-time.
+# These options are not needed or useful when using a static library.
+RPATHFLAGS = -R$(LIBDIR)
+
 # LDFLAGS is appended to the C compiler command line to specify loading the
 # WFDB library.
-LDFLAGS = -L$(LIBDIR) -lwfdb $(LDLIBWWW) $(LDLIBCURL)
+LDFLAGS = -L$(LIBDIR) -lwfdb $(RPATHFLAGS) $(LL)
 
 # CC is the name of your C compiler.
 CC = gcc
diff -Naur --exclude=Makefile wfdb-10.5.23/conf/solaris.def wfdb-10.5.24/conf/solaris.def
--- wfdb-10.5.23/conf/solaris.def	2010-05-13 11:00:07.000000000 -0400
+++ wfdb-10.5.24/conf/solaris.def	2015-05-28 15:55:13.000000000 -0400
@@ -1,5 +1,5 @@
 # file: solaris.def		G. Moody	31 May 2000
-#				Last revised:   13 May 2010
+#				Last revised:  13 August 2014
 # 'make' definitions for compiling the WFDB Software Package under Solaris
 
 # Choose a value for WFDBROOT to determine where the WFDB Software Package will
@@ -83,6 +83,11 @@
 # `gcc' users may comment out the previous line, and uncomment the next one.
 CFLAGS = $(MFLAGS) -g -O $(CCDEFS) $(LC) -I$(INCDIR)
 
+# RPATHFLAGS is a set of C compiler options that cause the program to
+# search for shared libraries in a non-standard location at run-time.
+# These options are not needed or useful when using a static library.
+RPATHFLAGS = -R$(LIBDIR)
+
 # LDFLAGS is appended to the C compiler command line to specify loading the
 # WFDB library.
 LDFLAGS = -L$(LIBDIR) -lwfdb $(LL)
diff -Naur --exclude=Makefile wfdb-10.5.23/configure wfdb-10.5.24/configure
--- wfdb-10.5.23/configure	2014-03-06 02:11:57.000000000 -0500
+++ wfdb-10.5.24/configure	2015-05-28 15:55:13.000000000 -0400
@@ -1,6 +1,6 @@
 #! /bin/sh
 # file: configure             G. Moody         24 May 2000
-#                             Last revised:    6 March 2014
+#                             Last revised:    19 May 2015
 # Configuration script for the WFDB Software Package
 
 # This script was not generated using 'autoconf'.  If you can implement
@@ -17,10 +17,15 @@
 LIBTYPE=dynamic
 DIR=/usr/local
 MANDIR=unknown
+LIBDIR=unknown
+MFLAGS=
 
 NETLIB=unknown
 WAVE=unknown
 
+LC_ALL=C
+export LC_ALL
+
 # Read and process command-line arguments
 for i in $*
 do
@@ -38,6 +43,7 @@
 		        fi ;;
     --mandir=*)         MANDIR=`echo $i | sed 's/[-a-zA-Z0-9]*=//'` ;;
     --prefix=*)         DIR=`echo $i | sed 's/[-a-zA-Z0-9]*=//'` ;;
+    --libdir=*)         LIBDIR=`echo $i | sed 's/[-a-zA-Z0-9]*=//'` ;;
     -q)			;; # ignored
     --shared)           LIBTYPE=dynamic ;;
     --static)           LIBTYPE=static ;;
@@ -165,8 +171,8 @@
 	else
 	    LIB=lib64
             WAVE=0
-	    cat site.def linux-slib.def | sed s+/lib\$+/lib64+g >site-slib.def
-	    cat linux.def | sed s+/lib\$+/lib64+g >>site.def
+	    cat site.def linux-slib.def >site-slib.def
+	    cat linux.def >>site.def
 	fi ;;
   FreeBSD)
 	cat site.def freebsd-slib.def >site-slib.def
@@ -200,8 +206,18 @@
 	    echo "Building static libraries is not supported on Darwin."
 	    LIBTYPE=dynamic
 	fi
-	cat site.def darwin-slib.def >site-slib.def
-	cat darwin.def >>site.def ;;
+        case `uname -m` in
+          x86_64) LMFLAGS="$MFLAGS -arch i386 -arch x86_64"
+                  WMFLAGS="$MFLAGS -arch i386" ;;
+          i386)   LMFLAGS="$MFLAGS -arch i386"
+                  WMFLAGS="$MFLAGS -arch i386" ;;
+          *)      LMFLAGS="$MFLAGS"
+                  WMFLAGS="$MFLAGS" ;;
+        esac
+	cat site.def darwin-slib.def | \
+	    sed "s+^MFLAGS =+MFLAGS = $LMFLAGS+" >site-slib.def
+	cat darwin.def | \
+	    sed "s+^MFLAGS =+MFLAGS = $LMFLAGS+;s+^WMFLAGS =+WMFLAGS = $WMFLAGS+" >>site.def ;;
   *)    OS=generic
 	cat site.def generic-slib.def >site-slib.def
 	cat generic.def >>site.def
@@ -259,6 +275,12 @@
     esac
 else
     SYSLIBS=dynamic
+
+    dynamic_ldflags=`sed -n '/^LDFLAGS =/{s/LDFLAGS = *//;p}' <site-slib.def`
+    if [ "x$dynamic_ldflags" != "x" ]; then
+        sed "s|^LDFLAGS =.*|LDFLAGS = $dynamic_ldflags|" <site.def >site.tmp
+        mv site.tmp site.def
+    fi
 fi
 
 echo
@@ -268,14 +290,14 @@
 then
     WCC="no gcc"
 fi
-if ( echo $WCC | egrep "no |not " >wcc.t1 )
+if ( echo $WCC | egrep "no |not |unknown " >wcc.t1 )
 then
     WCC=`which cc 2>&1`
     if [ "x$WCC" = "x" ]
     then
         WCC="no cc"
     fi
-    if ( echo $WCC | egrep "no |not " >wcc.t2 )
+    if ( echo $WCC | egrep "no |not |unknown " >wcc.t2 )
     then
         echo "not found"
 	echo
@@ -338,6 +360,34 @@
 
 echo  "The WFDB software will be installed in '$DIR'."
 
+if [ x$LIBDIR = xunknown ]
+then
+    case $OS in
+      Linux*)
+            cpu=`uname -m`
+            nativelibdirs=`$CC -print-search-dirs | sed -n '/^libraries:/{s/^[^=]*=//; s/:/\n/g; p}' | sed ':LP; s+/[^/]*/\.\./+/+; tLP; s+/$++'`
+            if [ "$cpu" = "x86_64" ] && echo "$nativelibdirs" | grep -q "^$DIR/lib64"; then
+                if [ "x$MFLAGS" = "x-m32" ]; then
+                    LIB=lib
+                else
+                    LIB=lib64
+                fi
+            else
+                if [ "x$MFLAGS" = "x-m32" ]; then
+                    LIB=lib32
+                else
+                    LIB=lib
+                fi
+            fi ;;
+    esac
+    LIBDIR="\$(WFDBROOT)/$LIB"
+fi
+sed "s+^LIBDIR = .*+LIBDIR = $LIBDIR+" <site.def >site.tmp
+mv site.tmp site.def
+sed "s+^LIBDIR = .*+LIBDIR = $LIBDIR+" <site-slib.def >site.tmp
+mv site.tmp site-slib.def
+xlibdir=`echo "$LIBDIR" | sed 's+$(WFDBROOT)+'"$DIR"+`
+
 MANTMP=`grep "MANDIR =" site.def |sed 's+$(WFDBROOT)/++' |cut -d " " -f 3`
 MANDEF=$DIR/$MANTMP
 if [ x$MANDIR = xunknown ]
@@ -391,7 +441,7 @@
 	then
 	WHICH="no curl-config"
     fi
-    if ( echo $WHICH | egrep "no |not " >which.t1 )
+    if ( echo $WHICH | egrep "no |not |unknown " >which.t1 )
 	then
 	echo "not found"
 	./prompt "Looking for libwww ..."
@@ -400,7 +450,7 @@
 	    then
 	    WHICH="no libwww-config"
 	fi
-	if ( echo $WHICH | egrep "no |not " >which.t2 )
+	if ( echo $WHICH | egrep "no |not |unknown " >which.t2 )
 	    then
 	    echo "not found"
 	    echo "The WFDB software will be compiled without NETFILES"
@@ -482,6 +532,12 @@
   fi
 done
 
+# Create output directories for documentation
+for D in doc/wag doc/wpg doc/wug
+do
+    [ -d $D ] || mkdir $D
+done
+
 echo rm conf/site.def conf/site-slib.def
 
 if [ "x$WAVE" = "x0" ]
@@ -516,7 +572,7 @@
 	WAVE=1;
 	sed "s+/usr/openwin+/usr+" <wave/Makefile >tmp.$$
 	mv tmp.$$ wave/Makefile
-    elif ( echo $TEXTEDIT | egrep "no |not " >textedit.t1 )
+    elif ( echo $TEXTEDIT | egrep "no |not |unknown " >textedit.t1 )
     then
 	WAVE=0;
     else
@@ -603,7 +659,7 @@
 
 $PACKAGE-$OS is now ready to be compiled using '$CC'.
 The WFDB library will be compiled as a $LIBTYPE library $WITHNF NETFILES
- access${VIANF}, and it will be installed in '$DIR/$LIB'.
+ access${VIANF}, and it will be installed in '$xlibdir'.
 The WFDB library .h files will be installed in '$DIR/include/wfdb'.
 The WFDB applications will be linked to $SYSLIBS system libraries, and
  they will be installed in '$DIR/bin'.
diff -Naur --exclude=Makefile wfdb-10.5.23/convert/wfdb2mat.c wfdb-10.5.24/convert/wfdb2mat.c
--- wfdb-10.5.23/convert/wfdb2mat.c	2013-12-08 11:53:54.000000000 -0500
+++ wfdb-10.5.24/convert/wfdb2mat.c	2015-05-28 15:55:13.000000000 -0400
@@ -326,7 +326,9 @@
     }
 
     /* Create the new header file. */
-    setbasetime(mstimstr(-from)+1);
+    p = mstimstr(-from);
+    if (p && *p == '[')
+	setbasetime(p+1);
     newheader(orec);
 
     /* Copy info from the old record, if any */
diff -Naur --exclude=Makefile wfdb-10.5.23/data/wfdbcal wfdb-10.5.24/data/wfdbcal
--- wfdb-10.5.23/data/wfdbcal	2012-08-09 23:27:29.000000000 -0400
+++ wfdb-10.5.24/data/wfdbcal	2015-05-28 15:55:13.000000000 -0400
@@ -1,5 +1,5 @@
 # file: wfdbcal		G. Moody	  June 1991
-#			Last revised:   31 July 2012
+#			Last revised:  21 January 2014
 # Default calibration database for WFDB library
 #
 # Format:
@@ -60,9 +60,6 @@
 V	- 2 square 1 mV
 PLETH	- - undefined 1 mV
 
-# Miscellaneous pressure signals in the MIMIC Database
-P	- - undefined 100 mmHg
-
 # ECG from implanted devices
 Atip	- - undefined 1 mV
 HVA	- - undefined 5 mV
@@ -76,10 +73,17 @@
 Abdomen	- - undefined 200 uV
 FECG	- - undefined 1 mV
 Direct	- - undefined 200 uV
+FHR	0 - undefined 20 bpm
+
+# Uterine contractions
+UC	- - undefined 50 nd
 
 # Intracardiac electrograms
 CS	- - undefined 1 mV
 
+# Phonocardiogram
+PCG	- - undefined 10000 mV
+
 # EEG
 F	- - undefined 100 uV
 C	- - undefined 100 uV
@@ -89,6 +93,9 @@
 O	- - undefined 100 uV
 I	- - undefined 100 uV
 
+# Miscellaneous pressure signals in the MIMIC Database
+P	- - undefined 100 mmHg
+
 # Definitions for nameless signals with defined units
 record	- - undefined 1 mV
 record  - - undefined 1000 uV
diff -Naur --exclude=Makefile wfdb-10.5.23/doc/wag-src/Makefile.top wfdb-10.5.24/doc/wag-src/Makefile.top
--- wfdb-10.5.23/doc/wag-src/Makefile.top	2001-12-20 16:05:34.000000000 -0500
+++ wfdb-10.5.24/doc/wag-src/Makefile.top	2015-05-28 15:55:13.000000000 -0400
@@ -52,9 +52,9 @@
 # formats from the sources in in this directory.  Here is a brief list of
 # available formats and the commands needed to produce them:
 
-# printed copy	'make wag-book'(requires troff, tbl, latex, dvips, & a printer)
 # HTML		'make wag.html'(requires rman, latex2html, and perl)
 # man pages	'make wag.man'
-# PDF		'make wag.pdf' (requires troff, tbl, latex, dvips, and ps2pdf)
-# PostScript	'make wag.ps'  (requires troff, tbl, latex, and dvips)
+# PDF		'make wag.pdf' (requires troff, tbl, pdflatex, ps2pdf, pdftk)
+# PostScript	'make wag.ps'  (requires the above tools plus pdftops)
+# printed copy	'make wag-book'(requires the above tools plus a printer)
 # _____________________________________________________________________________
diff -Naur --exclude=Makefile wfdb-10.5.23/doc/wag-src/Makefile.tpl wfdb-10.5.24/doc/wag-src/Makefile.tpl
--- wfdb-10.5.23/doc/wag-src/Makefile.tpl	2014-03-13 12:45:41.000000000 -0400
+++ wfdb-10.5.24/doc/wag-src/Makefile.tpl	2015-05-28 15:55:13.000000000 -0400
@@ -1,5 +1,5 @@
 # file: Makefile.tpl		G. Moody	 24 May 2000
-#				Last revised:	13 March 2014
+#				Last revised:	  8 May 2015
 # Change the settings below as appropriate for your setup.
 
 # D2PARGS is a list of options for dvips.  Uncomment one of these to set the
@@ -153,7 +153,7 @@
 	./maketoc-tex.sh >wag1.toc		# TOC, wag3.pdf, wag4.pdf
 	sed 's/VERSION/$(VERSION)/' <wag.tex | \
 	  sed 's/LONGDATE/$(LONGDATE)/' >wag1.tex
-	pdflatex wag1				# front matter
+	pdflatex '\nonstopmode\input{wag1}'	# front matter
 
 wag2.pdf:
 	tbl *.1 *.3 *.5 | $(TROFF) $(TMAN) >wag2.ps	# man pages
@@ -162,12 +162,12 @@
 wag3.pdf:	install.tex
 	sed "s/LONGDATE/$(LONGDATE)/" <install.tex | \
 	  sed "s/VERSION/$(VERSION)/" >wag3.tex
-	pdflatex wag3
+	pdflatex '\nonstopmode\input{wag3}'
 
 wag4.pdf:	eval.tex
 	sed "s/LONGDATE/$(LONGDATE)/" <eval.tex | \
 	  sed "s/VERSION/$(VERSION)/" >wag4.tex
-	pdflatex wag4
+	pdflatex '\nonstopmode\input{wag4}'
 
 # 'make clean': remove intermediate and backup files
 clean:
diff -Naur --exclude=Makefile wfdb-10.5.23/doc/wag-src/wabp.1 wfdb-10.5.24/doc/wag-src/wabp.1
--- wfdb-10.5.23/doc/wag-src/wabp.1	2011-11-07 12:20:24.000000000 -0500
+++ wfdb-10.5.24/doc/wag-src/wabp.1	2015-05-28 15:55:14.000000000 -0400
@@ -78,6 +78,10 @@
 .SH SEE ALSO
 \fBbxb\fR(1), \fBecgpuwave\fR(1), \fBrdann\fR(1), \fBsetwfdb\fR(1),
 \fBsqrs\fR(1), \fBwqrs\fR(1)
+.PP
+Zong W, Heldt T, Moody GB, and Mark RG.
+An open-source algorithm to detect onset of arterial blood pressure pulses.
+\fIComputers in Cardiology\fR \fB30\fR:259\-262 (2003).
 .SH AUTHORS
 Wei Zong (wzong@mit.edu) and George B. Moody (george@mit.edu).
 .SH SOURCE
diff -Naur --exclude=Makefile wfdb-10.5.23/doc/wag-src/wqrs.1 wfdb-10.5.24/doc/wag-src/wqrs.1
--- wfdb-10.5.23/doc/wag-src/wqrs.1	2009-01-07 15:12:34.000000000 -0500
+++ wfdb-10.5.24/doc/wag-src/wqrs.1	2015-05-28 15:55:14.000000000 -0400
@@ -100,6 +100,11 @@
 .SH SEE ALSO
 \fBbxb\fR(1), \fBecgpuwave\fR(1), \fBrdann\fR(1), \fBsetwfdb\fR(1),
 \fBsqrs\fR(1)
+.PP
+Zong W, Moody GB, and Jiang D.
+A robust open-source algorithm to detect onset and duration of QRS
+complexes.
+\fIComputers in Cardiology\fR \fB30\fR:737\-740 (2003).
 .SH AUTHORS
 Wei Zong (wzong@mit.edu) and George B. Moody (george@mit.edu).
 .SH SOURCE
diff -Naur --exclude=Makefile wfdb-10.5.23/doc/wug-src/Makefile.tpl wfdb-10.5.24/doc/wug-src/Makefile.tpl
--- wfdb-10.5.23/doc/wug-src/Makefile.tpl	2014-03-13 14:30:37.000000000 -0400
+++ wfdb-10.5.24/doc/wug-src/Makefile.tpl	2015-05-28 15:55:15.000000000 -0400
@@ -1,5 +1,5 @@
 # file: Makefile.tpl		G. Moody	  24 May 2000
-#				Last revised:	 13 March 2014
+#				Last revised:	   8 May 2015
 # Change the settings below as appropriate for your setup.
 
 # Set COLORS to 'color' if you have a color printer and would like to print
@@ -94,21 +94,21 @@
 	# convert does not do a great job on them, but the results are
 	# at least recognizable!
 	rm -f wug.aux wug.idx wug.ind wug.toc
-	pdflatex wug
+	pdflatex '\nonstopmode\input{wug}'
 	makeindex wug.idx
-	pdflatex wug
+	pdflatex '\nonstopmode\input{wug}'
 	makeindex wug.idx
-	pdflatex wug
+	pdflatex '\nonstopmode\input{wug}'
 
 # 'make wug.ps': format the WAVE User's Guide as PostScript
 wug.ps:		wug.tex
 	wave/scripts/wugfigures -$(COLORS)	# get a set of figures
 	rm -f wug.aux wug.idx wug.ind wug.toc
-	latex wug
+	latex '\nonstopmode\input{wug}'
 	makeindex wug.idx
-	latex wug
+	latex '\nonstopmode\input{wug}'
 	makeindex wug.idx
-	latex wug
+	latex '\nonstopmode\input{wug}'
 	dvips $(D2PARGS) -o wug.ps wug.dvi
 
 # 'wug.aux' is created by 'latex wug' or 'pdflatex wug' (which make slightly
diff -Naur --exclude=Makefile wfdb-10.5.23/lib/Makefile.tpl wfdb-10.5.24/lib/Makefile.tpl
--- wfdb-10.5.23/lib/Makefile.tpl	2014-03-01 13:52:06.000000000 -0500
+++ wfdb-10.5.24/lib/Makefile.tpl	2015-05-28 15:55:16.000000000 -0400
@@ -1,5 +1,5 @@
 # file: Makefile.tpl		G. Moody	  24 May 2000
-#				Last revised:     1 March 2014
+#				Last revised:    14 August 2014
 # This section of the Makefile should not need to be changed.
 
 INCLUDES = $(INCDIR)/wfdb/wfdb.h $(INCDIR)/wfdb/wfdblib.h \
@@ -14,9 +14,10 @@
 	$(BUILDLIB) $(OFILES) $(BUILDLIB_LDFLAGS)
 
 # `make install':  install the WFDB library and headers
-install:	$(INCLUDES) $(LIBDIR)
+install:
 	$(MAKE) clean	    # force recompilation since config may have changed
 	$(MAKE) all
+	$(MAKE) $(INCLUDES) $(LIBDIR)
 	cp $(WFDBLIB) $(LIBDIR) 
 	$(SETLPERMISSIONS) $(LIBDIR)/$(WFDBLIB)
 	$(MAKE) lib-post-install 2>/dev/null
@@ -71,4 +72,4 @@
 calib.o:	wfdb.h wfdblib.h calib.c
 wfdbio.o:	wfdb.h wfdblib.h wfdbio.c
 	$(CC) $(CFLAGS) -DVERSION='"$(VERSION)"' -DCFLAGS='"-I$(INCDIR)"' \
-	  -DLDFLAGS='"-L$(LIBDIR) -lwfdb $(CWLOPT) $(LL)"' -c wfdbio.c
\ No newline at end of file
+	  -DLDFLAGS='"$(LDFLAGS)"' -c wfdbio.c
diff -Naur --exclude=Makefile wfdb-10.5.23/lib/annot.c wfdb-10.5.24/lib/annot.c
--- wfdb-10.5.23/lib/annot.c	2013-11-21 10:18:40.000000000 -0500
+++ wfdb-10.5.24/lib/annot.c	2015-05-28 15:55:16.000000000 -0400
@@ -1,5 +1,5 @@
 /* file: annot.c	G. Moody       	 13 April 1989
-			Last revised:  18 November 2013		wfdblib 10.5.21
+			Last revised:   1 January 2015  	wfdblib 10.5.24
 WFDB library functions for annotations
 
 _______________________________________________________________________________
@@ -228,9 +228,16 @@
     annot.anntyp = NOTE;
     annot.subtyp = annot.chan = annot.num = 0;
     annot.aux = (unsigned char *)buf;
+    if (oafreq != oad[i]->afreq && oafreq > 0.) {
+	(void)sprintf(buf+1, "## time resolution: %.12g", oafreq);
+	buf[0] = strlen(buf+1);
+	oad[i]->afreq = oafreq;
+	if (putann(i, &annot) < 0) return (-1);
+	flag = 1;
+    }
     for (a = 0; a <= ACMAX; a++)
 	if (modified[a]) {
-	    if (flag == 0) { /* mark the beginning of the table */
+	    if (flag < 2) { /* mark the beginning of the table */
 		(void)sprintf(buf+1, "## annotation type definitions");
 		buf[0] = strlen(buf+1);
 		if (putann(i, &annot) < 0) return (-1);
@@ -238,21 +245,14 @@
 	    (void)sprintf(buf+1, "%d %s %s", a, annstr(a), anndesc(a));
 	    buf[0] = strlen(buf+1);
 	    if (putann(i, &annot) < 0) return (-1);
-	    flag = 1;
+	    flag = 2;
 	}
-    if (flag) {	/* if a table was written, mark its end */
+    if (flag == 2) {	/* if a table was written, mark its end */
 	(void)sprintf(buf+1, "## end of definitions");
 	buf[0] = strlen(buf+1);
 	if (putann(i, &annot) < 0) return (-1);
     }
 
-    if (oafreq != oad[i]->afreq && oafreq > 0.) {
-	(void)sprintf(buf+1, "## time resolution: %.12g", oafreq);
-	buf[0] = strlen(buf+1);
-	oad[i]->afreq = oafreq;
-	if (putann(i, &annot) < 0) return (-1);
-	flag = 1;
-    }
     if (flag) {	/* if a table was written, mark its end */
 	annot.anntyp = 0;
 	annot.aux = NULL;
diff -Naur --exclude=Makefile wfdb-10.5.23/lib/wfdb.h wfdb-10.5.24/lib/wfdb.h
--- wfdb-10.5.23/lib/wfdb.h	2014-03-13 15:39:40.000000000 -0400
+++ wfdb-10.5.24/lib/wfdb.h	2015-05-28 15:59:01.000000000 -0400
@@ -1,5 +1,5 @@
 /* file: wfdb.h		G. Moody	13 June 1983
-			Last revised: 18 November 2013		wfdblib 10.5.21
+			Last revised:    21 May 2015 		wfdblib 10.5.24
 WFDB library type, constant, structure, and function interface definitions
 _______________________________________________________________________________
 wfdb: a library for reading and writing annotated waveforms (time series data)
@@ -32,7 +32,7 @@
 /* WFDB library version. */
 #define WFDB_MAJOR   10
 #define WFDB_MINOR   5
-#define WFDB_RELEASE 23
+#define WFDB_RELEASE 24
 #define WFDB_NETFILES 1	/* if 1, library includes code for HTTP, FTP clients */
 #define WFDB_NETFILES_LIBCURL 1
 
@@ -40,7 +40,6 @@
 #ifdef __STDC__		/* true for ANSI C compilers only */
 #define wfdb_PROTO	/* function prototypes will be needed */
 #undef _WINDOWS		/* we don't want MS-Windows API in this case */
-#undef _WIN32		/* ... or 32-bit MS-Windows API either */
 #endif
 
 #ifdef __cplusplus	/* true for some C++ compilers */
@@ -215,8 +214,9 @@
 	 SALLOC(P, (size_t)strlen(Q)+1,1); strcpy(P, Q); } }
 
 /* Function types */
-#ifndef _WINDOWS	/* for everything *except* MS Windows applications */
+#ifndef _WINDLL	/* for everything *except* MS Windows applications */
 typedef char *FSTRING;
+typedef const char *FCONSTSTRING;
 typedef WFDB_Date FDATE;
 typedef double FDOUBLE;
 typedef WFDB_Frequency FFREQUENCY;
@@ -229,6 +229,7 @@
 #ifndef _WIN32	/* for 16-bit MS Windows applications using the WFDB DLL */
   /* typedefs don't work properly with _far or _pascal -- must use #defines */
 #define FSTRING char _far * _pascal
+#define FCONSTSTRING const char _far * _pascal
 #define FDATE WFDB_Date _far _pascal
 #define FDOUBLE double _far _pascal
 #define FFREQUENCY WFDB_Frequency _far _pascal
@@ -242,6 +243,7 @@
 #define CALLBACK __stdcall	/* from windef.h */
 #endif
 #define FSTRING __declspec (dllexport) char * CALLBACK
+#define FCONSTSTRING __declspec (dllexport) const char * CALLBACK
 #define FDATE __declspec (dllexport) WFDB_Date CALLBACK
 #define FDOUBLE __declspec (dllexport) double CALLBACK
 #define FFREQUENCY __declspec (dllexport) WFDB_Frequency CALLBACK
@@ -357,11 +359,11 @@
 extern FSTRING wfdbfile(char *file_type, char *record);
 extern FVOID wfdbflush(void);
 extern FVOID wfdbmemerr(int exit_on_error);
-extern const FSTRING wfdbversion(void);
-extern const FSTRING wfdbldflags(void);
-extern const FSTRING wfdbcflags(void);
-extern const FSTRING wfdbdefwfdb(void);
-extern const FSTRING wfdbdefwfdbcal(void);
+extern FCONSTSTRING wfdbversion(void);
+extern FCONSTSTRING wfdbldflags(void);
+extern FCONSTSTRING wfdbcflags(void);
+extern FCONSTSTRING wfdbdefwfdb(void);
+extern FCONSTSTRING wfdbdefwfdbcal(void);
 #endif
 
 #ifdef wfdb_CPP
diff -Naur --exclude=Makefile wfdb-10.5.23/lib/wfdb.h0 wfdb-10.5.24/lib/wfdb.h0
--- wfdb-10.5.23/lib/wfdb.h0	2013-11-21 10:18:29.000000000 -0500
+++ wfdb-10.5.24/lib/wfdb.h0	2015-05-28 15:55:16.000000000 -0400
@@ -1,5 +1,5 @@
 /* file: wfdb.h		G. Moody	13 June 1983
-			Last revised: 18 November 2013		wfdblib 10.5.21
+			Last revised:    21 May 2015 		wfdblib 10.5.24
 WFDB library type, constant, structure, and function interface definitions
 _______________________________________________________________________________
 wfdb: a library for reading and writing annotated waveforms (time series data)
@@ -40,7 +40,6 @@
 #ifdef __STDC__		/* true for ANSI C compilers only */
 #define wfdb_PROTO	/* function prototypes will be needed */
 #undef _WINDOWS		/* we don't want MS-Windows API in this case */
-#undef _WIN32		/* ... or 32-bit MS-Windows API either */
 #endif
 
 #ifdef __cplusplus	/* true for some C++ compilers */
@@ -215,8 +214,9 @@
 	 SALLOC(P, (size_t)strlen(Q)+1,1); strcpy(P, Q); } }
 
 /* Function types */
-#ifndef _WINDOWS	/* for everything *except* MS Windows applications */
+#ifndef _WINDLL	/* for everything *except* MS Windows applications */
 typedef char *FSTRING;
+typedef const char *FCONSTSTRING;
 typedef WFDB_Date FDATE;
 typedef double FDOUBLE;
 typedef WFDB_Frequency FFREQUENCY;
@@ -229,6 +229,7 @@
 #ifndef _WIN32	/* for 16-bit MS Windows applications using the WFDB DLL */
   /* typedefs don't work properly with _far or _pascal -- must use #defines */
 #define FSTRING char _far * _pascal
+#define FCONSTSTRING const char _far * _pascal
 #define FDATE WFDB_Date _far _pascal
 #define FDOUBLE double _far _pascal
 #define FFREQUENCY WFDB_Frequency _far _pascal
@@ -242,6 +243,7 @@
 #define CALLBACK __stdcall	/* from windef.h */
 #endif
 #define FSTRING __declspec (dllexport) char * CALLBACK
+#define FCONSTSTRING __declspec (dllexport) const char * CALLBACK
 #define FDATE __declspec (dllexport) WFDB_Date CALLBACK
 #define FDOUBLE __declspec (dllexport) double CALLBACK
 #define FFREQUENCY __declspec (dllexport) WFDB_Frequency CALLBACK
@@ -357,11 +359,11 @@
 extern FSTRING wfdbfile(char *file_type, char *record);
 extern FVOID wfdbflush(void);
 extern FVOID wfdbmemerr(int exit_on_error);
-extern const FSTRING wfdbversion(void);
-extern const FSTRING wfdbldflags(void);
-extern const FSTRING wfdbcflags(void);
-extern const FSTRING wfdbdefwfdb(void);
-extern const FSTRING wfdbdefwfdbcal(void);
+extern FCONSTSTRING wfdbversion(void);
+extern FCONSTSTRING wfdbldflags(void);
+extern FCONSTSTRING wfdbcflags(void);
+extern FCONSTSTRING wfdbdefwfdb(void);
+extern FCONSTSTRING wfdbdefwfdbcal(void);
 #endif
 
 #ifdef wfdb_CPP
diff -Naur --exclude=Makefile wfdb-10.5.23/lib/wfdbio.c wfdb-10.5.24/lib/wfdbio.c
--- wfdb-10.5.23/lib/wfdbio.c	2013-11-19 12:23:56.000000000 -0500
+++ wfdb-10.5.24/lib/wfdbio.c	2015-05-28 15:55:16.000000000 -0400
@@ -1,5 +1,5 @@
 /* file: wfdbio.c	G. Moody	18 November 1988
-                        Last revised:   18 November 2013       wfdblib 10.5.21
+                        Last revised:   22 May 2015       wfdblib 10.5.24
 Low-level I/O functions for the WFDB library
 
 _______________________________________________________________________________
@@ -79,6 +79,8 @@
 These functions, defined here if WFDB_NETFILES is non-zero, are intended only
 for the use of the functions in the next group below (their definitions are not
 visible outside of this file):
+ www_parse_passwords	(load username/password information)
+ www_userpwd		(get username/password for a given url)
  wfdb_wwwquit		(shut down libcurl or libwww cleanly)
  www_init		(initialize libcurl or libwww)
  www_get_cont_len	(find length of data for a given url)
@@ -265,27 +267,27 @@
 #define CFLAGS  "CFLAGS not defined"
 #endif
 
-const FSTRING wfdbversion(void)
+FCONSTSTRING wfdbversion(void)
 {
    return VERSION;
 }
 
-const FSTRING wfdbldflags(void)
+FCONSTSTRING wfdbldflags(void)
 {
    return LDFLAGS;
 }
 
-const FSTRING wfdbcflags(void)
+FCONSTSTRING wfdbcflags(void)
 {
    return CFLAGS;
 }
 
-const FSTRING wfdbdefwfdb(void)
+FCONSTSTRING wfdbdefwfdb(void)
 {
    return DEFWFDB;
 }
 
-const FSTRING wfdbdefwfdbcal(void)
+FCONSTSTRING wfdbdefwfdbcal(void)
 {
    return DEFWFDBCAL;
 }
@@ -744,7 +746,7 @@
     va_list arguments;
 
     va_start(arguments, format);
-#ifndef _WINDOWS		/* standard variant: use stderr output */
+#if 1				/* standard variant: use stderr output */
     (void)vsprintf(error_message, format, arguments);
     if (error_print) {
 	(void)fprintf(stderr, "%s", error_message);
@@ -1241,13 +1243,84 @@
 #define chunk_putb HTChunk_putb
 #endif
 
+static char **passwords;
+
+/* www_parse_passwords parses the WFDBPASSWORD environment variable.
+This environment variable contains a list of URL prefixes and
+corresponding usernames/passwords.  Alternatively, the environment
+variable may contain '@' followed by the name of a file containing
+password information.
+
+Each item in the list consists of a URL prefix, followed by a space,
+then the username and password separated by a colon.  For example,
+setting WFDBPASSWORD to "https://example.org john:letmein" would use
+the username "john" and the password "letmein" for all HTTPS requests
+to example.org.
+
+If there are multiple items in the list, they must be separated by
+end-of-line or tab characters. */
+static void www_parse_passwords(const char *str)
+{
+    static char sep[] = "\t\n\r";
+    char *xstr = NULL, *p, *q;
+    int n;
+
+    SSTRCPY(xstr, str);
+    if (!xstr)
+	return;
+    if (*xstr == '@')
+	xstr = wfdb_getiwfdb(xstr);
+
+    SALLOC(passwords, 1, sizeof(char *));
+    n = 0;
+    for (p = strtok(xstr, sep); p; p = strtok(NULL, sep)) {
+	if (!(q = strchr(p, ' ')) || !strchr(q, ':'))
+	    continue;
+	SREALLOC(passwords, n + 2, sizeof(char *));
+	if (!passwords)
+	    return;
+	SSTRCPY(passwords[n], p);
+	n++;
+    }
+    passwords[n] = NULL;
+
+    SFREE(xstr);
+}
+
+/* www_userpwd determines which username/password should be used for a
+given URL.  It returns a string of the form "username:password" if one
+is defined, or returns NULL if no login information is required for
+that URL. */
+static const char *www_userpwd(const char *url)
+{
+    int i, n;
+    const char *p;
+
+    for (i = 0; passwords && passwords[i]; i++) {
+	p = strchr(passwords[i], ' ');
+	if (!p || p == passwords[i])
+	    continue;
+
+	n = p - passwords[i];
+	if (strncmp(passwords[i], url, n) == 0 &&
+	    (url[n] == 0 || url[n] == '/' || url[n - 1] == '/')) {
+	    return &passwords[i][n + 1];
+	}
+    }
+
+    return NULL;
+}
+
 static void wfdb_wwwquit(void)
 {
+    int i;
     if (www_done_init) {
 #if WFDB_NETFILES_LIBCURL
+# ifndef _WINDOWS
 	curl_easy_cleanup(curl_ua);
 	curl_ua = NULL;
 	curl_global_cleanup();
+# endif
 #else
 #ifdef USEHTCACHE
 	HTCacheTerminate();
@@ -1255,13 +1328,16 @@
 	HTProfile_delete();
 #endif
 	www_done_init = FALSE;
+	for (i = 0; passwords && passwords[i]; i++)
+	    SFREE(passwords[i]);
+	SFREE(passwords);
     }
 }
 
 static void www_init(void)
 {
     if (!www_done_init) {
-	char *p, *u, version[20];
+	char *p, version[20];
 
 	if ((p = getenv("WFDB_PAGESIZE")) && *p)
 	    page_size = strtol(p, NULL, 10);
@@ -1280,22 +1356,20 @@
 	/* Search $HOME/.netrc for passwords */
 	curl_easy_setopt(curl_ua, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
 #endif
-	/* Get user name and password from the environment if available */
-	if ((u = getenv("PNWUSER")) && *u &&
-	    (p = getenv("PNWPASS")) && *p) {
-	    char *userpwd = (char *)malloc(strlen(u) + strlen(p) + 2);
-	    sprintf(userpwd, "%s:%s", u, p);
-	    curl_easy_setopt(curl_ua, CURLOPT_USERPWD, userpwd);
-	    for (p = userpwd; *p; p++)
-		*p = ' ';
-	    free(userpwd);
-	}
+	/* Get password information from the environment if available */
+	if ((p = getenv("WFDBPASSWORD")) && *p)
+            www_parse_passwords(p);
+
+	/* Get the name of the CA bundle file */
+	if ((p = getenv("CURL_CA_BUNDLE")) && *p)
+	    curl_easy_setopt(curl_ua, CURLOPT_CAINFO, p);
 
 	/* Use any available authentication method */
 	curl_easy_setopt(curl_ua, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
-	/* (Uncomment this line to enable tons of debugging
-	   information from libcurl) */
-	/* curl_easy_setopt(curl_ua, CURLOPT_VERBOSE, 1L); */
+
+	/* Show details of URL requests if WFDB_NET_DEBUG is set */
+	if ((p = getenv("WFDB_NET_DEBUG")) && *p)
+	    curl_easy_setopt(curl_ua, CURLOPT_VERBOSE, 1L);
 #else
 
 #ifdef USEHTCACHE
@@ -1355,6 +1429,9 @@
 	curl_try(curl_easy_setopt(curl_ua, CURLOPT_NOBODY, 1L))
 	/* Set the URL to retrieve */
 	|| curl_try(curl_easy_setopt(curl_ua, CURLOPT_URL, url))
+	/* Set username/password */
+	|| curl_try(curl_easy_setopt(curl_ua, CURLOPT_USERPWD,
+	                             www_userpwd(url)))
 	/* Don't send a range request */
 	|| curl_try(curl_easy_setopt(curl_ua, CURLOPT_RANGE, NULL))
 	/* If any body data is received, ignore it */
@@ -1467,6 +1544,9 @@
 	    || curl_try(curl_easy_setopt(curl_ua, CURLOPT_HTTPGET, 1L))
 	    /* URL to retrieve */
 	    || curl_try(curl_easy_setopt(curl_ua, CURLOPT_URL, url))
+	    /* Set username/password */
+	    || curl_try(curl_easy_setopt(curl_ua, CURLOPT_USERPWD,
+	                                 www_userpwd(url)))
 	    /* Range request */
 	    || curl_try(curl_easy_setopt(curl_ua, CURLOPT_RANGE,
 					 range_req_str))
diff -Naur --exclude=Makefile wfdb-10.5.23/lib/wfdblib.h wfdb-10.5.24/lib/wfdblib.h
--- wfdb-10.5.23/lib/wfdblib.h	2014-03-13 15:27:51.000000000 -0400
+++ wfdb-10.5.24/lib/wfdblib.h	2015-05-28 15:58:55.000000000 -0400
@@ -96,9 +96,9 @@
    variable is not set.  This value is edited by the configuration script
    (../configure), which also edits this block of comments to match.
 
-   If WFDB_NETFILES support is disabled, the string ". /home/george/database" is
+   If WFDB_NETFILES support is disabled, the string ". /usr/local/database" is
    usually sufficient for a default WFDB path, thus restricting the search for
-   WFDB files to the current directory ("."), followed by /home/george/database).
+   WFDB files to the current directory ("."), followed by /usr/local/database).
    
    If WFDB_NETFILES support is enabled, the first setting below adds the
    web-accessible PhysioBank databases to the default path; you may wish to
@@ -107,9 +107,9 @@
 */
 
 #ifndef WFDB_NETFILES
-# define DEFWFDB	". /home/george/database"
+# define DEFWFDB	". /usr/local/database"
 #else
-# define DEFWFDB ". /home/george/database http://physionet.org/physiobank/database"
+# define DEFWFDB ". /usr/local/database http://physionet.org/physiobank/database"
 #endif
 
 /* Mac OS 9 and earlier, only:  The value of DEFWFDB given below specifies
