diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/app/pschart.c wfdb-10.3.17/app/pschart.c
--- wfdb-10.3.16/app/pschart.c	2004-05-04 16:49:05.000000000 -0400
+++ wfdb-10.3.17/app/pschart.c	2005-08-11 17:56:18.000000000 -0400
@@ -1,9 +1,9 @@
 /* file: pschart.c	G. Moody       15 March 1988
-			Last revised:	 4 May 2004
+			Last revised:  11 August 2005
 
 -------------------------------------------------------------------------------
 pschart: Produce annotated `chart recordings' on a PostScript device
-Copyright (C) 1988-2004 George B. Moody
+Copyright (C) 1988-2005 George B. Moody
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -83,6 +83,7 @@
 
 /* Configuration parameters (changeable only by recompiling) */
 #define DPI	 300.0		/* default printer resolution (dots/inch) */
+#define LWMM	   0.2		/* default line width (mm) */
 #define TSCALE	  12.5		/* default time scale (mm/second) */
 #define VSCALE	   5.0		/* default voltage scale (mm/millivolt) */
 #define TPS	  25.0		/* grid ticks per second */
@@ -135,7 +136,7 @@
 int Gflag = 0;			/* if non-zero, plot alternate grid */
 int lflag = 0;			/* if non-zero, label signals */
 int Lflag = 0;			/* if non-zero, use landscape orientation */
-double lwmm = 0.;		/* line width (mm); 0 is narrowest possible */
+double lwmm = LWMM;		/* line width (mm); 0 is narrowest possible */
 int mflag = 0;			/* if non-zero, margins specified using -m */
 int Mflag = 0;			/* annotation/marker bar mode (0: do not print
 				   bars, print mnemonics at center; 1: print
@@ -146,6 +147,7 @@
 				   bars */
 int numberpages = 1;		/* if zero, suppress page numbering */
 int nosig = 0;			/* number of signals to be printed */
+int nomax = 0;			/* largest value for nosig seen so far */
 int page = 1;			/* logical page number */
 int pages_written = 0;		/* number of pages written already */
 int prolog_written = 0;		/* if non-zero, prolog has been written */
@@ -235,6 +237,7 @@
     
     /* Set other defaults (see descriptions above). */
     if ((p = getenv("DPI")) && (dpi = atof(p)) <= 0.0) dpi = DPI;
+    if ((p = getenv("LWMM")) && (lwmm = atof(p)) < 0.0) lwmm = LWMM;
     if ((p = getenv("TSCALE")) && (tscale = atof(p)) <= 0.0) tscale = TSCALE;
     if ((p = getenv("VSCALE")) && (vscale = atof(p)) <= 0.0) vscale = VSCALE;
     if ((p = getenv("TPS")) && (tps = atof(p)) <= 0.0) tps = TPS;
@@ -436,23 +439,27 @@
 	    break;
 	  case 's':	/* specify signals to be printed */
 	    sflag = 1;
-	    /* count the number of output signals */
-	    for (j = 0; ++i < argc && *argv[i] != '-'; j++)
+	    /* count the number of output signals (arguments beginning with
+	       a digit) */
+	    for (j = i+1; j<argc-1 && '0' <= *argv[j] && *argv[j] <= '9'; j++)
 		;
-	    if (j == 0) {
+	    if (j == i+1) {
 		(void)fprintf(stderr, "%s: signal list must follow -s\n",
 			pname);
 		exit(1);
 	    }
 	    /* allocate storage for the signal list and for sqstr */
-	    if ((siglist=realloc(siglist, (nosig+j) * sizeof(int))) == NULL ||
-		(sqstr = realloc(sqstr, (nosig+j+1) * sizeof(char))) == NULL) {
-		(void)fprintf(stderr, "%s: insufficient memory\n", pname);
-		exit(2);
+	    if (j - i > nomax) {
+		if ((siglist = realloc(siglist, (j-i)*sizeof(int))) == NULL ||
+		    (sqstr = realloc(sqstr, (j-i+1)*sizeof(char))) == NULL) {
+		    (void)fprintf(stderr, "%s: insufficient memory\n", pname);
+		    exit(2);
+		}
 	    }
 	    /* fill the signal list */
-	    for (i -= j; i < argc && *argv[i] != '-'; )
-		siglist[nosig++] = atoi(argv[i++]);
+	    nosig = 0;
+	    while (++i < j)
+		siglist[nosig++] = atoi(argv[i]);
 	    i--;
 	    break;
 	  case 'S':	/* set modes for scale and time stamp printing */
@@ -501,7 +508,7 @@
 	    vflag = 1;
 	    break;
 	  case 'w':	/* specify line width in mm */
-	    if (++i >= argc || ((lwmm = atof(argv[i])) <= 0)) {
+	    if (++i >= argc || ((lwmm = atof(argv[i])) < 0.0)) {
 		(void)fprintf(stderr,
 			      "%s: line width (mm) must follow -w\n",
 			pname);
@@ -539,17 +546,16 @@
 /* Parameters set from the WFDB header file */
 int nisig;		/* number of signals in current record */
 int nimax;		/* largest value for nisig seen so far */
-int nsig;		/* number of signals to be printed */
 double sps;		/* sampling frequency (samples/second/signal) */
 WFDB_Siginfo *s;	/* signal parameters, including gain */
 int *uncal;		/* if non-zero, signal is uncalibrated */
 
 /* Arrays indexed by signal # (allocated by process(), used by printstrip()) */
-int *buflen, *v, *vbase, **vbuf, *vmax, *vmin;
+int *accept, *buflen, *v, *vbase, **vbuf, *vmax, *vmin;
 long *vsum;
 
 /* Derived parameters */
-double dpmm = DPI/25.4;	/* pixels per millimeter */
+double dpmm;		/* pixels per millimeter */
 double dppt;		/* pixels per PostScript "printer's point" (PostScript
 			   "printer's points" are 1/72 inch;  true printer's
 			   points are 1/72.27 inch) */
@@ -619,39 +625,22 @@
 	    title = strtok((char *)NULL, "\n");
 	    if (tokptr == NULL || tstring == NULL ||
 		(nisig = isigopen(record, NULL, 0)) < 0) continue;
-	    if (nisig > nimax) {
-		if ((s = realloc(s, nisig * sizeof(WFDB_Siginfo))) == NULL ||
-		    (buflen = realloc(buflen, nisig * sizeof(int))) == NULL ||
-		    (uncal = realloc(uncal, nisig * sizeof(int))) == NULL ||
-		    (v = realloc(v, nisig * sizeof(int))) == NULL ||
-		    (vbase = realloc(vbase, nisig * sizeof(int))) == NULL ||
-		    (vmax = realloc(vmax, nisig * sizeof(int))) == NULL ||
-		    (vmin = realloc(vmin, nisig * sizeof(int))) == NULL ||
-		    (vsum = realloc(vsum, nisig * sizeof(long))) == NULL ||
-		    (vbuf = realloc(vbuf, nisig * sizeof(int *))) == NULL) {
-		    (void)fprintf(stderr, "%s: insufficient memory\n", pname);
-		    exit(2);
-		}
-		if (!sflag &&
-		    ((siglist = realloc(siglist,nisig*sizeof(int))) == NULL ||
-		     (sqstr =realloc(sqstr,(nisig+1)*sizeof(char))) == NULL)) {
-		    (void)fprintf(stderr, "%s: insufficient memory\n", pname);
-		    exit(2);
-		}
-		while (nimax < nisig) {
-		    vbuf[nimax] = NULL;
-		    buflen[nimax++] = 0;
-		}
+	    if (nisig > nimax &&
+		(s = realloc(s, nisig * sizeof(WFDB_Siginfo))) == NULL) {
+		(void)fprintf(stderr, "%s: insufficient memory\n", pname);
+		exit(2);
 	    }
 	    if (isigopen(record, s, nisig) != nisig)
 		continue;
-	    for (i = 0; i < nisig; i++)
-		uncal[i] = 0;
-	    (void)setpagetitle(0L);
 	    if (!sflag) {
+		if ((siglist == NULL || nisig > nosig) &&
+		    ((siglist=realloc(siglist,nisig*sizeof(int))) == NULL)) {
+		    (void)fprintf(stderr, "%s: insufficient memory\n", pname);
+		    exit(2);
+		}
 		for (i = 0; i < nisig; i++)
 		    siglist[i] = i;
-		nsig = nosig = nisig;
+		nosig = nisig;
 	    }
 	    else {
 		for (i = 0; i < nosig; i++)
@@ -662,8 +651,40 @@
 			wfdbquit();
 			return;
 		    }
-		nsig = nosig;
 	    }
+	    if (nisig > nimax) {
+		if ((uncal = realloc(uncal, nisig * sizeof(int))) == NULL ||
+		    (v = realloc(v, nisig * sizeof(int))) == NULL) {
+		    (void)fprintf(stderr, "%s: insufficient memory\n", pname);
+		    exit(2);
+		}
+		nimax = nisig;
+	    }
+	    for (i = 0; i < nisig; i++)
+		uncal[i] = 0;
+	    if (nosig > nomax) {
+		if ((accept = realloc(accept, nosig * sizeof(int))) == NULL ||
+		    (buflen = realloc(buflen, nosig * sizeof(int))) == NULL ||
+		    (vbase = realloc(vbase, nosig * sizeof(int))) == NULL ||
+		    (vmax = realloc(vmax, nosig * sizeof(int))) == NULL ||
+		    (vmin = realloc(vmin, nosig * sizeof(int))) == NULL ||
+		    (vsum = realloc(vsum, nosig * sizeof(long))) == NULL ||
+		    (vbuf = realloc(vbuf, nosig * sizeof(int *))) == NULL) {
+		    (void)fprintf(stderr, "%s: insufficient memory\n", pname);
+		    exit(2);
+		}
+		if (!sflag &&
+		    ((siglist = realloc(siglist,nosig*sizeof(int))) == NULL ||
+		     (sqstr =realloc(sqstr,(nosig+1)*sizeof(char))) == NULL)) {
+		    (void)fprintf(stderr, "%s: insufficient memory\n", pname);
+		    exit(2);
+		}
+		while (nomax < nosig) {
+		    vbuf[nomax] = NULL;
+		    buflen[nomax++] = 0;
+		}
+	    }
+	    (void)setpagetitle(0L);
 	    if ((sps = sampfreq((char *)NULL)) <= 0.) sps = WFDB_DEFFREQ;
 	    dpsi = dpmm * tscale / sps;
 	    nsamp = (int)(sps*sdur);
@@ -721,286 +742,302 @@
 
     /* Allocate buffers for the samples to be plotted, and initialize the
        range variables. */
-    for (i = 0; i < nsig; i++) {
-        int sig = siglist[i];
-
-	vmax[sig] = -32768; vmin[sig] = 32767; vsum[sig] = 0L;
-	if (nsamp > buflen[sig]) {
-	    if (vbuf[sig]) {
-		free((char *)vbuf[sig]);
-		vbuf[sig] = NULL;
-		buflen[sig] = 0;
-	    }
-	    if ((vbuf[sig]=(int *)calloc((unsigned)nsamp,sizeof(int)))==NULL) {
+    for (i = 0; i < nosig; i++) {
+	accept[i] = 0;
+	vmax[i] = -32768; vmin[i] = 32767; vsum[i] = 0L;
+	if (nsamp > buflen[i]) {
+	    if ((vbuf[i] = realloc(vbuf[i], nsamp * sizeof(int))) == NULL) {
+		buflen[i] = 0;
 		(void)fprintf(stderr, "insufficient memory\n");
 		return (0);
 	    }
-	    buflen[sig] = nsamp;
+	    buflen[i] = nsamp;
 	}
     }
 
     if ((jmax = (int)(t1 - t0)) > nsamp) jmax = nsamp;
-    if (nsig > 0) {
-      /* Fill the buffers. */
-      if (isigsettime(t0) < 0) return (0);
-      for (j = 0; j < jmax && getvec(v) == nisig; j++) {
-	for (i = 0; i < nsig; i++) {
-	    int sig = siglist[i], vtmp;
-
-	    vbuf[sig][j] = vtmp = v[sig];
-	    if (vtmp > vmax[sig]) vmax[sig] = vtmp;
-	    else if (vtmp < vmin[sig]) vmin[sig] = vtmp;
-	    vsum[sig] += vtmp;
-	}
-      }
-      if (j == 0) return (0);
-      jmax = j;
-
-      /* Calculate the midranges. */
-      for (i = 0; i < nsig; i++) {
-	int sig = siglist[i], vb, vm, vs;
-	double w;
-
-	vs = vsum[sig]/jmax;
-	vb = (vmax[sig] + vmin[sig])/2;
-	if (vb > vs) w = (vb - vs)/(vmax[sig] - vs);
-	else if (vb < vs) w = (vs - vb)/(vs - vmin[sig]);
-	else w = 0.0;
-	vbase[sig] = vs + ((double)vb-vs)*w;
-      }
-    }
-    t1 = t0 + jmax;
+    if (nosig > 0) {
+	/* Fill the buffers. */
+	if (isigsettime(t0) < 0) return (0);
+	for (j = 0; j < jmax && getvec(v) == nisig; j++) {
+	    for (i = 0; i < nosig; i++) {
+		int vtmp = v[siglist[i]];
+
+		vbuf[i][j] = vtmp;
+		if (vtmp != WFDB_INVALID_SAMPLE) {
+		    if (vtmp > vmax[i]) vmax[i] = vtmp;
+		    else if (vtmp < vmin[i]) vmin[i] = vtmp;
+		    vsum[i] += vtmp;
+		    accept[i]++;
+		}
+	    }
+	}
+	if (j == 0) return (0);
+	jmax = j;
+
+	/* Calculate the midranges. */
+	for (i = 0; i < nosig; i++) {
+	    int vb, vm, vs;
+	    double w;
+
+	    if (accept[i]) {
+		vs = vsum[i]/accept[i];
+		vb = (vmax[i] + vmin[i])/2;
+		if (vb > vs) w = (vb - vs)/(vmax[i] - vs);
+		else if (vb < vs) w = (vs - vb)/(vs - vmin[i]);
+		else w = 0.0;
+		vbase[i] = vs + ((double)vb-vs)*w;
+	    }
+	    else	/* no valid samples in this trace */
+		vbase[i] = 0;
+	}
+	t1 = t0 + jmax;
     
-    /* Determine the width and height of the strip.  Allow the greater of 4 mV
-       or 20 mm per trace if possible.  If n strips won't fit on the page
-       (even if the allowance per trace is decreased moderately), the allowance
-       is adjusted so that n-1 strips fill the page (for n = 2, 3, and 4). */
-    s_width = jmax*tscale/sps;
-    if (vscale >= 5.) s_height = 4. * vscale * nsig;
-    else s_height = 20. * nsig;
-    if (1.5 * (s_height+v_sep) > p_height - (tmargin+bmargin))
-	s_height = p_height - (tmargin+bmargin+v_sep);
-    else if (2.5 * (s_height+v_sep) > p_height - (tmargin+bmargin))
-	s_height = (p_height - (tmargin+bmargin+2*v_sep))/2; 
-    else if (3.5 * (s_height+v_sep) > p_height - (tmargin+bmargin))
-	s_height = (p_height - (tmargin+bmargin+3*v_sep))/3;
-    if (nsig == 0) t_height = s_height;
-    else t_height = s_height / nsig;
-
-    /* Decide where to put the strip.  Usually, this is directly below the
-       previous strip, and s_top will have been set correctly after the
-       previous strip was printed.  If the strip won't fit in the available
-       space, though, go to the top of the next page. */
-    s_bot = s_top - s_height;
-    if (s_bot < bmargin) {
-	setpagetitle(t0);
-	ejectpage();
-	newpage();
-	s_top = p_height - (tmargin + v_sep);
+	/* Determine the width and height of the strip.  Allow the greater of 4
+           mV or 20 mm per trace if possible.  If n strips won't fit on the
+           page (even if the allowance per trace is decreased moderately), the
+           allowance is adjusted so that n-1 strips fill the page (for n = 2,
+           3, and 4). */
+	s_width = jmax * tscale / sps;
+	if (vscale >= 5.) s_height = 4. * vscale * nosig;
+	else s_height = 20. * nosig;
+	if (1.5 * (s_height+v_sep) > p_height - (tmargin+bmargin))
+	    s_height = p_height - (tmargin+bmargin+v_sep);
+	else if (2.5 * (s_height+v_sep) > p_height - (tmargin+bmargin))
+	    s_height = (p_height - (tmargin+bmargin+2*v_sep))/2; 
+	else if (3.5 * (s_height+v_sep) > p_height - (tmargin+bmargin))
+	    s_height = (p_height - (tmargin+bmargin+3*v_sep))/3;
+	if (nosig == 0) t_height = s_height;
+	else t_height = s_height / nosig;
+
+	/* Decide where to put the strip.  Usually, this is directly below the
+           previous strip, and s_top will have been set correctly after the
+           previous strip was printed.  If the strip won't fit in the available
+           space, though, go to the top of the next page. */
 	s_bot = s_top - s_height;
-	if (pflag) s_left = lmargin;
-    }
-    /* If side-by-side printing is enabled, s_left will have been set
-       correctly after the previous strip was printed. */
-    if (!pflag) s_left = lmargin + (s_defwidth - s_width)/2;
-    s_right = s_left + s_width;
-
-    /* Draw the grid and print the title and time markers. */
-    if (gflag) {
-	setrgbcolor(&gc);
-	if (Gflag)
-	   grid(mm(s_left-10.0),mm(s_bot),mm(s_right),mm(s_top),t_tick,v_tick);
-	else
-	   grid(mm(s_left), mm(s_bot), mm(s_right), mm(s_top), t_tick, v_tick);
-    }
-    if (Gflag) {
-	setrgbcolor(&Gc);
-	Grid(mm(s_left), mm(s_bot), mm(s_right), mm(s_top), t_tick, v_tick);
-    }
-    setrgbcolor(&lc);
-    setroman(fs_title);
-    move(mm(s_left), mm(s_top + t_sep));
-    if (rflag) { label("Record "); label(record); label("    "); }
-    if (title) label(title);
-    /* If side-by-side strip printing is enabled, print the time markers within
-       the strip at the upper corners;  in this case, if the strip is less than
-       30 mm wide, only the starting time marker is printed.  Otherwise, if
-       signal labels are to be printed, and nsig is odd, print the time markers
-       at the bottom of the strip, so they won't interfere with the labels.
-       Otherwise, print time markers midway between top and bottom. */
-    if (pflag) tm_y = mm(s_top) - pt(10.);
-    else if (lflag && (nsig & 1)) tm_y = mm(s_bot);
-    else tm_y = mm(s_top + s_bot)/2 - pt(4.);
-    if (tsmode == 1) {	/* print elapsed times only */
-	if (t0) {
-	    ts = mstimstr(t0);
+	if (s_bot < bmargin) {
+	    setpagetitle(t0);
+	    ejectpage();
+	    newpage();
+	    s_top = p_height - (tmargin + v_sep);
+	    s_bot = s_top - s_height;
+	    if (pflag) s_left = lmargin;
+	}
+	/* If side-by-side printing is enabled, s_left will have been set
+	   correctly after the previous strip was printed. */
+	if (!pflag) s_left = lmargin + (s_defwidth - s_width)/2;
+	s_right = s_left + s_width;
+
+	/* Draw the grid and print the title and time markers. */
+	if (gflag) {
+	    setrgbcolor(&gc);
+	    if (Gflag)
+		grid(mm(s_left-10.0), mm(s_bot), mm(s_right), mm(s_top),
+		     t_tick, v_tick);
+	    else
+		grid(mm(s_left), mm(s_bot), mm(s_right), mm(s_top),
+		     t_tick, v_tick);
+	}
+	if (Gflag) {
+	    setrgbcolor(&Gc);
+	    Grid(mm(s_left), mm(s_bot), mm(s_right), mm(s_top), t_tick,v_tick);
+	}
+	setrgbcolor(&lc);
+	setroman(fs_title);
+	move(mm(s_left), mm(s_top + t_sep));
+	if (rflag) { label("Record "); label(record); label("    "); }
+	if (title) label(title);
+	/* If side-by-side strip printing is enabled, print the time markers
+	   within the strip at the upper corners; in this case, if the strip is
+	   less than 30 mm wide, only the starting time marker is printed.
+	   Otherwise, if signal labels are to be printed, and nosig is odd,
+	   print the time markers at the bottom of the strip, so they won't
+	   interfere with the labels.  Otherwise, print time markers midway
+	   between top and bottom. */
+	if (pflag) tm_y = mm(s_top) - pt(fs_title);
+	else if (lflag && (nosig & 1)) tm_y = mm(s_bot);
+	else tm_y = mm(s_top + s_bot)/2 - pt(fs_title/2.);
+	if (tsmode == 1) {	/* print elapsed times only */
+	    if (t0) {
+		ts = mstimstr(t0);
+		while (*ts == ' ') ts++;
+		/* Print milliseconds only if t0 is not an exact multiple of 1
+		   second. */
+		if (strcmp(ts + strlen(ts)-4, ".000") == 0)
+		    *(ts + strlen(ts)-4) = '\0';
+	    }
+	    else
+		ts = "0:00";
+	    if (!pflag) {
+		move(mm(s_left - l_sep), tm_y);
+		rlabel(ts);
+	    }
+	    else {
+		move(mm(s_left + l_sep), tm_y);
+		label(ts);
+	    }
+	    if (vflag)
+		(void)fprintf(stderr, "%s %s-", record, ts);
+	    ts = mstimstr(t1);
 	    while (*ts == ' ') ts++;
-	    /* Print milliseconds only if t0 is not an exact multiple of 1
-	       second. */
 	    if (strcmp(ts + strlen(ts)-4, ".000") == 0)
 		*(ts + strlen(ts)-4) = '\0';
-	}
-	else
-	    ts = "0:00";
-	if (!pflag) {
-	    move(mm(s_left - l_sep), tm_y);
-	    rlabel(ts);
-	}
-	else {
-	    move(mm(s_left + l_sep), tm_y);
-	    label(ts);
-	}
-	if (vflag)
-	    (void)fprintf(stderr, "%s %s-", record, ts);
-	ts = mstimstr(t1);
-	while (*ts == ' ') ts++;
-	if (strcmp(ts + strlen(ts)-4, ".000") == 0)
-	    *(ts + strlen(ts)-4) = '\0';
-	if (!pflag) {
-	    move(mm(s_right + l_sep), tm_y);
-	    label(ts);
-	}
-	else if (s_width >= 30.) {
-	    move(mm(s_right - l_sep), tm_y);
-	    rlabel(ts);
-	}
-	if (vflag)
-	    (void)fprintf(stderr, "%s %s\n", ts, (title != NULL) ? title : "");
-    }
-    else if (tsmode == 2) { /* print absolute times (but not date) if defined,
-			       elapsed times otherwise */
-	char *p;
-
-	ts = mstimstr(-t0);
-	while (*ts == ' ') ts++;
-	for (p = ts; *p != '.'; p++)
-	    ;
-	if (strncmp(p, ".000", 4))
-	    p += 4;
-	if (*ts == '[')
-	    *p++ = ']';
-	*p = '\0';
-	if (!pflag) {
-	    move(mm(s_left - l_sep), tm_y);
-	    rlabel(ts);
-	}
-	else {
-	    move(mm(s_left + l_sep), tm_y);
-	    label(ts);
-	}
-	if (vflag)
-	    (void)fprintf(stderr, "%s %s-", record, ts);
-	ts = mstimstr(-t1);
-	while (*ts == ' ') ts++;
-	for (p = ts; *p != '.'; p++)
-	    ;
-	if (strncmp(p, ".000", 4))
-	    p += 4;
-	if (*ts == '[')
-	    *p++ = ']';
-	*p = '\0';
-	if (!pflag) {
-	    move(mm(s_right + l_sep), tm_y);
-	    label(ts);
-	}
-	else if (s_width >= 30.) {
-	    move(mm(s_right - l_sep), tm_y);
-	    rlabel(ts);
-	}
-	if (vflag)
-	    (void)fprintf(stderr, "%s %s\n", ts, (title != NULL) ? title : "");
-    }
-
-    /* Draw the signals. */
-    x0 = mm(s_left);
-    if (lflag) {
-	setitalic(fs_label);
-	/* If side-by-side printing and signal label printing are both enabled,
-	   print the signal labels in the left margin only. */
-	if (pflag && s_left == lmargin)
-	    for (i = 0; i < nsig; i++) {
-		int sig = siglist[i];
-		char *d, *t;
-
-		d = s[sig].desc;
-		y0 = mm(s_top - (i + 0.5)*t_height);
-		move(mm(s_left - l_sep), y0 - pt(4.));
-		if (strncmp(d,"record ",7) == 0 && (t = strchr(d,',')) != NULL)
-		    d = t+1;
-		rlabel(d);
-		if (s[sig].gain == 0.) rlabel("* ");
+	    if (!pflag) {
+		move(mm(s_right + l_sep), tm_y);
+		label(ts);
+	    }
+	    else if (s_width >= 30.) {
+		move(mm(s_right - l_sep), tm_y);
+		rlabel(ts);
+	    }
+	    if (vflag)
+		(void)fprintf(stderr, "%s %s\n",
+			      ts, (title != NULL) ? title : "");
+	}
+	else if (tsmode == 2) { /* print absolute times (but not date) if
+				   defined, elapsed times otherwise */
+	    char *p;
+
+	    ts = mstimstr(-t0);
+	    while (*ts == ' ') ts++;
+	    for (p = ts; *p != '.'; p++)
+		;
+	    if (strncmp(p, ".000", 4))
+		p += 4;
+	    if (*ts == '[')
+		*p++ = ']';
+	    *p = '\0';
+	    if (!pflag) {
+		move(mm(s_left - l_sep), tm_y);
+		rlabel(ts);
 	    }
-    }
-    for (i = 0; i < nsig; i++) {
-	int sig = siglist[i];
-	static WFDB_Calinfo ci;
+	    else {
+		move(mm(s_left + l_sep), tm_y);
+		label(ts);
+	    }
+	    if (vflag)
+		(void)fprintf(stderr, "%s %s-", record, ts);
+	    ts = mstimstr(-t1);
+	    while (*ts == ' ') ts++;
+	    for (p = ts; *p != '.'; p++)
+		;
+	    if (strncmp(p, ".000", 4))
+		p += 4;
+	    if (*ts == '[')
+		*p++ = ']';
+	    *p = '\0';
+	    if (!pflag) {
+		move(mm(s_right + l_sep), tm_y);
+		label(ts);
+	    }
+	    else if (s_width >= 30.) {
+		move(mm(s_right - l_sep), tm_y);
+		rlabel(ts);
+	    }
+	    if (vflag)
+		(void)fprintf(stderr, "%s %s\n",
+			      ts, (title != NULL) ? title : "");
+	}
+
+	/* Draw the signals. */
+	x0 = mm(s_left);
+	if (lflag) {
+	    setitalic(fs_label);
+	    /* If side-by-side printing and signal label printing are both
+	       enabled, print the signal labels in the left margin only. */
+	    if (pflag && s_left == lmargin)
+		for (i = 0; i < nosig; i++) {
+		    int sig = siglist[i];
+		    char *d, *t;
 
-	setrgbcolor(&lc);
-	y0 = mm(s_top - (i + 0.5)*t_height);
-	if (s[sig].gain == 0.) {
-	    s[sig].gain = WFDB_DEFGAIN;
-	    usflag = uncal[sig] = 1;
-	}
-	if (lflag && !pflag) {
-	    char *d = s[sig].desc, *t;
-
-	    if (strncmp(d, "record ", 7) == 0 && (t = strchr(d, ',')) != NULL)
-		d = t+1;
-	    move(mm(s_left - l_sep), y0 - pt(3.));
-	    rlabel(d);
-	    if (uncal[sig]) rlabel("* ");
-	    move(mm(s_right + l_sep), y0 - pt(3.));
-	    label(d);
-	    if (uncal[sig]) label(" *");
-	}
-	dpadu = dpmm * vscale / s[sig].gain;
-	if (getcal(s[sig].desc, s[sig].units, &ci) == 0 &&
-	    ci.scale != 0.0) {
-	    dpadu /= ci.scale;
-	    append_scale(ci.sigtype, ci.units, ci.scale);
-	}
-	/* Handle the common case of mV-dimensioned signals which are not in
-	   the WFDB calibration database. */
-	else if (s[sig].units == NULL)
-	    append_scale("record", "mV", 1.0);
-	/* Adjust vbase for calibrated DC-coupled signals. */
-	if (ci.scale != 0.0 && (ci.caltype & 1) && !uncal[sig]) {
-	    int n, yzero = physadu((unsigned int)sig, 0.0), ytick;
-	    double ptick = 5.0*ci.scale/tpmv;
-
-	    ytick = physadu((unsigned int)sig, ptick) - yzero;
-	    if (ytick == 0) ytick = 1;
-	    if (vbase[sig] >= yzero)
-		n = (int)((vbase[sig] - yzero)/ytick);
-	    else
-		n = -(int)((yzero - vbase[sig])/ytick);
-	    vbase[sig] = yzero + ytick * n;
+		    d = s[sig].desc;
+		    y0 = mm(s_top - (i + 0.5)*t_height);
+		    move(mm(s_left - l_sep), y0 - pt(fs_label/2.));
+		    if (strncmp(d,"record ",7) == 0 &&
+			(t = strchr(d,',')) != NULL)
+			d = t+1;
+		    rlabel(d);
+		    if (s[sig].gain == 0.) rlabel("* ");
+		}
+	}
+	for (i = 0; i < nosig; i++) {
+	    int last_sample_valid,  sig = siglist[i];
+	    static WFDB_Calinfo ci;
+
+	    setrgbcolor(&lc);
+	    y0 = mm(s_top - (i + 0.5)*t_height);
+	    if (s[sig].gain == 0.) {
+		s[sig].gain = WFDB_DEFGAIN;
+		usflag = uncal[sig] = 1;
+	    }
 	    if (lflag && !pflag) {
-		char lbuf[20];
-		int yt, yi = pt(3.);
+		char *d = s[sig].desc, *t;
 
-		setroman(fs_label*0.75);
-		(void)sprintf(lbuf, "%g", ptick * (n-1));
-		yt = y0 - adu(ytick);
-		move(mm(s_left - 1.5*l_sep), yt - yi); rlabel(lbuf);
-		move(mm(s_left - l_sep), yt); cont(mm(s_left), yt);
-		move(mm(s_right + 1.5*l_sep), yt - yi); label(lbuf);
-		move(mm(s_right + l_sep), yt); cont(mm(s_right), yt);
-		(void)sprintf(lbuf, "%g", ptick * (n+1));
-		yt = y0 + adu(ytick);
-		move(mm(s_left - 1.5*l_sep), yt - yi); rlabel(lbuf);
-		move(mm(s_left - l_sep), yt); cont(mm(s_left), yt);
-		move(mm(s_right + 1.5*l_sep), yt - yi); label(lbuf);
-		move(mm(s_right + l_sep), yt); cont(mm(s_right), yt);
-		setitalic(fs_label);
+		if (strncmp(d, "record ", 7) == 0 &&
+		    (t = strchr(d, ',')) != NULL)
+		    d = t+1;
+		move(mm(s_left - l_sep), y0 - pt(fs_label * 0.3));
+		rlabel(d);
+		if (uncal[sig]) rlabel("* ");
+		move(mm(s_right + l_sep), y0 - pt(fs_label * 0.3));
+		label(d);
+		if (uncal[sig]) label(" *");
+	    }
+	    dpadu = dpmm * vscale / s[sig].gain;
+	    if (getcal(s[sig].desc, s[sig].units, &ci) == 0 &&
+		ci.scale != 0.0) {
+		dpadu /= ci.scale;
+		append_scale(ci.sigtype, ci.units, ci.scale);
+	    }
+	    /* Handle the common case of mV-dimensioned signals that are not
+	       in the WFDB calibration database. */
+	    else if (s[sig].units == NULL)
+		append_scale("record", "mV", 1.0);
+	    /* Adjust vbase for calibrated DC-coupled signals. */
+	    if (ci.scale != 0.0 && (ci.caltype & 1) && !uncal[sig]) {
+		int n, yzero = physadu((unsigned int)sig, 0.0), ytick;
+		double ptick = 5.0*ci.scale/tpmv;
+
+		ytick = physadu((unsigned int)sig, ptick) - yzero;
+		if (ytick == 0) ytick = 1;
+		if (vbase[i] >= yzero)
+		    n = (int)((vbase[i] - yzero)/ytick);
+		else
+		    n = -(int)((yzero - vbase[i])/ytick);
+		vbase[i] = yzero + ytick * n;
+		if (lflag && !pflag) {
+		    char lbuf[20];
+		    int yt, yi = pt(fs_label * 0.3);
+
+		    setroman(fs_label * 0.75);
+		    (void)sprintf(lbuf, "%g", ptick * (n-1));
+		    yt = y0 - adu(ytick);
+		    move(mm(s_left - 1.5*l_sep), yt - yi); rlabel(lbuf);
+		    move(mm(s_left - l_sep), yt); cont(mm(s_left), yt);
+		    move(mm(s_right + 1.5*l_sep), yt - yi); label(lbuf);
+		    move(mm(s_right + l_sep), yt); cont(mm(s_right), yt);
+		    (void)sprintf(lbuf, "%g", ptick * (n+1));
+		    yt = y0 + adu(ytick);
+		    move(mm(s_left - 1.5*l_sep), yt - yi); rlabel(lbuf);
+		    move(mm(s_left - l_sep), yt); cont(mm(s_left), yt);
+		    move(mm(s_right + 1.5*l_sep), yt - yi); label(lbuf);
+		    move(mm(s_right + l_sep), yt); cont(mm(s_right), yt);
+		    setitalic(fs_label);
+		}
+	    }
+	    y0 -= adu(vbase[i]);
+	    setrgbcolor(&sc);
+	    for (j = last_sample_valid = 0, vp = vbuf[i]; j < jmax; j++, vp++){
+		if (*vp == WFDB_INVALID_SAMPLE)
+		    last_sample_valid = 0;
+		else if (last_sample_valid)
+			cont(x0 + si(j), y0 + adu(*vp));
+		else {
+		    move(x0 + si(j), y0 + adu(*vp));
+		    last_sample_valid = 1;
+		}
 	    }
 	}
-	y0 -= adu(vbase[sig]);
-	vp = vbuf[sig];
-	setrgbcolor(&sc);
-	move(x0 + si(0), y0 + adu(*vp++));
-	for (j = 1; j < jmax; j++)
-	    cont(x0 + si(j), y0 + adu(*vp++));
     }
     if (lflag) setroman(fs_label);
     else flush_cont();
@@ -1022,9 +1059,9 @@
 
        The scheme on the left is used for records with only one signal, and
        that on the right is used in other cases. */
-    if (nsig < 2) ya[0] = mm(s_top - 5.0) - pt(fs_ann/2.);
+    if (nosig < 2) ya[0] = mm(s_top - 5.0) - pt(fs_ann/2.);
     else ya[0] = mm(s_top - t_height) - pt(fs_ann/2.);
-    if (nsig < 3) ya[1] = mm(s_bot + 5.0) - pt(fs_ann/2.);
+    if (nosig < 3) ya[1] = mm(s_bot + 5.0) - pt(fs_ann/2.);
     else ya[1] = mm(s_top - 2*t_height) - pt(fs_ann/2.);
     if (Mflag) setbar1(mm(s_top), mm(s_bot));
 
@@ -1039,11 +1076,11 @@
 	    if (lflag) {
 		setrgbcolor(&lc);
 		setitalic(fs_label);
-		for (i = 0; i < nsig; i++) {
+		for (i = 0; i < nosig; i++) {
 		    char *d = s[siglist[i]].desc, *t;
 
 		    y0 = mm(s_top - (i + 0.5)*t_height);
-		    move(mm(s_right + l_sep), y0 - pt(4.));
+		    move(mm(s_right + l_sep), y0 - pt(fs_label * 0.4));
 		    if (strncmp(d,"record ",7)==0 && (t=strchr(d,',')) != NULL)
 			d = t+1;
 		    label(d);
@@ -1073,18 +1110,23 @@
 		c = -1;
 	    while (getann(ia, &annot) >= 0 && annot.time < t1) {
 		if (Mflag >= 2 && annot.chan != c) {
-		    int i;
+		    int i, j;
 		    i = c = annot.chan;
-		    if (i < 0 || i >= nsig) i = 0;
-		    y = mm(curr_s_top - (i + 0.5)*t_height + 10.);
-		    if (Mflag > 2)
-			(void)printf("%d Ay\n", y);
+		    if (i < 0 || i >= nisig) i = 0;
+		    for (j = 0; j < nosig; j++) {
+			if (siglist[j] == i) {
+			    y = mm(curr_s_top - (j + 0.5)*t_height + 10.);
+			    if (Mflag > 2)
+				(void)printf("%d Ay\n", y);
+			    break;
+			}
+		    }
 		}
 		if (Mflag) setbar2(y);   
 		x = (int)(annot.time - t0);
                 switch (annot.anntyp) {
 		  case NOISE:
-		    move(x0 + si(x), ya[ia] + pt(fs_ann+1.0));
+		    move(x0 + si(x), ya[ia] + pt(fs_ann * 1.1));
 		    if (annot.subtyp == -1) { label("U"); break; }
 		    /* The existing scheme is good for up to 4 signals;  it can
 		       be easily extended to 8 or 12 signals using the chan and
@@ -1115,7 +1157,7 @@
 			(void)printf("(%s) %d a\n",
 				     annstr(annot.anntyp), x0+si(x));
 		    else {
-			move(x0 + si(x), y + pt(9.));
+			move(x0 + si(x), y + pt(fs_ann * 1.1));
 			if (aux_shorten && *annot.aux > 1)
 			    *(annot.aux+2) = '\0'; /* print first char only */
 			label(annot.aux+1);
@@ -1126,7 +1168,7 @@
 			(void)printf("(%s) %d a\n",
 				     annstr(annot.anntyp), x0+si(x));
 		    else {
-			move(x0 + si(x), ya[ia] - pt(9.));
+			move(x0 + si(x), ya[ia] - pt(fs_ann * 1.1));
 			label(annot.aux+1);
 		    }
 		    break;
@@ -1376,7 +1418,7 @@
 	(void)printf("/tm matrix currentmatrix def\n");
 	(void)printf("/gm matrix currentmatrix def\n");
     }
-    if (lwmm > 0.)
+    if (lwmm != LWMM)
 	(void)printf("/lwmm %f def\n", lwmm);
     (void)printf("%g newpage\n", dpi);
     setrgbcolor(&lc);
@@ -1420,9 +1462,9 @@
 	    double yt = mm(title_y) + mm(30.0);
 
 	    if (Rflag) yt -= mm(10.0);
-	    setcourier(10.0);
+	    setcourier(fs_label);
 	    while (fgets(tstr, sizeof(tstr), infofile)) {
-		move(mm(lmargin), (int)(yt -= pt(10)));
+		move(mm(lmargin), (int)(yt -= pt(fs_label * 1.1)));
 		label(tstr);
 	    }
 	    (void)fclose(infofile);
@@ -1446,7 +1488,7 @@
 	}
 	if (lflag && usflag) {
 	    setroman(fs_label*0.75);
-	    move(mm(p_width - rmargin), mm(bmargin) - pt(7.5));
+	    move(mm(p_width - rmargin), mm(bmargin) - pt(fs_label*0.75));
 	    rlabel("* uncalibrated signal");
 	}
 	if (smode == 1 || smode == 2) {
@@ -1459,7 +1501,8 @@
 		    p_width - rmargin - lmargin)
 		    move(mm(p_width - rmargin), mm(footer_y));
 		else
-		    move(mm(p_width - rmargin), mm(footer_y) + pt(7.5));
+		    move(mm(p_width - rmargin),
+			 mm(footer_y) + pt(fs_label*0.75));
 		rlabel(scales);
 		if (footer) {
 		    move(mm(lmargin), mm(footer_y));
@@ -1686,6 +1729,9 @@
     char c;
     int dx, dy;
 
+#if DEBUG
+    printf("cont(%4d,%4d)\n", x, y);
+#else
     dx = x - xc; dy = y - yc;
     xc = x; yc = y;
     if (0 <= dx && dx <= 94 && -47 <= dy && dy <= 47) {
@@ -1704,15 +1750,20 @@
 	flush_cont();
 	(void)printf("%d %d N\n", dx, dy);
     }
+#endif
 }
 
 void flush_cont()
 {
+#if DEBUG
+    printf("flush_cont()\n");
+#else
     if (contp > contbuf) {
 	*contp = '\0';
 	(void)printf("(%s) z\n", contbuf);
 	contp = contbuf;
     }
+#endif
 }
 
 char *prog_name(s)
@@ -1778,7 +1829,7 @@
  " -u        generate `unstructured' PostScript",
  " -v N      set voltage scale to N mm/mV (default: 5)",     /* ** VSCALE ** */
  " -V        verbose mode",
- " -w N      set line width to N mm (default: 0 (narrowest possible))",
+ " -w N      set line width to N mm (default: 0.2; 0 is narrowest possible)",
  " -1        print only first character of comment annotation strings",
  " -         read script from standard input",
  "Script line format:",
@@ -1816,11 +1867,11 @@
 " %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
 "save 100 dict begin /pschart exch def",
 "/dpi 300 def",
-"/lw 0 def",
-"/lwmm 0 def",
+"/mm {72 mul 25.4 div}def",
+"/lwmm 0.2 def",
+"/lw lwmm mm def",
 "/tm matrix currentmatrix def",
 "/gm matrix currentmatrix def",
-"/mm {72 mul 25.4 div}def",
 "/I {/Times-Italic findfont exch scalefont setfont}def",
 "/R {/Times-Roman findfont exch scalefont setfont}def",
 "/C {/Courier findfont exch scalefont setfont}def",
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/app/pschart.pro wfdb-10.3.17/app/pschart.pro
--- wfdb-10.3.16/app/pschart.pro	2000-10-07 13:59:52.000000000 -0400
+++ wfdb-10.3.17/app/pschart.pro	2005-08-11 17:47:32.000000000 -0400
@@ -1,5 +1,5 @@
 % file: pschart.pro	G. Moody	  27 May 1988
-%			Last revised:	  7 October 2000
+%			Last revised:	 11 August 2005
 
 % -----------------------------------------------------------------------------
 % prolog for pschart output
@@ -38,11 +38,14 @@
 % printer resolution (dots per inch; reset by newpage, see below)
 /dpi 300 def
 
-% basic line width (may be reset by newpage)
-/lw 0 def
+% x mm: convert x (in mm) to PostScript points (assuming default scales)
+/mm {72 mul 25.4 div}def
 
 % line width in mm for signals, grid lines, marker bars
-/lwmm 0 def
+/lwmm 0.2 def
+
+% line width in PostScript points (reset by newpage)
+/lw lwmm mm def
 
 % TM for text
 /tm matrix currentmatrix def
@@ -50,9 +53,6 @@
 % TM for graphics
 /gm matrix currentmatrix def
 
-% x mm: convert x (in mm) to Postscript points (assuming default scales)
-/mm {72 mul 25.4 div}def
-
 % n I: use italic font, n points
 /I {/Times-Italic findfont exch scalefont setfont}def
 
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/app/psfd.c wfdb-10.3.17/app/psfd.c
--- wfdb-10.3.16/app/psfd.c	2004-05-04 16:49:07.000000000 -0400
+++ wfdb-10.3.17/app/psfd.c	2005-08-11 17:56:38.000000000 -0400
@@ -1,9 +1,9 @@
 /* file: psfd.c		G. Moody         9 August 1988
-			Last revised:	   4 May 2004
+			Last revised:	11 August 2005
 
 -------------------------------------------------------------------------------
 psfd: Produces annotated full-disclosure ECG plots on a PostScript device
-Copyright (C) 1988-2004 George B. Moody
+Copyright (C) 1988-2005 George B. Moody
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -49,7 +49,7 @@
 #include <wfdb/wfdb.h>
 #include <wfdb/ecgcodes.h>
 
-/* The ANSI C function strstr is defined here for those systems which don't
+/* The ANSI C function strstr is defined here for those systems that don't
    include it in their libraries.  This includes all older (pre-ANSI) C
    libraries;  some modern non-ANSI C libraries (notably those supplied with
    SunOS 4.1) do have strstr, so we can't just make this conditional on
@@ -88,16 +88,17 @@
    with `%d' replaced by the current year obtained from the system clock. */
 #define COPYR "Massachusetts Institute of Technology %d. All rights reserved."
 
-#define INVALID_DATA	(-32768)	/* any samples read by getvec and
-					   having this value are deemed invalid
-					   and are not plotted */
-
 /* Configuration parameters (changeable only by recompiling) */
 #define DPI	 300.0		/* default printer resolution (dots/inch) */
+#define LWMM	   0.2		/* default line width (mm) */
 #define TSCALE	   2.5		/* default time scale (mm/second) */
 #define VSCALE	   1.0		/* default voltage scale (mm/millivolt) */
 #define TPS	   1.0		/* grid ticks per second */
 #define L_SEP	   1.5		/* distance from labels to sides of grid */
+#define FS_ANN	   4.5		/* font size (in PostScript points) for
+				   annotations */
+#define FS_LABEL   6.0		/* font size for labels */
+#define FS_TITLE  10.0		/* font size for title */
 
 #ifndef PTYPE
 #define PTYPE	 "letter"	/* default page type */
@@ -124,7 +125,7 @@
 char aname2[41] = "";		/* second annotator name */
 int aux_shorten = 0;		/* if non-zero, print first char of aux only */
 double boff = 0.;		/* binding offset (mm) */
-int Cflag = 0;			/* if non-zero, print counter values */
+int Cflag = 0;			/* if non-zero, produce color output */
 char *copyright;		/* copyright notice string */
 char *defpagetitle;		/* default page title */
 char *rdpagetitle;		/* page title based on recording date */
@@ -134,6 +135,7 @@
 int gflag = 0;			/* if non-zero, plot grid */
 int lflag = 0;			/* if non-zero, label signals */
 int Lflag = 0;			/* if non-zero, use landscape orientation */
+double lwmm = LWMM;		/* line width (mm); 0 is narrowest possible */
 int mflag = 0;			/* if non-zero, margins specified using -m */
 int Mflag = 0;			/* annotation/marker bar mode (0: do not print
 				   bars, print mnemonics at center; 1: print
@@ -142,8 +144,10 @@
 				   signal, mnemonics at center; 3: print bars
 				   across attached signal, mnemonics above
 				   bars */
+int Nflag = 0;			/* if non-zero, print counter values */
 int numberpages = 1;		/* if zero, suppress page numbering */
 int nosig = 0;			/* number of signals to be printed */
+int nomax = 0;			/* largest value for nosig seen so far */
 int page = 1;			/* logical page number */
 int pages_written = 0;		/* number of pages written already */
 char *pagetitle = NULL;		/* if not null, title for page header */
@@ -155,6 +159,7 @@
 				   footers; 2: units/tick in footers) */
 char *sqstr;			/* signal quality string (1 char/signal) */
 double t_hideal = 7.5;		/* ideal value for t_height (see below) */
+double tps = TPS;		/* grid ticks per second */
 double tscale = TSCALE;		/* time scale (mm/second) */
 int tsmode = 2;			/* time stamp mode (0: no time stamps; 1:
 				   elapsed times only; 2: absolute times if
@@ -166,20 +171,36 @@
 double vscale = VSCALE;		/* voltage scale (mm/millivolt) */
 int xflag = 0;			/* if non-zero, extend last strip if needed */
 
+double l_sep = L_SEP;		/* distance from labels to sides of grid */
+double fs_ann = FS_ANN;		/* font size (in PostScript points) for
+				   annotations */
+double fs_label = FS_LABEL;	/* font size for labels */
+double fs_title = FS_TITLE;	/* font size for titles */
+
+/* Color definitions. */
+struct pscolor {
+    float red, green, blue;
+};
+struct pscolor ac = { 0.0, 0.0, 1.0 };	/* annotations: blue */
+struct pscolor gc = { 1.0, 0.5, 0.5 };	/* grid: light red */
+struct pscolor lc = { 0.0, 0.0, 0.0 };	/* labels: black */
+struct pscolor sc = { 0.0, 0.0, 0.3 };	/* signals: dark blue */
+
 char *prog_name(), *timcstr();
 int printstrip(), setpagedim(), setpagetitle();
 void append_scale(), cont(), ejectpage(), flush_cont(), grid(), help(),
     label(), larger(), move(), newpage(), plabel(), process(), rlabel(),
     rtlabel(), setbar1(), setbar2(), setitalic(), setmargins(), setroman(),
-    setsans(), smaller(), tlabel();
+    setrgbcolor(), setsans(), smaller(), tlabel();
 
 main(argc, argv)
 int argc;
 char *argv[];
 {
-    char *getenv();
+    char *p, *getenv();
     FILE *cfile = NULL;
     int i, j;
+    struct pscolor *colorp;
     struct tm *now;
     time_t t, time();
 
@@ -204,6 +225,18 @@
     (void)setpagedim();
     setmargins();
     
+    /* Set other defaults (see descriptions above). */
+    if ((p = getenv("DPI")) && (dpi = atof(p)) <= 0.0) dpi = DPI;
+    if ((p = getenv("LWMM")) && (lwmm = atof(p)) < 0.0) lwmm = LWMM;
+    if ((p = getenv("TSCALE")) && (tscale = atof(p)) <= 0.0) tscale = TSCALE;
+    if ((p = getenv("VSCALE")) && (vscale = atof(p)) <= 0.0) vscale = VSCALE;
+    if ((p = getenv("TPS")) && (tps = atof(p)) <= 0.0) tps = TPS;
+    if (p = getenv("L_SEP")) l_sep = atof(p);
+    if ((p = getenv("FS_ANN")) && (fs_ann = atof(p)) <= 0.0) fs_ann = FS_ANN;
+    if ((p = getenv("FS_LABEL"))&&(fs_label=atof(p)) <= 0.0) fs_label=FS_LABEL;
+    if ((p = getenv("FS_TITLE"))&&(fs_title=atof(p)) <= 0.0) fs_title=FS_TITLE;
+    if (p = getenv("PTYPE")) ptype = p;
+ 
     /* Check for buggy TranScript software. */
     if (getenv("TRANSCRIPTBUG")) uflag = 1;
 
@@ -254,7 +287,34 @@
 	    else
 		copyright = "";
 	    break;
-	  case 'C':	/* print counter values */
+	  case 'C':     /* set a color */
+	    switch (argv[i][2]) {
+	    case 'a':	colorp = &ac; break;
+	    case 'g':	colorp = &gc; break;
+	    case 'l':	colorp = &lc; break;
+	    case 's':	colorp = &sc; break;
+	    case '\0':  break;
+	    default:
+		(void)fprintf(stderr,
+			      "%s: unrecognized color specification '%s'\n",
+			      pname, argv[i]);
+		exit(1);
+	    }
+	    if (argv[i][2]) {
+	      if (i >= argc+3) {
+	         (void)fprintf(stderr, "%s: RGB triplet must follow '%s'\n",
+			       pname, argv[i]);
+		 exit(1);
+	      }
+	      if ((colorp->red = atof(argv[++i]))<0.0 || colorp->red   > 1.0 ||
+		  (colorp->green=atof(argv[++i]))<0.0 || colorp->green > 1.0 ||
+		  (colorp->blue =atof(argv[++i]))<0.0 || colorp->blue  > 1.0) {
+		  (void)fprintf(stderr,
+			   "%s: RGB values must be between 0 (black) and 1\n",
+				pname);
+		  exit(1);
+	      }
+	    }
 	    Cflag = 1;
 	    break;
 	  case 'd':	/* specify printer resolution in dpi */
@@ -334,6 +394,9 @@
 	    page = atoi(argv[i]);
 	    numberpages = (page > 0);
 	    break;
+	  case 'N':	/* print counter values */
+	    Nflag = 1;
+	    break;
 	  case 'P':	/* set page size */
 	    if (++i >= argc || (ptype = argv[i], setpagedim() == 0)) {
 		(void)fprintf(stderr,
@@ -350,23 +413,27 @@
 	    break;
 	  case 's':	/* specify signals to be printed */
 	    sflag = 1;
-	    /* count the number of output signals */
-	    for (j = 0; ++i < argc && *argv[i] != '-'; j++)
+	    /* count the number of output signals (arguments beginning with
+	       a digit)*/
+	    for (j = i+1; j<argc-1 && '0' <= *argv[j] && *argv[j] <= '9'; j++)
 		;
-	    if (j == 0) {
+	    if (j == i+1) {
 		(void)fprintf(stderr, "%s: signal list must follow -s\n",
 			pname);
 		exit(1);
 	    }
 	    /* allocate storage for the signal list and for sqstr */
-	    if ((siglist=realloc(siglist, (nosig+j) * sizeof(int))) == NULL ||
-		(sqstr = realloc(sqstr, (nosig+j+1) * sizeof(char))) == NULL) {
-		(void)fprintf(stderr, "%s: insufficient memory\n", pname);
-		exit(2);
+	    if (j - i > nomax) {
+		if ((siglist = realloc(siglist, (j-i)*sizeof(int))) == NULL ||
+		    (sqstr = realloc(sqstr, (j-i+1)*sizeof(char))) == NULL) {
+		    (void)fprintf(stderr, "%s: insufficient memory\n", pname);
+		    exit(2);
+		}
 	    }
 	    /* fill the signal list */
-	    for (i -= j; i < argc && *argv[i] != '-'; )
-		siglist[nosig++] = atoi(argv[i++]);
+	    nosig = 0;
+	    while (++i < j)
+		siglist[nosig++] = atoi(argv[i]);
 	    i--;
 	    break;
 	  case 'S':	/* set modes for scale and time stamp printing */
@@ -423,6 +490,14 @@
 	  case 'V':	/* enable verbose mode */
 	    vflag = 1;
 	    break;
+	  case 'w':	/* specify line width in mm */
+	    if (++i >= argc || ((lwmm = atof(argv[i])) < 0.0)) {
+		(void)fprintf(stderr,
+			      "%s: line width (mm) must follow -w\n",
+			pname);
+		exit(1);
+	    }
+	    break;
 	  case 'x':	/* extend last strip if needed */
 	    xflag = 1;
 	    break;
@@ -457,13 +532,12 @@
 /* Parameters set from the WFDB header file */
 int nisig;		/* number of signals in current record */
 int nimax;		/* largest value for nisig seen so far */
-int nsig;		/* number of signals to be printed */
 double sps;		/* sampling frequency (samples/second/signal) */
 WFDB_Siginfo *s;	/* signal parameters, including gain */
 int *uncal;		/* if non-zero, signal is uncalibrated */
 
 /* Arrays indexed by signal # (allocated by process(), used by printstrip()) */
-int *buflen, *reject, *v, *vbase, **vbuf, *vmax, *vmin;
+int *accept, *buflen, *v, *vbase, **vbuf, *vmax, *vmin, *vn;
 long *vs, *vsum;
 
 /* Derived parameters */
@@ -482,7 +556,7 @@
 unsigned int nann = 0;	/* number of annotation files to be plotted (0-2) */
 int pright = 1;		/* if non-zero, print time, etc., in right margin */
 char *scales;		/* string which describes time and voltage scales */
-char record[20];	/* current record name */
+char record[80];	/* current record name */
 int usflag = 0;		/* if non-zero, uncalibrated signals were plotted */
 
 #define mm(A)	((int)((A)*dpmm))    /* convert millimeters to pixels */
@@ -526,7 +600,7 @@
 	}
     }
     else
-	(void)sprintf(scales, "Grid intervals: %g sec", 1.0/TPS);
+	(void)sprintf(scales, "Grid intervals: %g sec", 1.0/tps);
     dpmm = dpi/25.4; dppt = dpi/72.;
     sdur = s_defwidth/tscale;
     lmargin = rhpage() ? imargin + boff : omargin - boff;
@@ -544,41 +618,22 @@
 	    (void)strcpy(record, rstring);
 	    if ((nisig = isigopen(record, NULL, 0)) < 1)
 	        continue;
-	    if (nisig > nimax) {
-		if ((s = realloc(s, nisig * sizeof(WFDB_Siginfo))) == NULL ||
-		    (buflen = realloc(buflen, nisig * sizeof(int))) == NULL ||
-		    (reject = realloc(reject, nisig * sizeof(int))) == NULL ||
-		    (uncal = realloc(uncal, nisig * sizeof(int))) == NULL ||
-		    (v = realloc(v, nisig * sizeof(int))) == NULL ||
-		    (vbase = realloc(vbase, nisig * sizeof(int))) == NULL ||
-		    (vmax = realloc(vmax, nisig * sizeof(int))) == NULL ||
-		    (vmin = realloc(vmin, nisig * sizeof(int))) == NULL ||
-		    (vs = realloc(vs, nisig * sizeof(long))) == NULL ||
-		    (vsum = realloc(vsum, nisig * sizeof(long))) == NULL ||
-		    (vbuf = realloc(vbuf, nisig * sizeof(int *))) == NULL) {
-		    (void)fprintf(stderr, "%s: insufficient memory\n", pname);
-		    exit(2);
-		}
-		if (!sflag &&
-		    ((siglist = realloc(siglist,nisig*sizeof(int))) == NULL ||
-		     (sqstr =realloc(sqstr,(nisig+1)*sizeof(char))) == NULL)) {
-		    (void)fprintf(stderr, "%s: insufficient memory\n", pname);
-		    exit(2);
-		}
-		while (nimax < nisig) {
-		    vbuf[nimax] = NULL;
-		    buflen[nimax++] = 0;
-		}
+	    if (nisig > nimax &&
+		(s = realloc(s, nisig * sizeof(WFDB_Siginfo))) == NULL) {
+		(void)fprintf(stderr, "%s: insufficient memory\n", pname);
+		exit(2);
 	    }
 	    if (isigopen(record, s, nisig) != nisig)
 		continue;
-	    for (i = 0; i < nisig; i++)
-		uncal[i] = 0;
-	    (void)setpagetitle(0L);
 	    if (!sflag) {
+		if ((siglist == NULL || nisig > nosig) &&
+		    ((siglist=realloc(siglist,nisig*sizeof(int))) == NULL)) {
+		    (void)fprintf(stderr, "%s: insufficient memory\n", pname);
+		    exit(2);
+		}
 		for (i = 0; i < nisig; i++)
 		    siglist[i] = i;
-		nsig = nosig = nisig;
+		nosig = nisig;
 	    }
 	    else {
 		for (i = 0; i < nosig; i++)
@@ -589,8 +644,42 @@
 			wfdbquit();
 			return;
 		    }
-		nsig = nosig;
 	    }
+	    if (nisig > nimax) {
+		if ((uncal = realloc(uncal, nisig * sizeof(int))) == NULL ||
+		    (v = realloc(v, nisig * sizeof(int))) == NULL) {
+		    (void)fprintf(stderr, "%s: insufficient memory\n", pname);
+		    exit(2);
+		}
+		nimax = nisig;
+	    }
+	    for (i = 0; i < nisig; i++)
+		uncal[i] = 0;
+	    if (nosig > nomax) {
+		if ((accept = realloc(accept, nosig * sizeof(int))) == NULL ||
+		    (buflen = realloc(buflen, nosig * sizeof(int))) == NULL ||
+		    (vbase = realloc(vbase, nosig * sizeof(int))) == NULL ||
+		    (vmax = realloc(vmax, nosig * sizeof(int))) == NULL ||
+		    (vmin = realloc(vmin, nosig * sizeof(int))) == NULL ||
+		    (vn = realloc(vn, nosig * sizeof(int))) == NULL ||
+		    (vs = realloc(vs, nosig * sizeof(long))) == NULL ||
+		    (vsum = realloc(vsum, nosig * sizeof(long))) == NULL ||
+		    (vbuf = realloc(vbuf, nosig * sizeof(int *))) == NULL) {
+		    (void)fprintf(stderr, "%s: insufficient memory\n", pname);
+		    exit(2);
+		}
+		if (!sflag &&
+		    ((siglist = realloc(siglist,nosig*sizeof(int))) == NULL ||
+		     (sqstr =realloc(sqstr,(nosig+1)*sizeof(char))) == NULL)) {
+		    (void)fprintf(stderr, "%s: insufficient memory\n", pname);
+		    exit(2);
+		}
+		while (nomax < nosig) {
+		    vbuf[nomax] = NULL;
+		    buflen[nomax++] = 0;
+		}
+	    }
+	    (void)setpagetitle(0L);
 	    if ((sps = sampfreq((char *)NULL)) <= 0.) sps = WFDB_DEFFREQ;
 	    dpsi = dpmm * tscale / sps;
  	    nisamp = (int)(sps*sdur);
@@ -682,162 +771,145 @@
 
     /* Allocate buffers for the samples to be plotted, and initialize the
        range and filter variables. */
-    for (i = 0; i < nsig; i++) {
-	int sig = siglist[i];
-
-	vmax[sig] = -32768; vmin[sig] = 32767; vs[sig] = 0L; vsum[sig] = 0L;
-	if (nosamp > buflen[sig]) {
-	    if (vbuf[sig]) {
-		free((char *)vbuf[sig]);
-		vbuf[sig] = NULL;
-		buflen[sig] = 0;
-	    }
-	    if ((vbuf[sig] = (int *)calloc((unsigned)nosamp, sizeof(int))) ==
-		NULL) {
+    for (i = 0; i < nosig; i++) {
+	accept[i] = 0;
+	vmax[i] = -32768; vmin[i] = 32767; vs[i] = 0L; vsum[i] = 0L;
+	if (nosamp > buflen[i]) {
+	    if ((vbuf[i] = realloc(vbuf[i], nosamp * sizeof(int))) == NULL) {
+		buflen[i] = 0;
 		(void)fprintf(stderr, "insufficient memory\n");
 		return (0);
 	    }
-	    buflen[sig] = nosamp;
+	    buflen[i] = nosamp;
 	}
     }
 
-    /* Fill the buffers. */
-    if (isigsettime(t0) < 0) return (0);
     if ((jmax = t1 - t0) > nisamp) jmax = nisamp;
-    (void)getvec(v);
-    for (i = 0; i < nsig; i++) {
-	vs[i] = v[siglist[i]];
-	reject[i] = (vs[i] == INVALID_DATA);
-    }
-    for (j = 0L, k = tt = 0; j < jmax && getvec(v) == nisig; j++) {
-	if (++k < decf)
-	    for (i = 0; i < nsig; i++) {
-		int vv = v[siglist[i]];
-		
-		reject[i] |= (vv == INVALID_DATA);
-		vs[i] += vv;
-	    }
-	else {
-	    for (i = 0; i < nsig; i++) {
-		int sig = siglist[i];
-
-		if (reject[i]) {
-		    vbuf[sig][tt] = INVALID_DATA;
-		    if (tt) vsum[sig] += vbuf[sig][tt-1];
+    if (nosig > 0) {
+	/* Fill the buffers. */
+	if (isigsettime(t0) < 0) return (0);
+
+	for (j = 0L, k = 1, tt = 0; j < jmax && getvec(v) == nisig; j++) {
+	    for (i = 0; i < nosig; i++) {
+		int vtmp = v[siglist[i]];
+
+		/* add up all valid samples in each group of decf samples */
+		if (vtmp != WFDB_INVALID_SAMPLE) {
+		    vs[i] += vtmp;
+		    vn[i]++;
 		}
-		else {
-		    vs[i] /= decf;
-		    vsum[sig] += vbuf[sig][tt] = vs[i];
-		    if (vs[i] > vmax[sig]) vmax[sig] = vs[i];
-		    else if (vs[i] < vmin[sig]) vmin[sig] = vs[i];
+		if (k >= decf) {
+		    /* average the valid samples in each group */
+		    if (vn[i] > 0) {
+			vsum[i] += vbuf[i][tt] = vtmp = vs[i]/vn[i];
+			if (vtmp > vmax[i]) vmax[i] = vtmp;
+			else if (vtmp < vmin[i]) vmin[i] = vtmp;
+			vn[i] = vs[i] = 0;
+			accept[i]++;
+		    }
+		    else
+			vbuf[i][tt] = WFDB_INVALID_SAMPLE;
 		}
-		vs[i] = v[sig];
-		reject[i] = (vs[i] == INVALID_DATA);
 	    }
-	    tt++; k = 0;
+	    if (++k > decf) {
+		k = 1;
+		tt++;
+	    }
 	}
-    }
-    if (j == 0L) return (0);
-    if (j == jmax - 1) j++;
+	if (j == 0) return (0);
+	jmax = j;
+
+
+	if (j == 0L) return (0);
+	if (j == jmax - 1) j++;
 	/* reached end of record exactly at end of strip -- adjust j */
-    t1 = t0 + j;
-    ttmax = tt;
-    if (nticks < j/sps) nticks = j/sps;
-
-    /* Calculate the midranges. */
-    for (i = 0; i < nsig; i++) {
-	int sig = siglist[i], vb, vm, vsm;
-	double w;
-
-	vsm = vsum[sig]/ttmax;
-	vb = (vmax[sig] + vmin[sig])/2;
-	if (vb > vsm) w = (vb - vsm)/(vmax[sig] - vsm);
-	else if (vb < vsm) w = (vsm - vb)/(vsm - vmin[sig]);
-	else w = 0.0;
-	vbase[sig] = vsm + ((double)vb-vsm)*w;
-    }
-
-    /* Determine the width and height of the strip. */
-    s_width = j*tscale/sps;
-    /* The calculation of nstrips allots roughly t_hideal (7.5 by default) mm
-       per trace.  The formula is derived from the desired results: 30 for nsig
-       = 1, 15 for nsig = 2, 10 for nsig = 3, 8 for nsig = 4, 6 for nsig = 5,
-       etc., given the default paper size and margins. */
-    nstrips = (nsig<=16) ?
-	(int)((p_height-tmargin-bmargin)/(t_hideal*nsig)+0.45) : 1;
-    s_height = (p_height - (tmargin+bmargin)) / nstrips;
-    if (nsig > 2 || nann > 1) s_height -= s_height / (nsig+1);
-    t_height = s_height / nsig;
-
-    /* Decide where to put the strip.  Usually, this is directly below the
-       previous strip, and s_top will have been set correctly after the
-       previous strip was printed.  If the strip won't fit in the available
-       space, though, go to the top of the next page. */
-    if (s_top - s_height < bmargin - 2.0) {
-	setpagetitle(t0);
-	ejectpage();
-	newpage();
-	s_top = p_height - tmargin;
-	nticks = j/sps;
-    }
-    s_bot = s_top - s_height;
-    s_left = lmargin;
-    s_right = s_left + s_width;
-
-    /* If signal labels are to be printed, and nsig is odd, print the time
-       markers at the bottom of the strip (so they won't interfere with the
-       signal labels).  Otherwise, print them midway between top and bottom. */
-    setroman(8.);
-    if (lflag && (nsig & 1)) tm_y = mm(s_bot);
-    else tm_y = mm(s_top + s_bot)/2 - pt(4.);
-    if (tsmode == 1) {	/* print elapsed times only */
-	if (t0) {
-	    ts = mstimstr(t0);
-	    while (*ts == ' ') ts++;
-	    /* Print milliseconds only if t0 is not an exact multiple of 1
-	       second. */
-	    if (strcmp(ts + strlen(ts)-4, ".000") == 0)
-		*(ts + strlen(ts)-4) = '\0';
+	t1 = t0 + j;
+	ttmax = tt;
+	if (nticks < j/sps) nticks = j/sps;
+	
+	/* Calculate the midranges. */
+	for (i = 0; i < nosig; i++) {
+	    int sig = siglist[i], vb, vm, vsm;
+	    double w;
+	    
+	    if (accept[i]) {
+		vsm = vsum[i]/accept[i];
+		vb = (vmax[i] + vmin[i])/2;
+		if (vb > vsm) w = (vb - vsm)/(vmax[i] - vsm);
+		else if (vb < vsm) w = (vsm - vb)/(vsm - vmin[i]);
+		else w = 0.0;
+		vbase[i] = vsm + ((double)vb-vsm)*w;
+	    }
+	    else	/* no valid samples in this trace */
+		vbase[i] = 0;
+	}
+	
+	/* Determine the width and height of the strip. */
+	s_width = j*tscale/sps;
+	/* The calculation of nstrips allots roughly t_hideal (7.5 by default)
+	   mm per trace.  The formula is derived from the desired results: 30
+	   for nosig = 1, 15 for nosig = 2, 10 for nosig = 3, 8 for nosig = 4,
+	   6 for nosig = 5, etc., given the default paper size and margins. */
+	nstrips = (nosig<=16) ?
+	    (int)((p_height-tmargin-bmargin)/(t_hideal*nosig)+0.45) : 1;
+	s_height = (p_height - (tmargin+bmargin)) / nstrips;
+	if (nosig > 2 || nann > 1) s_height -= s_height / (nosig+1);
+	t_height = s_height / nosig;
+	
+	/* Decide where to put the strip.  Usually, this is directly below the
+	   previous strip, and s_top will have been set correctly after the
+	   previous strip was printed.  If the strip won't fit in the available
+	   space, though, go to the top of the next page. */
+	if (s_top - s_height < bmargin - 2.0) {
+	    setpagetitle(t0);
+	    ejectpage();
+	    newpage();
+	    s_top = p_height - tmargin;
+	    nticks = j/sps;
+	}
+	s_bot = s_top - s_height;
+	s_left = lmargin;
+	s_right = s_left + s_width;
+	
+	/* If signal labels are to be printed, and nosig is odd, print the time
+	   markers at the bottom of the strip (so they won't interfere with the
+	   signal labels).  Otherwise, print them midway between top and
+	   bottom. */
+	setrgbcolor(&lc);
+	setroman(fs_title * 0.8);
+	if (lflag && (nosig & 1)) tm_y = mm(s_bot) - pt(fs_title * 0.2);
+	else tm_y = mm(s_top + s_bot)/2 - pt(fs_title * 0.4);
+	if (tsmode == 1) {	/* print elapsed times only */
+	    if (t0) {
+		ts = mstimstr(t0);
+		while (*ts == ' ') ts++;
+		/* Print milliseconds only if t0 is not an exact multiple of 1
+		   second. */
+		if (strcmp(ts + strlen(ts)-4, ".000") == 0)
+		    *(ts + strlen(ts)-4) = '\0';
+	    }
+	    else
+		ts = "0:00";
+	    move(mm(s_left - l_sep), tm_y);
+	    if (Nflag) {
+		rlabel(")");
+		rlabel(timcstr(t0));
+		rlabel(" (");
+	    }
+	    rlabel(ts);
+	    if (pright) {
+		ts = mstimstr(t1);
+		while (*ts == ' ') ts++;
+		if (strcmp(ts + strlen(ts)-4, ".000") == 0)
+		    *(ts + strlen(ts)-4) = '\0';
+		move(mm(s_right + l_sep), tm_y); label(ts);
+	    }
 	}
-	else
-	    ts = "0:00";
-	move(mm(s_left - L_SEP), tm_y);
-	if (Cflag) {
-	    rlabel(")");
-	    rlabel(timcstr(t0));
-	    rlabel(" (");
-	}
-	rlabel(ts);
-	if (pright) {
-	    ts = mstimstr(t1);
-	    while (*ts == ' ') ts++;
-	    if (strcmp(ts + strlen(ts)-4, ".000") == 0)
-		*(ts + strlen(ts)-4) = '\0';
-	    move(mm(s_right + L_SEP), tm_y); label(ts);
-	}
-    }
-    else if (tsmode == 2) { /* print absolute times (but not date) if defined,
-			       elapsed times otherwise */
-	char *p;
-
-	ts = mstimstr(-t0);
-	while (*ts == ' ') ts++;
-	for (p = ts; *p != '.'; p++)
-	    ;
-	if (strncmp(p, ".000", 4))
-	    p += 4;
-	if (*ts == '[')
-	    *p++ = ']';
-	*p = '\0';
-	move(mm(s_left - L_SEP), tm_y);
-	if (Cflag) {
-	    rlabel(")");
-	    rlabel(timcstr(t0));
-	    rlabel(" (");
-	}
-	rlabel(ts);
-	if (pright) {
-	    ts = mstimstr(-t1);
+	else if (tsmode == 2) { /* print absolute times (but not date) if
+				   defined, elapsed times otherwise */
+	    char *p;
+	    
+	    ts = mstimstr(-t0);
 	    while (*ts == ' ') ts++;
 	    for (p = ts; *p != '.'; p++)
 		;
@@ -846,59 +918,77 @@
 	    if (*ts == '[')
 		*p++ = ']';
 	    *p = '\0';
-	    move(mm(s_right + L_SEP), tm_y); label(ts);
-	}
-    }
-
-    /* Draw the signals. */
-    x0 = mm(s_left);
-    if (lflag) setitalic(6.);
-    for (i = 0; i < nsig; i++) {
-	int sig = siglist[i];
-	WFDB_Calinfo ci;
-
-	y0 = mm(s_top - (i + 0.5)*t_height);
-	if (s[sig].gain == 0.) {
-	    s[sig].gain = WFDB_DEFGAIN;
-	    usflag = uncal[sig] = 1;
-	}
-	if (lflag) {
-	    char *d = s[sig].desc, *t;
-
-	    if (strncmp(d, "record ", 7) == 0 && (t = strchr(d, ',')) != NULL)
-		d = t+1;
-	    move(mm(s_left - L_SEP), y0 - pt(3.));
-	    rlabel(d);
-	    if (uncal[sig]) rlabel("* ");
+	    move(mm(s_left - l_sep), tm_y);
+	    if (Nflag) {
+		rlabel(")");
+		rlabel(timcstr(t0));
+		rlabel(" (");
+	    }
+	    rlabel(ts);
 	    if (pright) {
-		move(mm(s_right + L_SEP), y0 - pt(3.));
-		label(d);
-		if (uncal[sig]) label(" *");
-	    }
-	}
-	dpadu = dpmm * vscale / s[sig].gain;
-	if (getcal(s[sig].desc, s[sig].units, &ci) == 0 &&
-	    ci.scale != 0.0) {
-	    dpadu /= ci.scale;
-	    append_scale(ci.sigtype, ci.units, ci.scale);
-	}
-	/* Handle the common case of mV-dimensioned signals which are not in
-	   the WFDB calibration database. */
-	else if (s[sig].units == NULL)
-	    append_scale("record", "mV", 1.0);
-	y0 -= adu(vbase[sig]);
-	vp = vbuf[sig];
-	if (*vp != INVALID_DATA)
-	    move(x0 + si(0), y0 + adu(*vp));
-	for (tt = 0; tt < ttmax; tt++) {
-	    if (*vp == INVALID_DATA) {
-		while (++tt < ttmax && *(++vp) == INVALID_DATA)
+		ts = mstimstr(-t1);
+		while (*ts == ' ') ts++;
+		for (p = ts; *p != '.'; p++)
 		    ;
-		if (tt < ttmax)
-		    move(x0 + si(decf*tt), y0 + adu(*vp++));
+		if (strncmp(p, ".000", 4))
+		    p += 4;
+		if (*ts == '[')
+		    *p++ = ']';
+		*p = '\0';
+		move(mm(s_right + l_sep), tm_y); label(ts);
+	    }
+	}
+	
+	/* Draw the signals. */
+	x0 = mm(s_left);
+	if (lflag) setitalic(fs_label);
+	for (i = 0; i < nosig; i++) {
+	    int last_sample_valid, sig = siglist[i];
+	    static WFDB_Calinfo ci;
+	    
+	    setrgbcolor(&lc);
+	    y0 = mm(s_top - (i + 0.5)*t_height);
+	    if (s[sig].gain == 0.) {
+		s[sig].gain = WFDB_DEFGAIN;
+		usflag = uncal[sig] = 1;
+	    }
+	    if (lflag) {
+		char *d = s[sig].desc, *t;
+		
+		if (strncmp(d, "record ", 7) == 0 &&
+		    (t = strchr(d, ',')) != NULL)
+		    d = t+1;
+		move(mm(s_left - l_sep), y0 - pt(fs_label/2.));
+		rlabel(d);
+		if (uncal[sig]) rlabel("* ");
+		if (pright) {
+		    move(mm(s_right + l_sep), y0 - pt(fs_label/2.));
+		    label(d);
+		    if (uncal[sig]) label(" *");
+		}
+	    }
+	    dpadu = dpmm * vscale / s[sig].gain;
+	    if (getcal(s[sig].desc, s[sig].units, &ci) == 0 &&
+		ci.scale != 0.0) {
+		dpadu /= ci.scale;
+		append_scale(ci.sigtype, ci.units, ci.scale);
+	    }
+	    /* Handle the common case of mV-dimensioned signals that are not in
+	       the WFDB calibration database. */
+	    else if (s[sig].units == NULL)
+		append_scale("record", "mV", 1.0);
+	    y0 -= adu(vbase[i]);
+	    setrgbcolor(&sc);
+	    for (tt = last_sample_valid=0, vp=vbuf[i]; tt < ttmax; tt++, vp++){
+		if (*vp == WFDB_INVALID_SAMPLE)
+		    last_sample_valid = 0;
+		else if (last_sample_valid)
+			cont(x0 + si(decf*tt), y0 + adu(*vp));
+		else {
+		    move(x0 + si(decf*tt), y0 + adu(*vp));
+		    last_sample_valid = 1;
+		}
 	    }
-	    else	
-		cont(x0 + si(decf*tt), y0 + adu(*vp++));
 	}
     }
     flush_cont();
@@ -923,19 +1013,19 @@
        are to be printed for a record with one or two signals, or if there
        are three or more signals, additional space is allocated between the
        strips to separate them.  */
-    if (nsig < 2) ya[0] = mm(s_top) - pt(10.);
-    else ya[0] = mm(s_top - t_height) - pt(2.25);
+    if (nosig < 2) ya[0] = mm(s_top) - pt(fs_ann*2.);
+    else ya[0] = mm(s_top - t_height) - pt(fs_ann/2.);
     if (Mflag) setbar1(mm(s_top), mm(s_bot));
 
     curr_s_top = s_top;
-    if (nann > 1 && nsig < 3) {
-	ya[1] = mm(s_bot) - pt(2.25);
+    if (nann > 1 && nosig < 3) {
+	ya[1] = mm(s_bot) - pt(fs_ann/2.);
 	s_bot -= t_height;
 	s_top -= (s_height + t_height);
     }
     else {
-	ya[1] = mm(s_top - 2*t_height) - pt(2.25);
-	if (nsig > 2) {
+	ya[1] = mm(s_top - 2*t_height) - pt(fs_ann/2.);
+	if (nosig > 2) {
 	    s_bot -= t_height;
 	    s_top -= (s_height + t_height);
 	}
@@ -948,7 +1038,8 @@
 	unsigned int ia;
 
 	if (iannsettime(t0) < 0 && nann == 1) return (1);
-	setsans(4.5);
+	setrgbcolor(&ac);
+	setsans(fs_ann);
 	for (ia = 0; ia < nann; ia++) {
 	    if (Mflag <= 2)
 		(void)printf("%d Ay\n", y = ya[ia]);
@@ -958,7 +1049,7 @@
 		if (Mflag >= 2 && annot.chan != c) {
 		    int i;
 		    i = c = annot.chan;
-		    if (i < 0 || i >= nsig) i = 0;
+		    if (i < 0 || i >= nosig) i = 0;
 		    y = mm(curr_s_top - (i + 0.5)*t_height + 2.);
 		    if (Mflag > 2)
 			(void)printf("%d Ay\n", y);
@@ -967,7 +1058,7 @@
 		x = (int)(annot.time - t0);
 		switch (annot.anntyp) {
 		  case NOISE:
-		    move(x0 + si(x), ya[ia] + pt(5.));
+		    move(x0 + si(x), ya[ia] + pt(fs_ann * 1.1));
 		    if (annot.subtyp == -1) { label("U"); break; }
 		    /* The existing scheme is good for up to 4 signals;  it can
 		       be easily extended to 8 or 12 signals using the chan and
@@ -998,7 +1089,7 @@
 			(void)printf("(%s) %d a\n",
 				     annstr(annot.anntyp), x0+si(x));
 		    else {
-			move(x0 + si(x), y + pt(5.));
+			move(x0 + si(x), y + pt(fs_ann * 1.1));
 			if (aux_shorten && *annot.aux > 1)
 			    *(annot.aux+2) = '\0'; /* print first char only */
 			label(annot.aux+1);
@@ -1009,7 +1100,7 @@
 			(void)printf("(%s) %d a\n",
 				     annstr(annot.anntyp), x0+si(x));
 		    else {
-			move(x0 + si(x), ya[ia] - pt(5.));
+			move(x0 + si(x), ya[ia] - pt(fs_ann * 1.1));
 			label(annot.aux+1);
 		    }
 		    break;
@@ -1148,14 +1239,14 @@
 			  vscale/scale, units, desc);
 	else
 	    (void)sprintf(sctbuf, ", %g %s (%s)",
-		    tscale/vscale*VSCALE/TSCALE*1.0*scale/TPS, units, desc);
+		    tscale/vscale*VSCALE/TSCALE*1.0*scale/tps, units, desc);
     }
     else {
 	if (smode & 1)
 	    (void)sprintf(sctbuf, ", %g mm/%s", vscale/scale, units);
 	else
 	    (void)sprintf(sctbuf, ", %g %s", 
-		    tscale/vscale*VSCALE/TSCALE*1.0*scale/TPS, units);
+		    tscale/vscale*VSCALE/TSCALE*1.0*scale/tps, units);
     }
     if ((scp = (char *)malloc((unsigned)(strlen(scales)+strlen(sctbuf)+1))) ==
 	NULL)
@@ -1234,7 +1325,10 @@
 	(void)printf("/tm matrix currentmatrix def\n");
 	(void)printf("/gm matrix currentmatrix def\n");
     }
+    if (lwmm != LWMM)
+	(void)printf("/lwmm %f def\n", lwmm);
     (void)printf("%g newpage\n", dpi);
+    setrgbcolor(&lc);
     if (numberpages) {
 	pnx = p_width/2 + (rhpage() ? boff : -boff);
 	pny = title_y;
@@ -1259,7 +1353,10 @@
 {
     flush_cont();
     if (s_top != -9999.) {
-	if (rflag || *pagetitle) setroman(10.);
+	if (rflag || *pagetitle) {
+	    setrgbcolor(&lc);
+	    setroman(fs_title);
+	}
 	if (rflag) {
 	    if (rhpage()) {
 		move(mm(p_width - rmargin), mm(title_y));
@@ -1291,30 +1388,33 @@
 	if (gflag && nticks > 0.) {
 	    if (nticks > sdur) nticks = sdur;
 	    s_right = s_left + nticks*tscale;
+	    setrgbcolor(&gc);
 	    grid(mm(s_left),mm(s_bot),mm(s_right),mm(p_height-tmargin),nticks);
 	}
+	setrgbcolor(&lc);
 	if (lflag && usflag) {
-	    setroman(6.);
-	    move(mm(p_width - rmargin), mm(bmargin) - pt(7.5));
+	    setroman(fs_label);
+	    move(mm(p_width - rmargin), mm(bmargin) - pt(fs_label * 1.25));
 	    rlabel("* uncalibrated signal");
 	}
 	if (smode == 1 || smode == 2) {
-	    setroman(6.);
+	    setroman(fs_label);
 	    if (scales) {
 		/* 1 em at 6 points is about 1 mm.  Decide whether to
 		   try to fit the scales on the same line as the copyright
 		   notice. */
-		if ((int)(strlen(scales) + strlen(copyright)) <
+		if ((strlen(scales) + strlen(copyright)) * fs_label/6.0 <
 		    p_width - rmargin - lmargin)
 		    move(mm(p_width - rmargin), mm(footer_y));
 		else
-		    move(mm(p_width - rmargin), mm(footer_y) + pt(7.5));
+		    move(mm(p_width - rmargin),
+			 mm(footer_y) + pt(fs_label * 1.25));
 		rlabel(scales);
 		/* reset scales for next page */
 		if (smode == 1)
 		    (void)sprintf(scales, "%g mm/sec", tscale);
 		else
-		    (void)sprintf(scales, "Grid intervals: %g sec", 1.0/TPS);
+		    (void)sprintf(scales, "Grid intervals: %g sec", 1.0/tps);
 	    }
 	}
 	(void)printf("endpsfd\n");
@@ -1327,6 +1427,31 @@
     }
 }
 
+void setrgbcolor(color)
+struct pscolor *color;
+{
+  static struct pscolor currentcolor = { -1.0, -1.0, -1.0 };
+
+  if (Cflag == 0) {
+    color->red = 0;
+    color->green = 0;
+    color->blue = 0;
+  }
+  if (color->red == currentcolor.red &&
+    color->green == currentcolor.green &&
+    color->blue == currentcolor.blue)
+    return;
+  if (color->red < 0.0 || color->red > 1.0 ||
+    color->green < 0.0 || color->green > 1.0 ||
+    color->blue < 0.0 || color->blue > 1.0)
+    return;
+  if (Cflag == 0)
+    printf("0 setgray\n");
+  else
+    printf("%g %g %g setrgbcolor\n", color->red, color->green, color->blue);
+  currentcolor = *color;
+}
+
 static int bya, byd;
 void setbar1(ya, yd)
 int ya, yd;
@@ -1561,7 +1686,11 @@
  " -A ANN    specify second annotator (default: none)",
  " -b N      set binding offset in mm (default: 0)",
  " -c STR    set copyright notice",
- " -C        print counter values",
+ " -C        produce charts in color (default: black and white)",
+ " -CX RED GREEN BLUE  specify a color, where 'X' is 'a' (annotations),",
+ "   'g' (grid), 'l' (labels), or 's' (signals); and RED, GREEN, BLUE are",
+ "   between 0 and 1 inclusive (example: '-Cs 0 .5 1' causes the signals to",
+ "   be drawn in blue-green on a color-capable device)",
  " -d N      specify printer resolution in dpi (default: 300)",	/* ** DPI ** */
  " -e        even/odd processing for two-sided printing",
  " -E        generate EPSF",
@@ -1578,6 +1707,7 @@
  "   attached signal, annotations at center), or 3 (bars across attached",
  "   signal, annotations above bars) (default: 0)",
  " -n N      set first page number (default: 1)",
+ " -N        print counter values",
  " -p        pack short strips side-by-side",
  " -P PAGESIZE  set page dimensions (default: letter)",	  /* ** DEF_PTYPE ** */
  " -R        include record names in page headers",
@@ -1591,6 +1721,7 @@
  " -u        generate `unstructured' PostScript",
  " -v N      set voltage scale to N mm/mV (default: 1)",     /* ** VSCALE ** */
  " -V        verbose mode",
+ " -w N      set line width to N mm (default: 0.2; 0 is narrowest possible)",
  " -x        extend last strip up to 10% if necessary",
  " -1        print only first character of comment annotation strings",
  " -         read script from standard input",
@@ -1625,14 +1756,15 @@
 static char *dprolog[] = {
 " %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
 " % If this message appears in your printout, you may be using a buggy version %",
-" % of Adobe TranScript. Try using pschart with the -u option as a workaround. %",
+" % of Adobe TranScript. Try using psfd with the -u option as a workaround.    %",
 " %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
 "save 100 dict begin /psfd exch def",
 "/dpi 300 def",
-"/lw 0 def",
+"/mm {72 mul 25.4 div}def",
+"/lwmm 0.2 def",
+"/lw lwmm mm def",
 "/tm matrix currentmatrix def",
 "/gm matrix currentmatrix def",
-"/mm {72 mul 25.4 div}def",
 "/I {/Times-Italic findfont exch scalefont setfont}def",
 "/R {/Times-Roman findfont exch scalefont setfont}def",
 "/S {/Helvetica findfont exch scalefont setfont}def",
@@ -1656,11 +1788,11 @@
 
 "/prco { mm exch mm exch moveto",
 " 6 R (Copyright ) show",
-" /Symbol findfont 6 scalefont setfont (\323) show",
+" /Symbol findfont 6 scalefont setfont (\\323) show",
 " 6 R show } def",
 
 "/newpage {/dpi exch def tm setmatrix newpath [] 0 setdash 0 setgray",
-" 1 setlinecap dpi 600 idiv /lw exch def mark } def",
+" 1 setlinecap /lw lwmm mm def mark } def",
 
 "/ss {72 dpi div dup scale /gm matrix currentmatrix def lw setlinewidth} def",
 
@@ -1697,7 +1829,7 @@
 
 "/a {ya yb ne {dup mb}if ay m t}bind def",
 
-"/A {ya yb ne {dup mb}if ay m (\267) t}bind def",
+"/A {ya yb ne {dup mb}if ay m (\\267) t}bind def",
 
 "/endpsfd {cleartomark showpage psfd end restore}def",
 NULL
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/app/psfd.pro wfdb-10.3.17/app/psfd.pro
--- wfdb-10.3.16/app/psfd.pro	2000-01-30 04:13:16.000000000 -0500
+++ wfdb-10.3.17/app/psfd.pro	2005-08-11 17:49:03.000000000 -0400
@@ -1,9 +1,9 @@
 % file: psfd.pro	G. Moody	10 August 1988
-%			Last revised:	  3 May 1999
+%			Last revised:	11 August 2005
 
 % -----------------------------------------------------------------------------
 % prolog for psfd output
-% Copyright (C) 1999 George B. Moody
+% Copyright (C) 1988-2005 George B. Moody
 
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -38,8 +38,14 @@
 % printer resolution (dots per inch; reset by newpage, see below)
 /dpi 300 def
 
-% line width (may be reset by newpage)
-/lw 0 def
+% x mm: convert x (in mm) to PostScript points (assuming default scales)
+/mm {72 mul 25.4 div}def
+
+% line width in mm for signals, grid lines, marker bars
+/lwmm 0.2 def
+
+% line width in PostScript points (reset by newpage)
+/lw lwmm mm def
 
 % TM for text
 /tm matrix currentmatrix def
@@ -47,9 +53,6 @@
 % TM for graphics
 /gm matrix currentmatrix def
 
-% x mm: convert x (in mm) to Postscript points (assuming default scales)
-/mm {72 mul 25.4 div}def
-
 % n I: use italic font, n points
 /I {/Times-Italic findfont exch scalefont setfont}def
 
@@ -93,7 +96,7 @@
 
 % dpi newpage: start page, resolution dpi dots per inch
 /newpage {/dpi exch def tm setmatrix newpath [] 0 setdash 0 setgray
- 1 setlinecap dpi 600 idiv /lw exch def mark } def
+ 1 setlinecap /lw lwmm mm def mark } def
 
 % ss: set scales for plotting
 /ss {72 dpi div dup scale /gm matrix currentmatrix def lw setlinewidth} def
@@ -139,7 +142,7 @@
 
 % x mb: draw marker bars at x
 /mb { dup ya newpath moveto dup yb lineto dup yc moveto yd lineto
-[lw ye] 0 setdash stroke [] 0 setdash}bind def
+ [lw ye] 0 setdash stroke [] 0 setdash}bind def
 
 % str x a: plot str at (x, ay), with marker bars if defined
 /a {ya yb ne {dup mb}if ay m t}bind def
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/app/rdsamp.c wfdb-10.3.17/app/rdsamp.c
--- wfdb-10.3.16/app/rdsamp.c	2004-03-08 10:10:57.000000000 -0500
+++ wfdb-10.3.17/app/rdsamp.c	2005-06-29 17:51:12.000000000 -0400
@@ -1,5 +1,5 @@
 /* file: rdsamp.c	G. Moody	 23 June 1983
-			Last revised:    8 March 2004
+			Last revised:    29 June 2005
 
 -------------------------------------------------------------------------------
 rdsamp: Print an arbitrary number of samples from each signal
@@ -271,9 +271,13 @@
 
 	while ((to == 0L || from < to) && getvec(v) >= 0) {
 	    (void)printf("%7.3lf", (double)(from++)/freq);
-	    for (i = 0; i < nsig; i++)
-		(void)printf(fmt,
+	    for (i = 0; i < nsig; i++) {
+		if (v[sig[i]] != WFDB_INVALID_SAMPLE)
+		    (void)printf(fmt,
 		    (double)(v[sig[i]] - si[sig[i]].baseline)/si[sig[i]].gain);
+		else
+		    (void)printf(pflag > 1 ? "\t%15s" : "\t%7s", "-");
+	    }
 	    (void)printf("\n");
 	}
     }
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/app/sumstats.c wfdb-10.3.17/app/sumstats.c
--- wfdb-10.3.16/app/sumstats.c	2002-11-14 18:59:02.000000000 -0500
+++ wfdb-10.3.17/app/sumstats.c	2005-08-19 21:25:59.000000000 -0400
@@ -1,8 +1,8 @@
 /* file: sumstats.c	G. Moody	17 August 1989
-   			Last revised:  14 November 2002
+   			Last revised:	19 August 2005
 -------------------------------------------------------------------------------
 sumstats: Derive aggregate statistics from bxb, rxr, or epic line-format output
-Copyright (C) 2002 George B. Moody
+Copyright (C) 1989-2005 George B. Moody
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -34,7 +34,7 @@
 #include <stdio.h>
 #include <wfdb/wfdb.h>
 
-static int nrec, NQS, NQP, NVS, NVP, NVF, NSVS, NSVP;
+static int nrec, NQS, NQP, NVS, NVP, NVF, NSVS, NSVP, NRRE;
 static long Nn, Ns, Nv, No, Nx,
 	    Sn, Ss, Sv, So, Sx,
 	    Vn, Vs, Vv, Vo, Vx,
@@ -233,7 +233,7 @@
 	pstat(" %6.2f", CVP, (double)NVP);
 	pstat(" %6.2f", CSVS, (double)NSVS);
 	pstat(" %6.2f", CSVP, (double)NSVP);
-	pstat(" %6.2f", CRRE/100.0, (double)nrec);
+	pstat(" %6.2f", CRRE/100.0, (double)NRRE);
 	(void)printf(
 	     "\nTotal QRS complexes: %ld  Total VEBs: %ld  Total SVEBs: %ld\n",
 		  QTP+QFN, Vn+Vs+Vv+Vo, Sn+Ss+Sv+So);
@@ -283,7 +283,7 @@
 char *s;
 {
     static char rec[10], mb[8], mn[8], ms[8], mv[8], mf[8], mds[8], mdp[8];
-    static char qse[8], qpp[8], vse[8], vpp[8], sse[8], spp[8];
+    static char qse[8], qpp[8], vse[8], vpp[8], sse[8], spp[8], srre[8];
     static char rts[20], tts[20];
     static double rre, ds, dp, err, mref;
     static int cts, cfn, ctp, cfp, sts, sfn, stp, sfp, lts, lfn, ltp, lfp;
@@ -369,17 +369,17 @@
 	nrec++;
 	return (1);
       case 4:	/* bxb -L beat-by-beat report */
-	rre = -1.0;
+	fo = -1L;
 	(void)sscanf(s,
- "%s%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%s%s%s%s%s%s%lf",
+ "%s%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%s%s%s%s%s%s%s",
 	       rec, &nn, &sn, &vn, &fn, &on, &ns, &ss, &vs, &fs, &os,
 			  &nv, &sv, &vv, &fv, &ov, &no, &so, &vo, &fo,
-				  qse, qpp, vse, vpp, sse, spp, &rre);
-	if (rre < 0.0) return (0);
+				  qse, qpp, vse, vpp, sse, spp, srre);
+	if (fo < 0L) return (0);
 	Nn += nn; Sn += sn; Vn += vn; Fn += fn; On += on;
 	Ns += ns; Ss += ss; Vs += vs; Fs += fs; Os += os;
 	Nv += nv; Sv += sv; Vv += vv; Fv += fv; Ov += ov;
-	No += no; So += so; Vo += vo; Fo += fo; CRRE += rre;
+	No += no; So += so; Vo += vo; Fo += fo;
 	if (nn+ns+nv+no + sn+ss+sv+so + vn+vs+vv+vo + fn+fs+fv+fo) {
 	    CQS += (nn+ns+nv+sn+ss+sv+vn+vs+vv+fn+fs+fv) /
 		    (double)(nn+ns+nv+no+sn+ss+sv+so+vn+vs+vv+vo+fn+fs+fv+fo);
@@ -406,6 +406,12 @@
 	    CSVP += ss/(double)(ns+ss+vs+os);
 	    NSVP++;
 	}
+	rre = -1.0;
+	(void)sscanf(srre, "%lf", &rre);
+	if (rre >= 0.0) {
+	    CRRE += rre;
+	    NRRE++;
+	}
 	nrec++;
 	return (1);
       case 5:	/* bxb -L shutdown report */
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/app/wfdbdesc.c wfdb-10.3.17/app/wfdbdesc.c
--- wfdb-10.3.16/app/wfdbdesc.c	2003-07-09 14:22:24.000000000 -0400
+++ wfdb-10.3.17/app/wfdbdesc.c	2005-08-11 15:47:25.000000000 -0400
@@ -1,5 +1,5 @@
 /* file: wfdbdesc.c		G. Moody	  June 1989
-				Last revised:	9 July 2003
+				Last revised:  11 August 2005
 
 -------------------------------------------------------------------------------
 wfdbdesc: Describe signal specifications
@@ -67,10 +67,13 @@
     t = strtim("e");
     if (nsig > 0 && s[0].nsamp != t) {
 	msrec = 1;
-	(void)printf(" (a multi-segment record)\n");
-	(void)printf("----------------------------------------------\n");
-	(void)printf("The following data apply to the entire record:\n");
-	(void)printf("----------------------------------------------");
+	(void)printf(" (a %s-layout multi-segment record)\n",
+		     s[0].nsamp == 0L ? "variable" : "fixed");
+	if (s[0].nsamp != 0L) {
+	    (void)printf("----------------------------------------------\n");
+	    (void)printf("The following data apply to the entire record:\n");
+	    (void)printf("----------------------------------------------");
+	}
     }
     else if (info = getinfo((char *)NULL)) {
        (void)printf("\nNotes\n=====\n");
@@ -117,7 +120,7 @@
     (void)printf("Sampling frequency: %g Hz\n", sampfreq(NULL));
     (void)printf("%d signal%s\n", nsig, nsig == 1 ? "" : "s");
     if (nsig < 1) exit(2);
-    if (msrec) {
+    if (msrec && s[0].nsamp != 0L) {
 	(void)printf("----------------------------------------------\n");
 	(void)printf("The following data apply to the first segment:\n");
 	(void)printf("----------------------------------------------\n");
@@ -134,10 +137,12 @@
         else (void)printf("%g", s[i].gain);
 	(void)printf(" adu/%s\n", s[i].units ? s[i].units : "mV");
         (void)printf(" Initial value: %d\n", s[i].initval);
-        (void)printf(" Storage format: %d", s[i].fmt);
+	if (s[i].fmt != 0)
+	    (void)printf(" Storage format: %d", s[i].fmt);
 	if (s[i].spf > 1)
 	    (void)printf(" (%d samples per frame)", s[i].spf);
-	(void)printf("\n");
+	if (s[i].fmt != 0 || s[i].spf > 1)
+	    (void)printf("\n");
         (void)printf(" I/O: ");
         if (s[i].bsize == 0) (void)printf("can be unbuffered\n");
         else (void)printf("%d-byte blocks\n", s[i].bsize);
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/app/wrsamp.c wfdb-10.3.17/app/wrsamp.c
--- wfdb-10.3.16/app/wrsamp.c	2004-01-26 15:07:16.000000000 -0500
+++ wfdb-10.3.17/app/wrsamp.c	2005-08-11 15:50:13.000000000 -0400
@@ -1,5 +1,5 @@
 /* file: wrsamp.c	G. Moody	10 August 1993
-			Last revised:  21 November 2002
+			Last revised:   11 August 2005
 -------------------------------------------------------------------------------
 wrsamp: Select fields or columns from a file and generate a WFDB record
 Copyright (C) 2002 George B. Moody
@@ -264,13 +264,14 @@
 			(void)fprintf(stderr,
 				      "%s: line %ld, column %d missing\n",
 				      pname, t, fv[i]);
-			vout[i] = 0;
+			vout[i] = WFDB_INVALID_SAMPLE;
 		    }
 		    else if (sscanf(p, "%lf", &v) != 1) {
-			(void)fprintf(stderr,
+			if (strcmp(p, "-") != 0)
+			    (void)fprintf(stderr,
 			      "%s: line %ld, column %d improperly formatted\n",
 				      pname, t, fv[i]);
-			vout[i] = 0;
+			vout[i] = WFDB_INVALID_SAMPLE;
 		    }
 		    else {
 			v *= scalef[i];
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/app/xform.c wfdb-10.3.17/app/xform.c
--- wfdb-10.3.16/app/xform.c	2004-04-13 16:20:30.000000000 -0400
+++ wfdb-10.3.17/app/xform.c	2005-08-12 00:25:02.000000000 -0400
@@ -43,7 +43,7 @@
 	j, m, Mflag = 0, mn, *msiglist, n, nann = 0, nisig,
 	nminutes = 0, nosig = 0, oframelen, reopen = 0, sflag = 0,
 	*siglist = NULL, spf, uflag = 0, use_irec_desc = 1, *v, *vin, *vmax,
-	*vmin, *vout, *vv;
+	*vmin, *vout, vt, *vv;
     long from = 0L, it = 0L, nsamp = -1L, nsm = 0L, ot = 0L, spm, to = 0L;
     WFDB_Anninfo *ai = NULL;
     WFDB_Annotation annot;
@@ -732,18 +732,22 @@
 		}
 	    }
 	    for (i = 0; i < nosig; i++) {
-		vout[i] = vin[siglist[i]] + deltav[i];
-		if (vout[i] > vmax[i]) {
-		    (void)fprintf(stderr, "v[%d] = %d (out of range)\n",
-				  i, vout[i]);
-		    if (clip) vout[i] = vmax[i];
-		    else vmax[i] = vout[i];
-		}
-		else if (vout[i] < vmin[i]) {
-		    (void)fprintf(stderr, "v[%d] = %d (out of range)\n",
-				  i, vout[i]);
-		    if (clip) vout[i] = vmin[i];
-		    else vmin[i] = vout[i];
+		if ((vt = vin[siglist[i]]) == WFDB_INVALID_SAMPLE)
+		    vout[i] = vt;
+		else {
+		    vout[i] = vt + deltav[i];
+		    if (vout[i] > vmax[i]) {
+			(void)fprintf(stderr, "v[%d] = %d (out of range)\n",
+				      i, vout[i]);
+			if (clip) vout[i] = vmax[i];
+			else vmax[i] = vout[i];
+		    }
+		    else if (vout[i] < vmin[i]) {
+			(void)fprintf(stderr, "v[%d] = %d (out of range)\n",
+				      i, vout[i]);
+			if (clip) vout[i] = vmin[i];
+			else vmin[i] = vout[i];
+		    }
 		}
 	    }
 	    if (putvec(vout) < 0) break;
@@ -764,18 +768,22 @@
 	    }
 	    for (i = j = 0; i < nosig; i++) {
 	      for (k = 0; k < dfout[i].spf; j++, k++) {
-		vout[j] = vin[msiglist[i] + k] + deltav[i];
-		if (vout[j] > vmax[i]) {
-		    (void)fprintf(stderr, "v[%d] = %d (out of range)\n",
-				  i, vout[j]);
-		    if (clip) vout[j] = vmax[i];
-		    else vmax[i] = vout[j];
-		}
-		else if (vout[j] < vmin[i]) {
-		    (void)fprintf(stderr, "v[%d] = %d (out of range)\n",
-				  i, vout[j]);
-		    if (clip) vout[j] = vmin[i];
-		    else vmin[i] = vout[j];
+		if ((vt = vin[msiglist[i] + k]) == WFDB_INVALID_SAMPLE)
+		    vout[j] = vt;
+		else {
+		    vout[j] = vt + deltav[i];
+		    if (vout[j] > vmax[i]) {
+			(void)fprintf(stderr, "v[%d] = %d (out of range)\n",
+				      i, vout[j]);
+			if (clip) vout[j] = vmax[i];
+			else vmax[i] = vout[j];
+		    }
+		    else if (vout[j] < vmin[i]) {
+			(void)fprintf(stderr, "v[%d] = %d (out of range)\n",
+				      i, vout[j]);
+			if (clip) vout[j] = vmin[i];
+			else vmin[i] = vout[j];
+		    }
 		}
 	      }
 	    }
@@ -796,18 +804,22 @@
 		}
 	    }
 	    for (i = 0; i < nosig; i++) {
-		vout[i] = vin[siglist[i]]*gain[i] + deltav[i];
-		if (vout[i] > vmax[i]) {
-		    (void)fprintf(stderr, "v[%d] = %d (out of range)\n",
-				  i, vout[i]);
-		    if (clip) vout[i] = vmax[i];
-		    else vmax[i] = vout[i];
-		}
-		else if (vout[i] < vmin[i]) {
-		    (void)fprintf(stderr, "v[%d] = %d (out of range)\n",
-				  i, vout[i]);
-		    if (clip) vout[i] = vmin[i];
-		    else vmin[i] = vout[i];
+		if ((vt = vin[siglist[i]]) == WFDB_INVALID_SAMPLE)
+		    vout[i] = vt;
+		else {
+		    vout[i] = vt*gain[i] + deltav[i];
+		    if (vout[i] > vmax[i]) {
+			(void)fprintf(stderr, "v[%d] = %d (out of range)\n",
+				      i, vout[i]);
+			if (clip) vout[i] = vmax[i];
+			else vmax[i] = vout[i];
+		    }
+		    else if (vout[i] < vmin[i]) {
+			(void)fprintf(stderr, "v[%d] = %d (out of range)\n",
+				      i, vout[i]);
+			if (clip) vout[i] = vmin[i];
+			else vmin[i] = vout[i];
+		    }
 		}
 	    }
 	    if (putvec(vout) < 0) break;
@@ -828,18 +840,22 @@
 	    }
 	    for (i = j = 0; i < nosig; i++) {
 	      for (k = 0; k < dfout[i].spf; j++, k++) {
-		vout[j] = vin[msiglist[i] + k]*gain[i] + deltav[i];
-		if (vout[j] > vmax[i]) {
-		    (void)fprintf(stderr, "v[%d] = %d (out of range)\n",
-				  i, vout[j]);
-		    if (clip) vout[j] = vmax[i];
-		    else vmax[i] = vout[j];
-		}
-		else if (vout[j] < vmin[i]) {
-		    (void)fprintf(stderr, "v[%d] = %d (out of range)\n",
-				  i, vout[j]);
-		    if (clip) vout[j] = vmin[i];
-		    else vmin[i] = vout[j];
+		if ((vt = vin[msiglist[i] + k]) == WFDB_INVALID_SAMPLE)
+		    vout[j] = vt;
+		else {
+		    vout[j] = vt*gain[i] + deltav[i];
+		    if (vout[j] > vmax[i]) {
+			(void)fprintf(stderr, "v[%d] = %d (out of range)\n",
+				      i, vout[j]);
+			if (clip) vout[j] = vmax[i];
+			else vmax[i] = vout[j];
+		    }
+		    else if (vout[j] < vmin[i]) {
+			(void)fprintf(stderr, "v[%d] = %d (out of range)\n",
+				      i, vout[j]);
+			if (clip) vout[j] = vmin[i];
+			else vmin[i] = vout[j];
+		    }
 		}
 	      }
 	    }
@@ -858,23 +874,32 @@
 		    (void)fprintf(stderr, "\n");
 		}
 	    }
-	    for (i = 0; i < nosig; i++)
-		v[i] = vin[siglist[i]] + deltav[i];
+	    for (i = 0; i < nosig; i++) {
+		if ((vt = vin[siglist[i]]) == WFDB_INVALID_SAMPLE)
+		    v[i] = vt;
+		else
+		    v[i] = vt + deltav[i];
+	    }
 	    while (ot <= it) {
 		double x = (ot%n == 0) ? 1.0 : (double)(ot % n)/(double)n;
 		for (i = 0; i < nosig; i++) {
-		    vout[i] = vv[i] + x*(v[i]-vv[i]);
-		    if (vout[i] > vmax[i]) {
-			(void)fprintf(stderr, "v[%d] = %d (out of range)\n",
-				      i, vout[i]);
-			if (clip) vout[i] = vmax[i];
-			else vmax[i] = vout[i];
-		    }
-		    else if (vout[i] < vmin[i]) {
-			(void)fprintf(stderr, "v[%d] = %d (out of range)\n",
-				      i, vout[i]);
-			if (clip) vout[i] = vmin[i];
-			else vmin[i] = vout[i];
+		    if (v[i] == WFDB_INVALID_SAMPLE ||
+			vv[i] == WFDB_INVALID_SAMPLE)
+			vout[i] = WFDB_INVALID_SAMPLE;
+		    else {
+			vout[i] = vv[i] + x*(v[i]-vv[i]);
+			if (vout[i] > vmax[i]) {
+			    (void)fprintf(stderr,"v[%d] = %d (out of range)\n",
+					  i, vout[i]);
+			    if (clip) vout[i] = vmax[i];
+			    else vmax[i] = vout[i];
+			}
+			else if (vout[i] < vmin[i]) {
+			    (void)fprintf(stderr,"v[%d] = %d (out of range)\n",
+					  i, vout[i]);
+			    if (clip) vout[i] = vmin[i];
+			    else vmin[i] = vout[i];
+			}
 		    }
 		}
 		if (putvec(vout) < 0) { nsamp = 0L; break; }
@@ -897,23 +922,32 @@
 		    (void)fprintf(stderr, "\n");
 		}
 	    }
-	    for (i = 0; i < nosig; i++)
-		v[i] = vin[siglist[i]]*gain[i] + deltav[i];
+	    for (i = 0; i < nosig; i++) {
+		if ((vt = vin[siglist[i]]) == WFDB_INVALID_SAMPLE)
+		    v[i] = vt;
+		else
+		    v[i] = vt * gain[i] + deltav[i];
+	    }
 	    while (ot <= it) {
 		double x = (ot%n == 0) ? 1.0 : (double)(ot % n)/(double)n;
 		for (i = 0; i < nosig; i++) {
-		    vout[i] = vv[i] + x*(v[i]-vv[i]);
-		    if (vout[i] > vmax[i]) {
-			(void)fprintf(stderr, "v[%d] = %d (out of range)\n",
-				      i, vout[i]);
-			if (clip) vout[i] = vmax[i];
-			else vmax[i] = vout[i];
-		    }
-		    else if (vout[i] < vmin[i]) {
-			(void)fprintf(stderr, "v[%d] = %d (out of range)\n",
-				      i, vout[i]);
-			if (clip) vout[i] = vmin[i];
-			else vmin[i] = vout[i];
+		    if (v[i] == WFDB_INVALID_SAMPLE ||
+			vv[i] == WFDB_INVALID_SAMPLE)
+			vout[i] = WFDB_INVALID_SAMPLE;
+		    else {
+			vout[i] = vv[i] + x*(v[i]-vv[i]);
+			if (vout[i] > vmax[i]) {
+			    (void)fprintf(stderr,"v[%d] = %d (out of range)\n",
+					  i, vout[i]);
+			    if (clip) vout[i] = vmax[i];
+			    else vmax[i] = vout[i];
+			}
+			else if (vout[i] < vmin[i]) {
+			    (void)fprintf(stderr,"v[%d] = %d (out of range)\n",
+					  i, vout[i]);
+			    if (clip) vout[i] = vmin[i];
+			    else vmin[i] = vout[i];
+			}
 		    }
 		}
 		if (putvec(vout) < 0) { nsamp = 0L; break; }
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/check-manifest wfdb-10.3.17/check-manifest
--- wfdb-10.3.16/check-manifest	2002-11-01 06:54:38.000000000 -0500
+++ wfdb-10.3.17/check-manifest	2005-08-12 01:53:16.000000000 -0400
@@ -4,7 +4,7 @@
 # Verify tarball contents
 
 PACKAGE=$1
-sort <../${PACKAGE}-MANIFEST >../sort.$$
+sort -f <../${PACKAGE}-MANIFEST >../sort.$$
 mv ../sort.$$ ../${PACKAGE}-MANIFEST
 if diff MANIFEST ../${PACKAGE}-MANIFEST
 then
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/checkpkg/appcheck wfdb-10.3.17/checkpkg/appcheck
--- wfdb-10.3.16/checkpkg/appcheck	2003-02-23 15:38:57.000000000 -0500
+++ wfdb-10.3.17/checkpkg/appcheck	2005-08-04 20:59:09.000000000 -0400
@@ -1,6 +1,6 @@
 #!/bin/sh
 # file: appcheck		G. Moody       7 September 2001
-#                               Last revised:  23 February 2003
+#                               Last revised:   4 August 2005
 #
 # This script checks the functionality of the WFDB applications in the 'app'
 # directory.
@@ -12,11 +12,37 @@
 export WFDB
 
 INCDIR=$1
+BINDIR=$2
+LIBDIR=$3
 
 PASS=0
 FAIL=0
 TESTS=0
 
+PATH=$BINDIR:$PATH
+export PATH
+
+case `uname` in
+    Darwin*)
+	if [ "x$DYLD_LIBRARY_PATH" = x ]
+	    then
+	    DYLD_LIBRARY_PATH=$LIBDIR:$DYLD_LIBRARY_PATH
+	else
+	    DYLD_LIBRARY_PATH=$LIBDIR
+	fi
+	export DYLD_LIBRARY_PATH
+	;;
+    *)
+	if [ "x$LD_LIBRARY_PATH" = x ]
+	    then
+	    LD_LIBRARY_PATH=$LIBDIR:$LD_LIBRARY_PATH
+	else
+	    LD_LIBRARY_PATH=$LIBDIR
+	fi
+	export LD_LIBRARY_PATH
+	;;
+esac
+
 echo Testing wfdbwhich ...
 F=wfdbwhich.out
 wfdbwhich 100s.atr >$F 2>&1
@@ -331,7 +357,8 @@
 echo Testing sortann ...
 rdann -r 100s -a atr -f 30 >foo
 rdann -r 100s -a atr -t 30 >>foo
-( WFDBANNSORT=0; export WFDBANNSORT; wrann -r 100s -a mix <foo 2>wrann.log )
+( WFDBANNSORT=0; export WFDBANNSORT; \
+  wrann -r 100s -a mix <foo 2>wrann.log )
 rm -f foo
 sortann -r 100s -a mix
 F=100s.mix
@@ -448,8 +475,8 @@
 if ( grep "WFDB_NETFILES 1" $INCDIR/wfdb/wfdb.h >grep.out 2>&1 )
 then
   echo "Testing xform (with NETFILES) ..."
-  xform -i mimicdb/237/237 -s 1 2 0 3 -f 9:19:45 -t "[22:01:23 20/07/1995]" \
-   -a all -M -n xform -S input/xform >xform-2.out 2>&1
+  xform -i mimicdb/237/237 -s 1 2 0 3 -a all -M -n xform -f 9:19:45 \
+   -t "[22:01:23 20/07/1995]" -S input/xform >xform-2.out 2>&1
   for F in xform-2.out xform.hea xform.dat xform.all
   do
     if ( ./checkfile $F )
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/checkpkg/expected/lcheck.log-NETFILES wfdb-10.3.17/checkpkg/expected/lcheck.log-NETFILES
--- wfdb-10.3.16/checkpkg/expected/lcheck.log-NETFILES	2002-06-17 18:18:45.000000000 -0400
+++ wfdb-10.3.17/checkpkg/expected/lcheck.log-NETFILES	2005-07-01 20:56:04.000000000 -0400
@@ -3,7 +3,7 @@
 [OK]:  WFDB_MAXANN = 2
 [OK]:  WFDB_MAXSIG = 32
 [OK]:  WFDB_MAXSPF = 4
-[OK]:  WFDB_MAXRNL = 11
+[OK]:  WFDB_MAXRNL = 20
 [OK]:  WFDB_MAXUSL = 20
 [OK]:  WFDB_MAXDSL = 60
 [OK]:  Signal formats = {0, 8, 16, 61, 80, 160, 212, 310, 311}
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/checkpkg/expected/lcheck.log-no-NETFILES wfdb-10.3.17/checkpkg/expected/lcheck.log-no-NETFILES
--- wfdb-10.3.16/checkpkg/expected/lcheck.log-no-NETFILES	2002-06-17 18:16:54.000000000 -0400
+++ wfdb-10.3.17/checkpkg/expected/lcheck.log-no-NETFILES	2005-07-01 20:57:40.000000000 -0400
@@ -3,7 +3,7 @@
 [OK]:  WFDB_MAXANN = 2
 [OK]:  WFDB_MAXSIG = 32
 [OK]:  WFDB_MAXSPF = 4
-[OK]:  WFDB_MAXRNL = 11
+[OK]:  WFDB_MAXRNL = 20
 [OK]:  WFDB_MAXUSL = 20
 [OK]:  WFDB_MAXDSL = 60
 [OK]:  Signal formats = {0, 8, 16, 61, 80, 160, 212, 310, 311}
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/checkpkg/expected/pschart.ps wfdb-10.3.17/checkpkg/expected/pschart.ps
--- wfdb-10.3.16/checkpkg/expected/pschart.ps	2003-07-09 13:59:45.000000000 -0400
+++ wfdb-10.3.17/checkpkg/expected/pschart.ps	2005-08-11 18:07:50.000000000 -0400
@@ -15,11 +15,11 @@
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 save 100 dict begin /pschart exch def
 /dpi 300 def
-/lw 0 def
-/lwmm 0 def
+/mm {72 mul 25.4 div}def
+/lwmm 0.2 def
+/lw lwmm mm def
 /tm matrix currentmatrix def
 /gm matrix currentmatrix def
-/mm {72 mul 25.4 div}def
 /I {/Times-Italic findfont exch scalefont setfont}def
 /R {/Times-Roman findfont exch scalefont setfont}def
 /C {/Courier findfont exch scalefont setfont}def
@@ -83,9 +83,9 @@
 862 2440 1601 2912 0.5 0.5 grid
 12 R
 862 2924 m
-851 2660 m
+851 2651 m
 (0:10)b
-1612 2660 m
+1612 2651 m
 (0:15)t
 10 I
 851 2782 m
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/checkpkg/expected/psfd.ps wfdb-10.3.17/checkpkg/expected/psfd.ps
--- wfdb-10.3.16/checkpkg/expected/psfd.ps	2002-11-22 14:23:32.000000000 -0500
+++ wfdb-10.3.17/checkpkg/expected/psfd.ps	2005-08-11 18:07:50.000000000 -0400
@@ -15,10 +15,11 @@
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 save 100 dict begin /psfd exch def
 /dpi 300 def
-/lw 0 def
+/mm {72 mul 25.4 div}def
+/lwmm 0.2 def
+/lw lwmm mm def
 /tm matrix currentmatrix def
 /gm matrix currentmatrix def
-/mm {72 mul 25.4 div}def
 /I {/Times-Italic findfont exch scalefont setfont}def
 /R {/Times-Roman findfont exch scalefont setfont}def
 /S {/Helvetica findfont exch scalefont setfont}def
@@ -42,7 +43,7 @@
  /Symbol findfont 6 scalefont setfont (\323) show
  6 R show } def
 /newpage {/dpi exch def tm setmatrix newpath [] 0 setdash 0 setgray
- 1 setlinecap dpi 600 idiv /lw exch def mark } def
+ 1 setlinecap /lw lwmm mm def mark } def
 /ss {72 dpi div dup scale /gm matrix currentmatrix def lw setlinewidth} def
 /t {tm setmatrix show gm setmatrix}def
 /b {tm setmatrix dup stringwidth exch neg exch rmoveto currentpoint 3 -1 roll
@@ -63,11 +64,12 @@
 /Sb {/yb exch def /ya exch def /yc yb def /yd yb def
  /ye dpi 50.8 div lw sub def}def
 /mb { dup ya newpath moveto dup yb lineto dup yc moveto yd lineto
-[lw ye] 0 setdash stroke [] 0 setdash}bind def
+ [lw ye] 0 setdash stroke [] 0 setdash}bind def
 /a {ya yb ne {dup mb}if ay m t}bind def
 /A {ya yb ne {dup mb}if ay m (\267) t}bind def
 /endpsfd {cleartomark showpage psfd end restore}def
 300 newpage
+0 setgray
 1 104.31 259.61 prpn
 ss
 8 R
@@ -81,27 +83,27 @@
 2135 2915 m
 (MLII)t
 346 2930 m
-(OMPNPN`@PRPNPPPPRRNPPPPPPRPNNP^HJPPPPPNPRRPPPNPPPRRNNPP^BPPPPPPPQPPNPPPPRPPNPNZLLPPPPPPPRPPPPNPPRRNNPN`@RPPPPNPRRPPPPPPPRPNNPP\\DOPPPPPNRRPPPPPPPPRPNNP^DNPPPPPPPRPPPPRNNPN`BPPPPPPPPRPPNPPPPPPPOPPRPPNPP^@PPPPRNPPRRPPNPPPPRPPNPNb>RPPPPPPPRPPPPNPRPRPNNP) z
-(\\FNPPPOPPPRPPPPPPPPRPNPN^BPPPPPPPRPPPPPPPPRPNNP^BPPPPPPNRRPPPPPPPPPRPMPNZLJPPPPPPPRRNPPPPPPPRPNPNNb@PPPPPPPPRPPPPPPPPRPNNPRXFPPPPPPNRQPPPNPPPRPPNPPTVFPNRNRNPRRPPNPPPPRRNNPN`BPPPPPPPPRPPPPPPPRPPNNN_BPPPPPPPPRPPPPPPPPRNNPPd<PPPPPPNRRPPNPPPPRPPNPP\\DPP) z
-(PPPNRRPPPPPPOPPRPNNP\\HLPPPPPPPPRPPPPPPNRPRPNNPZLJPPPPPPPRPPPPPPPPPRNNPNb>RPOPPNPRRPPPNPPRPPPNPRZDPPPPPPPRPPPPPPPPRPNNP\\PDPPPPPPPRPPPPPPPRPPMNRZDPPPPPPPPRPPPNPPRRNNPP^BPNPPPPPPRRPNPPPPPRPNPNTZBPPPPPPPRPPOPPPPPPRPNNNb@PPPPPPPPRPPPPNPPPRPPNPN`@PPPPPRN) z
-(PRRPPNPPPPRRNNPN^FMPPPPNPRRPPPPNRPPRPNPN\\NFPPPPPPPRRNPPPPPRPPNPP\\DPNRPPNRPRPNPPPPORPNPNRZDPPPPPPPRPPPPPPPPRPNNP\\HLPPPPPPPRRNPPPPPPPRPPNPLd>PPPPPPOPRPRNPPPPPPRPNPN\\JJPPPPPPPRPPPPPPPPPRPNNN`BPPPPPPPPRPPPPPPPPRPMPN`@PPPPPPPPRRPPPNPPPRPPNPNb@NPPPPPPR) z
-(RPNPPPPPRPPNPN^BRPPPPPPPRNOPPPPPRPNNPR\\BPPPPPNPRRPPPNPPPRRNNPN`BPPPPPPNRRPPPPPPPPPRPNPNTZAPPPPPPPPRPPPPPPPPPRPNPNNb@PPPPPPPPRPPPPPPPPRPNPPPZDPPPPPPPRPPPPOPPRPRLPNb>RPPPPPNRRPPPNRNRPRPNNNb>RPPPPPPPRPPPPNPPRRNPNPXLJPPPOPPPRPPPPPPPPRPNNPZJLPPPPPNRRPPPP) z
-(PPPPRPPNPNXPHPPPPPPPRRPPPNPPPRROLPN\\HNPPPPPPPRPPPPNPPRPRPLPN`@RPPNRPNPRRPNPPPPPRPNPPVPJNPPPPPPQRPNPPPPRPPNPNf<NRPPPPNRRPPNPPPPRPPNPVVDPPPPPPPPRPNPPPPPRPNPPN^BOPPPPPPPRPPPPPPPPRPPNPN`@RPPPPNPRRPPPPPPPPPRPNNNb@PPPPPPPPRPPPPOPPPRPPNPNh8PPPPPPPPRPPPNPPP) z
-(RPPNPN`@PPPPPPPRPPPPPPPPRPNPNZLJPPPPOPRRPPNPPPPRPPNPN\\HLPPPPPPRPPPPPPPPRPNPNP`@PPPPPPPRPPPPPPPPRPNPMTVFPPPPPPPPRRPPNPPPRRPNNRLb@PPPPPPPPRRPNPPPPPRPPPNPTXBPRNPPPPRRONPPPPPRPPNPN\\FNPPPPPPPRPPPPPPPRPNPPN^BPPPPPPPRRPPNPPPRRPNNPZJLOPPPPPPRPPPPPPPRPPNPLb) z
-(@PPPPPPPRPPPPPPPPPRPNNPVPJPPPPPNPRRPPPNPPPQPPNPP`>RPPPPPNRRPPP) z
+(MPNPN`@PRPNPPPPRRNPPPPPPRPNNP^HJPPPPPNPRRPPPNPPPRRNNPP^BPPPPPPPQPPNPPPPRPPNPNZLLPPPPPPPRPPPPNPPRRNNPN`@RPPPPNPRRPPPPPPPRPNNPP\\DOPPPPPNRRPPPPPPPPRPNNP^DNPPPPPPPRPPPPRNNPN`BPPPPPPPPRPPNPPPPPPPOPPRPPNPP^@PPPPRNPPRRPPNPPPPRPPNPNb>RPPPPPPPRPPPPNPRPRPNNP\\) z
+(FNPPPOPPPRPPPPPPPPRPNPN^BPPPPPPPRPPPPPPPPRPNNP^BPPPPPPNRRPPPPPPPPPRPMPNZLJPPPPPPPRRNPPPPPPPRPNPNNb@PPPPPPPPRPPPPPPPPRPNNPRXFPPPPPPNRQPPPNPPPRPPNPPTVFPNRNRNPRRPPNPPPPRRNNPN`BPPPPPPPPRPPPPPPPRPPNNN_BPPPPPPPPRPPPPPPPPRNNPPd<PPPPPPNRRPPNPPPPRPPNPP\\DPPPP) z
+(PNRRPPPPPPOPPRPNNP\\HLPPPPPPPPRPPPPPPNRPRPNNPZLJPPPPPPPRPPPPPPPPPRNNPNb>RPOPPNPRRPPPNPPRPPPNPRZDPPPPPPPRPPPPPPPPRPNNP\\PDPPPPPPPRPPPPPPPRPPMNRZDPPPPPPPPRPPPNPPRRNNPP^BPNPPPPPPRRPNPPPPPRPNPNTZBPPPPPPPRPPOPPPPPPRPNNNb@PPPPPPPPRPPPPNPPPRPPNPN`@PPPPPRNPR) z
+(RPPNPPPPRRNNPN^FMPPPPNPRRPPPPNRPPRPNPN\\NFPPPPPPPRRNPPPPPRPPNPP\\DPNRPPNRPRPNPPPPORPNPNRZDPPPPPPPRPPPPPPPPRPNNP\\HLPPPPPPPRRNPPPPPPPRPPNPLd>PPPPPPOPRPRNPPPPPPRPNPN\\JJPPPPPPPRPPPPPPPPPRPNNN`BPPPPPPPPRPPPPPPPPRPMPN`@PPPPPPPPRRPPPNPPPRPPNPNb@NPPPPPPRRP) z
+(NPPPPPRPPNPN^BRPPPPPPPRNOPPPPPRPNNPR\\BPPPPPNPRRPPPNPPPRRNNPN`BPPPPPPNRRPPPPPPPPPRPNPNTZAPPPPPPPPRPPPPPPPPPRPNPNNb@PPPPPPPPRPPPPPPPPRPNPPPZDPPPPPPPRPPPPOPPRPRLPNb>RPPPPPNRRPPPNRNRPRPNNNb>RPPPPPPPRPPPPNPPRRNPNPXLJPPPOPPPRPPPPPPPPRPNNPZJLPPPPPNRRPPPPPP) z
+(PPRPPNPNXPHPPPPPPPRRPPPNPPPRROLPN\\HNPPPPPPPRPPPPNPPRPRPLPN`@RPPNRPNPRRPNPPPPPRPNPPVPJNPPPPPPQRPNPPPPRPPNPNf<NRPPPPNRRPPNPPPPRPPNPVVDPPPPPPPPRPNPPPPPRPNPPN^BOPPPPPPPRPPPPPPPPRPPNPN`@RPPPPNPRRPPPPPPPPPRPNNNb@PPPPPPPPRPPPPOPPPRPPNPNh8PPPPPPPPRPPPNPPPRP) z
+(PNPN`@PPPPPPPRPPPPPPPPRPNPNZLJPPPPOPRRPPNPPPPRPPNPN\\HLPPPPPPRPPPPPPPPRPNPNP`@PPPPPPPRPPPPPPPPRPNPMTVFPPPPPPPPRRPPNPPPRRPNNRLb@PPPPPPPPRRPNPPPPPRPPPNPTXBPRNPPPPRRONPPPPPRPPNPN\\FNPPPPPPPRPPPPPPPRPNPPN^BPPPPPPPRRPPNPPPRRPNNPZJLOPPPPPPRPPPPPPPRPPNPLb@P) z
+(PPPPPPRPPPPPPPPPRPNNPVPJPPPPPNPRRPPPNPPPQPPNPP`>RPPPPPNRRPPPP) z
 328 2825 m
 (V5)b
 2135 2825 m
 (V5)t
 346 2839 m
-(OONPPPVHPPPPPNPPRRNPPPPPPPPPPN\\BRPPPPPNPTPPPPPPPPPPPPPTRHPPPPNPPSPPPPPPPPPPPPN\\FNPPPPNPRRPPPPPPPPPPPNPXHPPPPPNPRRPNPPPPPRPPNPTRJORPPNPNTRPPPNPRPPPPPPN^BPPPPPPNPTPPPPPNRPPVJNPPPPNPRPRPPNPPPPPPOPPPRNPPTPJPRPNPPNPTPPPPPPPPPRPNPPXHPPPPPNNRRRPNPPPPPRPPN) z
-(P\\DPPPPMPNRRRPNPPPRPPPPPNXHPPPPPNPRPPPPPPPPPPPPNXHPPPPPNPPTPPPPPPPPPPPOPN\\FNPRPNPNRRPPPPPPPPPPRNPPN\\DPPPPPNPRRPPPPPPNPRPNPPTNNPPPPNPNRQPPPPNRNRPPPPNXJPPPPNPNPTRPNPPPPPPRPPPN\\DPPPPPNPRRPPPPPPPPPPPPNYFPPPPPNPRRPNPPPPPPPPPPRVFPPPPPNPRRPPNPPPPRPPPPTP) z
-(JPRNPPNPTPPPPPPOPPRPPPN^BPPPPPNPNTPPPPPPPPPRPPPPN\\DPPPPPNPPRPPPPPPPPPPPPPNZFRPOPNNPRRPPPPPPPRPPPNVNLPRPNPNPTPPPPPPPPPRNPN`DLPPPPNPRRPPPPPPPPPPONVNLPPPPNPPRPPPPPPPPPPPPNZFRPPPNPNRRRPPPNRPPPPPPNZLJPPPPPNPRRPOPPPPPPPPPPN\\DPPPPPNPRRPPPPPPPPPPPPNPVJPPPP) z
-(PNNRRPPPPPPPPPPPPPNZFORPPPNNRTPPPPPPPPPRNPN^DNPPPPNPRRPPPPPPPPPPPNVPJPPPPPNPTPPPPNPPORPNPPTNNPPPPNPPRPPPPPPPPPPPPNZFRPPPPNPPRRPPPNPRPPPPPPNP\\DPPPPNPMPTPRNPPPPPPPRNPN^BPRPPPNNPTPPPPPPPPPPPPPPVHPRPPNPNRRPPPPPPPPPRMPPZFPPPPPNPPTPPPPPPPPPRPNPN`BPPPNPNPT) z
-(PPPPPPPPPRPNPPXHPPPPNNRRPPOPPPPPPPNPPVNLPPPNPNPTPPPPPPPPPPPPPN\\DRPPPNPNPTRNPPPPPPPRPPNPXNIPPPPNNPRRPPPPPPPRPPPPPNRXFPRPNPPNPTPPPPPPPPPPPPPTNLPRPNPNPTPPPPORPPPRNPPXFRPPPNPNTRPPNPPRPPPRNPN\\DPPPPPNPPTPPPPPPPPPPPPNXHPPPPMPNRRPPNPPPPPPRNPNZFRPPPPNNRRRPP) z
-(NPPRPPPPPPN\\DPPPPPNNRRRPPPNPPPPROPNP\\DPPPPNPNRRPPPPPPPPPRPNPNXHPPPPPPNPRRPNPPPPPRPNPPXHPPPPPNPPSPPPPPPPPPPPPP\\@RPPPPNNTRPPPPPPPPPPPN\\HLPPPPPNPTPPPNPPPPRPNPPRRLOPPPNPNRRPPPPPPPPPRNPPPXHPPPPPNPRRPPPPPPPPPPPPPPZDPPPPPNPRRPPPPOPPPPRNPPRZDPPPPNNPRRPPN) z
-(PPPPPRNPPPVJPPPPNPNTPPPPPPPPRPNPN^DPPPPPMNTRPPPNPPPRPPPPN\\DPPPPPNNTRPPNPPPPRPPNPTRJPPPPNNPTPPPPNPPPRPPNOXHPPPPPPNPRRPPPPPPPPPRPNRN^BPPPPPNNRRRPPPPPPPPPRNPN\\JJPRPNPNPTPOPPPPPPPPPPPNZFPPPPPNPPRRPNPPPPRPPPNRRLPPPPPNRRPPPPPPPRPPPPN^BPOPPPNPRRPPPPPPPPRN) z
-(PPPXHPPPPNNPRRPPPPPPPPRNPPNXHPPPPPPNPRRNPPPPPPORNPPRRLPPPPPNPPRRPP) z
+(ONPPPVHPPPPPNPPRRNPPPPPPPPPPN\\BRPPPPPNPTPPPPPPPPPPPPPTRHPPPPNPPSPPPPPPPPPPPPN\\FNPPPPNPRRPPPPPPPPPPPNPXHPPPPPNPRRPNPPPPPRPPNPTRJORPPNPNTRPPPNPRPPPPPPN^BPPPPPPNPTPPPPPNRPPVJNPPPPNPRPRPPNPPPPPPOPPPRNPPTPJPRPNPPNPTPPPPPPPPPRPNPPXHPPPPPNNRRRPNPPPPPRPPNP) z
+(\\DPPPPMPNRRRPNPPPRPPPPPNXHPPPPPNPRPPPPPPPPPPPPNXHPPPPPNPPTPPPPPPPPPPPOPN\\FNPRPNPNRRPPPPPPPPPPRNPPN\\DPPPPPNPRRPPPPPPNPRPNPPTNNPPPPNPNRQPPPPNRNRPPPPNXJPPPPNPNPTRPNPPPPPPRPPPN\\DPPPPPNPRRPPPPPPPPPPPPNYFPPPPPNPRRPNPPPPPPPPPPRVFPPPPPNPRRPPNPPPPRPPPPTPJ) z
+(PRNPPNPTPPPPPPOPPRPPPN^BPPPPPNPNTPPPPPPPPPRPPPPN\\DPPPPPNPPRPPPPPPPPPPPPPNZFRPOPNNPRRPPPPPPPRPPPNVNLPRPNPNPTPPPPPPPPPRNPN`DLPPPPNPRRPPPPPPPPPPONVNLPPPPNPPRPPPPPPPPPPPPNZFRPPPNPNRRRPPPNRPPPPPPNZLJPPPPPNPRRPOPPPPPPPPPPN\\DPPPPPNPRRPPPPPPPPPPPPNPVJPPPPP) z
+(NNRRPPPPPPPPPPPPPNZFORPPPNNRTPPPPPPPPPRNPN^DNPPPPNPRRPPPPPPPPPPPNVPJPPPPPNPTPPPPNPPORPNPPTNNPPPPNPPRPPPPPPPPPPPPNZFRPPPPNPPRRPPPNPRPPPPPPNP\\DPPPPNPMPTPRNPPPPPPPRNPN^BPRPPPNNPTPPPPPPPPPPPPPPVHPRPPNPNRRPPPPPPPPPRMPPZFPPPPPNPPTPPPPPPPPPRPNPN`BPPPNPNPTP) z
+(PPPPPPPPRPNPPXHPPPPNNRRPPOPPPPPPPNPPVNLPPPNPNPTPPPPPPPPPPPPPN\\DRPPPNPNPTRNPPPPPPPRPPNPXNIPPPPNNPRRPPPPPPPRPPPPPNRXFPRPNPPNPTPPPPPPPPPPPPPTNLPRPNPNPTPPPPORPPPRNPPXFRPPPNPNTRPPNPPRPPPRNPN\\DPPPPPNPPTPPPPPPPPPPPPNXHPPPPMPNRRPPNPPPPPPRNPNZFRPPPPNNRRRPPN) z
+(PPRPPPPPPN\\DPPPPPNNRRRPPPNPPPPROPNP\\DPPPPNPNRRPPPPPPPPPRPNPNXHPPPPPPNPRRPNPPPPPRPNPPXHPPPPPNPPSPPPPPPPPPPPPP\\@RPPPPNNTRPPPPPPPPPPPN\\HLPPPPPNPTPPPNPPPPRPNPPRRLOPPPNPNRRPPPPPPPPPRNPPPXHPPPPPNPRRPPPPPPPPPPPPPPZDPPPPPNPRRPPPPOPPPPRNPPRZDPPPPNNPRRPPNP) z
+(PPPPRNPPPVJPPPPNPNTPPPPPPPPRPNPN^DPPPPPMNTRPPPNPPPRPPPPN\\DPPPPPNNTRPPNPPPPRPPNPTRJPPPPNNPTPPPPNPPPRPPNOXHPPPPPPNPRRPPPPPPPPPRPNRN^BPPPPPNNRRRPPPPPPPPPRNPN\\JJPRPNPNPTPOPPPPPPPPPPPNZFPPPPPNPPRRPNPPPPRPPPNRRLPPPPPNRRPPPPPPPRPPPPN^BPOPPPNPRRPPPPPPPPRNP) z
+(PPXHPPPPNNPRRPPPPPPPPRNPPNXHPPPPPPNPRRNPPPPPPORNPPRRLPPPPPNPPRRPPP) z
 4.5 S
 2873 Ay
 347 2853 m
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/checkpkg/libcheck wfdb-10.3.17/checkpkg/libcheck
--- wfdb-10.3.16/checkpkg/libcheck	2002-11-22 15:23:53.000000000 -0500
+++ wfdb-10.3.17/checkpkg/libcheck	2005-08-11 11:44:53.000000000 -0400
@@ -1,6 +1,6 @@
 #!/bin/sh
 # file: libcheck		G. Moody       8 September 2001
-#                               Last revised:  22 November 2002
+#                               Last revised:   11 August 2005
 #
 # This script checks the functionality of the WFDB library by comparing the
 # outputs of 'lcheck' with expected outputs.  See 'lcheck.c' for details of
@@ -27,6 +27,33 @@
   *) VERBOSE=1 ;;
 esac
 
+DBDIR=$1
+LIBDIR=$2
+
+case `uname` in
+    Darwin*)
+	if [ "x$DYLD_LIBRARY_PATH" != x ]
+	    then
+	    DYLD_LIBRARY_PATH=$LIBDIR:$DYLD_LIBRARY_PATH
+	else
+	    DYLD_LIBRARY_PATH=$LIBDIR
+	fi
+	export DYLD_LIBRARY_PATH
+	;;
+    CYGWIN*|MINGW*)
+	export PATH=.:$LIBDIR/../bin:$PATH
+	;;
+    *)
+	if [ "x$LD_LIBRARY_PATH" != x ]
+	    then
+	    LD_LIBRARY_PATH=$LIBDIR:$LD_LIBRARY_PATH
+	else
+	    LD_LIBRARY_PATH=$LIBDIR
+	fi
+	export LD_LIBRARY_PATH
+	;;
+esac
+
 test -s Makefile || ( cd ..; ./configure )
 test -s lcheck || make lcheck
 ./lcheck -v >lcheck.log
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/checkpkg/Makefile.tpl wfdb-10.3.17/checkpkg/Makefile.tpl
--- wfdb-10.3.16/checkpkg/Makefile.tpl	2002-11-26 10:12:47.000000000 -0500
+++ wfdb-10.3.17/checkpkg/Makefile.tpl	2005-08-04 21:25:10.000000000 -0400
@@ -1,10 +1,8 @@
 all:
 	@rm -f lcheck
 	@make lcheck	
-	@./libcheck $(DBDIR)
-	@../conf/prompt "Press <Enter> to continue ... "
-	@read a
-	@./appcheck $(INCDIR)
+	@./libcheck $(DBDIR) $(LIBDIR)
+	@./appcheck $(INCDIR) $(BINDIR) $(LIBDIR)
 
 lcheck:	lcheck.c
 	@echo Compiling WFDB library test application ...
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/conf/cygwin.def wfdb-10.3.17/conf/cygwin.def
--- wfdb-10.3.16/conf/cygwin.def	2005-06-10 09:42:40.000000000 -0400
+++ wfdb-10.3.17/conf/cygwin.def	2005-08-08 07:09:13.000000000 -0400
@@ -1,5 +1,5 @@
 # file: cygwin.def		G. Moody	6 June 2000
-#				Last revised:  10 June 2005
+#				Last revised:  8 August 2005
 #
 # This file contains default 'make' definitions for compiling the WFDB Software
 # Package under MS Windows using the free Cygwin/gcc ANSI C compiler, available
@@ -22,28 +22,18 @@
 # name of your home directory, as in the example below (change as needed).
 # WFDBROOT = /home/frodo
 
-# If the W3C's libwww library of HTTP and FTP client code is available, and
-# you wish to compile a WFDB library with NETFILES support, set LWC to
-# 'libwww-config' (a utility supplied with libwww).  Otherwise set LWC to ':'
-# (a program that does nothing, successfully).
-LWC = libwww-config
-
-# Similarly, to use the libcurl library instead of libwww, set LCC to
-# 'curl-config'.  Otherwise set LCC to ':'.  Only one of libwww or
-# libcurl should be enabled.
-LCC = curl-config
-
-# LDLIBWWW, which is appended to LDFLAGS below, is the set of options needed
-# to link with libwww.  If libwww is not installed, or if libwfdb is a shared
-# library, LDLIBWWW can be empty (if there is a '#' immediately after the '='
-# below, the remainder of the line is ignored, so LDLIBWWW is empty in this
-# case).  Otherwise, it is generated from the output of LWC.  Note that up to
-# three passes through the option list are necessary to satisfy all
-# dependencies when linking to the static libwww libraries.
-LDLIBWWW = # `$(LWC) --libs` `$(LWC) --libs` `$(LWC) --libs`
-
-# LDLIBCURL is the set of options needed to link with libcurl.
-LDLIBCURL = # `$(LCC) --libs` `$(LCC) --libs` `$(LCC) --libs`
+# LC and LL are used to determine C compiler and linker options needed to
+# enable NETFILES (code that allows applications linked to the WFDB library to
+# read input from HTTP and FTP servers, in addition to the standard filesystem
+# support available without NETFILES).  The WFDB library can use either
+# libcurl (recommended) or libwww to provide NETFILES support.  To use libcurl,
+# set LC to `curl-config --cflags` (note the backquotes) and LN to
+# `curl-config --libs`.  Otherwise, to use libwww, set LC to
+# `libwww-config --cflags` and LL to `libwww-config --libs`.  If neither
+# libcurl nor libwww is available, LC and LL should be empty (and NETFILES
+# will be disabled).
+LC =
+LL =
 
 # BINDIR specifies the directory in which the applications will be installed;
 # it should be a directory in the PATH of those who will use the applications.
@@ -70,7 +60,7 @@
 
 # PSPDIR specifies the name of a directory in which to install the PostScript
 # prolog (*.pro) files from the 'app' directory.
-PSPDIR = /usr/lib/ps
+PSPDIR = $(WFDBROOT)/lib/ps
 
 # CC is the name of your C compiler.  The WFDB library can be compiled with K&R
 # C compilers (`cc' on most if not all UNIX systems) as well as with ANSI C
@@ -96,6 +86,10 @@
 # and try again (see signal.c).
 CCDEFS = $(VDEFS) -DNOVALUES_H
 
+# MFLAGS is the set of architecture-dependent (-m*) compiler options, which
+# is usually empty.  See the gcc manual for information about gcc's -m options.
+MFLAGS =
+
 # CFLAGS is the set of C compiler options.  CFLAGS should always include
 # CCDEFS.  Add the following options to CFLAGS as appropriate (separating them
 # by spaces if you use more than one):
@@ -103,13 +97,11 @@
 #   -O		  if you trust your C compiler's optimizer
 # With the exception of `gcc', most C compilers do not allow you to use -g and
 # -O simultaneously.
-CFLAGS = -g $(CCDEFS) `$(LWC) --cflags` `$(LCC) --cflags` -I$(INCDIR)
-# `gcc' users may comment out the previous line, and uncomment the next one.
-# CFLAGS = -g -O $(CCDEFS) `$(LWC) --cflags` `$(LCC) --cflags` -I$(INCDIR)
+CFLAGS = $(MFLAGS) -g -O $(CCDEFS) $(LC) -I$(INCDIR)
 
 # 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'.
@@ -178,8 +170,20 @@
 # OWLIBDIR is the directory in which the XView library is found.
 OWLIBDIR = $(OPENWINHOME)/lib
 
+# XHOME specifies the root directory of the X11 hierarchy.
+# This is usually /usr/X11R6 (or /usr/X11).
+XHOME = /usr/X11R6
+
+# XINCDIR is the directory in which the 'X11' directory containing X11 *.h
+# files is found.  This is usually /usr/X11R6/include, although there is often
+# a link connecting /usr/include/X11 to this directory.
+XINCDIR = $(XHOME)/include
+
+# XLIBDIR is the directory in which the X11 libraries are found.
+XLIBDIR = $(XHOME)/lib
+
 # WCFLAGS is the set of C compiler options to use when compiling WAVE.
-WCFLAGS = $(CFLAGS) -I$(OWINCDIR)
+WCFLAGS = $(CFLAGS) -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).
@@ -189,7 +193,7 @@
 
 # WLDFLAGS is the set of loader options appended to the C compiler command line
 # to specify loading the WFDB, XView, and Xlib libraries.
-WLDFLAGS = $(LDFLAGS) -L$(OWLIBDIR) -L/usr/X11R6/lib -lxview -lolgx -lX11
+WLDFLAGS = $(LDFLAGS) -L$(OWLIBDIR) -L$(XLIBDIR) -lxview -lolgx -lX11
 # ...........................................................................
 
 # `make' (with no target specified) will be equivalent to `make all'.
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/conf/cygwin-slib.def wfdb-10.3.17/conf/cygwin-slib.def
--- wfdb-10.3.16/conf/cygwin-slib.def	2005-05-18 16:20:28.000000000 -0400
+++ wfdb-10.3.17/conf/cygwin-slib.def	2005-08-08 07:23:46.000000000 -0400
@@ -1,5 +1,5 @@
 # file: cygwin-slib.def	I. Henry and G. Moody	19 November 2002
-#				Last revised:	  18 May 2005
+#				Last revised:	 5 August 2005
 
 # This section contains settings suitable for generating a DLL (shared library)
 # under MS Windows using the free Cygwin/gcc ANSI C compiler, available from
@@ -22,10 +22,27 @@
 # name of your home directory, as in the example below (change as needed).
 # WFDBROOT = /home/frodo
 
+# LC and LL are used to determine C compiler and linker options needed to
+# enable NETFILES (code that allows applications linked to the WFDB library to
+# read input from HTTP and FTP servers, in addition to the standard filesystem
+# support available without NETFILES).  The WFDB library can use either
+# libcurl (recommended) or libwww to provide NETFILES support.  To use libcurl,
+# set LC to `curl-config --cflags` (note the backquotes) and LN to
+# `curl-config --libs`.  Otherwise, to use libwww, set LC to
+# `libwww-config --cflags` and LL to `libwww-config --libs`.  If neither
+# libcurl nor libwww is available, LC and LL should be empty (and NETFILES
+# will be disabled).
+LC =
+LL =
+
 # BINDIR specifies the name of a directory in which to install the WFDB
 # DLL and the WFDB applications.
 BINDIR = $(WFDBROOT)/bin
 
+# DBDIR specifies the name of a directory in which to install the contents
+# of the `data' directory.
+DBDIR = $(WFDBROOT)/database
+
 # INCDIR specifies the name of a directory in which to install the WFDB
 # library's #include <...> files.
 INCDIR = $(WFDBROOT)/include
@@ -34,32 +51,9 @@
 # library.
 LIBDIR = $(WFDBROOT)/lib
 
-# If the W3C's libwww library of HTTP and FTP client code is available, and
-# you wish to compile a WFDB library with NETFILES support, set LWC
-# to 'libwww-config' (a utility supplied with libwww).  Otherwise set
-# LWC to ':' (a program that does nothing, successfully).
-LWC = libwww-config
-
-# Similarly, to use the libcurl library instead of libwww, set LCC to
-# 'curl-config'.  Otherwise set LCC to ':'.  Only one of libwww or
-# libcurl should be enabled.
-LCC = curl-config
-
-# LDLIBWWW, which is appended to LDFLAGS below, is the set of options needed
-# to link with libwww.  If libwww is not installed, or if libwfdb is a shared
-# library, LDLIBWWW can be empty (if there is a '#' immediately after the '='
-# below, the remainder of the line is ignored, so LDLIBWWW is empty in this
-# case).  Otherwise, it is generated from the output of LWC.  Note that up to
-# three passes through the option list are necessary to satisfy all
-# dependencies when linking to the static libwww libraries.
-LDLIBWWW = # `$(LWC) --libs` `$(LWC) --libs` `$(LWC) --libs`
-
-# LDLIBCURL is the set of options needed to link with libcurl.
-LDLIBCURL = # `$(LCC) --libs` `$(LCC) --libs` `$(LCC) --libs`
-
 # 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)
 
 # CC is the name of your C compiler.
 CC = gcc
@@ -69,9 +63,13 @@
 # VDEFS.
 CCDEFS = $(VDEFS) -DNOVALUES_H
 
+# MFLAGS is the set of architecture-dependent (-m*) compiler options, which
+# is usually empty.  See the gcc manual for information about gcc's -m options.
+MFLAGS =
+
 # CFLAGS is the set of C compiler options used when compiling the shared
 # library.  CFLAGS should always include CCDEFS.
-CFLAGS = -g -O $(CCDEFS) `$(LWC) --cflags` `$(LCC) --cflags` -I$(INCDIR)
+CFLAGS = $(MFLAGS) -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
@@ -102,9 +100,8 @@
 
 # BUILDLIB_LDFLAGS is a list of arguments appended to BUILDLIB following
 # the list of *.o files.
-BUILDLIB_LDFLAGS = `$(LWC) --libs` `$(LWC) --libs` `$(LWC) --libs` \
- `$(LCC) --libs` `$(LCC) --libs` `$(LCC) --libs`
- 
+BUILDLIB_LDFLAGS = $(LL)
+
 # LDCONFIG is the name of the program needed to refresh the system's cached
 # index of shared libraries.
 LDCONFIG = /sbin/ldconfig
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/conf/darwin.def wfdb-10.3.17/conf/darwin.def
--- wfdb-10.3.16/conf/darwin.def	2005-05-13 16:36:35.000000000 -0400
+++ wfdb-10.3.17/conf/darwin.def	2005-08-07 10:52:37.000000000 -0400
@@ -1,5 +1,5 @@
 # file: darwin.def	G. Moody and I. Henry	14 November 2002
-#				Last revised: 	  4 March 2003
+#				Last revised: 	 7 August 2005
 # 'make' definitions for compiling the WFDB Software Package under Darwin
 #
 # Based on 'freebsd.def'.
@@ -20,28 +20,18 @@
 # name of your home directory, as in the example below (change as needed).
 # WFDBROOT = /Users/frodo
 
-# If the W3C's libwww library of HTTP and FTP client code is available, and
-# you wish to compile a WFDB library with NETFILES support, set LWC to
-# 'libwww-config' (a utility supplied with libwww).  Otherwise set LWC to ':'
-# (a program that does nothing, successfully).
-LWC = libwww-config
-
-# Similarly, to use the libcurl library instead of libwww, set LCC to
-# 'curl-config'.  Otherwise set LCC to ':'.  Only one of libwww or
-# libcurl should be enabled.
-LCC = curl-config
-
-# LDLIBWWW, which is appended to LDFLAGS below, is the set of options needed
-# to link with libwww.  If libwww is not installed, or if libwfdb is a shared
-# library, LDLIBWWW can be empty (if there is a '#' immediately after the '='
-# below, the remainder of the line is ignored, so LDLIBWWW is empty in this
-# case).  Otherwise, it is generated from the output of LWC.  Note that up to
-# three passes through the option list are necessary to satisfy all
-# dependencies when linking to the static libwww libraries.
-LDLIBWWW = # `$(LWC) --libs` `$(LWC) --libs` `$(LWC) --libs`
-
-# LDLIBCURL is the set of options needed to link with libcurl.
-LDLIBCURL = # `$(LCC) --libs` `$(LCC) --libs` `$(LCC) --libs`
+# LC and LL are used to determine C compiler and linker options needed to
+# enable NETFILES (code that allows applications linked to the WFDB library to
+# read input from HTTP and FTP servers, in addition to the standard filesystem
+# support available without NETFILES).  The WFDB library can use either
+# libcurl (recommended) or libwww to provide NETFILES support.  To use libcurl,
+# set LC to `curl-config --cflags` (note the backquotes) and LN to
+# `curl-config --libs`.  Otherwise, to use libwww, set LC to
+# `libwww-config --cflags` and LL to `libwww-config --libs`.  If neither
+# libcurl nor libwww is available, LC and LL should be empty (and NETFILES
+# will be disabled).
+LC =
+LL =
 
 # BINDIR specifies the directory in which the applications will be installed;
 # it should be a directory in the PATH of those who will use the applications.
@@ -68,7 +58,7 @@
 
 # PSPDIR specifies the name of a directory in which to install the PostScript
 # prolog (*.pro) files from the 'app' directory.
-PSPDIR = /usr/lib/ps
+PSPDIR = $(WFDBROOT)/lib/ps
 
 # CC is the name of your C compiler.
 CC = gcc
@@ -78,13 +68,17 @@
 # VDEFS.
 CCDEFS = $(VDEFS)  -DNOVALUES_H
 
+# MFLAGS is the set of architecture-dependent (-m*) compiler options, which
+# is usually empty.  See the gcc manual for information about gcc's -m options.
+MFLAGS =
+
 # CFLAGS is the set of C compiler options.  CFLAGS should always include
 # CCDEFS.
-CFLAGS = -g -O $(CCDEFS) `$(LWC) --cflags` `$(LCC) --cflags` -I$(INCDIR)
+CFLAGS = $(MFLAGS) -g -O $(CCDEFS) $(LC) -I$(INCDIR)
 
 # 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'.
@@ -139,8 +133,20 @@
 # OWLIBDIR is the directory in which the XView library is found.
 OWLIBDIR = $(OPENWINHOME)/lib
 
+# XHOME specifies the root directory of the X11 hierarchy.
+# This is usually /usr/X11R6 (or /usr/X11).
+XHOME = /usr/X11R6
+
+# XINCDIR is the directory in which the 'X11' directory containing X11 *.h
+# files is found.  This is usually /usr/X11R6/include, although there is often
+# a link connecting /usr/include/X11 to this directory.
+XINCDIR = $(XHOME)/include
+
+# XLIBDIR is the directory in which the X11 libraries are found.
+XLIBDIR = $(XHOME)/lib
+
 # WCFLAGS is the set of C compiler options to use when compiling WAVE.
-WCFLAGS = $(CFLAGS) -I$(OWINCDIR)
+WCFLAGS = $(CFLAGS) -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).
@@ -150,7 +156,7 @@
 
 # WLDFLAGS is the set of loader options appended to the C compiler command line
 # to specify loading the WFDB, XView, and Xlib libraries.
-WLDFLAGS = $(LDFLAGS) -L$(OWLIBDIR) -L/usr/X11R6/lib -lxview -lolgx -lX11
+WLDFLAGS = $(LDFLAGS) -L$(OWLIBDIR) -L/$(XLIBDIR) -lxview -lolgx -lX11
 # ...........................................................................
 
 # `make' (with no target specified) will be equivalent to `make all'.
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/conf/darwin-slib.def wfdb-10.3.17/conf/darwin-slib.def
--- wfdb-10.3.16/conf/darwin-slib.def	2005-05-13 16:36:35.000000000 -0400
+++ wfdb-10.3.17/conf/darwin-slib.def	2005-08-05 15:29:08.000000000 -0400
@@ -1,5 +1,5 @@
 # file: darwin-slib.def	I. Henry and G. Moody	14 November 2002
-#				Last revised:	28 November 2004
+#				Last revised:	 5 August 2005
 # Based on 'freebsd-slib.def'.
 
 # This section contains settings suitable for generating a shared library under
@@ -21,21 +21,27 @@
 # name of your home directory, as in the example below (change as needed).
 # WFDBROOT = /Users/frodo
 
-# If the W3C's libwww library of HTTP and FTP client code is available, and
-# you wish to compile a WFDB library with NETFILES support, set LWC
-# to 'libwww-config' (a utility supplied with libwww).  Otherwise set
-# LWC to ':' (a program that does nothing, successfully).
-LWC = libwww-config
-
-# Similarly, to use the libcurl library instead of libwww, set LCC to
-# 'curl-config'.  Otherwise set LCC to ':'.  Only one of libwww or
-# libcurl should be enabled.
-LCC = curl-config
+# LC and LL are used to determine C compiler and linker options needed to
+# enable NETFILES (code that allows applications linked to the WFDB library to
+# read input from HTTP and FTP servers, in addition to the standard filesystem
+# support available without NETFILES).  The WFDB library can use either
+# libcurl (recommended) or libwww to provide NETFILES support.  To use libcurl,
+# set LC to `curl-config --cflags` (note the backquotes) and LN to
+# `curl-config --libs`.  Otherwise, to use libwww, set LC to
+# `libwww-config --cflags` and LL to `libwww-config --libs`.  If neither
+# libcurl nor libwww is available, LC and LL should be empty (and NETFILES
+# will be disabled).
+LC =
+LL =
 
 # BINDIR specifies the directory in which the applications will be installed;
 # it should be a directory in the PATH of those who will use the applications.
 BINDIR = $(WFDBROOT)/bin
 
+# DBDIR specifies the name of a directory in which to install the contents
+# of the `data' directory.
+DBDIR = $(WFDBROOT)/database
+
 # INCDIR specifies the name of a directory in which to install the WFDB
 # library's #include <...> files.
 INCDIR = $(WFDBROOT)/include
@@ -44,21 +50,9 @@
 # library.
 LIBDIR = $(WFDBROOT)/lib
 
-# LDLIBWWW, which is appended to LDFLAGS below, is the set of options needed
-# to link with libwww.  If libwww is not installed, or if libwfdb is a shared
-# library, LDLIBWWW can be empty (if there is a '#' immediately after the '='
-# below, the remainder of the line is ignored, so LDLIBWWW is empty in this
-# case).  Otherwise, it is generated from the output of LWC.  Note that up to
-# three passes through the option list are necessary to satisfy all
-# dependencies when linking to the static libwww libraries.
-LDLIBWWW = # `$(LWC) --libs` `$(LWC) --libs` `$(LWC) --libs`
-
-# LDLIBCURL is the set of options needed to link with libcurl.
-LDLIBCURL = # `$(LCC) --libs` `$(LCC) --libs` `$(LCC) --libs`
-
 # 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)
 
 # CC is the name of your C compiler.
 CC = gcc
@@ -68,9 +62,13 @@
 # VDEFS.
 CCDEFS = $(VDEFS) -DNOVALUES_H
 
+# MFLAGS is the set of architecture-dependent (-m*) compiler options, which
+# is usually empty.  See the gcc manual for information about gcc's -m options.
+MFLAGS =
+
 # CFLAGS is the set of C compiler options used when compiling the shared
 # library.  CFLAGS should always include CCDEFS.
-CFLAGS = -fPIC -fno-common -g -O $(CCDEFS) `$(LWC) --cflags` `$(LCC) --cflags` -I$(INCDIR)
+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
@@ -94,10 +92,11 @@
 # 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 -dynamiclib  -install_name $(LIBDIR)/$(WFDBLIB_SONAME) \
+BUILDLIB = gcc $(MFLAGS) -dynamiclib \
+ -install_name $(LIBDIR)/$(WFDBLIB_SONAME) \
  -compatibility_version $(MAJOR).$(MINOR) \
  -current_version $(MAJOR).$(MINOR).$(RELEASE) \
- `$(LWC) --libs` `$(LCC) --libs` -o $(WFDBLIB)
+ $(LL) -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).
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/conf/freebsd.def wfdb-10.3.17/conf/freebsd.def
--- wfdb-10.3.16/conf/freebsd.def	2005-05-13 16:36:35.000000000 -0400
+++ wfdb-10.3.17/conf/freebsd.def	2005-08-07 10:52:31.000000000 -0400
@@ -1,5 +1,5 @@
 # file: freebsd.def		G. Moody	5 March 2002
-#				Last revised:   4 March 2003
+#				Last revised:  7 August 2005
 # 'make' definitions for compiling the WFDB Software Package under FreeBSD
 #
 # Based on 'linux.def', with edits for FreeBSD thanks to Giuseppe Pagnoni.
@@ -20,28 +20,18 @@
 # name of your home directory, as in the example below (change as needed).
 # WFDBROOT = /home/frodo
 
-# If the W3C's libwww library of HTTP and FTP client code is available, and
-# you wish to compile a WFDB library with NETFILES support, set LWC to
-# 'libwww-config' (a utility supplied with libwww).  Otherwise set LWC to ':'
-# (a program that does nothing, successfully).
-LWC = libwww-config
-
-# Similarly, to use the libcurl library instead of libwww, set LCC to
-# 'curl-config'.  Otherwise set LCC to ':'.  Only one of libwww or
-# libcurl should be enabled.
-LCC = curl-config
-
-# LDLIBWWW, which is appended to LDFLAGS below, is the set of options needed
-# to link with libwww.  If libwww is not installed, or if libwfdb is a shared
-# library, LDLIBWWW can be empty (if there is a '#' immediately after the '='
-# below, the remainder of the line is ignored, so LDLIBWWW is empty in this
-# case).  Otherwise, it is generated from the output of LWC.  Note that up to
-# three passes through the option list are necessary to satisfy all
-# dependencies when linking to the static libwww libraries.
-LDLIBWWW = # `$(LWC) --libs` `$(LWC) --libs` `$(LWC) --libs`
-
-# LDLIBCURL is the set of options needed to link with libcurl.
-LDLIBCURL = # `$(LCC) --libs` `$(LCC) --libs` `$(LCC) --libs`
+# LC and LL are used to determine C compiler and linker options needed to
+# enable NETFILES (code that allows applications linked to the WFDB library to
+# read input from HTTP and FTP servers, in addition to the standard filesystem
+# support available without NETFILES).  The WFDB library can use either
+# libcurl (recommended) or libwww to provide NETFILES support.  To use libcurl,
+# set LC to `curl-config --cflags` (note the backquotes) and LN to
+# `curl-config --libs`.  Otherwise, to use libwww, set LC to
+# `libwww-config --cflags` and LL to `libwww-config --libs`.  If neither
+# libcurl nor libwww is available, LC and LL should be empty (and NETFILES
+# will be disabled).
+LC =
+LL =
 
 # BINDIR specifies the directory in which the applications will be installed;
 # it should be a directory in the PATH of those who will use the applications.
@@ -68,7 +58,7 @@
 
 # PSPDIR specifies the name of a directory in which to install the PostScript
 # prolog (*.pro) files from the 'app' directory.
-PSPDIR = /usr/lib/ps
+PSPDIR = $(WFDBROOT)/lib/ps
 
 # CC is the name of your C compiler.
 CC = gcc
@@ -78,9 +68,13 @@
 # VDEFS.
 CCDEFS = $(VDEFS)
 
+# MFLAGS is the set of architecture-dependent (-m*) compiler options, which
+# is usually empty.  See the gcc manual for information about gcc's -m options.
+MFLAGS =
+
 # CFLAGS is the set of C compiler options.  CFLAGS should always include
 # CCDEFS.
-CFLAGS = -g -O $(CCDEFS) `$(LWC) --cflags` `$(LCC) --cflags` -I$(INCDIR)
+CFLAGS = $(MFLAGS) -g -O $(CCDEFS) $(LC) -I$(INCDIR)
 
 # LDFLAGS is appended to the C compiler command line to specify loading the
 # WFDB library.
@@ -139,8 +133,20 @@
 # OWLIBDIR is the directory in which the XView library is found.
 OWLIBDIR = $(OPENWINHOME)/lib
 
+# XHOME specifies the root directory of the X11 hierarchy.
+# This is usually /usr/X11R6 (or /usr/X11).
+XHOME = /usr/X11R6
+
+# XINCDIR is the directory in which the 'X11' directory containing X11 *.h
+# files is found.  This is usually /usr/X11R6/include, although there is often
+# a link connecting /usr/include/X11 to this directory.
+XINCDIR = $(XHOME)/include
+
+# XLIBDIR is the directory in which the X11 libraries are found.
+XLIBDIR = $(XHOME)/lib
+
 # WCFLAGS is the set of C compiler options to use when compiling WAVE.
-WCFLAGS = $(CFLAGS) -I$(OWINCDIR)
+WCFLAGS = $(CFLAGS) -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).
@@ -150,7 +156,7 @@
 
 # WLDFLAGS is the set of loader options appended to the C compiler command line
 # to specify loading the WFDB, XView, and Xlib libraries.
-WLDFLAGS = $(LDFLAGS) -L$(OWLIBDIR) -L/usr/X11R6/lib -lxview -lolgx -lX11
+WLDFLAGS = $(LDFLAGS) -L$(OWLIBDIR) -L$(XLIBDIR) -lxview -lolgx -lX11
 # ...........................................................................
 
 # `make' (with no target specified) will be equivalent to `make all'.
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/conf/freebsd-slib.def wfdb-10.3.17/conf/freebsd-slib.def
--- wfdb-10.3.16/conf/freebsd-slib.def	2005-05-13 16:36:35.000000000 -0400
+++ wfdb-10.3.17/conf/freebsd-slib.def	2005-08-05 15:25:23.000000000 -0400
@@ -1,5 +1,5 @@
 # file: freebsd-slib.def	G. Moody	5 March 2002
-#				Last revised: 28 November 2004
+#				Last revised:  5 August 2005
 # Based on 'linux-slib.def'.
 
 # This section contains settings suitable for generating an ELF-format shared
@@ -21,21 +21,27 @@
 # name of your home directory, as in the example below (change as needed).
 # WFDBROOT = /home/frodo
 
-# If the W3C's libwww library of HTTP and FTP client code is available, and
-# you wish to compile a WFDB library with NETFILES support, set LWC
-# to 'libwww-config' (a utility supplied with libwww).  Otherwise set
-# LWC to ':' (a program that does nothing, successfully).
-LWC = libwww-config
-
-# Similarly, to use the libcurl library instead of libwww, set LCC to
-# 'curl-config'.  Otherwise set LCC to ':'.  Only one of libwww or
-# libcurl should be enabled.
-LCC = curl-config
+# LC and LL are used to determine C compiler and linker options needed to
+# enable NETFILES (code that allows applications linked to the WFDB library to
+# read input from HTTP and FTP servers, in addition to the standard filesystem
+# support available without NETFILES).  The WFDB library can use either
+# libcurl (recommended) or libwww to provide NETFILES support.  To use libcurl,
+# set LC to `curl-config --cflags` (note the backquotes) and LN to
+# `curl-config --libs`.  Otherwise, to use libwww, set LC to
+# `libwww-config --cflags` and LL to `libwww-config --libs`.  If neither
+# libcurl nor libwww is available, LC and LL should be empty (and NETFILES
+# will be disabled).
+LC =
+LL =
 
 # BINDIR specifies the directory in which the applications will be installed;
 # it should be a directory in the PATH of those who will use the applications.
 BINDIR = $(WFDBROOT)/bin
 
+# DBDIR specifies the name of a directory in which to install the contents
+# of the `data' directory.
+DBDIR = $(WFDBROOT)/database
+
 # INCDIR specifies the name of a directory in which to install the WFDB
 # library's #include <...> files.
 INCDIR = $(WFDBROOT)/include
@@ -44,21 +50,9 @@
 # library.
 LIBDIR = $(WFDBROOT)/lib
 
-# LDLIBWWW, which is appended to LDFLAGS below, is the set of options needed
-# to link with libwww.  If libwww is not installed, or if libwfdb is a shared
-# library, LDLIBWWW can be empty (if there is a '#' immediately after the '='
-# below, the remainder of the line is ignored, so LDLIBWWW is empty in this
-# case).  Otherwise, it is generated from the output of LWC.  Note that up to
-# three passes through the option list are necessary to satisfy all
-# dependencies when linking to the static libwww libraries.
-LDLIBWWW = # `$(LWC) --libs` `$(LWC) --libs` `$(LWC) --libs`
-
-# LDLIBCURL is the set of options needed to link with libcurl.
-LDLIBCURL = # `$(LCC) --libs` `$(LCC) --libs` `$(LCC) --libs`
-
 # 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)
 
 # CC is the name of your C compiler.
 CC = gcc
@@ -68,9 +62,13 @@
 # VDEFS.
 CCDEFS = $(VDEFS)
 
+# MFLAGS is the set of architecture-dependent (-m*) compiler options, which
+# is usually empty.  See the gcc manual for information about gcc's -m options.
+MFLAGS =
+
 # CFLAGS is the set of C compiler options used when compiling the shared
 # library.  CFLAGS should always include CCDEFS.
-CFLAGS = -fpic -g -O $(CCDEFS) `$(LWC) --cflags` `$(LCC) --cflags` -I$(INCDIR)
+CFLAGS = $(MFLAGS) -fpic -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,8 +91,8 @@
 # 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 -shared -Wl,-soname,$(WFDBLIB_SONAME) `$(LWC) --libs` \
- `$(LCC) --libs` -o $(WFDBLIB)
+BUILDLIB = gcc $(MFLAGS) -shared -Wl,-soname,$(WFDBLIB_SONAME) $(LL) \
+ -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).
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/conf/generic.def wfdb-10.3.17/conf/generic.def
--- wfdb-10.3.16/conf/generic.def	2005-06-10 06:47:04.000000000 -0400
+++ wfdb-10.3.17/conf/generic.def	2005-08-07 10:52:24.000000000 -0400
@@ -1,5 +1,5 @@
 # file: generic.def		G. Moody	31 May 2000
-#				Last revised:   10 June 2005
+#				Last revised:  7 August 2005
 # This file contains default 'make' definitions for compiling the WFDB Software
 # Package under versions of UNIX that are not otherwise recognized by
 # 'configure'.
@@ -26,27 +26,18 @@
 # name of your home directory, as in the example below (change as needed).
 # WFDBROOT = /home/frodo
 
-# If the W3C's libwww library of HTTP and FTP client code is available, and
-# you wish to compile a WFDB library with NETFILES support, set LWC to
-# 'libwww-config' (a utility supplied with libwww).  Otherwise set LWC to ':'
-# (a program that does nothing, successfully).
-LWC = libwww-config
-
-# 'curl-config'.  Otherwise set LCC to ':'.  Only one of libwww or
-# libcurl should be enabled.
-LCC = curl-config
-
-# LDLIBWWW, which is appended to LDFLAGS below, is the set of options needed
-# to link with libwww.  If libwww is not installed, or if libwfdb is a shared
-# library, LDLIBWWW can be empty (if there is a '#' immediately after the '='
-# below, the remainder of the line is ignored, so LDLIBWWW is empty in this
-# case).  Otherwise, it is generated from the output of LWC.  Note that up to
-# three passes through the option list are necessary to satisfy all
-# dependencies when linking to the static libwww libraries.
-LDLIBWWW = # `$(LWC) --libs` `$(LWC) --libs` `$(LWC) --libs`
-
-# LDLIBCURL is the set of options needed to link with libcurl.
-LDLIBCURL = # `$(LCC) --libs` `$(LCC) --libs` `$(LCC) --libs`
+# LC and LL are used to determine C compiler and linker options needed to
+# enable NETFILES (code that allows applications linked to the WFDB library to
+# read input from HTTP and FTP servers, in addition to the standard filesystem
+# support available without NETFILES).  The WFDB library can use either
+# libcurl (recommended) or libwww to provide NETFILES support.  To use libcurl,
+# set LC to `curl-config --cflags` (note the backquotes) and LN to
+# `curl-config --libs`.  Otherwise, to use libwww, set LC to
+# `libwww-config --cflags` and LL to `libwww-config --libs`.  If neither
+# libcurl nor libwww is available, LC and LL should be empty (and NETFILES
+# will be disabled).
+LC =
+LL =
 
 # BINDIR specifies the directory in which the applications will be installed;
 # it should be a directory in the PATH of those who will use the applications.
@@ -81,7 +72,7 @@
 
 # PSPDIR specifies the name of a directory in which to install the PostScript
 # prolog (*.pro) files from the 'app' directory.
-PSPDIR = /usr/lib/ps
+PSPDIR = $(WFDBROOT)/lib/ps
 
 # CC is the name of your C compiler.  The WFDB library can be compiled with K&R
 # C compilers (`cc' on most if not all UNIX systems) as well as with ANSI C
@@ -108,6 +99,10 @@
 # and try again (see signal.c).
 CCDEFS = $(VDEFS)
 
+# MFLAGS is the set of architecture-dependent (-m*) compiler options, which
+# is usually empty.  See the gcc manual for information about gcc's -m options.
+MFLAGS =
+
 # CFLAGS is the set of C compiler options.  CFLAGS should always include
 # CCDEFS.  Add the following options to CFLAGS as appropriate (separating them
 # by spaces if you use more than one):
@@ -115,13 +110,13 @@
 #   -O		  if you trust your C compiler's optimizer
 # With the exception of `gcc', most C compilers do not allow you to use -g and
 # -O simultaneously.
-CFLAGS = -g $(CCDEFS) `$(LWC) --cflags` `$(LCC) --cflags` -I$(INCDIR)
+# CFLAGS = -g $(CCDEFS) $(LC) -I$(INCDIR)
 # `gcc' users may comment out the previous line, and uncomment the next one.
-# CFLAGS = -g -O $(CCDEFS) `$(LWC) --cflags` `$(LCC) --cflags` -I$(INCDIR)
+CFLAGS = $(MFLAGS) -g -O $(CCDEFS) $(LC) -I$(INCDIR)
 
 # 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'.
@@ -189,8 +184,20 @@
 # OWLIBDIR is the directory in which the XView library is found.
 OWLIBDIR = $(OPENWINHOME)/lib
 
+# XHOME specifies the root directory of the X11 hierarchy.
+# This is usually /usr/X11R6 (or /usr/X11).
+XHOME = /usr/X11R6
+
+# XINCDIR is the directory in which the 'X11' directory containing X11 *.h
+# files is found.  This is usually /usr/X11R6/include, although there is often
+# a link connecting /usr/include/X11 to this directory.
+XINCDIR = $(XHOME)/include
+
+# XLIBDIR is the directory in which the X11 libraries are found.
+XLIBDIR = $(XHOME)/lib
+
 # WCFLAGS is the set of C compiler options to use when compiling WAVE.
-WCFLAGS = $(CFLAGS) -I$(OWINCDIR)
+WCFLAGS = $(CFLAGS) -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).
@@ -200,7 +207,7 @@
 
 # WLDFLAGS is the set of loader options appended to the C compiler command line
 # to specify loading the WFDB, XView, and Xlib libraries.
-WLDFLAGS = $(LDFLAGS) -L$(OWLIBDIR) -L/usr/X11R6/lib -lxview -lolgx -lX11
+WLDFLAGS = $(LDFLAGS) -L$(OWLIBDIR) -L$(XLIBDIR) -lxview -lolgx -lX11
 # ...........................................................................
 
 # `make' (with no target specified) will be equivalent to `make all'.
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/conf/generic-slib.def wfdb-10.3.17/conf/generic-slib.def
--- wfdb-10.3.16/conf/generic-slib.def	2005-06-10 06:47:54.000000000 -0400
+++ wfdb-10.3.17/conf/generic-slib.def	2005-08-05 15:22:27.000000000 -0400
@@ -1,5 +1,5 @@
 # file: generic-slib.def	G. Moody	31 May 2000
-#				Last revised:   10 June 2005
+#				Last revised:  5 August 2005
 # 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
@@ -27,21 +27,27 @@
 # name of your home directory, as in the example below (change as needed).
 # WFDBROOT = /home/frodo
 
-# If the W3C's libwww library of HTTP and FTP client code is available, and
-# you wish to compile a WFDB library with NETFILES support, set LWC
-# to 'libwww-config' (a utility supplied with libwww).  Otherwise set
-# LWC to ':' (a program that does nothing, successfully).
-LWC = libwww-config
-
-# Similarly, to use the libcurl library instead of libwww, set LCC to
-# 'curl-config'.  Otherwise set LCC to ':'.  Only one of libwww or
-# libcurl should be enabled.
-LCC = curl-config
+# LC and LL are used to determine C compiler and linker options needed to
+# enable NETFILES (code that allows applications linked to the WFDB library to
+# read input from HTTP and FTP servers, in addition to the standard filesystem
+# support available without NETFILES).  The WFDB library can use either
+# libcurl (recommended) or libwww to provide NETFILES support.  To use libcurl,
+# set LC to `curl-config --cflags` (note the backquotes) and LN to
+# `curl-config --libs`.  Otherwise, to use libwww, set LC to
+# `libwww-config --cflags` and LL to `libwww-config --libs`.  If neither
+# libcurl nor libwww is available, LC and LL should be empty (and NETFILES
+# will be disabled).
+LC =
+LL =
 
 # BINDIR specifies the directory in which the applications will be installed;
 # it should be a directory in the PATH of those who will use the applications.
 BINDIR = $(WFDBROOT)/bin
 
+# DBDIR specifies the name of a directory in which to install the contents
+# of the `data' directory.
+DBDIR = $(WFDBROOT)/database
+
 # INCDIR specifies the name of a directory in which to install the WFDB
 # library's #include <...> files.
 INCDIR = $(WFDBROOT)/include
@@ -50,21 +56,9 @@
 # library.
 LIBDIR = $(WFDBROOT)/lib
 
-# LDLIBWWW, which is appended to LDFLAGS below, is the set of options needed
-# to link with libwww.  If libwww is not installed, or if libwfdb is a shared
-# library, LDLIBWWW can be empty (if there is a '#' immediately after the '='
-# below, the remainder of the line is ignored, so LDLIBWWW is empty in this
-# case).  Otherwise, it is generated from the output of LWC.  Note that up to
-# three passes through the option list are necessary to satisfy all
-# dependencies when linking to the static libwww libraries.
-LDLIBWWW = # `$(LWC) --libs` `$(LWC) --libs` `$(LWC) --libs`
-
-# LDLIBCURL is the set of options needed to link with libcurl.
-LDLIBCURL = # `$(LCC) --libs` `$(LCC) --libs` `$(LCC) --libs`
-
 # 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)
 
 # CC is the name of your C compiler.
 CC = gcc
@@ -87,9 +81,13 @@
 # and try again (see signal.c).
 CCDEFS = $(VDEFS)
 
+# MFLAGS is the set of architecture-dependent (-m*) compiler options, which
+# is usually empty.  See the gcc manual for information about gcc's -m options.
+MFLAGS =
+
 # CFLAGS is the set of C compiler options used when compiling the shared
 # library.  CFLAGS should always include CCDEFS.
-CFLAGS = -fpic -g -O $(CCDEFS) `$(LWC) --cflags` `$(LCC) --cflags` -I$(INCDIR)
+CFLAGS = $(MFLAGS) -fpic -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
@@ -114,8 +112,8 @@
 # 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 -shared -Wl,-soname,$(SWFDBLIB_SONAME) \
- `$(LWC) --libs` `$(LCC) --libs` -o $(SWFDBLIB)
+BUILDLIB = gcc $(MFLAGS) -shared -Wl,-soname,$(SWFDBLIB_SONAME) $(LL) \
+ -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).
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/conf/hpux.def wfdb-10.3.17/conf/hpux.def
--- wfdb-10.3.16/conf/hpux.def	2005-05-13 16:36:35.000000000 -0400
+++ wfdb-10.3.17/conf/hpux.def	2005-08-07 10:52:20.000000000 -0400
@@ -1,5 +1,5 @@
 # file: hpux.def		G. Moody	31 May 2000
-#				Last revised:  4 March 2003
+#				Last revised:  7 August 2005
 # 'make' definitions for compiling the WFDB library under HP-UX
 
 # Choose a value for WFDBROOT to determine where the WFDB Software Package will
@@ -18,28 +18,18 @@
 # name of your home directory, as in the example below (change as needed).
 # WFDBROOT = /home/frodo
 
-# If the W3C's libwww library of HTTP and FTP client code is available, and
-# you wish to compile a WFDB library with NETFILES support, set LWC to
-# 'libwww-config' (a utility supplied with libwww).  Otherwise set LWC to ':'
-# (a program that does nothing, successfully).
-LWC = libwww-config
-
-# Similarly, to use the libcurl library instead of libwww, set LCC to
-# 'curl-config'.  Otherwise set LCC to ':'.  Only one of libwww or
-# libcurl should be enabled.
-LCC = curl-config
-
-# LDLIBWWW, which is appended to LDFLAGS below, is the set of options needed
-# to link with libwww.  If libwww is not installed, or if libwfdb is a shared
-# library, LDLIBWWW can be empty (if there is a '#' immediately after the '='
-# below, the remainder of the line is ignored, so LDLIBWWW is empty in this
-# case).  Otherwise, it is generated from the output of LWC.  Note that up to
-# three passes through the option list are necessary to satisfy all
-# dependencies when linking to the static libwww libraries.
-LDLIBWWW = # `$(LWC) --libs` `$(LWC) --libs` `$(LWC) --libs`
-
-# LDLIBCURL is the set of options needed to link with libcurl.
-LDLIBCURL = # `$(LCC) --libs` `$(LCC) --libs` `$(LCC) --libs`
+# LC and LL are used to determine C compiler and linker options needed to
+# enable NETFILES (code that allows applications linked to the WFDB library to
+# read input from HTTP and FTP servers, in addition to the standard filesystem
+# support available without NETFILES).  The WFDB library can use either
+# libcurl (recommended) or libwww to provide NETFILES support.  To use libcurl,
+# set LC to `curl-config --cflags` (note the backquotes) and LN to
+# `curl-config --libs`.  Otherwise, to use libwww, set LC to
+# `libwww-config --cflags` and LL to `libwww-config --libs`.  If neither
+# libcurl nor libwww is available, LC and LL should be empty (and NETFILES
+# will be disabled).
+LC =
+LL =
 
 # BINDIR specifies the directory in which the applications will be installed;
 # it should be a directory in the PATH of those who will use the applications.
@@ -74,7 +64,7 @@
 
 # PSPDIR specifies the name of a directory in which to install the PostScript
 # prolog (*.pro) files from the 'app' directory.
-PSPDIR = /usr/lib/ps
+PSPDIR = $(WFDBROOT)/lib/ps
 
 # CC is the name of your C compiler.
 CC = gcc
@@ -84,6 +74,10 @@
 # VDEFS.
 CCDEFS = $(VDEFS)
 
+# MFLAGS is the set of architecture-dependent (-m*) compiler options, which
+# is usually empty.  See the gcc manual for information about gcc's -m options.
+MFLAGS =
+
 # CFLAGS is the set of C compiler options.  CFLAGS should always include
 # CCDEFS.  Add the following options to CFLAGS as appropriate (separating them
 # by spaces if you use more than one):
@@ -91,13 +85,13 @@
 #   -O		  if you trust your C compiler's optimizer
 # With the exception of `gcc', most C compilers do not allow you to use -g and
 # -O simultaneously.
-CFLAGS = -g $(CCDEFS) `$(LWC) --cflags` `$(LCC) --cflags` -I$(INCDIR)
+# CFLAGS = -g $(CCDEFS) $(LC) -I$(INCDIR)
 # `gcc' users may comment out the previous line, and uncomment the next one.
-# CFLAGS = -g -O $(CCDEFS) `$(LWC) --cflags` `$(LCC) --cflags` -I$(INCDIR)
+CFLAGS = $(MFLAGS) -g -O $(CCDEFS) $(LC) -I$(INCDIR)
 
 # 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'.
@@ -160,8 +154,20 @@
 # OWLIBDIR is the directory in which the XView library is found.
 OWLIBDIR = $(OPENWINHOME)/lib
 
+# XHOME specifies the root directory of the X11 hierarchy.
+# This is usually /usr/X11R6 (or /usr/X11).
+XHOME = /usr/X11R6
+
+# XINCDIR is the directory in which the 'X11' directory containing X11 *.h
+# files is found.  This is usually /usr/X11R6/include, although there is often
+# a link connecting /usr/include/X11 to this directory.
+XINCDIR = $(XHOME)/include
+
+# XLIBDIR is the directory in which the X11 libraries are found.
+XLIBDIR = $(XHOME)/lib
+
 # WCFLAGS is the set of C compiler options to use when compiling WAVE.
-WCFLAGS = $(CFLAGS) -I$(OWINCDIR)
+WCFLAGS = $(CFLAGS) -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).
@@ -171,7 +177,7 @@
 
 # WLDFLAGS is the set of loader options appended to the C compiler command line
 # to specify loading the WFDB, XView, and Xlib libraries.
-WLDFLAGS = $(LDFLAGS) -L$(OWLIBDIR) -L/usr/X11R6/lib -lxview -lolgx -lX11
+WLDFLAGS = $(LDFLAGS) -L$(OWLIBDIR) -L$(XINCDIR) -lxview -lolgx -lX11
 # ...........................................................................
 
 # `make' (with no target specified) will be equivalent to `make all'.
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/conf/hpux-slib.def wfdb-10.3.17/conf/hpux-slib.def
--- wfdb-10.3.16/conf/hpux-slib.def	2005-05-13 16:36:35.000000000 -0400
+++ wfdb-10.3.17/conf/hpux-slib.def	2005-08-05 15:18:40.000000000 -0400
@@ -1,5 +1,5 @@
 # file: hpux-slib.def	G. Moody	31 May 2000
-#			Last revised: 28 November 2004
+#			Last revised:  5 August 2005
 # This section contains settings suitable for generating a shared library under
 # HP-UX.
 
@@ -19,21 +19,27 @@
 # name of your home directory, as in the example below (change as needed).
 # WFDBROOT = /home/frodo
 
-# If the W3C's libwww library of HTTP and FTP client code is available, and
-# you wish to compile a shared WFDB library with NETFILES support, set LWC
-# to 'libwww-config' (a utility supplied with libwww).  Otherwise set
-# LWC to ':' (a program that does nothing, successfully).
-LWC = libwww-config
-
-# Similarly, to use the libcurl library instead of libwww, set LCC to
-# 'curl-config'.  Otherwise set LCC to ':'.  Only one of libwww or
-# libcurl should be enabled.
-LCC = curl-config
+# LC and LL are used to determine C compiler and linker options needed to
+# enable NETFILES (code that allows applications linked to the WFDB library to
+# read input from HTTP and FTP servers, in addition to the standard filesystem
+# support available without NETFILES).  The WFDB library can use either
+# libcurl (recommended) or libwww to provide NETFILES support.  To use libcurl,
+# set LC to `curl-config --cflags` (note the backquotes) and LN to
+# `curl-config --libs`.  Otherwise, to use libwww, set LC to
+# `libwww-config --cflags` and LL to `libwww-config --libs`.  If neither
+# libcurl nor libwww is available, LC and LL should be empty (and NETFILES
+# will be disabled).
+LC =
+LL =
 
 # BINDIR specifies the directory in which the applications will be installed;
 # it should be a directory in the PATH of those who will use the applications.
 BINDIR = $(WFDBROOT)/bin
 
+# DBDIR specifies the name of a directory in which to install the contents
+# of the `data' directory.
+DBDIR = $(WFDBROOT)/database
+
 # INCDIR specifies the name of a directory in which to install the WFDB
 # library's #include <...> files.
 INCDIR = $(WFDBROOT)/include
@@ -46,21 +52,9 @@
 # library.
 LIBDIR = $(WFDBROOT)/lib
 
-# LDLIBWWW, which is appended to LDFLAGS below, is the set of options needed
-# to link with libwww.  If libwww is not installed, or if libwfdb is a shared
-# library, LDLIBWWW can be empty (if there is a '#' immediately after the '='
-# below, the remainder of the line is ignored, so LDLIBWWW is empty in this
-# case).  Otherwise, it is generated from the output of LWC.  Note that up to
-# three passes through the option list are necessary to satisfy all
-# dependencies when linking to the static libwww libraries.
-LDLIBWWW = # `$(LWC) --libs` `$(LWC) --libs` `$(LWC) --libs`
-
-# LDLIBCURL is the set of options needed to link with libcurl.
-LDLIBCURL = # `$(LCC) --libs` `$(LCC) --libs` `$(LCC) --libs`
-
 # 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)
 
 # CC is the name of your C compiler.
 CC = gcc
@@ -70,9 +64,13 @@
 # VDEFS.
 CCDEFS = $(VDEFS)
 
+# MFLAGS is the set of architecture-dependent (-m*) compiler options, which
+# is usually empty.  See the gcc manual for information about gcc's -m options.
+MFLAGS =
+
 # CFLAGS is the set of C compiler options used when compiling the shared
 # library.  CFLAGS should always include CCDEFS.
-CFLAGS = -fpic -g -O $(CCDEFS) `$(LWC) --cflags` `$(LCC) --cflags` -I$(INCDIR)
+CFLAGS = $(MFLAGS) -fpic -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
@@ -95,7 +93,7 @@
 # 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 = ld -b `$(LWC) --libs` `$(LCC) --libs` -o $(WFDBLIB)
+BUILDLIB = ld -b $(LL) -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).
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/conf/linux.def wfdb-10.3.17/conf/linux.def
--- wfdb-10.3.16/conf/linux.def	2005-05-13 16:36:35.000000000 -0400
+++ wfdb-10.3.17/conf/linux.def	2005-08-04 15:42:49.000000000 -0400
@@ -1,5 +1,5 @@
 # file: linux.def		G. Moody	31 May 2000
-#				Last revised:  4 March 2003
+#				Last revised:  4 August 2005
 # 'make' definitions for compiling the WFDB Software Package under Linux
 
 # Choose a value for WFDBROOT to determine where the WFDB Software Package will
@@ -18,28 +18,18 @@
 # name of your home directory, as in the example below (change as needed).
 # WFDBROOT = /home/frodo
 
-# If the W3C's libwww library of HTTP and FTP client code is available, and
-# you wish to compile a WFDB library with NETFILES support, set LWC to
-# 'libwww-config' (a utility supplied with libwww).  Otherwise set LWC to ':'
-# (a program that does nothing, successfully).
-LWC = libwww-config
-
-# Similarly, to use the libcurl library instead of libwww, set LCC to
-# 'curl-config'.  Otherwise set LCC to ':'.  Only one of libwww or
-# libcurl should be enabled.
-LCC = curl-config
-
-# LDLIBWWW, which is appended to LDFLAGS below, is the set of options needed
-# to link with libwww.  If libwww is not installed, or if libwfdb is a shared
-# library, LDLIBWWW can be empty (if there is a '#' immediately after the '='
-# below, the remainder of the line is ignored, so LDLIBWWW is empty in this
-# case).  Otherwise, it is generated from the output of LWC.  Note that up to
-# three passes through the option list are necessary to satisfy all
-# dependencies when linking to the static libwww libraries.
-LDLIBWWW = # `$(LWC) --libs` `$(LWC) --libs` `$(LWC) --libs`
-
-# LDLIBCURL is the set of options needed to link with libcurl.
-LDLIBCURL = # `$(LCC) --libs` `$(LCC) --libs` `$(LCC) --libs`
+# LC and LL are used to determine C compiler and linker options needed to
+# enable NETFILES (code that allows applications linked to the WFDB library to
+# read input from HTTP and FTP servers, in addition to the standard filesystem
+# support available without NETFILES).  The WFDB library can use either
+# libcurl (recommended) or libwww to provide NETFILES support.  To use libcurl,
+# set LC to `curl-config --cflags` (note the backquotes) and LN to
+# `curl-config --libs`.  Otherwise, to use libwww, set LC to
+# `libwww-config --cflags` and LL to `libwww-config --libs`.  If neither
+# libcurl nor libwww is available, LC and LL should be empty (and NETFILES
+# will be disabled).
+LC =
+LL =
 
 # BINDIR specifies the directory in which the applications will be installed;
 # it should be a directory in the PATH of those who will use the applications.
@@ -76,13 +66,17 @@
 # VDEFS.
 CCDEFS = $(VDEFS)
 
+# MFLAGS is the set of architecture-dependent (-m*) compiler options, which
+# is usually empty.  See the gcc manual for information about gcc's -m options.
+MFLAGS =
+
 # CFLAGS is the set of C compiler options.  CFLAGS should always include
 # CCDEFS.
-CFLAGS = -g -O $(CCDEFS) `$(LWC) --cflags` `$(LCC) --cflags` -I$(INCDIR)
+CFLAGS = $(MFLAGS) -g -O $(CCDEFS) $(LC) -I$(INCDIR)
 
 # 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'.
@@ -137,8 +131,20 @@
 # OWLIBDIR is the directory in which the XView library is found.
 OWLIBDIR = $(OPENWINHOME)/lib
 
+# XHOME specifies the root directory of the X11 hierarchy.
+# This is usually /usr/X11R6 (or /usr/X11).
+XHOME = /usr/X11R6
+
+# XINCDIR is the directory in which the 'X11' directory containing X11 *.h
+# files is found.  This is usually /usr/X11R6/include, although there is often
+# a link connecting /usr/include/X11 to this directory.
+XINCDIR = $(XHOME)/include
+
+# XLIBDIR is the directory in which the X11 libraries are found.
+XLIBDIR = $(XHOME)/lib
+
 # WCFLAGS is the set of C compiler options to use when compiling WAVE.
-WCFLAGS = $(CFLAGS) -I$(OWINCDIR)
+WCFLAGS = $(CFLAGS) -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).
@@ -148,9 +154,9 @@
 
 # WLDFLAGS is the set of loader options appended to the C compiler command line
 # to specify loading the WFDB, XView, and Xlib libraries.
-WLDFLAGS = $(LDFLAGS) -L$(OWLIBDIR) -L/usr/X11R6/lib -lxview -lolgx -lX11
+WLDFLAGS = $(LDFLAGS) -L$(OWLIBDIR) -L$(XLIBDIR) -lxview -lolgx -lX11
 # Users of Red Hat Linux 5.0 or 5.1 (not later versions), use this instead:
-# WLDFLAGS = $(LDFLAGS) -L/usr/X11R6/lib $(OWLIBDIR)/libxview.a \
+# WLDFLAGS = $(LDFLAGS) -L$(XLIBDIR) $(OWLIBDIR)/libxview.a \
 #  $(OWLIBDIR)/libolgx.a -lX11
 # This setting avoids incompatibilities with the shared (dynamic) libraries.
 # ...........................................................................
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/conf/linux-slib.def wfdb-10.3.17/conf/linux-slib.def
--- wfdb-10.3.16/conf/linux-slib.def	2005-06-08 16:16:59.000000000 -0400
+++ wfdb-10.3.17/conf/linux-slib.def	2005-08-04 21:31:11.000000000 -0400
@@ -1,5 +1,5 @@
 # file: linux-slib.def		G. Moody	31 May 2000
-#                               Last revised:   8 June 2005
+#                               Last revised:  4 August 2005
 # This section contains settings suitable for generating an ELF-format shared
 # library under Linux.
 
@@ -19,21 +19,27 @@
 # name of your home directory, as in the example below (change as needed).
 # WFDBROOT = /home/frodo
 
-# If the W3C's libwww library of HTTP and FTP client code is available, and
-# you wish to compile a WFDB library with NETFILES support, set LWC
-# to 'libwww-config' (a utility supplied with libwww).  Otherwise set
-# LWC to ':' (a program that does nothing, successfully).
-LWC = libwww-config
-
-# Similarly, to use the libcurl library instead of libwww, set LCC to
-# 'curl-config'.  Otherwise set LCC to ':'.  Only one of libwww or
-# libcurl should be enabled.
-LCC = curl-config
+# LC and LL are used to determine C compiler and linker options needed to
+# enable NETFILES (code that allows applications linked to the WFDB library to
+# read input from HTTP and FTP servers, in addition to the standard filesystem
+# support available without NETFILES).  The WFDB library can use either
+# libcurl (recommended) or libwww to provide NETFILES support.  To use libcurl,
+# set LC to `curl-config --cflags` (note the backquotes) and LN to
+# `curl-config --libs`.  Otherwise, to use libwww, set LC to
+# `libwww-config --cflags` and LL to `libwww-config --libs`.  If neither
+# libcurl nor libwww is available, LC and LL should be empty (and NETFILES
+# will be disabled).
+LC =
+LL =
 
 # BINDIR specifies the directory in which the applications will be installed;
 # it should be a directory in the PATH of those who will use the applications.
 BINDIR = $(WFDBROOT)/bin
 
+# DBDIR specifies the name of a directory in which to install the contents
+# of the `data' directory.
+DBDIR = $(WFDBROOT)/database
+
 # INCDIR specifies the name of a directory in which to install the WFDB
 # library's #include <...> files.
 INCDIR = $(WFDBROOT)/include
@@ -42,21 +48,9 @@
 # library.
 LIBDIR = $(WFDBROOT)/lib
 
-# LDLIBWWW, which is appended to LDFLAGS below, is the set of options needed
-# to link with libwww.  If libwww is not installed, or if libwfdb is a shared
-# library, LDLIBWWW can be empty (if there is a '#' immediately after the '='
-# below, the remainder of the line is ignored, so LDLIBWWW is empty in this
-# case).  Otherwise, it is generated from the output of LWC.  Note that up to
-# three passes through the option list are necessary to satisfy all
-# dependencies when linking to the static libwww libraries.
-LDLIBWWW = # `$(LWC) --libs` `$(LWC) --libs` `$(LWC) --libs`
-
-# LDLIBCURL is the set of options needed to link with libcurl.
-LDLIBCURL = # `$(LCC) --libs` `$(LCC) --libs` `$(LCC) --libs`
-
 # 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)
 
 # CC is the name of your C compiler.
 CC = gcc
@@ -66,9 +60,13 @@
 # VDEFS.
 CCDEFS = $(VDEFS)
 
+# MFLAGS is the set of architecture-dependent (-m*) compiler options, which
+# is usually empty.  See the gcc manual for information about gcc's -m options.
+MFLAGS =
+
 # CFLAGS is the set of C compiler options used when compiling the shared
 # library.  CFLAGS should always include CCDEFS.
-CFLAGS = -fpic -g -O $(CCDEFS) `$(LWC) --cflags` `$(LCC) --cflags` -I$(INCDIR)
+CFLAGS = $(MFLAGS) -fpic -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
@@ -91,8 +89,8 @@
 # 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 -shared -Wl,-soname,$(WFDBLIB_SONAME) `$(LWC) --libs` \
- `$(LCC) --libs` -o $(WFDBLIB)
+BUILDLIB = gcc $(MFLAGS) -shared -Wl,-soname,$(WFDBLIB_SONAME) $(LL) \
+ -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).
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/conf/mingw.def wfdb-10.3.17/conf/mingw.def
--- wfdb-10.3.16/conf/mingw.def	2005-06-10 09:42:23.000000000 -0400
+++ wfdb-10.3.17/conf/mingw.def	2005-08-05 20:00:07.000000000 -0400
@@ -1,5 +1,5 @@
 # file: mingw.def		I. Henry and G. Moody       11 February 2005 
-#				Last revised:		      10 June 2005
+#				Last revised:		     5 August 2005
 #
 # This file contains default 'make' definitions for compiling the WFDB Software
 # Package under MS Windows using the free Mininmalist GNU for Windows (MinGW) 
@@ -23,28 +23,18 @@
 # name of your home directory, as in the example below (change as needed).
 # WFDBROOT = /home/frodo
 
-# If the W3C's libwww library of HTTP and FTP client code is available, and
-# you wish to compile a WFDB library with NETFILES support, set LWC to
-# 'libwww-config' (a utility supplied with libwww).  Otherwise set LWC to ':'
-# (a program that does nothing, successfully).
-LWC = libwww-config
-
-# Similarly, to use the libcurl library instead of libwww, set LCC to
-# 'curl-config'.  Otherwise set LCC to ':'.  Only one of libwww or
-# libcurl should be enabled.
-LCC = curl-config
-
-# LDLIBWWW, which is appended to LDFLAGS below, is the set of options needed
-# to link with libwww.  If libwww is not installed, or if libwfdb is a shared
-# library, LDLIBWWW can be empty (if there is a '#' immediately after the '='
-# below, the remainder of the line is ignored, so LDLIBWWW is empty in this
-# case).  Otherwise, it is generated from the output of LWC.  Note that up to
-# three passes through the option list are necessary to satisfy all
-# dependencies when linking to the static libwww libraries.
-LDLIBWWW = # `$(LWC) --libs` `$(LWC) --libs` `$(LWC) --libs`
-
-# LDLIBCURL is the set of options needed to link with libcurl.
-LDLIBCURL = # `$(LCC) --libs` `$(LCC) --libs` `$(LCC) --libs`
+# LC and LL are used to determine C compiler and linker options needed to
+# enable NETFILES (code that allows applications linked to the WFDB library to
+# read input from HTTP and FTP servers, in addition to the standard filesystem
+# support available without NETFILES).  The WFDB library can use either
+# libcurl (recommended) or libwww to provide NETFILES support.  To use libcurl,
+# set LC to `curl-config --cflags` (note the backquotes) and LN to
+# `curl-config --libs`.  Otherwise, to use libwww, set LC to
+# `libwww-config --cflags` and LL to `libwww-config --libs`.  If neither
+# libcurl nor libwww is available, LC and LL should be empty (and NETFILES
+# will be disabled).
+LC =
+LL =
 
 # BINDIR specifies the directory in which the applications will be installed;
 # it should be a directory in the PATH of those who will use the applications.
@@ -97,20 +87,17 @@
 # and try again (see signal.c).
 CCDEFS = $(VDEFS) -DNOVALUES_H -DNOMKSTEMP
 
+# MFLAGS is the set of architecture-dependent (-m*) compiler options, which
+# is usually empty.  See the gcc manual for information about gcc's -m options.
+MFLAGS =
+
 # CFLAGS is the set of C compiler options.  CFLAGS should always include
-# CCDEFS.  Add the following options to CFLAGS as appropriate (separating them
-# by spaces if you use more than one):
-#   -g		  to save symbols for debugging
-#   -O		  if you trust your C compiler's optimizer
-# With the exception of `gcc', most C compilers do not allow you to use -g and
-# -O simultaneously.
-CFLAGS = -g $(CCDEFS) `$(LWC) --cflags` `$(LCC) --cflags` -I$(INCDIR)
-# `gcc' users may comment out the previous line, and uncomment the next one.
-# CFLAGS = -g -O $(CCDEFS) `$(LWC) --cflags` `$(LCC) --cflags` -I$(INCDIR)
+# CCDEFS.
+CFLAGS = $(MFLAGS) -g -O $(CCDEFS) $(LC) -I$(INCDIR)
 
 # 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'.
@@ -170,7 +157,8 @@
 # ...........................................................................
 # This section of definitions is used only when compiling WAVE, which is
 # possible only if the XView and Xlib libraries and include files have been
-# installed.
+# installed.  This is not currently possible using mingw, and is unlikely to
+# become possible in the future, although it can be done using cygwin.
 
 # OPENWINHOME specifies the root directory of the OpenWindows hierarchy.
 # This is usually /usr/openwin.
@@ -183,8 +171,20 @@
 # OWLIBDIR is the directory in which the XView library is found.
 OWLIBDIR = $(OPENWINHOME)/lib
 
+# XHOME specifies the root directory of the X11 hierarchy.
+# This is usually /usr/X11R6 (or /usr/X11).
+XHOME = /usr/X11R6
+
+# XINCDIR is the directory in which the 'X11' directory containing X11 *.h
+# files is found.  This is usually /usr/X11R6/include, although there is often
+# a link connecting /usr/include/X11 to this directory.
+XINCDIR = $(XHOME)/include
+
+# XLIBDIR is the directory in which the X11 libraries are found.
+XLIBDIR = $(XHOME)/lib
+
 # WCFLAGS is the set of C compiler options to use when compiling WAVE.
-WCFLAGS = $(CFLAGS) -I$(OWINCDIR)
+WCFLAGS = $(CFLAGS) -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).
@@ -194,7 +194,7 @@
 
 # WLDFLAGS is the set of loader options appended to the C compiler command line
 # to specify loading the WFDB, XView, and Xlib libraries.
-WLDFLAGS = $(LDFLAGS) -L$(OWLIBDIR) -L/usr/X11R6/lib -lxview -lolgx -lX11
+WLDFLAGS = $(LDFLAGS) -L$(OWLIBDIR) -L$(XLIBDIR) -lxview -lolgx -lX11
 # ...........................................................................
 
 # `make' (with no target specified) will be equivalent to `make all'.
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/conf/mingw-slib.def wfdb-10.3.17/conf/mingw-slib.def
--- wfdb-10.3.16/conf/mingw-slib.def	2005-06-08 16:05:32.000000000 -0400
+++ wfdb-10.3.17/conf/mingw-slib.def	2005-08-05 15:15:56.000000000 -0400
@@ -20,16 +20,26 @@
 # name of your home directory, as in the example below (change as needed).
 # WFDBROOT = /home/frodo
 
-# If the W3C's libwww library of HTTP and FTP client code is available, and
-# you wish to compile a WFDB library with NETFILES support, set LWC
-# to 'libwww-config' (a utility supplied with libwww).  Otherwise set
-# LWC to ':' (a program that does nothing, successfully).
-LWC = libwww-config
-
-# Similarly, to use the libcurl library instead of libwww, set LCC to
-# 'curl-config'.  Otherwise set LCC to ':'.  Only one of libwww or
-# libcurl should be enabled.
-LCC = curl-config
+# LC and LL are used to determine C compiler and linker options needed to
+# enable NETFILES (code that allows applications linked to the WFDB library to
+# read input from HTTP and FTP servers, in addition to the standard filesystem
+# support available without NETFILES).  The WFDB library can use either
+# libcurl (recommended) or libwww to provide NETFILES support.  To use libcurl,
+# set LC to `curl-config --cflags` (note the backquotes) and LN to
+# `curl-config --libs`.  Otherwise, to use libwww, set LC to
+# `libwww-config --cflags` and LL to `libwww-config --libs`.  If neither
+# libcurl nor libwww is available, LC and LL should be empty (and NETFILES
+# will be disabled).
+LC =
+LL =
+
+# BINDIR specifies the name of a directory in which to install the WFDB
+# DLL.
+BINDIR = $(WFDBROOT)/bin
+
+# DBDIR specifies the name of a directory in which to install the contents
+# of the `data' directory.
+DBDIR = $(WFDBROOT)/database
 
 # INCDIR specifies the name of a directory in which to install the WFDB
 # library's #include <...> files.
@@ -39,11 +49,7 @@
 # library.
 LIBDIR = $(WFDBROOT)/lib
 
-# BINDIR specifies the name of a directory in which to install the WFDB
-# DLL.
-BINDIR = $(WFDBROOT)/bin
-
-# CC is the name of your C compiler.
+# CC is the name of your C compiler ('configure' will modify this).
 CC = gcc NOCYGWIN
 
 # CCDEFS is the set of C compiler options needed to set preprocessor variables
@@ -51,9 +57,13 @@
 # VDEFS.
 CCDEFS = $(VDEFS) -DNOVALUES_H -DNOMKSTEMP
 
+# MFLAGS is the set of architecture-dependent (-m*) compiler options, which
+# is usually empty.  See the gcc manual for information about gcc's -m options.
+MFLAGS =
+
 # CFLAGS is the set of C compiler options used when compiling the shared
 # library.  CFLAGS should always include CCDEFS.
-CFLAGS = -g -O $(CCDEFS) `$(LWC) --cflags` `$(LCC) --cflags` -I$(INCDIR)
+CFLAGS =$(MFLAGS) -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
@@ -84,8 +94,7 @@
 
 # BUILDLIB_LDFLAGS is a list of arguments appended to BUILDLIB following
 # the list of *.o files.
-BUILDLIB_LDFLAGS = `$(LWC) --libs` `$(LWC) --libs` `$(LWC) --libs` \
- `$(LCC) --libs` `$(LCC) --libs` `$(LCC) --libs`
+BUILDLIB_LDFLAGS = $(LL)
  
 # LDCONFIG is the name of the program needed to refresh the system's cached
 # index of shared libraries.
@@ -109,20 +118,6 @@
 # programs linked to it.
 SETLPERMISSIONS = chmod 755
 
-# STRIP is the command used to compact the compiled binaries by removing their
-# symbol tables.  'exestrip' is a script that appends the '.exe' suffix to the
-# files in its argument list before passing their names to 'strip' itself.
-STRIP = $(SRCDIR)/conf/exestrip
-# To retain the symbol tables for debugging, comment out the previous line, and
-# uncomment the next line.
-# STRIP = :
-
-# RM is the command used to delete binaries. 'exerm' is a script that appends
-# the '.exe' suffix to the files in its argument list before deleting.
-RM = $(SRCDIR)/conf/exerm
-
-OTHER_CLEAN_FILES = $(WFDBLIB_DLLNAME)
-
 # `make' (with no target specified) will be equivalent to `make all'.
 make-all:	all
 
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/conf/solaris.def wfdb-10.3.17/conf/solaris.def
--- wfdb-10.3.16/conf/solaris.def	2005-05-13 16:36:35.000000000 -0400
+++ wfdb-10.3.17/conf/solaris.def	2005-08-07 10:52:14.000000000 -0400
@@ -1,5 +1,5 @@
 # file: solaris.def		G. Moody	31 May 2000
-#				Last revised:  4 March 2003
+#				Last revised:  7 August 2005
 # 'make' definitions for compiling the WFDB Software Package under Solaris
 
 # Choose a value for WFDBROOT to determine where the WFDB Software Package will
@@ -19,28 +19,18 @@
 # WFDBROOT = /home/frodo
 # WFDBROOT = /home/frodo
 
-# If the W3C's libwww library of HTTP and FTP client code is available, and
-# you wish to compile a WFDB library with NETFILES support, set LWC to
-# 'libwww-config' (a utility supplied with libwww).  Otherwise set LWC to ':'
-# (a program that does nothing, successfully).
-LWC = libwww-config
-
-# Similarly, to use the libcurl library instead of libwww, set LCC to
-# 'curl-config'.  Otherwise set LCC to ':'.  Only one of libwww or
-# libcurl should be enabled.
-LCC = curl-config
-
-# LDLIBWWW, which is appended to LDFLAGS below, is the set of options needed
-# to link with libwww.  If libwww is not installed, or if libwfdb is a shared
-# library, LDLIBWWW can be empty (if there is a '#' immediately after the '='
-# below, the remainder of the line is ignored, so LDLIBWWW is empty in this
-# case).  Otherwise, it is generated from the output of LWC.  Note that up to
-# three passes through the option list are necessary to satisfy all
-# dependencies when linking to the static libwww libraries.
-LDLIBWWW = # `$(LWC) --libs` `$(LWC) --libs` `$(LWC) --libs`
-
-# LDLIBCURL is the set of options needed to link with libcurl.
-LDLIBCURL = # `$(LCC) --libs` `$(LCC) --libs` `$(LCC) --libs`
+# LC and LL are used to determine C compiler and linker options needed to
+# enable NETFILES (code that allows applications linked to the WFDB library to
+# read input from HTTP and FTP servers, in addition to the standard filesystem
+# support available without NETFILES).  The WFDB library can use either
+# libcurl (recommended) or libwww to provide NETFILES support.  To use libcurl,
+# set LC to `curl-config --cflags` (note the backquotes) and LN to
+# `curl-config --libs`.  Otherwise, to use libwww, set LC to
+# `libwww-config --cflags` and LL to `libwww-config --libs`.  If neither
+# libcurl nor libwww is available, LC and LL should be empty (and NETFILES
+# will be disabled).
+LC =
+LL =
 
 # BINDIR specifies the directory in which the applications will be installed;
 # it should be a directory in the PATH of those who will use the applications.
@@ -53,6 +43,7 @@
 # INCDIR specifies the name of a directory in which to install the WFDB
 # library's #include <...> files.
 INCDIR = $(WFDBROOT)/include
+
 # Note: if you have both gcc and a vendor-supplied C compiler, and if INCDIR
 # is /usr/include, CFLAGS should *not* contain -I$(INCDIR) (if it does, gcc may
 # read the wrong version of files such as stdio.h when compiling WFDB
@@ -71,7 +62,7 @@
 
 # PSPDIR specifies the name of a directory in which to install the PostScript
 # prolog (*.pro) files from the 'app' directory.
-PSPDIR = /usr/lib/ps
+PSPDIR = $(WFDBROOT)/lib/ps
 
 # CC is the name of your C compiler.
 CC = gcc
@@ -81,16 +72,20 @@
 # VDEFS.
 CCDEFS = $(VDEFS)
 
+# MFLAGS is the set of architecture-dependent (-m*) compiler options, which
+# is usually empty.  See the gcc manual for information about gcc's -m options.
+MFLAGS =
+
 # CFLAGS is the set of C compiler options.  CFLAGS should always include
 # CCDEFS.  With the exception of `gcc', most C compilers do not allow you to
-# use -g and -O simultaneously.
-CFLAGS = -O $(CCDEFS) `$(LWC) --cflags` `$(LCC) --cflags` -I$(INCDIR)
+# use -g and -O simultaneously.  MFLAGS is gcc-specific.
+# CFLAGS = -O $(CCDEFS) $(LC) -I$(INCDIR)
 # `gcc' users may comment out the previous line, and uncomment the next one.
-# CFLAGS = -g -O $(CCDEFS) `$(LWC) --cflags` `$(LCC) --cflags` -I$(INCDIR)
+CFLAGS = $(MFLAGS) -g -O $(CCDEFS)`$(LC) -I$(INCDIR)
 
 # 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'.
@@ -145,8 +140,20 @@
 # OWLIBDIR is the directory in which the XView library is found.
 OWLIBDIR = $(OPENWINHOME)/lib
 
+# XHOME specifies the root directory of the X11 hierarchy.
+# This is usually /usr/X11R6 (or /usr/X11).
+XHOME = /usr/X11R6
+
+# XINCDIR is the directory in which the 'X11' directory containing X11 *.h
+# files is found.  This is usually /usr/X11R6/include, although there is often
+# a link connecting /usr/include/X11 to this directory.
+XINCDIR = $(XHOME)/include
+
+# XLIBDIR is the directory in which the X11 libraries are found.
+XLIBDIR = $(XHOME)/lib
+
 # WCFLAGS is the set of C compiler options to use when compiling WAVE.
-WCFLAGS = $(CFLAGS) -I$(OWINCDIR) -DOWTOOLKIT_WARNING_DISABLED
+WCFLAGS = $(CFLAGS) -I$(OWINCDIR) -DOWTOOLKIT_WARNING_DISABLED -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).
@@ -156,7 +163,7 @@
 
 # WLDFLAGS is the set of loader options appended to the C compiler command line
 # to specify loading the WFDB, XView, and Xlib libraries.
-WLDFLAGS = $(LDFLAGS) -L$(OWLIBDIR) -L/usr/X11R6/lib -lxview -lolgx -lX11
+WLDFLAGS = $(LDFLAGS) -L$(OWLIBDIR) -L$(XLIBDIR) -lxview -lolgx -lX11
 # ...........................................................................
 
 # `make' (with no target specified) will be equivalent to `make all'.
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/conf/solaris-slib.def wfdb-10.3.17/conf/solaris-slib.def
--- wfdb-10.3.16/conf/solaris-slib.def	2005-05-13 16:36:36.000000000 -0400
+++ wfdb-10.3.17/conf/solaris-slib.def	2005-08-05 15:04:21.000000000 -0400
@@ -1,5 +1,5 @@
 # file: solaris-slib.def	G. Moody	31 May 2000
-#				Last revised: 28 November 2004
+#				Last revised:  5 August 2005
 # This section contains settings suitable for generating a shared library under
 # Solaris.
 
@@ -19,21 +19,27 @@
 # name of your home directory, as in the example below (change as needed).
 # WFDBROOT = /home/frodo
 
-# If the W3C's libwww library of HTTP and FTP client code is available, and
-# you wish to compile a WFDB library with NETFILES support, set LWC
-# to 'libwww-config' (a utility supplied with libwww).  Otherwise set
-# LWC to ':' (a program that does nothing, successfully).
-LWC = libwww-config
-
-# Similarly, to use the libcurl library instead of libwww, set LCC to
-# 'curl-config'.  Otherwise set LCC to ':'.  Only one of libwww or
-# libcurl should be enabled.
-LCC = curl-config
+# LC and LL are used to determine C compiler and linker options needed to
+# enable NETFILES (code that allows applications linked to the WFDB library to
+# read input from HTTP and FTP servers, in addition to the standard filesystem
+# support available without NETFILES).  The WFDB library can use either
+# libcurl (recommended) or libwww to provide NETFILES support.  To use libcurl,
+# set LC to `curl-config --cflags` (note the backquotes) and LN to
+# `curl-config --libs`.  Otherwise, to use libwww, set LC to
+# `libwww-config --cflags` and LL to `libwww-config --libs`.  If neither
+# libcurl nor libwww is available, LC and LL should be empty (and NETFILES
+# will be disabled).
+LC =
+LL =
 
 # BINDIR specifies the directory in which the applications will be installed;
 # it should be a directory in the PATH of those who will use the applications.
 BINDIR = $(WFDBROOT)/bin
 
+# DBDIR specifies the name of a directory in which to install the contents
+# of the `data' directory.
+DBDIR = $(WFDBROOT)/database
+
 # INCDIR specifies the name of a directory in which to install the WFDB
 # library's #include <...> files.
 INCDIR = $(WFDBROOT)/include
@@ -42,18 +48,6 @@
 # library.
 LIBDIR = $(WFDBROOT)/lib
 
-# LDLIBWWW, which is appended to LDFLAGS below, is the set of options needed
-# to link with libwww.  If libwww is not installed, or if libwfdb is a shared
-# library, LDLIBWWW can be empty (if there is a '#' immediately after the '='
-# below, the remainder of the line is ignored, so LDLIBWWW is empty in this
-# case).  Otherwise, it is generated from the output of LWC.  Note that up to
-# three passes through the option list are necessary to satisfy all
-# dependencies when linking to the static libwww libraries.
-LDLIBWWW = # `$(LWC) --libs` `$(LWC) --libs` `$(LWC) --libs`
-
-# LDLIBCURL is the set of options needed to link with libcurl.
-LDLIBCURL = # `$(LCC) --libs` `$(LCC) --libs` `$(LCC) --libs`
-
 # LDFLAGS is appended to the C compiler command line to specify loading the
 # WFDB library.
 LDFLAGS = -L$(LIBDIR) -lwfdb $(LDLIBWWW) $(LDLIBCURL)
@@ -66,14 +60,18 @@
 # VDEFS.
 CCDEFS = $(VDEFS)
 
+# MFLAGS is the set of architecture-dependent (-m*) compiler options, which
+# is usually empty.  See the gcc manual for information about gcc's -m options.
+MFLAGS =
+
 # CFLAGS is the set of C compiler options used when compiling the shared
 # library.  CFLAGS should always include CCDEFS.  These settings are for use
 # with gcc:
-CFLAGS = -fpic -g -O $(CCDEFS) `$(LWC) --cflags` `$(LCC) --cflags` -I$(INCDIR)
-# For SunOS `cc', uncomment the next line.
-# CFLAGS = -pic -O $(CCDEFS) `$(LWC) --cflags` `$(LCC) --cflags` -I$(INCDIR)
-# For Solaris or SVR4 `cc', uncomment the next line.
-# CFLAGS = -K PIC -O $(CCDEFS) `$(LWC) --cflags` `$(LCC) --cflags` -I$(INCDIR)
+CFLAGS = $(MFLAGS) -fpic -g -O $(CCDEFS) $(LC) -I$(INCDIR)
+# For SunOS cc, uncomment the next line. MFLAGS is gcc-specific, thus excluded.
+# CFLAGS = -pic -O $(CCDEFS) $(LC) -I$(INCDIR)
+# For Solaris or SVR4 cc, uncomment the next line.
+# CFLAGS = -K PIC -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
@@ -96,7 +94,7 @@
 # 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 = ld -o $(WFDBLIB) -G -z text `$(LWC) --libs` `$(LCC) --libs`
+BUILDLIB = ld -o $(WFDBLIB) -G -z text $(LL)
 
 # BUILDLIB_LDFLAGS is a list of arguments appended to BUILDLIB following
 # the list of *.o files (for most platforms, BUILDLIB_LDFLAGS is empty).
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/conf/version.def wfdb-10.3.17/conf/version.def
--- wfdb-10.3.16/conf/version.def	2005-06-11 17:51:57.000000000 -0400
+++ wfdb-10.3.17/conf/version.def	2005-06-27 15:02:29.000000000 -0400
@@ -4,7 +4,7 @@
 # version number, defined here:
 MAJOR = 10
 MINOR = 3
-RELEASE = 16
+RELEASE = 17
 VERSION = $(MAJOR).$(MINOR).$(RELEASE)
 
 # RPMRELEASE can be incremented if changes are made between official
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/configure wfdb-10.3.17/configure
--- wfdb-10.3.16/configure	2005-06-08 16:38:39.000000000 -0400
+++ wfdb-10.3.17/configure	2005-08-08 07:04:37.000000000 -0400
@@ -1,6 +1,6 @@
 #! /bin/sh
 # file: configure             G. Moody         24 May 2000
-#                             Last revised:    8 June 2005
+#                             Last revised:   8 August 2005
 # Configuration script for the WFDB Software Package
 
 # This script was not generated using 'autoconf'.  If you can implement
@@ -8,43 +8,54 @@
 # please send them to me (george@mit.edu) for inclusion in a future
 # version of this package.
 
-if [ $# -gt 0 ]
-then
-    DIR=/usr
-    LIBTYPE=dynamic
-    SYSLIBS=dynamic
-fi
- 
+# Note that any -m options (although parsed below) are currently ignored,
+# except on x86_64 Linux, where they are prefixed to CFLAGS.  The help
+# text below documents only -m32;  see the gcc manual for other -m options.
+
+NETLIB=unknown
 for i in $*
 do
   case $i in
-    --dynamic)        LIBTYPE=dynamic ;;
-    --mandir=*)       MANDIR=`echo $i | sed 's/[-a-zA-Z0-9]*=//'` ;;
-    --prefix=*)       DIR=`echo $i | sed 's/[-a-zA-Z0-9]*=//'` ;;
-    --shared)         LIBTYPE=dynamic ;;
-    --static)         LIBTYPE=static ;;
-    --static_only)    LIBTYPE=static
-		      SYSLIBS=static ;;
-    --no-cygwin)      NOCYGWIN=yes ;;
-    *)             cat <<EOF
+    --dynamic)          LIBTYPE=dynamic ;;
+    -m*)                if [ "x$MFLAGS" = x ]
+                        then
+		            MFLAGS=$i
+		        else
+		            MFLAGS="$MFLAGS $i"
+		        fi ;;
+    --mandir=*)         MANDIR=`echo $i | sed 's/[-a-zA-Z0-9]*=//'` ;;
+    --prefix=*)         DIR=`echo $i | sed 's/[-a-zA-Z0-9]*=//'` ;;
+    --shared)           LIBTYPE=dynamic ;;
+    --static)           LIBTYPE=static ;;
+    --static_only)      LIBTYPE=static
+		        SYSLIBS=static ;;
+    --without-cygwin)   NOCYGWIN=yes ;;
+    --without-netfiles) NETLIB=none ;;
+    --with-libcurl)     NETLIB=libcurl ;;
+    --with-libwww)      NETLIB=libwww ;;
+    *)                  cat <<EOF
 usage: $0 [options]
 Options:
-    --dynamic         make a shared (dynamically linkable) WFDB library
-                       if possible [default]
-    --help            print this message
-    --mandir=MANDIR   install man pages in MANDIR
-    --prefix=PREFIX   install files in PREFIX [default: $DIR]
-    --shared          (same as --dynamic)
-    --static          make a static WFDB library (do not make a shared
-                       library even if possible)
-    --static_only     link WFDB applications to static libraries only
-                       (assumes --static;  compilation may fail if any
-	               necessary libraries are available as shared libraries
-		       only)
-    --no-cygwin       on Cygwin, compile binaries that do not link to the
-                       Cygwin DLL. WAVE will not be built.
+    --dynamic           make a shared (dynamically linkable) WFDB library
+                         if possible [default]
+    --help              print this message
+    -m32                on 64-bit Linux, force compilation in 32-bit mode
+    --mandir=MANDIR     install man pages in MANDIR
+    --prefix=PREFIX     install files in PREFIX [default: $DIR]
+    --shared            (same as --dynamic)
+    --static            make a static WFDB library (do not make a shared
+                         library even if possible)
+    --static_only       link WFDB applications to static libraries only
+                         (assumes --static;  compilation may fail if any
+	                 necessary libraries are available as shared libraries
+		         only)
+    --without-cygwin    on Cygwin, compile binaries that do not link to the
+                         Cygwin DLL. WAVE will not be built.
+    --without-netfiles  disable NETFILES even if libcurl or libwww is available
+    --with-libcurl      enable NETFILES via libcurl [default]
+    --with-libwww       enable NETFILES via libwww
 EOF
-                   exit ;;
+                        exit ;;
   esac
 done
 
@@ -53,6 +64,7 @@
 echo "Configuring the WFDB software package for $OS."
 
 SRCDIR="`pwd`"
+LIB=lib
 cd conf
 
 echo "Checking the echo command ..."
@@ -76,11 +88,26 @@
 echo "# _____________________________________________________________________________" >>site.def
 echo >>site.def
 
-cp /dev/null site-slib.def
+rm -f site-slib.def
+touch site-slib.def
 case `uname` in
   Linux*) OS=Linux
-    cat site.def linux-slib.def >site-slib.def
-    cat linux.def >>site.def ;;
+    case `arch` in
+      x86_64)
+	if [ "x$MFLAGS" = x ]
+	then
+	    LIB=lib64
+	    cat site.def linux-slib.def | sed s+/lib\$+/lib64+g >site-slib.def
+	    cat linux.def | sed s+/lib\$+/lib64+g >>site.def
+	else
+	    cat site.def linux-slib.def | \
+		sed "s+MFLAGS =+MFLAGS = $MFLAGS+" >site-slib.def
+	    cat linux.def | \
+		sed "s+MFLAGS =+MFLAGS = $MFLAGS+" >>site.def
+	fi ;;
+      *) cat site.def linux-slib.def >site-slib.def
+	 cat linux.def >>site.def ;;
+    esac ;;
   FreeBSD*) OS=FreeBSD
     cat site.def freebsd-slib.def >site-slib.def
     cat freebsd.def >>site.def ;;
@@ -135,7 +162,8 @@
 fi
 
 case x$LIBTYPE in
-  xS*|xs*) cp /dev/null site-slib.def
+  xS*|xs*) rm -f site-slib.def
+           touch site-slib.def
            LIBTYPE=static ;;
         *) LIBTYPE=dynamic ;;
 esac
@@ -176,14 +204,14 @@
 then
     WCC="no gcc"
 fi
-if ( echo $WCC | grep "no \|not " >/dev/null )
+if ( echo $WCC | grep "no \|not " >wcc.t1 )
 then
     WCC=`which cc 2>&1`
     if [ "x$WCC" = "x" ]
     then
         WCC="no cc"
     fi
-    if ( echo $WCC | grep "no \|not " >/dev/null )
+    if ( echo $WCC | grep "no \|not " >wcc.t2 )
     then
         echo "not found"
 	echo
@@ -203,8 +231,8 @@
 else
     CC=gcc
 fi
-
 echo "$CC"
+rm -f wcc.t1 wcc.t2
 
 if [ x$DIR = x ]
 then
@@ -212,7 +240,7 @@
     echo "Where do you wish to install the WFDB Software Package?"
     echo "It will be installed in subdirectories of WFDBROOT (by default,"
     echo "WFDBROOT is /usr, so that files are installed in /usr/bin,"
-    echo "/usr/include, /usr/lib, etc.).  Other reasonable choices for"
+    echo "/usr/include, /usr/$LIB, etc.).  Other reasonable choices for"
     echo "WFDBROOT are /usr/local, /opt, or your home directory ($HOME)."
     echo "The value of WFDBROOT must be a full pathname (beginning with '/',"
     echo "but without a '/' at the end).  If the subdirectories (bin, include,"
@@ -283,167 +311,163 @@
 fi
 
 echo  "The manual pages will be installed in '$MANDIR'."
-
 echo
-./prompt "Looking for libcurl ..."
-WLCC=`which curl-config 2>&1`
-if [ "x$WLCC" = "x" ]
-then
-    WLCC="no curl-config"
-fi
-if ( echo $WLCC | grep "no \|not " >/dev/null )
-then
-    echo "not found"
-    ./prompt "Looking for libwww ..."
-    WLC=`which libwww-config 2>&1`
-    if [ "x$WLC" = "x" ]
+
+# Search for NETLIB if not specified on the command line
+if [ x$NETLIB = xunknown ]
     then
-	WLC="no libwww-config"
+    ./prompt "Looking for libcurl ..."
+    WHICH=`which curl-config 2>&1`
+    if [ "x$WHICH" = "x" ]
+	then
+	WHICH="no curl-config"
     fi
-    if ( echo $WLC | grep "no \|not " >/dev/null )
-    then
-	echo "not found"
-
+    if ( echo $WHICH | grep "no \|not " >which.t1 )
+	then
 	echo "not found"
-	echo "The WFDB software will be compiled without NETFILES"
-	echo "access, because neither libcurl nor libwww appears to be"
-	echo "installed on this system.  To add NETFILES access,"
-	echo "install libcurl or libwww and run ./configure again."
-
-	echo "NETFILES=0" >../config.cache
-	echo "NETFILES_LIBCURL=0" >../config.cache
-	sed "s/LWC = libwww-config/LWC = :/" <site.def >site.tmp
-	sed "s/LCC = curl-config/LCC = :/" <site.tmp >site.def
-	sed "s/LWC = libwww-config/LWC = :/" <site-slib.def >site.tmp
-	sed "s/LCC = curl-config/LCC = :/" <site.tmp >site-slib.def
-	rm site.tmp
-	sed "s/WFDB_NETFILES 1/WFDB_NETFILES 0/" <../lib/wfdb.h0 | \
-	sed "s/WFDB_NETFILES_LIBCURL 1/WFDB_NETFILES_LIBCURL 0/" >../lib/wfdb.h
-	VIANF=""
-	WITHNF=without
+	./prompt "Looking for libwww ..."
+	WHICH=`which libwww-config 2>&1`
+	if [ "x$WHICH" = "x" ]
+	    then
+	    WHICH="no libwww-config"
+	fi
+	if ( echo $WHICH | grep "no \|not " >which.t2 )
+	    then
+	    echo "not found"
+	    echo "The WFDB software will be compiled without NETFILES"
+	    echo "access, because neither libcurl nor libwww appears to"
+	    echo "be installed on this system.  To add NETFILES access,"
+	    echo "install libcurl or libwww and run ./configure again."
+	    NETLIB=none
+	else
+	    echo "found"
+	    echo "The WFDB software will be compiled with NETFILES access"
+	    echo "using libwww."
+	    NETLIB=libwww
+	fi
     else
 	echo "found"
 	echo "The WFDB software will be compiled with NETFILES access"
-	echo "using libwww."
-	echo "NETFILES=1" >../config.cache
-	echo "NETFILES_LIBCURL=0" >../config.cache
-	sed "s/LWC = :/LWC = libwww-config/" <site.def >site.tmp
-	sed "s/LCC = curl-config/LCC = :/" <site.tmp >site.def
-	if [ $LIBTYPE = "static" ]
-	then
-	    sed "s/LDLIBWWW = #/LDLIBWWW =/" <site.def >site.tmp
-	    mv site.tmp site.def
-	fi
-	sed "s/LWC = :/LWC = libwww-config/" <site-slib.def >site.tmp
-	sed "s/LCC = curl-config/LCC = :/" <site.tmp >site-slib.def
-	rm site.tmp
-	sed "s/WFDB_NETFILES 0/WFDB_NETFILES 1/" <../lib/wfdb.h0 | \
-	sed "s/WFDB_NETFILES_LIBCURL 1/WFDB_NETFILES_LIBCURL 0/" >../lib/wfdb.h
-	VIANF=" via libwww"
-	WITHNF=with
+	echo "using libcurl."
+	NETLIB=libcurl
     fi
-else
-    echo "found"
-    echo "The WFDB software will be compiled with NETFILES access"
-    echo "using libcurl."
-    echo "NETFILES=1" >../config.cache
-    echo "NETFILES_LIBCURL=1" >../config.cache
-    sed "s/LWC = libwww-config/LWC = :/" <site.def >site.tmp
-    sed "s/LCC = :/LCC = curl-config/" <site.tmp >site.def
-    if [ $LIBTYPE = "static" ]
+    rm -f which.t1 which.t2
+fi
+
+case $NETLIB in
+  libcurl) LC="\`curl-config --cflags\`"
+	   LL="\`curl-config --libs\`"
+	   NETFILES=1
+	   NETFILES_LIBCURL=1
+	   VIANF=" via libcurl"
+	   WITHNF=with
+	   ;;
+  libwww)  LC="\`libwww-config --cflags\`"
+	   LL="\`libwww-config --libs\`"
+	   NETFILES=1
+	   NETFILES_LIBCURL=0
+	   VIANF=" via libwww"
+	   WITHNF=with
+	   ;;
+  none)    LC=""
+	   LL=""
+	   NETFILES=0
+	   NETFILES_LIBCURL=0
+	   VIANF=""
+	   WITHNF=without
+	   ;;
+esac
+
+echo "NETFILES=$NETFILES" >../config.cache
+echo "NETFILES_LIBCURL=$NETFILES_LIBCURL" >>../config.cache
+sed "s/WFDB_NETFILES 1/WFDB_NETFILES $NETFILES/" < ../lib/wfdb.h0 | \
+    sed "s/WFDB_NETFILES_LIBCURL 1/WFDB_NETFILES_LIBCURL $NETFILES_LIBCURL/" \
+      >../lib/wfdb.h
+if [ $LIBTYPE = "static" -a $NETLIB != "none" ]
     then
-	sed "s/LDLIBCURL = #/LDLIBCURL =/" <site.def >site.tmp
-	mv site.tmp site.def
-    fi
-    sed "s/LWC = libwww-config/LWC = :/" <site-slib.def >site.tmp
-    sed "s/LCC = :/LCC = curl-config/" <site.tmp >site-slib.def
-    rm site.tmp
-    sed "s/WFDB_NETFILES 0/WFDB_NETFILES 1/" <../lib/wfdb.h0 | \
-	sed "s/WFDB_NETFILES_LIBCURL 0/WFDB_NETFILES_LIBCURL 1/" >../lib/wfdb.h
-    VIANF=" via libcurl"
-    WITHNF=with
+    LL = "$LL $LL $LL"
 fi
+sed "s/LC =/LC = $LC/" <site-slib.def | sed "s/LL =/LL = $LL/" >site.tmp
+mv site.tmp site-slib.def
+sed "s/LC =/LC = $LC/" <site.def | sed "s/LL =/LL = $LL/" >site.tmp
+mv site.tmp site.def
+
 
 cd ..
 echo
 echo "Creating Makefile in lib ..."
 if [ -s conf/site-slib.def ]
-then
+    then
     cat lib/Makefile.top conf/site-slib.def lib/Makefile.tpl >lib/Makefile
 else
     cat lib/Makefile.top conf/site.def lib/Makefile.tpl >lib/Makefile
 fi
 for D in app checkpkg convert data doc doc/wag-src doc/wpg-src doc/wug-src \
          examples fortran psd wave waverc .
-do
-   if [ -s $D/Makefile.top ]
-   then
-       echo "Creating Makefile in $D ..."
-       cat $D/Makefile.top conf/site.def $D/Makefile.tpl >$D/Makefile
-   fi
+  do
+  if [ -s $D/Makefile.top ]
+      then
+      echo "Creating Makefile in $D ..."
+      cat $D/Makefile.top conf/site.def $D/Makefile.tpl >$D/Makefile
+  fi
 done
 
-rm conf/site.def conf/site-slib.def
-
-echo
-echo "Adding $DIR/database to the default WFDB path ..."
-sed "s+DBDIR+$DIR/database+" <lib/wfdblib.h0 >lib/wfdblib.h
-
+echo rm conf/site.def conf/site-slib.def
 
 if [ "$OS" = "mingw" ]
-then
-    cp -p wave/nomake wave/Makefile
-    cp -p wave/nomake waverc/Makefile
-    echo "WAVE=0" >>config.cache
-    WAVECOMP="WAVE will not be compiled."
-else
-echo
-conf/prompt "Looking for the XView libraries ..."
-TEXTEDIT=`which textedit 2>&1`
-if [ "x$TEXTEDIT" = "x" ]
-then
-    TEXTEDIT="no textedit"
-fi
-if [ -d /usr/openwin ]
-then
-    WAVE=1;
-elif [ -d /usr/local/openwin ]
-then
-    WAVE=1;
-    sed "s+/usr/openwin+/usr/local/openwin+" <wave/Makefile >tmp.$$
-    mv tmp.$$ wave/Makefile
-elif [ -d /opt/openwin ]
-then
-    WAVE=1;
-    sed "s+/usr/openwin+/opt/openwin+" <wave/Makefile >tmp.$$
-    mv tmp.$$ wave/Makefile
-elif ( echo $TEXTEDIT | grep "no \|not " >/dev/null )
-then
-    WAVE=0;
-else
-    WAVE=1;
-    TEDIR=`dirname $TEXTEDIT`;
-    OWHOME=`dirname $TEDIR`;
-    sed "s+/usr/openwin+$OWHOME+" <wave/Makefile >tmp.$$
-    mv tmp.$$ wave/Makefile
-fi
-if [ $WAVE = 0 ]
-then
-    echo "not found"
-    echo "WAVE will not be compiled, because the XView libraries do not"
-    echo "appear to be installed on this system."
-    echo "To compile WAVE, install XView, add the directory containing the"
-    echo "XView textedit application to your PATH, and run ./configure again."
+    then
     cp -p wave/nomake wave/Makefile
     cp -p wave/nomake waverc/Makefile
     echo "WAVE=0" >>config.cache
     WAVECOMP="WAVE will not be compiled."
 else
-    echo "found"
-    WAVECOMP="WAVE will be compiled and installed in '$DIR/bin'."
-    echo "WAVE=1" >>config.cache
-fi
-
+    echo
+    conf/prompt "Looking for the XView libraries ..."
+    TEXTEDIT=`which textedit 2>&1`
+    if [ "x$TEXTEDIT" = "x" ]
+	then
+	TEXTEDIT="no textedit"
+    fi
+    if [ -d /usr/openwin ]
+	then
+	WAVE=1;
+    elif [ -d /usr/local/openwin ]
+	then
+	WAVE=1;
+	sed "s+/usr/openwin+/usr/local/openwin+" <wave/Makefile >tmp.$$
+	mv tmp.$$ wave/Makefile
+    elif [ -d /opt/openwin ]
+	then
+	WAVE=1;
+	sed "s+/usr/openwin+/opt/openwin+" <wave/Makefile >tmp.$$
+	mv tmp.$$ wave/Makefile
+    elif ( echo $TEXTEDIT | grep "no \|not " >textedit.t1 )
+	then
+	WAVE=0;
+    else
+	WAVE=1;
+	TEDIR=`dirname $TEXTEDIT`;
+	OWHOME=`dirname $TEDIR`;
+	sed "s+/usr/openwin+$OWHOME+" <wave/Makefile >tmp.$$
+	mv tmp.$$ wave/Makefile
+    fi
+    rm -f textedit.t1
+    if [ $WAVE = 0 ]
+	then
+	echo "not found"
+	echo "WAVE will not be compiled, because the XView libraries do not"
+	echo "appear to be installed on this system."
+	echo "To compile WAVE, install XView, add the directory containing the"
+	echo "XView textedit application to your PATH, and run ./configure again."
+	cp -p wave/nomake wave/Makefile
+	cp -p wave/nomake waverc/Makefile
+	echo "WAVE=0" >>config.cache
+	WAVECOMP="WAVE will not be compiled."
+    else
+	echo "found"
+	WAVECOMP="WAVE will be compiled and installed in '$DIR/bin'."
+	echo "WAVE=1" >>config.cache
+    fi
 fi
 
 # Clean up old *.o files in lib, to avoid possibly using binaries intended
@@ -451,39 +475,51 @@
 rm -f lib/*.o
 
 if [ $DIR != "/usr" -a  $LIBTYPE = dynamic ]
-then
-    echo
-    echo "IMPORTANT:  You have chosen to build a dynamic (shared) WFDB"
-    echo "library in a directory, $DIR/lib, that is not normally"
-    echo "searched for such libraries.  In order to use the applications"
-    echo "that will be compiled with this library, it may be necessary to"
-    echo "add this directory to your LD_LIBRARY_PATH.  If your shell is csh"
-    echo "or a variant, do this by typing:"
-    case "x$LD_LIBRARY_PATH" in
-      x) echo "  setenv LD_LIBRARY_PATH $DIR/lib"
-         echo "Otherwise, do this by typing:"
-         echo "  LD_LIBRARY_PATH=$DIR/lib"
-         echo "  export LD_LIBRARY_PATH" ;;
-      *) echo "  setenv LD_LIBRARY_PATH \${LD_LIBRARY_PATH}:$DIR/lib"
-         echo "Otherwise, do this by typing:"
-         echo "  LD_LIBRARY_PATH=\${LD_LIBRARY_PATH}:$DIR/lib"
-         echo "  export LD_LIBRARY_PATH" ;;
-    esac
+    then
+    cat <<EOF
+
+IMPORTANT: You have chosen to build a dynamic (shared) WFDB library in
+a directory, $DIR/$LIB, that is not normally searched for such
+libraries.  In order to use the applications that will be compiled
+with this library, it may be necessary to add this directory to your
+LD_LIBRARY_PATH.  If your shell is csh or a variant, do this by
+typing:
+EOF
+    if [ "x$LD_LIBRARY_PATH" = x ]
+	then
+	echo "  setenv LD_LIBRARY_PATH $DIR/$LIB"
+	echo "Otherwise, do this by typing:"
+	echo "  LD_LIBRARY_PATH=$DIR/$LIB"
+	echo "  export LD_LIBRARY_PATH"
+    else
+	echo "  setenv LD_LIBRARY_PATH \${LD_LIBRARY_PATH}:$DIR/$LIB"
+	echo "Otherwise, do this by typing:"
+	echo "  LD_LIBRARY_PATH=\${LD_LIBRARY_PATH}:$DIR/$LIB"
+	echo "  export LD_LIBRARY_PATH"
+    fi
 fi
 
 if [ $OS = generic ]
-then
-    echo
-    echo "No specific configuration information is available for your"
-    echo "operating system.  Please try compiling using the generic Makefiles"
-    echo "that have been generated by this configuration utility.  If there"
-    echo "are problems, it may be possible to solve them by customizing"
-    echo "conf/generic.def (and conf/generic-slib.def if you are attempting"
-    echo "to compile a shared WFDB library).  Run ./configure again after"
-    echo "making any necessary changes to these files.  Please send reports"
-    echo "of success or failure, together with the output of the command"
-    echo "'uname -a', and copies of any files you have changed, to:"
-    echo "        george@mit.edu"
+    then
+    cat <<EOF
+
+No specific configuration information is available for your operating
+system.  Please try compiling using the generic Makefiles that have
+been generated by this configuration utility.  If there are problems,
+it may be possible to solve them by customizing conf/generic.def (and
+conf/generic-slib.def if you are attempting to compile a shared WFDB
+library).  Run ./configure again after making any necessary changes to
+these files.  Please send reports of success or failure, together with
+the output of the command 'uname -a', and copies of any files you have
+changed, to:
+             george@mit.edu
+EOF
+
+fi
+
+if [ "x$MFLAGS" != x ]
+    then
+    CC="$CC $MFLAGS"
 fi
 
 cat <<EOF
@@ -492,7 +528,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 '$DIR/$LIB'.
 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'.
@@ -502,6 +538,8 @@
  will be included in the default WFDB path.
 
 WFDB software configuration is complete.
-Now run 'make', followed by 'make install'.
+Now run 'make' to compile and test, followed by 'make install' to recompile
+and install the software, man pages, and example data.  Finally, run
+'make check' to verify that the installation is complete and successful.
 
 EOF
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/doc/wag-src/fixag.sed wfdb-10.3.17/doc/wag-src/fixag.sed
--- wfdb-10.3.16/doc/wag-src/fixag.sed	2005-06-12 01:09:57.000000000 -0400
+++ wfdb-10.3.17/doc/wag-src/fixag.sed	2005-08-20 22:31:53.000000000 -0400
@@ -43,17 +43,50 @@
 s+<A HREF="xmodmap-1.htm">xmodmap</B>(1)</A>+xmodmap</B>(1)+g
 s+<A HREF=" xnews-1.htm">xnews</B>(1)</A>+xnews</B>(1)+g
 s+<A HREF=" xview-1.htm">xview</B>(1)</A>+xview</B>(1)+g
-s+<I>strtim+<I><A HREF="../wpg/strtim.htm">strtim</A>+
+s+<a href='    bc-1.htm'><b>bc</b>(1)</a>+<b>bc</b>(1)+g
+s+<a href='    cc-1.htm'><b>cc</b>(1)</a>+<b>cc</b>(1)+g
+s+<a href='     F-n.htm'><b>F(n)</a>+<b>F(n)+g
+s+<a href='     F-n.htm'><b>F(n)</b></a>+<b>F(n)</b>+g
+s+<a href='     F-n.htm'><b>F(n)</I></a>+<b>F(n)</I>+g
+s+<a href=' fseek-3.htm'><b>fseek</b>(3)</a>+<b>fseek</b>(3)+g
+s+<a href='   gcc-1.htm'><b>gcc</b>(1)</a>+<b>gcc</b>(1)+g
+s+<a href='gnuplot-1.htm'><b>gnuplot</b>(1)</a>+<b>gnuplot</b>(1)+g
+s+<a href='iconedit-1.htm'><b>iconedit</b>(1)</a>+<b>iconedit</b>(1)+g
+s+<a href='    ld-1.htm'><b>ld</b>(1)</a>+<b>ld</b>(1)+g
+s+<a href='osigfopen-n.htm'><b>osigfopen(nsig)</a>+<b>osigfopen(nsig)+g
+s+<a href='     N-1.htm'><b>N (1)</a>+<b>N (1)+g
+s+<a href='     N-2.htm'><b>N (2)</a>+<b>N (2)+g
+s+<a href='     N-3.htm'><b>N (3)</a>+<b>N (3)+g
+s+<a href='     N-4.htm'><b>N (4)</a>+<b>N (4)+g
+s+<a href='     N-8.htm'><b>N (8)</a>+<b>N (8)+g
+s+<a href='osigfopen-nsig.htm'><b>osigfopen(nsig)</a>+<b>osigfopen(nsig)+g
+s+<a href='openwin-1.htm'><b>openwin</b>(1)</a>+<b>openwin</b>(1)+g
+s+<a href='  plot-1.htm'><b>plot</b>(1)</a>+<b>plot</b>(1)+g
+s+<a href='  plot-3.htm'><b>plot</b>(3)</a>+<b>plot</b>(3)+g
+s+<a href='printf-3.htm'><b>printf(3)</b></a>+<b>printf(3)</b>+g
+s+<a href=' scanf-3.htm'><b>scanf</b>(3)</a>+<b>scanf</b>(3)+g
+s+<a href='    sh-1.htm'><b>sh</b>(1)</a>+<b>sh</b>(1)+g
+s+<a href='     X-1.htm'><b>X</b>(1)</a>+<b>X</b>(1)+g
+s+<a href='xdpyinfo-1.htm'><b>xdpyinfo</b>(1)</a>+<b>xdpyinfo</b>(1)+g
+s+<a href=' xhost-1.htm'><b>xhost</b>(1)</a>+<b>xhost</b>(1)+g
+s+<a href='xlsfonts-1.htm'><b>xlsfonts</b>(1)</a>+<b>xlsfonts</b>(1)+g
+s+<a href='xmodmap-1.htm'><b>xmodmap</b>(1)</a>+<b>xmodmap</b>(1)+g
+s+<a href=' xnews-1.htm'><b>xnews</b>(1)</a>+<b>xnews</b>(1)+g
+s+<a href=' xview-1.htm'><b>xview</b>(1)</a>+<b>xview</b>(1)+g
+s+>strtim+><A HREF="../wpg/strtim.htm">strtim</A>+
 s+BGCOLOR="[^"]*"+BGCOLOR="#FFFFFF"+
+s+bgcolor='[^']*'+bgcolor='#ffffff'+
 s+(http://www.physionet.org/physiobank/database)+<A HREF="http://www.physionet.org/physiobank/database">(http://www.physionet.org/physiobank/database)</A>+
 s+(http://www.aami.org/)+<A HREF="http://www.aami.org/" target="other">(http://www.aami.org/)</A>+
 s+"http://www.gnuplot.info/"+"http://www.gnuplot.info/" target="other"+
 s+http://www.mstarlabs.com/+<A HREF="http://www.mstarlabs.com/" target="other">http://www.mstarlabs.com/</A>+
-s+<A HREF="http://www.hsr.nl/edf/"+<a href="http://www.hsr.nl/edf/" target="other"+
-s+<I>Evaluating ECG Analyzers</I>+<a href="eval.htm"><I>Evaluating ECG Analyzers</I></a>+
-s+<I>WFDB Programmer's Guide</I>+<a href="../wpg/wpg.htm"><I>WFDB Programmer's Guide</I></a>+
-s+<I>WFDB Applications Guide</I>+<a href="wag.htm"><I>WFDB Applications Guide</I></a>+
-s+<I>WAVE User's Guide</I>+<a href="../wug/wug.htm"><I>WAVE User's Guide</I></a>+
-s+<I>plt Tutorial and Cookbook</I>+<a href="../plt/html/"><I>plt Tutorial and Cookbook</I></a>+
+s+"http://www.hsr.nl/edf/"+"http://www.hsr.nl/edf/" target="other"+
+s+>Evaluating ECG Analyzers<+><a href="eval.htm">Evaluating ECG Analyzers</a><+
+s+>WFDB Programmer's Guide<+><a href="../wpg/wpg.htm">WFDB Programmer's Guide</a><+
+s+>WFDB Applications Guide<+><a href="wag.htm">WFDB Applications Guide</a><+
+s+>WAVE User's Guide<+><a href="../wug/wug.htm">WAVE User's Guide</a><+
+s+>plt Tutorial and Cookbook<+><a href="../plt/html/">plt Tutorial and Cookbook</a><+
 s+<A HREF="#toc">Table of Contents</A>+<table width=100%><tr><td align=left><b>Next:</b> NEXTPAGE <b>Up:</b> <a href="wag.htm">WFDB Applications Guide</a> <b>Previous:</b> PREVPAGE</td><td align=right><a href="#toc">On This Page</a></td></tr></table>+
+s+<a href='#toc'>Table of Contents</a>+<table width=100%><tr><td align=left><b>Next:</b> NEXTPAGE <b>Up:</b> <a href="wag.htm">WFDB Applications Guide</a> <b>Previous:</b> PREVPAGE</td><td align=right><a href="#toc">On This Page</a></td></tr></table>+
 s+</BODY>+<p><b>Up:</b> <a href="wag.htm">WFDB Applications Guide</a><hr><font size=-1><p>Please e-mail your comments and suggestions to <a href="mailto:webmaster@physionet.org?subject=PAGENAME"><tt>webmaster@physionet.org</tt></a>, or post them to:<p><address>PhysioNet<br>MIT Room E25-505A<br>77 Massachusetts Avenue<br>Cambridge, MA 02139 USA<br></address></i><p>Updated LONGDATE</font></BODY>+
+s+</body>+<p><b>Up:</b> <a href="wag.htm">WFDB Applications Guide</a><hr><font size=-1><p>Please e-mail your comments and suggestions to <a href="mailto:webmaster@physionet.org?subject=PAGENAME"><tt>webmaster@physionet.org</tt></a>, or post them to:<p><address>PhysioNet<br>MIT Room E25-505A<br>77 Massachusetts Avenue<br>Cambridge, MA 02139 USA<br></address></i><p>Updated LONGDATE</font></body>+
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/doc/wag-src/fixag.sh wfdb-10.3.17/doc/wag-src/fixag.sh
--- wfdb-10.3.16/doc/wag-src/fixag.sh	2003-04-07 14:44:35.000000000 -0400
+++ wfdb-10.3.17/doc/wag-src/fixag.sh	2005-08-20 22:14:14.000000000 -0400
@@ -40,19 +40,23 @@
 for i in *-1.htm *-3.htm *-5.htm *-7.htm
 do
   NEXTT=`grep "<TITLE>" $i | sed "s+<TITLE>++" | sed "s+</TITLE>++"`
+  if [ "x$NEXTT" = "x" ]
+  then
+    NEXTT=`grep "<title>" $i | sed "s+<title>++" | sed "s+</title>++"`
+  fi
   NEXTU=$i
   if [ "$THISU" = "faq.htm" ]
   then
     sed "s+NEXTPAGE+<a href=$NEXTU>$NEXTT</a>+" <$THISU >tmp.$$
   else
     sed "s+NEXTPAGE+<a href=$NEXTU>$NEXTT</a>+" <$THISU |
-     sed "s+<I>record+<i><a href=\"intro.htm#record\">record</a>+g" |
-     sed "s+<I>annotator+<i><a href=\"intro.htm#annotator\">annotator</a>+g" |
+     sed "s+>record+><a href=\"intro.htm#record\">record</a>+g" |
+     sed "s+>annotator+><a href=\"intro.htm#annotator\">annotator</a>+g" |
      sed "s+[a-zA-Z]*-annotator+<a href=\"intro.htm#annotator\">&</a>+g" |
-     sed "s+<I>\\(ann[1-3]\\)\\([ <]\\)+<I><a href=\"intro.htm#annotator\">\\1</a>\\2+g" |
-     sed "s+<I>time+<i><a href=\"intro.htm#time\">time</a>+g" |
-     sed "s+<I>signal-list+<i><a href=\"intro.htm#signal-list\">signal-list</a>+g" |
-     sed "s+<I>signal+<i><a href=\"intro.htm#signal\">signal</a>+g" |
+     sed "s+>\\(ann[1-3]\\)\\([ <]\\)+><a href=\"intro.htm#annotator\">\\1</a>\\2+g" |
+     sed "s+>time+><a href=\"intro.htm#time\">time</a>+g" |
+     sed "s+>signal-list+><a href=\"intro.htm#signal-list\">signal-list</a>+g" |
+     sed "s+>signal+><a href=\"intro.htm#signal\">signal</a>+g" |
      sed "s+PREVPAGE+<a href=$PREVU>$PREVT</a>+" >tmp.$$
   fi
   mv tmp.$$ $THISU
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/doc/wag-src/psfd.1 wfdb-10.3.17/doc/wag-src/psfd.1
--- wfdb-10.3.16/doc/wag-src/psfd.1	2002-08-06 14:57:06.000000000 -0400
+++ wfdb-10.3.17/doc/wag-src/psfd.1	2005-07-26 15:04:37.000000000 -0400
@@ -1,4 +1,4 @@
-.TH PSFD 1 "6 August 2002" "WFDB 10.2.7" "WFDB Applications Guide"
+.TH PSFD 1 "26 July 2005" "WFDB 10.3.5" "WFDB Applications Guide"
 .SH NAME
 psfd \- produce annotated `full-disclosure' plots on a PostScript device
 .SH SYNOPSIS
@@ -43,7 +43,24 @@
 notice, use `\fB-c ""\fR'.
 .TP
 \fB-C\fR
-Print counter values after time stamps in the left margin.
+Produce charts in color (default: black and white).
+.TP
+\fB-Ca\fR \fIr g b\fR
+Draw annotations (if enabled) in the specified color. The color is
+specified using three numerical arguments (with values between 0 and 1
+inclusive) that indicate the amounts of red, green, and blue respectively.
+Examples: \fB-Ca 0.5 0.5 1.0\fR produces light blue (the default obtained
+using \fB-C\fR only); \fB-Ca 0 0.5 0\fR produces a deep green color.
+.TP
+\fB-Cg\fR \fIr g b\fR
+Draw the grid (if enabled) in the specified color. Default: red (1 0 0).
+.TP
+\fB-Cl\fR \fIr g b\fR
+Draw labels and other non-annotation text in the specified color.  Default:
+black (0 0 0).
+.TP
+\fB-Cs\fR \fIr g b\fR
+Draw signals in the specified color.  Default: deep blue (0 0 0.5).
 .TP
 \fB-d\fR \fIn\fR
 Set up for using a printer with a resolution of \fIn\fR dots per inch (default:
@@ -105,6 +122,9 @@
 Use \fIn\fR as the number of the first page (default: 1).  Use `\fB-n 0\fR'
 (or any negative value for \fIn\fR) to suppress page numbering.
 .TP
+\fB-N\fR
+Print counter values after time stamps in the left margin.
+.TP
 \fB-P\fR \fIpagesize\fR
 Specify the size of the output pages to be printed.  Legal values for
 \fIpagesize\fR are: `letter' (8.5" x 11", 216 mm x 279 mm; imageable area
@@ -167,6 +187,11 @@
 \fB-V\fR
 Verbose mode (echo each command as it is read from the script file).
 .TP
+\fB-w \fIn\fR
+Set the line width for signals, grid lines, and marker bars to \fIn\fR mm.
+Default: 0 (the narrowest possible width;  note that some devices may not
+render zero-width lines correctly).
+.TP
 \fB-x\fR
 Extend the last strip of each record up to 10% if necessary to avoid
 printing a short strip at the end.  (This option may be used to obtain
@@ -200,7 +225,7 @@
 .SH ENVIRONMENT
 .PP
 .PP
-The environment variable \fBPSCHARTPRO\fR can be used to name an
+The environment variable \fBPSFDPRO\fR can be used to name an
 alternate prolog file (see below) for custom formats.  The environment
 variable \fBTRANSCRIPTBUG\fR may be set (to any value) to generate
 `unstructured' PostScript by default (see the \fB-u\fR option above).
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/doc/wpg-src/wpg0.tex wfdb-10.3.17/doc/wpg-src/wpg0.tex
--- wfdb-10.3.16/doc/wpg-src/wpg0.tex	2005-06-13 03:17:13.000000000 -0400
+++ wfdb-10.3.17/doc/wpg-src/wpg0.tex	2005-08-20 15:44:31.000000000 -0400
@@ -489,6 +489,34 @@
 WFDB Software Package distribution, for information on any more recent
 changes that may not be described here.
 
+@unnumberedsubsec Changes in version 10.3.17
+
+This version is the first to support reading variable-layout records
+(multi-segment records in which the number, arrangement, gains, and baselines
+of the signals may vary from one segment to the next; @pxref{Multi-Segment
+Records}).
+
+Rounding errors in the WFDB library's @code{mstimstr} function have been
+reduced.  Previous versions did not always round appropriately when the
+sampling frequency was much less than 1 Hz.
+
+The maximum length for a record name (@code{WFDB_MAXRNL}, defined in
+@file{wfdb.h}) has been increased from 11 to 20.
+
+A new constant, @code{WFDB_INVALID_SAMPLE}, is now defined in @file{wfdb.h}.
+It is used to identify padding inserted to fill in for missing data.  When
+writing in any format that uses fewer than 16 bits per sample, @code{putvec}
+maps @code{WFDB_INVALID_SAMPLE} to the lowest (most negative) value expressible
+in that format; when reading a signal file in such a format, @code{getframe}
+performs the inverse mapping, so that missing data can be identified regardless
+of the data format.
+
+A side effect of this change is that (for example) any samples that had the
+most negative value (for example, -2048 in a format 212 signal file) are now
+flagged as invalid.  To treat such samples as invalid is reasonable, however,
+since these occur only when the input level falls below the working range of
+the analog-to-digital converter.
+
 @unnumberedsubsec Changes in version 10.3.16
 
 Benjamin Moody has added an interface between the WFDB library and
@@ -5402,34 +5430,72 @@
 @cindex multi-segment records
 @cindex concatenating records
 @cindex nested records
+@cindex layout segment
+@cindex fixed layout
+@cindex variable layout
 
 A multi-segment record consists of two or more concatenated segments.
 Each segment is an ordinary WFDB record, with its own header file and
-signal file(s).  In any given multi-segment record, all signals must
-appear in the same order within each segment (signals may not be
-omitted), and the sampling frequency of any given signal must be the
-same in each segment.  Segments of multi-segment records must be
-ordinary records (it is not permitted to nest one multi-segment record
-within another, for example), and the length of each segment must be
-specified (the WFDB library does not impose this requirement on ordinary
-records that are not part of a multi-segment record).  There are no
-other restrictions on segments; specifically, it is permitted to mix
-segments with different storage formats, and for any segment to appear
-more than once.  A special header file (created either manually or by
-using @code{setmsheader}) specifies the record name for each segment in
-a multi-segment record.  Once this special header exists, the
-multi-segment record can be read by any WFDB application.  Note that only
-the signal files of the segments are ``linked'' by the multi-segment
-record's header; annotation files associated with the individual
-segments are @emph{not} readable as part of the multi-segment record
-(although an annotation file associated directly with the multi-segment
-record can be created and read just as for an ordinary record).  From
-the point of view of a WFDB application, reading a multi-segment record is
+signal file(s).  There are two types of multi-segment records:
+@dfn{fixed-layout} records, in which all signals must appear in the
+same order within each segment (signals may not be omitted, added, or
+swapped), and the gain and baseline of any given signal may not change
+from segment to segment; and @dfn{variable-layout} records, which are
+not bound by these constraints.  If the first segment of a
+multi-segment record has a length of zero samples, that segment is a
+@dfn{layout segment}, and the record is a variable-layout record.
+Version 9.1 of the WFDB library is the first to support reading and
+writing fixed-layout multi-segment records, and version 10.3.17 is the
+first to support reading variable-layout multi-segment records.
+
+In both types of multi-segment records, the sampling frequency of any
+given signal must be the same in each segment.  Segments of
+multi-segment records must be ordinary records (it is not permitted to
+nest one multi-segment record within another, for example), and the
+length of each segment must be specified (the WFDB library does not
+impose this requirement on ordinary records that are not part of a
+multi-segment record).  There are no other restrictions on segments;
+specifically, it is permitted to mix segments with different storage
+formats, and for any segment to appear more than once.  A special
+header file (created either manually or by using @code{setmsheader})
+specifies the record name for each segment in a multi-segment record.
+Once this special header exists, the multi-segment record can be read
+by any WFDB application.  Note that only the signal files of the
+segments are ``linked'' by the multi-segment record's header;
+annotation files associated with the individual segments are
+@emph{not} readable as part of the multi-segment record (although an
+annotation file associated directly with the multi-segment record can
+be created and read just as for an ordinary record).  From the point
+of view of a WFDB application, reading a multi-segment record is
 exactly like reading an ordinary record; specifically,
 @code{isigsettime} works as expected, permitting jumps forward and
-backward between as well as within segments.  Version 9.1 of the WFDB
-library is the first to support reading and writing multi-segment
-records.
+backward between as well as within segments.
+
+Unlike ordinary segments, no signal file is associated with a layout segment;
+only the header file is needed.  In the header file of a layout segment, all of
+the signals present in any of the other segments of the record are listed, in
+the desired order and with the desired gains and baselines.  When the WFDB
+library reads the record, @code{getframe} assembles the frame, scaling and
+shifting each component as needed.  If any signals are missing during a
+segment, the resulting gaps are filled with the sample value
+@code{WFDB_INVALID_SAMPLE}.  In this way, WFDB applications do not need to be
+aware of signal changes; rather, they may read variable-layout records as if
+they were ordinary (fixed-layout) records.
+
+WFDB applications generally assume fixed-layout records, i.e., that
+the number and types of available signals (and their sampling
+frequencies, gains, and baselines) are constant throughout the record.
+These conditions do not always apply in clinical settings, in which
+signals may be added, removed, or recalibrated to meet clinical needs,
+resulting in variable-layout recordings.  A variable-layout recording
+may be divided into segments such that each segment is a fixed-layout
+WFDB record.  The segments can then be reassembled into a
+multi-segment WFDB record.  Version 10.3.17, and later versions, of
+the WFDB library contain code in @code{signal.c} to create a virtual
+fixed-layout record on the fly when reading a variable-layout record.
+This feature can also be used to transform ordinary records on the fly, if
+it is desirable to rearrange, delete, duplicate, scale, or shift
+signals.
 
 @node     Multiple Record Access, Special Files, Multi-Segment Records, Database Files
 @section Simultaneous Access to Multiple Records
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/doc/wug-src/wave/scripts/wugfigures wfdb-10.3.17/doc/wug-src/wave/scripts/wugfigures
--- wfdb-10.3.16/doc/wug-src/wave/scripts/wugfigures	2002-08-07 15:26:46.000000000 -0400
+++ wfdb-10.3.17/doc/wug-src/wave/scripts/wugfigures	2005-08-08 07:32:08.000000000 -0400
@@ -1,14 +1,27 @@
 #! /bin/sh
 # file: wugfigures		G. Moody	20 December 2001
-#				Last revised:	 7 August 2002
+#				Last revised:	 8 August 2005
 #
 # Get or remove a set of WAVE User's Guide figures in the wug-src directory.
 # The wug-src directory must be the current directory when this script is run.
 
-# Arrgh!!! The latest version of pnmtops, standard with Redhat Linux 7.3,
-# produces incorrect output unless the option -nosetpage is used ... but
-# the previous version produces no output if -nosetpage is used.  So, let's
-# see which version we've got:
+# Arrgh!!! Current versions of pnmtops, standard with Redhat Linux 7.3 and
+# later, produce incorrect output unless the option -nosetpage is used ... but
+# older versions produces no output if -nosetpage is used.  So, let's see which
+# version we've got:
+
+if [ x$1 = x-clean ]
+    then
+    for i in wave/ps/*.ps
+      do
+      rm -f `basename $i .ps`.p*
+    done
+    for i in wave/ppm/*.ppm.gz
+      do
+      rm -f `basename $i .ppm.gz`.p*
+    done
+    exit
+fi
 
 gzip -d <wave/ppm/wave-icon.ppm.gz | pnmdepth 255 | \
   pnmtops -nosetpage -noturn -scale .5 >tmp$$.ps 2>/dev/null
@@ -22,14 +35,6 @@
 fi
 
 case $OPT in
-  -clean) for i in wave/ps/*.ps
-	  do
-	     rm -f `basename $i .ps`.p*
-	  done
-          for i in wave/ppm/*.ppm.gz
-	  do
-	     rm -f `basename $i .ppm.gz`.p*
-	  done ;;
   -color) for i in wave/ps/*.ps
 	  do
 	     OUT=`basename $i`
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/lib/Makefile.tpl wfdb-10.3.17/lib/Makefile.tpl
--- wfdb-10.3.16/lib/Makefile.tpl	2004-12-13 23:45:54.000000000 -0500
+++ wfdb-10.3.17/lib/Makefile.tpl	2005-08-08 07:23:41.000000000 -0400
@@ -1,5 +1,5 @@
 # file: Makefile.tpl		G. Moody	  24 May 2000
-#				Last revised:   28 November 2004
+#				Last revised:    8 August 2005
 # This section of the Makefile should not need to be changed.
 
 INCLUDES = $(INCDIR)/wfdb/wfdb.h $(INCDIR)/wfdb/ecgcodes.h \
@@ -12,7 +12,7 @@
 MFILES = Makefile Makefile.dos
 
 # `make' or `make all':  build the WFDB library and wfdb-config
-all:	$(OFILES) wfdb-config
+all:	setup $(OFILES) wfdb-config
 	$(BUILDLIB) $(OFILES) $(BUILDLIB_LDFLAGS)
 
 # `make install':  install the WFDB library and headers
@@ -31,8 +31,11 @@
 	$(MAKE) lib-post-uninstall
 	../uninstall.sh $(LIBDIR)
 
+setup:
+	sed "s+DBDIR+$(DBDIR)+" <wfdblib.h0 >wfdblib.h
+
 wfdb-config:	wfdb-config.c Makefile
-	$(CC) -DVERSION='"$(VERSION)"' -DCFLAGS='"-I$(INCDIR)"' \
+	$(CC) $(CFLAGS) -DVERSION='"$(VERSION)"' -DCFLAGS='"$(CFLAGS)"' \
 	  -DLDFLAGS='"$(LDFLAGS)"' -I$(INCDIR) -o $@ wfdb-config.c
 
 # `make compat':  install the includes needed for source compatibility with
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/lib/signal.c wfdb-10.3.17/lib/signal.c
--- wfdb-10.3.16/lib/signal.c	2004-11-14 11:02:32.000000000 -0500
+++ wfdb-10.3.17/lib/signal.c	2005-08-12 01:48:43.000000000 -0400
@@ -1,10 +1,10 @@
 /* file: signal.c	G. Moody	13 April 1989
-			Last revised:   14 November 2004	wfdblib 10.3.14
+			Last revised:   11 August 2005	wfdblib 10.3.17
 WFDB library functions for signals
 
 _______________________________________________________________________________
 wfdb: a library for reading and writing annotated waveforms (time series data)
-Copyright (C) 1989-2004 George B. Moody
+Copyright (C) 1989-2005 George B. Moody
 
 This library is free software; you can redistribute it and/or modify it under
 the terms of the GNU Library General Public License as published by the Free
@@ -33,6 +33,10 @@
  allocogroup	(sets max number of simultaneously open output signal groups)
  isfmt		(checks if argument is a legal signal format type)
  copysi		(deep-copies a WFDB_Siginfo structure)
+ sigmap_cleanup (deallocates memory used by sigmap)
+ make_vsd	(makes a virtual signal object)
+ sigmap_init	(manages the signal maps)
+ sigmap		(creates a virtual signal vector from a raw sample vector)
  readheader	(reads a header file)
  hsdfree	(deallocates memory used by readheader)
  isigclose	(closes input signals)
@@ -95,7 +99,7 @@
 
 These functions, also defined here, are intended only for the use of WFDB
 library functions defined elsewhere:
- wfdb_sampquit  (frees memory allocated by sample())
+ wfdb_sampquit  (frees memory allocated by sample() and sigmap_init())
  wfdb_sigclose 	(closes signals and resets variables)
  wfdb_osflush	(flushes output signals)
 
@@ -464,6 +468,215 @@
     return (1);
 }
 
+/* Code for handling variable-layout multi-segment records
+
+    The following code (together with minor changes elsewhere in this file)
+   was written to permit reading a record consisting of multiple segments
+   on-the-fly, even if the segments do not contain the same signals or the
+   same number of signals.  If the gain or baseline of any signal changes
+   from segment to segment, the code in this section adjusts for the changes
+   transparently, so that a WFDB application can assume that all signals
+   are always present in the same order, with constant gains and baselines
+   as specified in the .hea file for the first segment.  This .hea file
+   is in the same format as an ordinary .hea file, but if its length is
+   specified as zero samples, it is recognized as a "layout header".  In
+   this case, the signal file name is conventionally given as "~" (although
+   any name is acceptable), and the format is given as 0 (required).
+
+   The "layout header" contains a signal description line for each signal
+   of interest that appears anywhere in the record.  The gain and baseline
+   specified in the layout header are those that will apply to samples
+   throughout the record (sigmap, below, scales and shifts the raw samples
+   as needed).
+
+   If a gap occurs between the end of one segment and the beginning of the
+   next, a special "null" segment can be listed in the master .hea file,
+   like this:
+       ~ 4590
+   The segment name, "~", does not correspond to a real .hea file, but the
+   number that follows indicates the length of the gap in sample intervals.
+ */
+
+static int need_sigmap, maxvsig, nvsig, tspf;
+static struct isdata **vsd;
+static WFDB_Sample *ovec;
+
+static struct sigmapinfo {
+    char *desc;
+    double gain, scale, offset;
+    WFDB_Sample baseline;
+    int index;
+    int spf;
+} *smi;
+
+static void sigmap_cleanup()
+{
+    int i;
+
+    maxvsig = need_sigmap = nvsig = tspf = 0;
+    if (ovec) { free(ovec); ovec = NULL; }
+    if (smi) {
+	for (i = 0; i < tspf; i += smi[i].spf)
+	    if (smi[i].desc) free(smi[i].desc);
+	free(smi);
+	smi = NULL;
+    }
+
+    if (vsd) {
+	struct isdata *is;
+
+	while (nvsig)
+	    if (is = vsd[--nisig]) {
+		if (is->info.fname) (void)free(is->info.fname);
+		if (is->info.units) (void)free(is->info.units);
+		if (is->info.desc)  (void)free(is->info.desc);
+		(void)free(is);
+	    }
+    	(void)free(vsd);
+	vsd = NULL;
+    }
+}
+
+static int make_vsd()
+{
+    int i;
+
+    if (nvsig != nisig) {
+	wfdb_error("make_vsd: oops! nvsig = %d, nisig = %d\n", nvsig, nisig);
+	return (-1);
+    }
+
+    if (maxvsig < nvsig) {
+	unsigned m = maxvsig;
+	struct isdata **vsdnew = realloc(vsd, nvsig*sizeof(struct isdata *));
+
+	if (vsdnew == NULL) {
+	    wfdb_error("init: too many (%d) input signals\n", nvsig);
+	    return (-1);
+	}
+	vsd = vsdnew;
+	while (m < nvsig) {
+	    if ((vsd[m] = calloc(1, sizeof(struct isdata))) == NULL) {
+		wfdb_error("init: too many (%d) input signals\n", nvsig);
+		while (--m > maxvsig)
+		    free(isd[m]);
+		return (-1);
+	    }
+	    m++;
+	}
+	maxvsig = nvsig;
+    }
+
+    for (i = 0; i < nvsig; i++)
+	copysi(&vsd[i]->info, &isd[i]->info);
+
+    return (nvsig);
+}
+
+static int sigmap_init()
+{
+    int i, j, k, kmax, s;
+    struct sigmapinfo *ps;
+
+    /* is this the layout segment?  if so, set up output side of map */
+    if (in_msrec && ovec == NULL && isd[0]->info.nsamp == 0L) {
+	need_sigmap = 1;
+
+	/* The number of virtual signals is the number of signals defined
+	   in the layout segment. */
+	nvsig = nisig;
+	for (s = tspf = 0; s < nisig; s++)
+	    tspf += isd[s]->info.spf;
+	if ((smi = malloc(tspf * sizeof(struct sigmapinfo))) == NULL) {
+	    wfdb_error("sigmap_init: out of memory\n");
+	    return (-1);
+	}
+
+	for (i = s = 0; i < nisig; i++) {
+	    if (smi[s].desc = malloc(strlen(isd[i]->info.desc)+1))
+		strcpy(smi[s].desc, isd[i]->info.desc);
+	    else {
+		wfdb_error("sigmap_init: out of memory\n");
+		return (-1);
+	    }
+	    smi[s].gain = isd[i]->info.gain;
+	    smi[s].baseline = isd[i]->info.baseline;
+	    k = smi[s].spf = isd[i]->info.spf;
+	    for (j = 1; j < k; j++)
+		smi[s + j] = smi[s];
+	    s += k;	    
+	}
+
+	if ((ovec = malloc(tspf * sizeof(WFDB_Sample))) == NULL) {
+	    wfdb_error("sigmap_init: out of memory\n");
+	    return (-1);
+	}
+	return (make_vsd());
+    }
+
+    else if (need_sigmap) {	/* set up the input side of the map */
+	for (s = 0; s < tspf; s++) {
+	    smi[s].index = 0;
+	    smi[s].scale = 0.;
+	    smi[s].offset = WFDB_INVALID_SAMPLE;
+	}
+
+	if (isd[0]->info.fmt == 0 && nisig == 1)
+	    return (0);    /* the current segment is a null record */
+
+	for (i = j = 0; i < nisig; j += isd[i++]->info.spf)
+	    for (s = 0; s < tspf; s += smi[s].spf)
+		if (strcmp(smi[s].desc, isd[i]->info.desc) == 0) {
+		    if ((kmax = smi[s].spf) != isd[i]->info.spf) {
+			wfdb_error(
+		   "sigmap_init: unexpected spf for signal %d in segment %s\n",
+		                   i, segp->recname);
+			if (kmax > isd[i]->info.spf)
+			    kmax = isd[i]->info.spf;
+		    }
+		    for (k = 0; k < kmax; k++) {
+			ps = &smi[s + k];
+			ps->index = j + k;
+			ps->scale = ps->gain / isd[i]->info.gain;
+			if (ps->scale < 1.0)
+			    wfdb_error(
+	       "sigmap_init: loss of precision in signal %d in segment %s\n",
+				       i, segp->recname);
+			ps->offset = ps->baseline -
+			             ps->scale * isd[i]->info.baseline;
+		    }
+		    break;
+		}
+    }
+
+    else {	/* normal record, or multisegment record without a dummy
+		   header */
+	nvsig = nisig;
+	return (make_vsd());
+    }
+
+    return (0);
+}
+
+static void sigmap(WFDB_Sample *vector)
+{
+    int i;
+    double v;
+
+    for (i = 0; i < tspf; i++)
+	ovec[i] = vector[i];
+
+    for (i = 0; i < tspf; i++) {
+	vector[i] = v = ovec[smi[i].index] * smi[i].scale + smi[i].offset;
+#if defined(WFDB_OVERFLOW_CHECK)
+	if (((v > 0.0 && v - ovec[i]) > 1.0) || ((v - ovec[i]) < -1.0))
+	    wfdb_error("sigmap: overflow detected\n");
+#endif
+    }
+}
+
+/* end of code for handling variable-layout records */
+
 static int readheader(record)
 char *record;
 {
@@ -477,21 +690,58 @@
     /* If another input header file was opened, close it. */
     if (hheader) (void)wfdb_fclose(hheader);
 
+    if (strcmp(record, "~") == 0) {
+	if (in_msrec && vsd) {
+	    char *p;
+
+	    hsd = calloc(1, sizeof(struct hsdata *));
+	    hsd[0] = calloc(1, sizeof(struct hsdata));
+	    p = calloc(2, sizeof(char)); *p = '~';
+	    hsd[0]->info.desc = p;
+	    hsd[0]->info.spf = 1;
+	    hsd[0]->info.fmt = 0;
+	    hsd[0]->info.nsamp = nsamples = segp->nsamp;
+	    return (1);	       
+	}
+	return (0);
+    }
+
     /* Try to open the header file. */
     if ((hheader = wfdb_open("hea", record, WFDB_READ)) == NULL) {
 	wfdb_error("init: can't open header for record %s\n", record);
 	return (-1);
     }
 
+    /* Read the first line and check for a magic string. */
+    if (wfdb_fgets(linebuf, 256, hheader) == NULL) {
+        wfdb_error("init: record %s header is empty\n", record);
+	    return (-2);
+    }
+    if (strncmp("#wfdb", linebuf, 5) == 0) { /* found the magic string */
+	int i, major, minor = 0, release = 0;
+
+	i = sscanf(linebuf+5, "%d.%d.%d", &major, &minor, &release);
+	if ((i > 0 && major > WFDB_MAJOR) ||
+	    (i > 1 && minor > WFDB_MINOR) ||
+	    (i > 2 && release > WFDB_RELEASE)) {
+	    wfdb_error("init: reading record %s requires WFDB library "
+		       "version %d.%d.%d or later\n"
+"  (the most recent version is always available from http://physionet.org)\n",
+		       record, major, minor, release);
+	    return (-1);
+	}
+    }
+
     /* Get the first token (the record name) from the first non-empty,
        non-comment line. */
-    do {
+    while ((p = strtok(linebuf, sep)) == NULL || *p == '#') {
 	if (wfdb_fgets(linebuf, 256, hheader) == NULL) {
 	    wfdb_error("init: can't find record name in record %s header\n",
 		     record);
 	    return (-2);
 	}
-    } while ((p = strtok(linebuf, sep)) == NULL || *p == '#');
+    }
+
     for (q = p+1; *q && *q != '/'; q++)
 	;
     if (*q == '/') {
@@ -647,7 +897,7 @@
 	    }
 	    (void)strcpy(segp->recname, p);
 	    if ((p = strtok((char *)NULL, sep)) == NULL ||
-		(segp->nsamp = (WFDB_Time)atol(p)) <= 0L) {
+		(segp->nsamp = (WFDB_Time)atol(p)) < 0L) {
 		wfdb_error(
 		"init: length must be specified for segment %s in record %s\n",
 		           segp->recname, record);
@@ -1201,7 +1451,7 @@
 	    tseg++;
 	if (segp != tseg) {
 	    segp = tseg;
-	    if (isigopen(segp->recname, NULL, (int)nisig) != nisig) {
+	    if (isigopen(segp->recname, NULL, (int)nvsig) < 0) {
 	        wfdb_error("isigsettime: can't open segment %s\n",
 			   segp->recname);
 		return (-1);
@@ -1359,6 +1609,7 @@
     struct isdata *is;
     struct igdata *ig;
     WFDB_Group g;
+    WFDB_Sample v;
     WFDB_Signal s;
 
     if ((stat = (int)nisig) == 0) return (0);
@@ -1378,27 +1629,37 @@
 	ig = igd[is->info.group];
 	for (c = 0; c < is->info.spf; c++, vector++) {
 	    switch (is->info.fmt) {
-	      case 0:	/* null signal: return adczero */
-		*vector = is->info.adczero;
+	      case 0:	/* null signal: return sample tagged as invalid */
+		*vector = v = WFDB_INVALID_SAMPLE;
 		if (is->info.nsamp == 0) ig->stat = -1;
 		break;
 	      case 8:	/* 8-bit first differences */
 	      default:
-		*vector = is->samp += r8(ig); break;
+		*vector = v = is->samp += r8(ig); break;
 	      case 16:	/* 16-bit amplitudes */
-		*vector = r16(ig); break;
+		*vector = v = r16(ig); break;
 	      case 61:	/* 16-bit amplitudes, bytes swapped */
-		*vector = r61(ig); break;
+		*vector = v = r61(ig); break;
 	      case 80:	/* 8-bit offset binary amplitudes */
-		*vector = r80(ig); break;
+		*vector = v = r80(ig);
+		if (v == 0) *vector = WFDB_INVALID_SAMPLE;
+		break;
 	      case 160:	/* 16-bit offset binary amplitudes */
-		*vector = r160(ig); break;
+		*vector = v = r160(ig);
+		if (v == 0) *vector = WFDB_INVALID_SAMPLE;
+		break;
 	      case 212:	/* 2 12-bit amplitudes bit-packed in 3 bytes */
-		*vector = r212(ig); break;
+		*vector = v = r212(ig);
+		if (v == -2048) *vector = WFDB_INVALID_SAMPLE;
+		break;
 	      case 310:	/* 3 10-bit amplitudes bit-packed in 4 bytes */
-		*vector = r310(ig); break;
+		*vector = v = r310(ig);
+		if (v == -512) *vector = WFDB_INVALID_SAMPLE;
+		break;
 	      case 311:	/* 3 10-bit amplitudes bit-packed in 4 bytes */
-		*vector = r311(ig); break;
+		*vector = v = r311(ig);
+		if (v == -512) *vector = WFDB_INVALID_SAMPLE;
+		break;
 	    }
 	    if (ig->stat <= 0) {
 		/* End of file -- reset input counter. */
@@ -1409,7 +1670,7 @@
 		}
 		else if (in_msrec && segp < segend) {
 		    segp++;
-		    if (isigopen(segp->recname, NULL, (int)nisig) < nisig) {
+		    if (isigopen(segp->recname, NULL, (int)nvsig) < 0) {
 			wfdb_error("getvec: error opening segment %s\n",
 				   segp->recname);
 			stat = -3;
@@ -1429,7 +1690,7 @@
 		    stat = -1;
 	    }
 	    else
-		is->info.cksum -= *vector;
+		is->info.cksum -= v;
 	}
 	if (--is->info.nsamp == (WFDB_Time)0L &&
 	    (is->info.cksum & 0xffff) &&
@@ -1457,8 +1718,8 @@
 	long v;
 
 	stat = getframe(tvector);
-	for (s = 0, tp = tvector; s < nisig; s++) {
-	    int sf = isd[s]->info.spf;
+	for (s = 0, tp = tvector; s < nvsig; s++) {
+	    int sf = vsd[s]->info.spf;
 
 	    for (c = v = 0; c < sf; c++)
 		v += *tp++;
@@ -1471,8 +1732,8 @@
 	    stat = getframe(tvector);
 	    gvc = 0;
 	}
-	for (s = 0, tp = tvector; s < nisig; s++) {
-	    int sf = isd[s]->info.spf;
+	for (s = 0, tp = tvector; s < nvsig; s++) {
+	    int sf = vsd[s]->info.spf;
 
 	    *vector++ = tp[(sf*gvc)/ispfmax];
 	    tp += sf;
@@ -1637,6 +1898,9 @@
     nisig += s;		/* Update the count of open input signals. */
     nigroups += g;	/* Update the count of open input signal groups. */
 
+    if (sigmap_init() < 0)
+	return (-1);
+
     /* Determine the total number of samples per frame. */
     for (si = framelen = 0; si < nisig; si++)
 	framelen += isd[si]->info.spf;
@@ -2048,6 +2312,8 @@
     }
     else		/* no deskewing necessary */
 	stat = getskewedframe(vector);
+    if (need_sigmap && stat > 0)
+	sigmap(vector);
     istime++;
     return (stat);
 }
@@ -2068,6 +2334,23 @@
 	if (os->info.nsamp++ == (WFDB_Time)0L)
 	    os->info.initval = os->samp = *vector;
 	for (c = 0; c < os->info.spf; c++, vector++) {
+	    if (*vector == WFDB_INVALID_SAMPLE)	/* use lowest possible value */
+		switch (os->info.fmt) {
+		  case 0:
+		  case 8:
+		  case 16:
+		  case 61:
+		  default:
+		    break;
+		  case 80:
+		  case 160:
+		    *vector = 0; break;
+		  case 212:
+		    *vector = -2048; break;
+		  case 310:
+		  case 311:
+		    *vector = -512; break;
+		}
 	    switch (os->info.fmt) {
 	      case 0:	/* null signal (do not write) */
 		os->samp = *vector; break;
@@ -2427,7 +2710,7 @@
 WFDB_Signal s;
 {
     if (s < nisig)
-	return (isd[s]->skew);
+	return (vsd[s]->skew);
     else
 	return (0);
 }
@@ -2439,7 +2722,7 @@
 int skew;
 {
     if (s < nisig)
-        isd[s]->skew = skew;
+        vsd[s]->skew = skew;
 }
 
 /* Note: wfdbsetskew affects *only* the skew to be written by setheader.
@@ -2457,7 +2740,7 @@
 WFDB_Signal s;
 {
     if (s < nisig)
-        return (igd[isd[s]->info.group]->start);
+        return (igd[vsd[s]->info.group]->start);
     else
 	return (0L);
 }
@@ -2637,7 +2920,7 @@
     }
     else {			/* time of day */
 	/* Convert to sample intervals since midnight. */
-	t = (WFDB_Time)(btime*sfreq/1000.0) - t;
+	t = (WFDB_Time)(btime*sfreq/1000.0 + 0.5) - t;
 	/* Convert from sample intervals to seconds. */
 	s = t / f;
 	msec = (t - s*f)*1000/f;
@@ -2783,7 +3066,7 @@
 WFDB_Sample a;
 {
     double x;
-    WFDB_Gain g = (s < nisig) ? isd[s]->info.gain : WFDB_DEFGAIN;
+    WFDB_Gain g = (s < nvsig) ? vsd[s]->info.gain : WFDB_DEFGAIN;
 
     if (g == 0.) g = WFDB_DEFGAIN;
     x = a*1000./g;
@@ -2798,7 +3081,7 @@
 int v;
 {
     double x;
-    WFDB_Gain g = (s < nisig) ? isd[s]->info.gain : WFDB_DEFGAIN;
+    WFDB_Gain g = (s < nvsig) ? vsd[s]->info.gain : WFDB_DEFGAIN;
 
     if (g == 0.) g = WFDB_DEFGAIN;
     x = g*v*0.001;
@@ -2815,9 +3098,9 @@
     int b;
     WFDB_Gain g;
 
-    if (s < nisig) {
-	b = isd[s]->info.baseline;
-	g = isd[s]->info.gain;
+    if (s < nvsig) {
+	b = vsd[s]->info.baseline;
+	g = vsd[s]->info.gain;
 	if (g == 0.) g = WFDB_DEFGAIN;
     }
     else {
@@ -2834,9 +3117,9 @@
     int b;
     WFDB_Gain g;
 
-    if (s < nisig) {
-	b = isd[s]->info.baseline;
-	g = isd[s]->info.gain;
+    if (s < nvsig) {
+	b = vsd[s]->info.baseline;
+	g = vsd[s]->info.gain;
 	if (g == 0.) g = WFDB_DEFGAIN;
     }
     else {
@@ -2950,6 +3233,8 @@
     if (gv0) (void)free(gv0);
     if (gv1) (void)free(gv1);
     gv0 = gv1 = NULL;
+
+    sigmap_cleanup();
 }
 
 void wfdb_osflush()
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/lib/wfdb.h0 wfdb-10.3.17/lib/wfdb.h0
--- wfdb-10.3.16/lib/wfdb.h0	2005-06-11 17:58:16.000000000 -0400
+++ wfdb-10.3.17/lib/wfdb.h0	2005-07-01 20:42:41.000000000 -0400
@@ -1,5 +1,5 @@
 /* file: wfdb.h		G. Moody	13 June 1983
-			Last revised: 	11 June 2005	wfdblib 10.3.16
+			Last revised: 	 1 July 2005	wfdblib 10.3.17
 WFDB library type, constant, structure, and function interface definitions
 
 _______________________________________________________________________________
@@ -33,7 +33,7 @@
 /* WFDB library version. */
 #define WFDB_MAJOR   10
 #define WFDB_MINOR   3
-#define WFDB_RELEASE 16
+#define WFDB_RELEASE 17
 #define WFDB_NETFILES 1	/* if 1, library includes code for HTTP, FTP clients */
 #define WFDB_NETFILES_LIBCURL 1
 
@@ -79,6 +79,9 @@
 typedef unsigned int WFDB_Signal;   /* signal number */
 typedef unsigned int WFDB_Annotator;/* annotator number */
 
+#define WFDB_INVALID_SAMPLE (-32768) /* samples from getvec or getframe with
+				        this value are not valid */
+
 /* Array sizes
    Many older applications use the values of WFDB_MAXANN, WFDB_MAXSIG, and
    WFDB_MAXSPF to determine array sizes, but (since WFDB library version 10.2)
@@ -87,7 +90,7 @@
 #define WFDB_MAXANN    2   /* maximum number of input or output annotators */
 #define	WFDB_MAXSIG   32   /* maximum number of input or output signals */
 #define WFDB_MAXSPF    4   /* maximum number of samples per signal per frame */
-#define WFDB_MAXRNL   11   /* maximum length of record name */
+#define WFDB_MAXRNL   20   /* maximum length of record name */
 #define WFDB_MAXUSL   20   /* maximum length of WFDB_siginfo `.units' string */
 #define WFDB_MAXDSL   60   /* maximum length of WFDB_siginfo `.desc' string */
 
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/Makefile.tpl wfdb-10.3.17/Makefile.tpl
--- wfdb-10.3.16/Makefile.tpl	2005-06-13 04:28:59.000000000 -0400
+++ wfdb-10.3.17/Makefile.tpl	2005-08-04 22:04:57.000000000 -0400
@@ -1,37 +1,30 @@
 # file: Makefile.tpl		G. Moody	 24 May 2000
-#				Last revised:	 13 June 2005
+#				Last revised:	4 August 2005
 # This section of the Makefile should not need to be changed.
 
 # 'make' or 'make all': compile the WFDB applications without installing them
-# (requires installation of the WFDB library and includes)
 all:		config.cache
-	cd lib;	     $(MAKE) install
-	cd wave;     $(MAKE) all
-	cd waverc;   $(MAKE) all
-	cd app;      $(MAKE) all
-	cd psd;      $(MAKE) all
-	cd examples; $(MAKE) all
-	cd convert;  $(MAKE) all
+	$(MAKE) WFDBROOT=`pwd`/build install check
 
 # 'make install': compile and install the WFDB software package
 install:	config.cache
 	cd lib;	     $(MAKE) install
-	cd wave;     $(MAKE) install
-	cd waverc;   $(MAKE) install
 	cd app;      $(MAKE) install
-	cd psd;      $(MAKE) install
 	cd convert;  $(MAKE) install
 	cd data;     $(MAKE) install
+	cd psd;      $(MAKE) install
+	-( cd wave;  $(MAKE) install )
+	cd waverc;   $(MAKE) install
 	test -d doc && ( cd doc; $(MAKE) install )
 
 uninstall:	config.cache
 	cd lib;	     $(MAKE) uninstall
-	cd wave;     $(MAKE) uninstall
-	cd waverc;   $(MAKE) uninstall
 	cd app;      $(MAKE) uninstall
-	cd psd;      $(MAKE) uninstall
 	cd convert;  $(MAKE) uninstall
+	cd psd;      $(MAKE) uninstall
 	cd data;     $(MAKE) uninstall
+	cd wave;     $(MAKE) uninstall
+	cd waverc;   $(MAKE) uninstall
 	test -d doc && ( cd doc; $(MAKE) uninstall )
 	./uninstall.sh $(WFDBROOT)
 
@@ -48,7 +41,9 @@
 	cd wave;     $(MAKE) clean
 	cd waverc;   $(MAKE) clean
 	test -d doc && ( cd doc; $(MAKE) clean )
-	rm -f *~ conf/*~ conf/prompt config.cache */*.exe $(PACKAGE)-*.spec
+	cd conf; rm -f *~ prompt site.def site-slib.def
+	rm -f *~ config.cache */*.exe $(PACKAGE)-*.spec
+	rm -rf build
 
 # 'make config.cache': check configuration
 config.cache:
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/NEWS wfdb-10.3.17/NEWS
--- wfdb-10.3.16/NEWS	2005-06-12 00:13:43.000000000 -0400
+++ wfdb-10.3.17/NEWS	2005-08-20 15:51:38.000000000 -0400
@@ -1,3 +1,64 @@
+10.3.17:
+	The WFDB library now supports reading variable-layout records
+	(multi-segment records in which the number, arrangement, gains,
+	and baselines of the signals may vary from one segment to the next;
+	see 'Multi-Segment Records' in the WFDB Programmer's Guide).
+
+	Rounding errors in the WFDB library's mstimstr function have been
+	reduced.  Previous versions did not always round appropriately when
+	the sampling frequency was much less than 1 Hz.
+
+	The maximum length for a record name (WFDB_MAXRNL, defined in wfdb.h)
+	has been increased from 11 to 20.
+
+	A new constant, WFDB_INVALID_SAMPLE, is now defined in wfdb.h.  It
+	is used to identify padding inserted to fill in for missing data.
+	When writing in any format that uses fewer than 16 bits per sample,
+	putvec maps WFDB_INVALID_SAMPLE to the lowest (most negative) value
+	expressible in that format;  when reading a signal file in such a
+	format, getframe performs the inverse mapping, so that missing data
+	can be identified regardless of the data format.
+
+	A side effect of this change is that (for example) any samples that
+	had the most negative value (for example, -2048 in a format 212 signal
+	file) are now flagged as invalid.  To treat such samples as invalid
+	is reasonable, however, since these occur only when the input level
+	falls below the working range of the analog-to-digital converter.
+
+	'pschart', 'psfd', and 'wave' recognize this value, skip over missing
+	data, and determine the position of each trace using the valid data
+	only.  'rdsamp' also recognizes this value when using its '-p' option,
+	indicating missing values as '-', and 'wrsamp' interprets a '-' token
+	in its input as a missing value indicator to be written in its output
+	as a sample with the value WFDB_INVALID_SAMPLE.  'xform' also
+	recognizes and preserves this value in its output.
+
+	'pschart' and 'psfd' process signal lists more cleanly (each '-s'
+	option resets the signal list);  grid lines and other narrow lines
+	are now 0.2 mm wide by default (earlier versions drew "zero width"
+	lines that can be nearly invisible on modern high-resolution printers).
+
+	An error in the psfd man page (doc/wag-src/psfd.1) has been corrected.
+
+	'sumstats' now accepts certain valid inputs that previous versions
+	rejected.
+
+	A bug affecting signal highlighting in 'wave' was introduced in
+	10.3.16, and has now been corrected.
+
+	wave/soelim.c now works on the x86_64 architecture.
+
+	The 'configure' script and the .def files in 'conf' have been
+	revised, with several new options added to 'configure' (-m32,
+	--without-netfiles, --withlibcurl, and --with-libwww.  'make all'
+	(or simply 'make') builds and checks a complete test installation
+	of the WFDB Software Package without affecting any previously installed
+	version of the package (until now, 'make' has installed the WFDB
+	library and its associated *.h files). The 'configure' script now
+	automatically detects the x86_64 (AMD64) architecture under GNU/Linux,
+	and sets up the Makefiles appropriately (unless the '-m32' option
+	is used to force 32-bit mode).
+
 10.3.16:
 	Benjamin Moody has added an interface between the WFDB library and
 	libcurl as an alternative to the existing libwww interface, and has
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/wave/init.c wfdb-10.3.17/wave/init.c
--- wfdb-10.3.16/wave/init.c	2004-03-05 11:33:27.000000000 -0500
+++ wfdb-10.3.17/wave/init.c	2005-08-05 12:02:17.000000000 -0400
@@ -1,10 +1,10 @@
 /* file: init.c		G. Moody	 1 May 1990
-			Last revised:   5 March 2004
+			Last revised:   5 August 2005
 Initialization functions for WAVE
 
 -------------------------------------------------------------------------------
 WAVE: Waveform analyzer, viewer, and editor
-Copyright (C) 1990-2004 George B. Moody
+Copyright (C) 1990-2005 George B. Moody
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -66,6 +66,7 @@
 	(v0 = realloc(v0, ns * sizeof(WFDB_Sample))) == NULL ||
 	(vmax = realloc(vmax, ns * sizeof(WFDB_Sample))) == NULL ||
 	(vmin = realloc(vmin, ns * sizeof(WFDB_Sample))) == NULL ||
+	(vvalid = realloc(vvalid, ns * sizeof(int))) == NULL ||
 	(level_name_string =
 		realloc(level_name_string, ns * sizeof(char **))) == NULL ||
 	(level_value_string =
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/wave/Makefile.tpl wfdb-10.3.17/wave/Makefile.tpl
--- wfdb-10.3.16/wave/Makefile.tpl	2005-05-31 13:03:26.000000000 -0400
+++ wfdb-10.3.17/wave/Makefile.tpl	2005-06-14 16:20:57.000000000 -0400
@@ -88,7 +88,7 @@
 	$(CC) $(WCFLAGS) -o wave-static $(OFILES) -static $(LDFLAGS)
 
 soelim:		soelim.c
-	$(CC) $(CFLAGS) -o soelim -O soelim.c
+	$(CC) -o soelim -O soelim.c
 
 wave.hlp:	soelim wave.hl0 $(HELPFILES)
 	./soelim wave.hl0 >wave.hlp
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/wave/sig.c wfdb-10.3.17/wave/sig.c
--- wfdb-10.3.16/wave/sig.c	2005-06-10 10:31:41.000000000 -0400
+++ wfdb-10.3.17/wave/sig.c	2005-08-05 13:32:51.000000000 -0400
@@ -46,30 +46,54 @@
     return (0);
 }
 
+static void drawtrace(b, n, ybase, gc, mode)
+XPoint *b;
+int mode, n, ybase;
+GC gc;
+{
+    int j, xn, xp;
+    XPoint *p, *q;
+
+    for (j = 0, p = q = b; j <= n; j++) {
+	if (j == n || q->y == WFDB_INVALID_SAMPLE) {
+	    if (p < q) {
+		while (p < q && p->y == WFDB_INVALID_SAMPLE)
+		    p++;
+		xp = p->x;
+		xn = p - b;
+		if (nsamp <= canvas_width) xn *= tscale;
+		p->x = xn;
+		p->y += ybase;
+		XDrawLines(display, osb, gc, p, q-p, CoordModePrevious);
+		if (mode)
+		    XDrawLines(display, xid, gc, p, q-p, CoordModePrevious);
+		p->x = xp;
+		p->y -= ybase;
+	    }
+	    p = ++q;
+	}
+	else
+	    ++q;
+    }
+}
+
 static void show_display_list(lp)
 struct display_list *lp;
 {
-    int i, in_siglist();
+    int i, j, k, xn, xp, in_siglist();
+    XPoint *p, *q;
 
     lp_current = lp;
     if (!lp) return;
     if (sig_mode == 0)
 	for (i = 0; i < nsig; i++) {
-	    if (lp->vlist[i]) {
-		lp->vlist[i][0].y += base[i];
-		XDrawLines(display, osb, draw_sig, lp->vlist[i], lp->ndpts,
-		       CoordModePrevious);
-		lp->vlist[i][0].y -= base[i];
-	    }
+	    if (lp->vlist[i])
+		drawtrace(lp->vlist[i], lp->ndpts, base[i], draw_sig, 0);
 	}
     else
 	for (i = 0; i < siglistlen; i++) {
-	    if (0 <= siglist[i] && siglist[i] < nsig && lp->vlist[siglist[i]]){
-		lp->vlist[siglist[i]][0].y += base[i];
-		XDrawLines(display, osb, draw_sig, lp->vlist[siglist[i]],
-			   lp->ndpts, CoordModePrevious);
-		lp->vlist[siglist[i]][0].y -= base[i];
-	    }
+	    if (0 <= siglist[i] && siglist[i] < nsig && lp->vlist[siglist[i]])
+		drawtrace(lp->vlist[siglist[i]], lp->ndpts,base[i],draw_sig,0);
 	}
     highlighted = -1;
 }
@@ -77,30 +101,24 @@
 void sig_highlight(i)
 int i;
 {
+    extern void repaint();
+
     if (!lp_current) return;
     if (0 <= highlighted && highlighted < lp_current->nsig) {
 	if (sig_mode == 0) {
-	    lp_current->vlist[highlighted][0].y += base[highlighted];
-	    XDrawLines(display, osb, unhighlight_sig,
-		       lp_current->vlist[highlighted],
-		       lp_current->ndpts, CoordModePrevious);
-	    XDrawLines(display, osb, draw_sig,
-		       lp_current->vlist[highlighted],
-		       lp_current->ndpts, CoordModePrevious);
-	    lp_current->vlist[highlighted][0].y -= base[highlighted];
+	    drawtrace(lp_current->vlist[highlighted], lp_current->ndpts,
+		      base[highlighted], unhighlight_sig, 1);
+	    drawtrace(lp_current->vlist[highlighted], lp_current->ndpts,
+		      base[highlighted], draw_sig, 1);
 	}
 	else {
 	    int j;
 	    for (j = 0; j < siglistlen; j++) {
 		if (siglist[j] == highlighted) {
-		    lp_current->vlist[highlighted][0].y += base[j];
-		    XDrawLines(display, osb, unhighlight_sig,
-			       lp_current->vlist[highlighted],
-			       lp_current->ndpts, CoordModePrevious);
-		    XDrawLines(display, osb, draw_sig,
-			       lp_current->vlist[highlighted],
-			       lp_current->ndpts, CoordModePrevious);
-		    lp_current->vlist[highlighted][0].y -= base[j];
+		    drawtrace(lp_current->vlist[highlighted],
+			      lp_current->ndpts, base[j], unhighlight_sig, 1);
+		    drawtrace(lp_current->vlist[highlighted],
+			      lp_current->ndpts, base[j], draw_sig, 1);
 		}
 	    }
 	}
@@ -108,27 +126,19 @@
     highlighted = i;
     if (0 <= highlighted && highlighted < lp_current->nsig) {
 	if (sig_mode == 0) {
-	    lp_current->vlist[highlighted][0].y += base[highlighted];
-	    XDrawLines(display, osb, clear_sig,
-		       lp_current->vlist[highlighted],
-		       lp_current->ndpts, CoordModePrevious);
-	    XDrawLines(display, osb, highlight_sig,
-		       lp_current->vlist[highlighted],
-		       lp_current->ndpts, CoordModePrevious);
-	    lp_current->vlist[highlighted][0].y -= base[highlighted];
+	    drawtrace(lp_current->vlist[highlighted], lp_current->ndpts,
+		      base[highlighted], clear_sig, 1);
+	    drawtrace(lp_current->vlist[highlighted], lp_current->ndpts,
+		      base[highlighted], highlight_sig, 1);
 	}
 	else {
 	    int j;
 	    for (j = 0; j < siglistlen; j++) {
 		if (siglist[j] == highlighted) {
-		    lp_current->vlist[highlighted][0].y += base[j];
-		    XDrawLines(display, osb, clear_sig,
-			       lp_current->vlist[highlighted],
-			       lp_current->ndpts, CoordModePrevious);
-		    XDrawLines(display, osb, highlight_sig,
-			       lp_current->vlist[highlighted],
-			       lp_current->ndpts, CoordModePrevious);
-		    lp_current->vlist[highlighted][0].y -= base[j];
+		    drawtrace(lp_current->vlist[highlighted],
+			      lp_current->ndpts, base[j], clear_sig, 1);
+		    drawtrace(lp_current->vlist[highlighted],
+			      lp_current->ndpts, base[j], highlight_sig, 1);
 		}
 	    }
 	}
@@ -310,8 +320,9 @@
     /* Set the starting point for each signal. */
     for (c = 0; c < nsig; c++) {
 	vmin[c] = vmax[c] = v0[c];
-	if (v0[c] == -32768)
-	    lp->vlist[c][0].y = -32768;
+	vvalid[c] = 0;
+	if (v0[c] == WFDB_INVALID_SAMPLE)
+	    lp->vlist[c][0].y = WFDB_INVALID_SAMPLE;
 	else
 	    lp->vlist[c][0].y = v0[c]*vscale[c];
     }
@@ -320,25 +331,26 @@
        data. */
     if (nsamp > canvas_width) {
 	for (i = 1, x0 = 0; i < nsamp && getvec(v) > 0; i++) {
-	    if ((x = i*tscale) > x0) {
-		x0 = x;
-		for (c = 0; c < nsig; c++) {
+	    for (c = 0; c < nsig; c++) {
+		if (v[c] != WFDB_INVALID_SAMPLE) {
 		    if (v[c] > vmax[c]) vmax[c] = v[c];
-		    else if (v[c] < vmin[c]) vmin[c] = v[c];
-		    if (vmax[c] - v0[c] > v0[c] - vmin[c])
-			v0[c] = vmin[c] = vmax[c];
-		    else
-			v0[c] = vmax[c] = vmin[c];
-		    if (v0[c] == -32768)
-			lp->vlist[c][x0].y = -32768;
-		    else
-			lp->vlist[c][x0].y = v0[c]*vscale[c];
+		    if (v[c] < vmin[c]) vmin[c] = v[c];
+		    vvalid[c] = 1;
 		}
 	    }
-	    else {
+	    if ((x = i*tscale) > x0) {
+		x0 = x;
 		for (c = 0; c < nsig; c++) {
-		    if (v[c] > vmax[c]) vmax[c] = v[c];
-		    else if (v[c] < vmin[c]) vmin[c] = v[c];
+		    if (vvalid[c]) {
+			if (vmax[c] - v0[c] > v0[c] - vmin[c])
+			    v0[c] = vmin[c] = vmax[c];
+			else
+			    v0[c] = vmax[c] = vmin[c];
+			lp->vlist[c][x0].y = v0[c]*vscale[c];
+		    }
+		    else
+			lp->vlist[c][x0].y = WFDB_INVALID_SAMPLE;
+		    vvalid[c] = 0;
 		}
 	    }
 	}
@@ -349,8 +361,8 @@
     else
 	for (i = 1; i < nsamp && getvec(v) > 0; i++)
 	    for (c = 0; c < nsig; c++) {
-		if (v[c] == -32768)
-		    lp->vlist[c][i].y = -32768;
+		if (v[c] == WFDB_INVALID_SAMPLE)
+		    lp->vlist[c][i].y = WFDB_INVALID_SAMPLE;
 		else
 		    lp->vlist[c][i].y = v[c]*vscale[c];
 	    }
@@ -371,15 +383,17 @@
 	double w;	/* weight assigned to ymean in y-offset calculation */
 
 	tp = lp->vlist[c];
-	ymean = ymax = ymin = tp[0].y;
-	for (j = i-1, n = 1; j >= 0; j--) {
-	    y = tp[j].y;
-	    if (y > ymax) ymax = y;
-	    else if (y < ymin && y != -32768) ymin = y;
-	    if (y != -32768) { ymean += y; n++; }
+	ymean = 0;  ymax = -32768; ymin = 32767;
+	for (j = n = 0, n = 1; j < i; j++) {
+	    if ((y = tp[j].y) != WFDB_INVALID_SAMPLE) {
+		if (y > ymax) ymax = y;
+		else if (y < ymin) ymin = y;
+		ymean += y;
+		n++;
+	    }
 	}
 	ymid = (ymax + ymin)/2;
-	ymean /= n;
+	if (n > 0) ymean /= n;
 	/* Since ymin <= ymid <= ymax, the next lines imply 0 <= w <= 1 */
 	if (ymid > ymean) /* in this case, ymax must be > ymean */
 	    w = (ymid - ymean)/(ymax - ymean);
@@ -388,6 +402,7 @@
 	else w = 1.0;
 	dy = -(ymid + ((double)ymean-ymid)*w);
 	for (j = i-1; j >= 0; j--) {
+	    if (tp[j].y == WFDB_INVALID_SAMPLE) continue;
 	    /* The bounds-checking below shouldn't be necessary (the X server
 	       should clip at the canvas boundaries), but Sun's X11/NeWS
 	       server will crash (and may bring the system down with it) if
@@ -401,8 +416,10 @@
 	       This bug has not been observed with other X servers. */
 	    if ((tp[j].y += dy) < -canvas_height) tp[j].y = -canvas_height;
 	    else if  (tp[j].y > canvas_height) tp[j].y = canvas_height;
-	    /* Convert all except the first ordinate to relative ordinates. */
-	    if (j < i-1) tp[j+1].y -= tp[j].y;
+	    /* Convert all except the first ordinate in each set of contiguous
+	       valid samples to relative ordinates. */
+	    if (j < i-1 && tp[j+1].y != WFDB_INVALID_SAMPLE)
+		tp[j+1].y -= tp[j].y;
 	}
 	if (dc_coupled[c]) lp->sb[c] = sigbase[c]*vscale[c] + dy;
     }	    
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/wave/soelim.c wfdb-10.3.17/wave/soelim.c
--- wfdb-10.3.16/wave/soelim.c	2000-01-30 04:13:21.000000000 -0500
+++ wfdb-10.3.17/wave/soelim.c	2005-06-29 18:54:56.000000000 -0400
@@ -1,8 +1,8 @@
 /* file: soelim.c	G. Moody	25 January 1995
-
+			Last revised:	 29 June 2005
 -------------------------------------------------------------------------------
 soelim: expands .so requests in [nt]roff source files
-Copyright (C) 1995 George B. Moody
+Copyright (C) 1995-2005 George B. Moody
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -34,6 +34,16 @@
 */
 
 #include <stdio.h>
+#if defined(__STDC__) || defined(_WINDOWS)
+#include <stdlib.h>
+#else
+extern void exit();
+#endif
+#ifndef BSD
+# include <string.h>
+#else		/* for Berkeley UNIX only */
+# include <strings.h>
+#endif
 
 #define MAXLEVEL 100
 
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/wave/wave.h wfdb-10.3.17/wave/wave.h
--- wfdb-10.3.16/wave/wave.h	2004-03-05 10:57:13.000000000 -0500
+++ wfdb-10.3.17/wave/wave.h	2005-08-05 12:01:52.000000000 -0400
@@ -1,10 +1,10 @@
 /* file: wave.h		G. Moody	26 April 1990
-			Last revised:    5 March 2004
+			Last revised:   5 August 2005
 Constants, macros, global variables, and function prototypes for WAVE
 
 -------------------------------------------------------------------------------
 WAVE: Waveform analyzer, viewer, and editor
-Copyright (C) 1990-2004 George B. Moody
+Copyright (C) 1990-2005 George B. Moody
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -137,6 +137,7 @@
 COMMON WFDB_Sample *v0;
 COMMON WFDB_Sample *vmax;
 COMMON WFDB_Sample *vmin;
+COMMON int *vvalid;
 
 COMMON double *vscale;			/* amplitude scales for each signal
 					   (pixels/adu) */
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/wave/xvwave.c wfdb-10.3.17/wave/xvwave.c
--- wfdb-10.3.16/wave/xvwave.c	2005-06-10 10:27:55.000000000 -0400
+++ wfdb-10.3.17/wave/xvwave.c	2005-08-05 13:34:10.000000000 -0400
@@ -1,5 +1,5 @@
 /* file: xvwave.c	G. Moody	27 April 1990
-			Last revised:	10 June 2005
+			Last revised:	5 August 2005
 XView support functions for WAVE
 
 -------------------------------------------------------------------------------
@@ -59,7 +59,7 @@
 static GC bg_fill;
 
 /* Handle exposures in the signal window. */
-static void repaint(canvas, paint_window, repaint_area)
+void repaint(canvas, paint_window, repaint_area)
 Canvas canvas;
 Xv_Window paint_window;
 Rectlist *repaint_area;
@@ -133,10 +133,10 @@
 int width;
 int height;
 {
-    XEvent next_event;
+    XEvent nextev;
     if (in_xv_main_loop) {
-	XPeekEvent((Display *)xv_get(canvas, XV_DISPLAY), &next_event);
-	if (next_event.type != ConfigureNotify ) do_resize(canvas, width, height);
+	XPeekEvent((Display *)xv_get(canvas, XV_DISPLAY), &nextev);
+	if (nextev.type == ConfigureNotify) do_resize(canvas, width, height);
     }
 }
 
diff -Naur --exclude Makefile --exclude info wfdb-10.3.16/wfdb.spec wfdb-10.3.17/wfdb.spec
--- wfdb-10.3.16/wfdb.spec	2005-06-12 01:35:30.000000000 -0400
+++ wfdb-10.3.17/wfdb.spec	2005-08-03 11:40:03.000000000 -0400
@@ -16,6 +16,9 @@
 BuildRoot: /var/tmp/%{name}-root
 
 %changelog
+* Wed Aug 3 2005 George B Moody <george@mit.edu>
+- added --dynamic to 'configure' argument list
+
 * Wed Jun 8 2005 George B Moody <george@mit.edu>
 - replaced libwww dependencies with libcurl
 
@@ -37,7 +40,7 @@
 %setup
 
 %build
-PATH=$PATH:/usr/openwin/bin ./configure --prefix=/usr --mandir=%{_mandir}
+PATH=$PATH:/usr/openwin/bin ./configure --prefix=/usr --dynamic --mandir=%{_mandir}
 make
 
 # The 'make' command above actually *installs* the WFDB library and its *.h
