Package-Name: xwave
Requires: XFree86|Xorg
Source: ibibliolinux:///apps/sound/editors/xwave-(\d+.\d+).tar.gz $1
Zap-Before-Install: 1
Repack:
	tar xzvfp "$(SOURCE)"
	if [ -d xwave ] ; then mv xwave xwave-"$(VERSION)" ; fi
Compile:
	-xmkmf -a
	# Avoid pulling in glibc's libieee
	mv -f src/Makefile src/Makefile~
	sed -e 's@-lieee@../ieee/libieee.a@' <src/Makefile~ >src/Makefile
	if [ "$DEBUG" ] ; then OPTFLAG="" ; else OPTFLAG=-O2 ; fi ; \
	$(MAKE) CDEBUGFLAGS="$$OPTFLAG $(GCC_OPT_FLAGS) -fno-strict-aliasing -D_FILE_OFFSET_BITS=64"
	umask 022 ; mkdir -p "$(PREFIX)"/bin "$(PREFIX)"/man/man1
	mv -f src/xwave "$(PREFIX)"/bin/
	mv -f src/xwave.man "$(PREFIX)"/man/man1/xwave.1
	mv -f src/XWave "$(PREFIX)"/XWave.ad
Install:
	$(MAKE) instbin BIN=xwave
	$(MAKE) instman SECTION=1 MAN=xwave
	ln -fs "$(PREFIX)"/XWave.ad /usr/X11/lib/X11/app-defaults/XWave
Patch: <<EOT
######## begin saved-mark.diff
--- ../xwave-0.7-orig/src/graphics.c	2006-05-21 15:04:19 +0900
+++ src/graphics.c	2006-05-22 19:30:46 +0900
@@ -42,6 +42,7 @@
 #include <X11/Intrinsic.h>
 #include <X11/StringDefs.h>
 #include <X11/Shell.h>
+#include <X11/keysym.h>
 #include <X11/Xaw/Scrollbar.h>
 
 #include "types.h"
@@ -1770,6 +1771,38 @@
     firstmark=-1;
 }
 
+void keyp_action (Widget w, Main_Data *md, XKeyEvent *event,
+		  Boolean *flg)
+{
+    int savedmark;
+    if (md->no==0) return;
+    if (md->wd->length==0) return;
+    if (md->mb->playing) return;
+    /* FIXME: we should use XLookupString or the like */
+    if (event->keycode != 96) return;  // F12
+    
+    if (md->wd->isplay) {
+	clear_line(md->wd->markbeg/md->mg->step);
+    }
+    if (md->wd->ismark) {
+	set_whole_mark(md);
+	set_canvas_mark(get_actual_nw(md));
+    }
+    savedmark=md->wd->markbeg;
+    md->wd->markbeg=md->wd->savedmark;
+    md->wd->savedmark=savedmark;
+    set_beginmark_label(md->wd->markbeg);
+    md->cg->pos=md->wd->markbeg*md->wd->bpspl;
+    if (md->wd->isplay) {
+	set_line(md->wd->markbeg/md->mg->step);
+    }
+    if (md->wd->ismark) {
+	set_whole_mark(md);
+	set_canvas_mark(get_actual_nw(md));
+    } 
+    update_canvas(md,NULL);
+}
+
 void set_mark_beg(Main_Data *md,int x)
 {
     Window win = XtWindow(md->mw->graph);
--- ../xwave-0.7-orig/src/graphics.h	1996-11-08 02:04:17 +0900
+++ src/graphics.h	2006-05-22 19:21:11 +0900
@@ -6,6 +6,7 @@
 void mark_action (Widget, Main_Data *,XMotionEvent *, Boolean *);
 void buttonp_action (Widget,Main_Data *,XButtonEvent *, Boolean *);
 void buttonr_action (Widget,Main_Data *,XButtonEvent *, Boolean *);
+void keyp_action (Widget,Main_Data *,XKeyEvent *, Boolean *);
 void mark_canvas (Widget, Main_Data *, XEvent *, Boolean *);
 void update_display(Main_Data *);
 void update_canvas(Main_Data *,Next_Wave *nw);
--- ../xwave-0.7-orig/src/types.h	1996-11-07 07:41:53 +0900
+++ src/types.h	2006-05-22 19:10:51 +0900
@@ -44,6 +44,7 @@
     int	          markbeg;	   /* the begin of the mark/playline */
     int	          marklength;	   /* the length of the mark */
     int 	  tlength;	   /* length / bpspl */
+    int 	  savedmark;
     int	          fd;		   /* fileno if not complete in mem */
     int           headoffs;
     int           peak_l;
--- ../xwave-0.7-orig/src/xwave.c	2006-05-21 15:04:19 +0900
+++ src/xwave.c	2006-05-22 19:10:40 +0900
@@ -415,6 +415,8 @@
 		      (XtEventHandler)buttonp_action, (XtPointer) MD);
     XtAddEventHandler(graph, ButtonReleaseMask, FALSE, 
 		      (XtEventHandler)buttonr_action, (XtPointer) MD);
+    XtAddEventHandler(MD->mw->form, KeyPressMask, FALSE, 
+		      (XtEventHandler)keyp_action, (XtPointer) MD);
     
     /* if server can backing store, we want backing store */
     wattr.backing_store=DoesBackingStore(DefaultScreenOfDisplay(dpy));
######## end saved-mark.diff
EOT
Patch-0.6: <<EOT
######## begin debian-makefile.diff
diff -urN ../xwave-0.6-orig/FWF/FWF.rules ./FWF/FWF.rules
--- ../xwave-0.6-orig/FWF/FWF.rules	Tue Jan 30 02:55:22 1996
+++ ./FWF/FWF.rules	Sun Nov 17 21:09:10 2002
@@ -20,7 +20,7 @@
 #define	AddToLibraryTarget(target,libdir,libname,objlist)		@@\
 target:: libdir/libname							@@\
 									@@\
-libdir/libname:: objlist						@@\
+libdir/libname:: objlist force						@@\
 	-@(if [ ! -f libdir/libname ]; then \				@@\
 		$(MKDIRHIER) libdir ; \					@@\
 		echo Creating Library libdir/libname ; \		@@\
@@ -29,7 +29,10 @@
 	fi; exit 0)							@@\
 	@echo Adding objlist To Library libdir/libname			@@\
 	$(ARMERGE) libdir/libname objlist				@@\
-	RanLibrary(libdir/libname)
+	RanLibrary(libdir/libname)					@@\
+									@@\
+force::									@@\
+.PHONY: force
 #endif /* AddToLibraryTarget */
 
 /*
diff -urN ../xwave-0.6-orig/Imakefile ./Imakefile
--- ../xwave-0.6-orig/Imakefile	Thu Apr 18 18:03:05 1996
+++ ./Imakefile	Sun Nov 17 21:09:10 2002
@@ -6,7 +6,7 @@
 
 MakeSubdirs($(SUBDIRS))
 InstallSubdirs($(SUBDIRS))
-DependSubdirs($(SUBDIRS))
+DependSubdirs(ccitt adpcm2pcm ieee src)
 CleanSubdirs($(SUBDIRS))
 MakefileSubdirs($(SUBDIRS))
 
######## end debian-makefile.diff
######## begin debian-man-page.diff
diff -urN ../xwave-0.6-orig/src/xwave.man ./src/xwave.man
--- ../xwave-0.6-orig/src/xwave.man	Thu Jan  1 09:00:00 1970
+++ ./src/xwave.man	Sun Nov 17 21:09:10 2002
@@ -0,0 +1,109 @@
+.TH XWAVE 1 "17 July 1999"
+.SH NAME
+xwave \- edits audio files in X Window System
+.SH SYNOPSIS
+.B xwave
+[
+.B \-h
+|
+.B \-?
+|
+.B \-help
+]
+[
+.B \-device " device"
+]
+[
+.BI \-wdir " working-directory"
+]
+[
+.BI \-maxmem " mem-in-bytes"
+]
+.I audio-file
+ ...
+.LP
+
+.SH DESCRIPTION
+.B XWave
+can edit, modify, and apply effects to sound files.
+
+It supports RIFF (also known as WAV), AIFC, AU and RAW audio formats
+with different compression schemes (PCM, ALAW, ULAW and ADPCM).
+
+.SH OPTIONS
+.TP
+.B \-h
+.B \-?
+.B \-help
+Prints a short help.
+.TP
+.BI \-device " device"
+Use the specified 
+.I device
+for playing and recording. Defaults to /dev/dsp
+.TP
+.BI \-wdir " working-directory"
+The directory where files will be loaded and saved by default.
+.TP
+.BI \-maxmem " mem-in-bytes"
+Use at most 
+.I mem-in-bytes
+bytes of memory per file loaded. If a file exceeds
+.I mem-in-bytes
+bytes, it will be played and edited on disk.
+
+.SH RESOURCES
+.TP
+.BI XWave*wdir
+The working directory.
+
+.TP
+.BI XWave*tdir
+The temporary directory where files which cannot fit in physical
+memory are edited. This is overridden by the environment variables
+.I TMP
+and
+.I TMPDIR.
+
+.TP
+.BI XWave*device
+The device used for playing and recording.
+
+.TP
+.BI XWave*maxmem
+Maximum memory in bytes to be allocated in RAM. Any edited file
+exceeding this size will be edited on disk.
+
+.SH ENVIRONMENT
+.TP
+.BI TMP
+If this variable exists and points to a writable directory, this
+directory will be used as temporary directory.
+
+.TP
+.BI TMPDIR
+Same as 
+.I TMP.
+
+.SH NOTES
+.B Xwave
+will try to find the temporary directory by searching successively:
+.PP
+the environment variable
+.I TMP,
+.PP
+the environment variable
+.I TMPDIR,
+.PP
+the X resource
+.I XWave*tdir,
+.PP 
+or the hard-coded /tmp directory.
+
+.SH AUTHOR
+.PP
+This man page has been written for Debian by Philippe Troin
+<phil@fifi.org>.
+
+\"  LocalWords:  XWAVE xwave wdir maxmem mem XWave RIFF WAV AIFC AU PCM ALAW
+\"  LocalWords:  ULAW ADPCM tdir TMP TMPDIR tmp Debian Troin
######## end debian-man-page.diff
######## begin debian-misc-fixes.diff
--- ../xwave-0.6-orig/src/audio.c	Tue Nov 26 19:13:44 1996
+++ ./src/audio.c	Sun Nov 17 21:09:10 2002
@@ -97,7 +97,7 @@
     }
     
     ioctl(audio, SNDCTL_DSP_GETBLKSIZE, buf_size);
-    if (*buf_size < 1024 || *buf_size > 2*65536) {
+    if (*buf_size < 64 || *buf_size > 2*65536) {
 	fprintf(stderr,"XWave: Wrong audio buffer size \"%i\"!\n",*buf_size);
 	return(-1);
     }
diff -urN ../xwave-0.6-orig/src/edit.c ./src/edit.c
--- ../xwave-0.6-orig/src/edit.c	Fri Nov  8 02:26:29 1996
+++ ./src/edit.c	Sun Nov 17 21:09:10 2002
@@ -1136,7 +1136,8 @@
 	}
 	if (wd->inmem) {
 	    memcpy(newbuf,wd->buffer,beg);
-	    memcpy(newbuf+beg,wd->buffer+offset,length-beg);
+	    if (length>beg)
+	      memcpy(newbuf+beg,wd->buffer+offset,length-beg);
 	    free(wd->buffer);
 	} else {
 	    /* after cut the samples fitting in memory */
diff -urN ../xwave-0.6-orig/src/graphics.c ./src/graphics.c
--- ../xwave-0.6-orig/src/graphics.c	Mon Nov 25 21:33:43 1996
+++ ./src/graphics.c	Sun Nov 17 21:09:10 2002
@@ -1965,6 +1965,11 @@
 		 x=ev->x;
 		 break;
 	     } 
+	     default: {
+		 /* throw away this event, it is not interesting */
+		 XNextEvent(dpy,&pev);
+		 break;
+	     }
 	     case ButtonRelease: {
 		 XButtonEvent *ev;
 		 Boolean update_cvmark=False;
@@ -1972,6 +1977,11 @@
 		 /* remove event from queue */
 		 XNextEvent(dpy,&pev);
 		 ev=(XButtonEvent*) &pev;
+
+		 /* we only care about Button1 */
+		 if (ev->button != Button1)
+		     break;
+
 		 x=ev->x;
 		 set_cursor(md->cw->graph,CURSOR_DEFAULT);
 		 
diff -urN ../xwave-0.6-orig/src/misc.c ./src/misc.c
--- ../xwave-0.6-orig/src/misc.c	Thu Nov 11 20:38:03 1996
+++ ./src/misc.c	Sun May 21 14:55:58 2006
@@ -234,6 +234,9 @@
     char fname[MAX_NAMELENGTH];
     uid_t myuid;
     gid_t mygid;
+    gid_t* xgroups;
+    int nxgroups;
+    int i;
     
     strcpy(fname,filename);
     if ((lstat(fname,&buffer)==-1)) {
@@ -245,6 +248,12 @@
     }
     myuid=getuid();
     mygid=getgid();
+    nxgroups = getgroups(0, NULL);
+    if (nxgroups) {
+      xgroups=alloca(nxgroups*sizeof(gid_t));
+      getgroups(nxgroups, xgroups);
+    }
+
     if (S_ISLNK(buffer.st_mode)) {
 	bool statdone=TRUE;
 	int lcount;
@@ -271,7 +280,11 @@
 	}
     }
     if ((buffer.st_uid == myuid)&&(S_IWUSR & buffer.st_mode)) return(TRUE);
-    if ((buffer.st_gid == mygid)&&(S_IWGRP & buffer.st_mode)) return(TRUE);
+    if (S_IWGRP & buffer.st_mode) {
+      if (buffer.st_gid == mygid) return(TRUE);
+      for ( i=0; i<nxgroups; i++)
+	if (buffer.st_gid == xgroups[i]) return(TRUE);
+    }
     if (S_IWOTH & buffer.st_mode) return(TRUE);
     return(FALSE);
 }
diff -urN ../xwave-0.6-orig/src/xwave.c ./src/xwave.c
--- ../xwave-0.6-orig/src/xwave.c	Thu Nov 21 19:19:15 1996
+++ ./src/xwave.c	Sun Nov 17 21:09:14 2002
@@ -198,6 +198,7 @@
     Dimension width,height;
     Display *dpy;
     XSetWindowAttributes wattr;
+    const char *env_tmpdir;
 
    /*
 #if defined (_LITTLE_ENDIAN) || BYTE_ORDER == LITTLE_ENDIAN
@@ -292,7 +293,11 @@
     if (getenv(AUDIODEV_ENV)!=NULL) app_resources.device=getenv(AUDIODEV_ENV);
 #endif
     /* set the tmp directory, should really have permissions to write here */
-    if (!can_write(app_resources.tdir)) {
+    if ((env_tmpdir = getenv("TMP")) && can_write(env_tmpdir))
+      app_resources.tdir = XtNewString(env_tmpdir);
+    else if ((env_tmpdir = getenv("TMPDIR")) && can_write(env_tmpdir))
+      app_resources.tdir = XtNewString(env_tmpdir);
+    else if (!can_write(app_resources.tdir)) {
 	if (can_write(TMP)) {
 	    if (strlen(app_resources.tdir)>=strlen(TMP)) 
 	      strcpy(app_resources.tdir,TMP);
######## end debian-misc-fixes.diff
######## begin debian-xresources.diff
diff -urN ../xwave-0.6-orig/src/XWave ./src/XWave
--- ../xwave-0.6-orig/src/XWave	Tue Nov 19 21:25:36 1996
+++ ./src/XWave	Sun Nov 17 21:09:10 2002
@@ -1,9 +1,9 @@
 ! My self defined Resources
 
-XWave*wdir: 					/usr/share/data/sounds/prosonus
+XWave*wdir: 					/
 XWave*tdir:					/tmp
 XWave*device:					/dev/dsp
-XWave*maxmem:					1000
+XWave*maxmem:					16384
 XWave*doubleplay:				False
 XWave*raisecanvas:				False
 
@@ -56,7 +56,7 @@
 XWave*err_bg:					Error in child procedure !\nTake a look at stdout for more info !\n
 XWave*err_nohome:				No $HOME environment variable !\n
 XWave*err_notmp:				No tmp directory,\nor no write permissions to tmp directory !\n
-XWave*err_notimplement:				Sorry ! Only available with samples which fit complete in memory !\n
+XWave*err_notimplement:				Sorry ! Only available with samples which fit complete in memory !\nTry starting xwave with the -maxmem option or change the XWave*maxmem resource.\n
 
 ! Main window
 
######## end debian-xresources.diff
######## begin fname-string-overflow.diff
--- src/misc.c.old	1996-11-11 20:38:03 +0900
+++ src/misc.c	2006-05-21 14:01:15 +0900
@@ -198,7 +198,7 @@
     XtVaGetValues(w,XtNfont,&font,XtNwidth,&width,NULL);
     dim=XTextWidth(font,fname,strlen(fname));
     if (dim>width) {
-	char *fn=XtMalloc(strlen(fname)),*fp;
+	char *fn=XtMalloc(strlen(fname)+4),*fp;
 	int i=strlen(fname);
 	int pdim;
 	strcpy(fn,"...");
######## end fname-string-overflow.diff
######## begin graphics-off-by-one.diff
--- src/graphics.c.old	1996-11-25 21:33:43 +0900
+++ src/graphics.c	2006-02-09 14:30:30 +0900
@@ -385,6 +385,7 @@
 		if (y<lines_l[j]) lines_l[j]=y;
 		if (y>lines_l[j+1]) lines_l[j+1]=y;
 		if ((float)i>step) {
+		    if (k>=width-1) break;
 		    lines_l[j]=height-lines_l[j];
 		    lines_l[j+1]=height-lines_l[j+1];
 		    XDrawLine(dpy,win,md->mg->gcl,k,lines_l[j],k,lines_l[j+1]);
@@ -412,6 +413,7 @@
 		if (y<lines_r[j]) lines_r[j]=y;
 		if (y>lines_r[j+1]) lines_r[j+1]=y;
 		if ((float)i>step) {
+		    if (k>=width-1) break;
 		    lines_l[j]>>=1;lines_l[j+1]>>=1;
 		    lines_l[j]=base-lines_l[j];
 		    lines_l[j+1]=base-lines_l[j+1];
@@ -460,6 +462,7 @@
 		if (y<lines_l[j]) lines_l[j]=y;
 		if (y>lines_l[j+1]) lines_l[j+1]=y;
 		if ((float)i>step) {
+		    if (k>=width-1) break;
 		    lines_l[j]=height-lines_l[j];
 		    lines_l[j+1]=height-lines_l[j+1];
 		    XDrawLine(dpy,win,md->mg->gcl,k,lines_l[j],k,lines_l[j+1]);
@@ -491,6 +494,7 @@
 		if (y<lines_r[j]) lines_r[j]=y;
 		if (y>lines_r[j+1]) lines_r[j+1]=y;
 		if ((float)i>step) {
+		    if (k>=width-1) break;
 		    lines_l[j]>>=1;lines_l[j+1]>>=1;
 		    lines_l[j]=base-lines_l[j];
 		    lines_l[j+1]=base-lines_l[j+1];
@@ -655,6 +659,7 @@
 		    m++;
 		}
 		y=data[i]*factor;
+		if (y>=height) y=height-1;
 		if (!ispointl[y]) { 
 		    ispointl[y]=True;
 		    pointsl[k].y=height_s-y;
@@ -679,6 +684,7 @@
 		}
 		y=data[i]*factor;
 		i++;
+		if (y>=height/2) y=height/2-1;
 		if (!ispointl[y]) { 
 		    ispointl[y]=True;
 		    pointsl[k].y=base_s-y;
@@ -687,6 +693,7 @@
 		}
 		y=data[i]*factor;
 		i++;
+		if (y>=height/2) y=height/2-1;
 		if (!ispointr[y]) { 
 		    ispointr[y]=True;
 		    pointsr[l].y=base+(base_s-y);
@@ -711,8 +718,9 @@
 		    k=0;
 		    m++;
 		}
-		value=data16[i]+32767;
+		value=data16[i]+32768;
 		y=value*factor;
+		if (y>=height) y=height-1;
 		if (!ispointl[y]) { 
 		    ispointl[y]=True;
 		    pointsl[k].y=height_s-y;
@@ -735,18 +743,20 @@
 		    l=0;
 		    m++;
 		}
-		value=data16[i]+32767;
+		value=data16[i]+32768;
 		y=value*factor;
 		i++;
+		if (y>=height/2) y=height/2-1;
 		if (!ispointl[y]) { 
 		    ispointl[y]=True;
 		    pointsl[k].y=base_s-y;
 		    pointsl[k].x=m;
 		    k++;
 		}
-		value=data16[i]+32767;
+		value=data16[i]+32768;
 		y=value*factor;
 		i++;
+		if (y>=height/2) y=height/2-1;
 		if (!ispointr[y]) { 
 		    ispointr[y]=True;
 		    pointsr[l].y=base+(base_s-y);
@@ -825,19 +835,19 @@
 	
 	if (nw->wd->channels==MONO) {
 	    for (i=0;i<length;i++) {
-		value=data16[i]+32767;
+		value=data16[i]+32768;
 		y=value*factor;
 		pointsl[i].y=height_s-y;
 		pointsl[i].x=i;
 	    }
 	} else { 
 	    for (i=0,j=0;i<length;i++) {
-		value=data16[j]+32767;
+		value=data16[j]+32768;
 		y=value*factor;
 		pointsl[i].y=base_s-y;
 		pointsl[i].x=i;
 		j++;
-		value=data16[j]+32767;
+		value=data16[j]+32768;
 		y=value*factor;
 		pointsr[i].y=base+(base_s-y);
 		pointsr[i].x=i;
@@ -931,7 +941,7 @@
 	
 	if (nw->wd->channels==MONO) {
 	    for (i=0,j=0,k=0; i<length;i++,j++) {
-		y=data16[i]+32767;
+		y=data16[i]+32768;
 		if (y>left_u) left_u=y;if (y<left_b) left_b=y;
 		if (j==nw->cg->step) {
 		    left_u*=factor;left_b*=factor;
@@ -947,9 +957,9 @@
 	    XDrawLine(dpy,win,nw->cg->gcl,k,left_b,k,left_u);
 	} else { 
 	    for (i=0,j=0,k=0; i<length*2;j++) {
-		y=data16[i]+32767;i++;
+		y=data16[i]+32768;i++;
 		if (y>left_u) left_u=y;if (y<left_b) left_b=y;
-		y=data16[i]+32767;i++;
+		y=data16[i]+32768;i++;
 		if (y>right_u) right_u=y;if (y<right_b) right_b=y;
 		if (j==nw->cg->step) {
 		    left_u*=factor;left_b*=factor;
@@ -1121,7 +1131,7 @@
 		    if (af_read(af,(char*)data16,MAXUSHORT)==AF_ERROR) return;
 		    n=0;
 		}
-		value=data16[n]+32767;
+		value=data16[n]+32768;
 		y=value*factor;
 		if (!ispointl[y]) { 
 		    ispointl[y]=True;
@@ -1134,7 +1144,7 @@
 	} else { 
 	    for (i=0,j=0,k=0,l=0,m=0,n=0; i<length;i++,j++) {	
 		if (j==nw->cg->step) {
-		    for (j=0;j<=height/2;j++) { 
+		    for (j=0;j<height/2;j++) { 
 			ispointl[j]=False;   /* clear test array */
 			ispointr[j]=False;   /* clear test array */
 		    }
@@ -1149,7 +1159,7 @@
 		    if (af_read(af,(char*)data16,MAXUSHORT)==AF_ERROR) return;
 		    n=0;
 		}
-		value=data16[n]+32767;
+		value=data16[n]+32768;
 		y=value*factor;
 		n++;
 		if (!ispointl[y]) { 
@@ -1158,7 +1168,7 @@
 		    pointsl[k].x=m;
 		    k++;
 		}
-		value=data16[n]+32767;
+		value=data16[n]+32768;
 		y=value*factor;
 		n++;
 		if (!ispointr[y]) { 
@@ -1257,7 +1267,7 @@
 		    if (af_read(af,(char*)data16,MAXUSHORT)==AF_ERROR) return;
 		    n=0;
 		}
-		value=data16[n]+32767;
+		value=data16[n]+32768;
 		y=value*factor;
 		pointsl[i].y=height_s-y;
 		pointsl[i].x=i;
@@ -1268,12 +1278,12 @@
 		    if (af_read(af,(char*)data16,MAXUSHORT)==AF_ERROR) return;
 		    n=0;
 		}
-		value=data16[n]+32767;
+		value=data16[n]+32768;
 		y=value*factor;
 		pointsl[i].y=base_s-y;
 		pointsl[i].x=i;
 		n++;
-		value=data16[n]+32767;
+		value=data16[n]+32768;
 		y=value*factor;
 		pointsr[i].y=base+(base_s-y);
 		pointsr[i].x=i;
@@ -1386,7 +1396,7 @@
 		    if (af_read(af,(char*) data16,MAXUSHORT)==AF_ERROR) return;
 		    n=0;
 		}
-		y=data16[n]+32767;
+		y=data16[n]+32768;
 		if (y>left_u) left_u=y;if (y<left_b) left_b=y;
 		if (j==nw->cg->step) {
 		    left_u*=factor;left_b*=factor;
@@ -1406,9 +1416,9 @@
 		    if (af_read(af,(char*) data16,MAXUSHORT)==AF_ERROR) return;
 		    n=0;
 		}
-		y=data16[n]+32767;n++;
+		y=data16[n]+32768;n++;
 		if (y>left_u) left_u=y;if (y<left_b) left_b=y;
-		y=data16[n]+32767;n++;
+		y=data16[n]+32768;n++;
 		if (y>right_u) right_u=y;if (y<right_b) right_b=y;
 		if (j==nw->cg->step) {
 		    left_u*=factor;left_b*=factor;
######## end graphics-off-by-one.diff
######## begin loop-button.diff
diff -urN ../xwave-0.6-orig/src/bitmaps/loop_off.xbm ./src/bitmaps/loop_off.xbm
--- ../xwave-0.6-orig/src/bitmaps/loop_off.xbm	Thu Jan  1 09:00:00 1970
+++ ./src/bitmaps/loop_off.xbm	Sun Nov 17 21:09:17 2002
@@ -0,0 +1,6 @@
+#define loop_off_width 15
+#define loop_off_height 15
+static unsigned char loop_off_bits[] = {
+  0x08, 0x60, 0xcc, 0x7b, 0xfc, 0x3f, 0xfe, 0x1f, 0xbe, 0x1f, 0xfc, 0x3b,
+  0xf0, 0x39, 0x78, 0x38, 0x3e, 0x1c, 0x1f, 0x1e, 0xff, 0x1f, 0xfb, 0x07,
+  0xe1, 0x03, 0x00, 0x00, 0x00, 0x00, };
diff -urN ../xwave-0.6-orig/src/bitmaps/loop_on.xbm ./src/bitmaps/loop_on.xbm
--- ../xwave-0.6-orig/src/bitmaps/loop_on.xbm	Thu Jan  1 09:00:00 1970
+++ ./src/bitmaps/loop_on.xbm	Sun Nov 17 21:09:17 2002
@@ -0,0 +1,6 @@
+#define loop_on_width 15
+#define loop_on_height 15
+static unsigned char loop_on_bits[] = {
+  0x08, 0x00, 0xcc, 0x03, 0xfc, 0x0f, 0xfe, 0x1f, 0x3e, 0x1c, 0x3c, 0x38,
+  0x60, 0x38, 0x00, 0x38, 0x18, 0x1c, 0x1c, 0x1e, 0xf8, 0x1f, 0xf8, 0x07,
+  0xe0, 0x03, 0x00, 0x00, 0x00, 0x00, };
diff -urN ../xwave-0.6-orig/src/button.c ./src/button.c
--- ../xwave-0.6-orig/src/button.c	Tue Nov 19 21:27:11 1996
+++ ./src/button.c	Sun Nov 17 21:09:17 2002
@@ -68,6 +68,8 @@
 #include "bitmaps/begin.xbm"
 #include "bitmaps/end.xbm"
 #include "bitmaps/zoom.xbm"
+#include "bitmaps/loop_on.xbm"
+#include "bitmaps/loop_off.xbm"
 
 char begin_text[MAX_NUMLENGTH]="0";
 char length_text[MAX_NUMLENGTH]="0";
@@ -75,16 +77,21 @@
 Pixmap upBitmap = None;
 Pixmap downBitmap = None;
 bool button_2=False;
+static bool Loop_on=False,Loop=False;
+static Pixmap loop_onBitmap = None;
+static Pixmap loop_offBitmap = None;
 
 extern Main_Data *MD;
 
 static void try_record(Widget w, XtPointer client_data, XtPointer call_data);
+static void change_bitmap(Widget w, Pixmap bitmap); 
+static void try_loop(Widget w, XtPointer client_data, XtPointer call_data);
 static void button_2_on();
 static void button_2_off();
 static Boolean set_playline(XtPointer client_data);
 
 static int pid=-1;
-static Widget buttons[16];
+static Widget buttons[17];
 static int last_pos;
 static XtWorkProcId p_id;
 static time_t start_clock;
@@ -137,6 +144,8 @@
     stopBitmap= XCBFD(dpy,win,(char *)stop_bits,stop_width,stop_height);
     playBitmap= XCBFD(dpy,win,(char *)play_bits,play_width,play_height);
     recordBitmap= XCBFD(dpy,win,(char *)record_bits,record_width,record_height);
+    loop_onBitmap= XCBFD(dpy,win,(char *)loop_on_bits,loop_on_width,loop_on_height);
+    loop_offBitmap= XCBFD(dpy,win,(char *)loop_off_bits,loop_off_width,loop_off_height);
     upBitmap= XCBFD(dpy,win,(char *)up_bits,up_width,up_height);
     downBitmap= XCBFD(dpy,win,(char *)down_bits,down_width,down_height);
     
@@ -213,6 +222,17 @@
     
     XtAddCallback (buttons[i], XtNcallback, try_record, (XtPointer) MD);
     
+    i++;
+    buttons[i]= MW ("bb_loop_btn",commandWidgetClass,w,
+		    XtNfromHoriz,buttons[i-1],
+		    XtNtop,XawChainTop,XtNbottom,XawChainTop,
+		    XtNbitmap, loop_offBitmap,
+		    XtNsensitive, MD->mb->canplay,
+		    XtNleft,XawChainLeft,XtNright,XawChainLeft,
+		    NULL);
+    
+    XtAddCallback (buttons[i], XtNcallback, try_loop, (XtPointer) MD);
+    
     label = MW ("bb_begin_label",labelWidgetClass,w,
 		XtNfromHoriz,buttons[i],
 		XtNborderWidth,0,
@@ -425,12 +445,34 @@
     record_dialog(md);
 }
 
+void change_bitmap(Widget w, Pixmap bitmap)
+{
+   Arg wargs[1];
+   int n=0;
+		
+     XtSetArg(wargs[n],XtNbitmap, bitmap); n++;
+     XtSetValues(w,wargs,n);
+}
+ 
+void try_loop(Widget w, XtPointer client_data, XtPointer call_data)
+{
+    Loop_on = !Loop_on;
+    
+    if(Loop_on)
+      change_bitmap(w,loop_onBitmap);
+    else
+      change_bitmap(w,loop_offBitmap);
+}
+
 void play_it(Widget w, XtPointer client_data, XtPointer call_data)
 {
     void abort_playing();
     Main_Data *md=(Main_Data*) client_data;
     int pid_status;
-    
+   
+    if (!MD->wd->ismark && Loop_on)
+       change_bitmap(buttons[B_LOOP],loop_offBitmap);
+
     signal(SIGUSR1,abort_playing);
     menu_state(False);
     if (md->mb->playing) {
@@ -444,12 +486,15 @@
     
     md->mb->playing=True;
     button_state(False);
-    
+    Loop=Loop_on && MD->wd->ismark;
     pid= fork();
     if (!pid) {
-     	XtDestroyApplicationContext(XtWidgetToApplicationContext(w));
-     	play_buffer(md);   
-    	exit(0);
+ 	   XtDestroyApplicationContext(XtWidgetToApplicationContext(w));
+           do{
+     	       play_buffer(md);
+             }while(Loop);
+    Loop=False;
+      	   exit(0);
     } else if (pid<=0) {
    	md->mb->playing=FALSE;
         button_state(True);
@@ -475,7 +520,11 @@
 {
     Main_Data *md=(Main_Data*) client_data;
     int pid_status;
-    
+
+    if (Loop_on)
+       change_bitmap(buttons[B_LOOP],loop_onBitmap);
+    Loop=False;
+
     if (md->mb->playing) {
 	kill((pid_t)pid,SIGKILL);
 	waitpid((pid_t)pid, &pid_status, 0);
@@ -494,10 +543,18 @@
 {
     int pid_status;
 
-    set_button_state(B_STOP,B_PLAY,False);
-    signal(SIGUSR1,SIG_IGN);
+  if(Loop)
+  {
+    signal(SIGUSR1,abort_playing);
+    start_clock=clock();
+    return;
+  } 
+  if (Loop_on)
+     change_bitmap(buttons[B_LOOP],loop_onBitmap);
     waitpid((pid_t)pid, &pid_status,0);
     pid=-1;
+    signal(SIGUSR1,SIG_IGN);
+    set_button_state(B_STOP,B_PLAY,False);
     MD->mb->playing=FALSE;
     button_state(True);
     menu_state(True);
@@ -538,10 +595,17 @@
     
     if (last_pos>=0 && last_pos<md->mg->width) clear_line(last_pos);
     last_pos=now_pos;
-    
     if ((!md->mb->playing)||now_pos>=end) {
 	if (md->wd->isplay) set_line(md->wd->markbeg/md->mg->step);
-	return(True);
+	
+        if(!Loop)
+          return(True);
+        else
+        { 
+           last_pos=now_pos=md->wd->markbeg/md->mg->step;
+           last_pos--;
+           return False;
+        }
     }
     
     set_line(now_pos);
diff -urN ../xwave-0.6-orig/src/button.h ./src/button.h
--- ../xwave-0.6-orig/src/button.h	Thu Nov  7 07:42:02 1996
+++ ./src/button.h	Sun Nov 17 21:09:17 2002
@@ -9,17 +9,18 @@
 #define B_STOP 4
 #define B_PLAY 5
 #define B_REC 6
-#define B_BEG 7
-#define B_BUP 8
-#define B_BDOWN 9
-#define B_LENGTH 10
-#define B_LUP 11
-#define B_LDOWN 12
-#define B_ZOOM 13
-#define B_ZUP 14
-#define B_ZDOWN 15
+#define B_LOOP 7
+#define B_BEG 8
+#define B_BUP 9
+#define B_BDOWN 10
+#define B_LENGTH 11
+#define B_LUP 12
+#define B_LDOWN 13
+#define B_ZOOM 14
+#define B_ZUP 15
+#define B_ZDOWN 16
 
-#define B_LAST 15
+#define B_LAST 16
 
 void create_button(Widget);
 void set_button_state(int,int,bool);
diff -urN ../xwave-0.6-orig/src/status.c ./src/status.c
--- ../xwave-0.6-orig/src/status.c	Thu Oct 24 05:36:34 1996
+++ ./src/status.c	Sun Nov 17 21:09:17 2002
@@ -147,6 +147,7 @@
     if (md->no==1) {
 	set_button_state(B_BEG,B_ZDOWN,True);
 	set_button_state(B_PLAY,B_REC,md->mb->canplay);
+	set_button_state(B_LOOP,B_LOOP,md->mb->canplay);
 	set_menu_state(M_SAVEAS,M_CLOSE,True);
 	set_menu_state(M_ECHO,M_PROPS,True);
 	set_cmenu_state(CM_PLAY,CM_PLAY,md->mb->canplay);
######## end loop-button.diff
######## begin no-backing-store-warning.diff
diff -urN ../xwave-0.6-orig/src/xwave.c ./src/xwave.c
--- ../xwave-0.6-orig/src/xwave.c	Thu Nov 21 19:19:15 1996
+++ ./src/xwave.c	Sun Nov 17 21:09:14 2002
@@ -615,9 +620,11 @@
      if (XInternAtom(dpy, "_SUN_WM_PROTOCOLS", TRUE)!=None)
      	warn_popup(w,"SUN WM present (olwm,olvwm), expect problems !");
      */
+    /*
     if (DoesBackingStore(DefaultScreenOfDisplay(dpy))==NotUseful) {
 	warn_popup(w,"Your X-Server doesn't support BackingStore !\nThis will slow down the screen updates !");
     }
+    */
     if (!MD->mb->canplay) {
 	warn_popup(w,"Couldn't access audio device !\nNo play and record !");
     }
######## end no-backing-store-warning.diff
######## begin widgets-off-by-one.diff
--- src/menu.c.old	1996-11-23 20:27:48 +0900
+++ src/menu.c	2005-04-11 15:18:45 +0900
@@ -76,7 +76,7 @@
 static Pixmap pullBitmap = None;
 static Widget listpopup,wlist;
 static int lcounter=0;
-static Widget cm_widgets[CM_ALL];
+static Widget cm_widgets[CM_ALL+1];
 static Next_Wave **lnw=NULL;
 
 static RightMenuItem items_paste[]={
######## end widgets-off-by-one.diff
EOT
NoPatch: <<EOT
######## begin fix for >2GB files (unstable?)
--- src/audio.c.old	1996-11-26 19:13:44 +0900
+++ src/audio.c	2005-08-26 19:56:04 +0900
@@ -437,7 +437,8 @@
     int buf_size;
     byte *buffer;
     Wave_Data *wd=md->wd;
-    int offset=0,playlength,length;
+    int offset=0,length;
+    unsigned int playlength;
 #ifdef sgi
     ALport port;
 #elif defined(linux) || defined (FreeBSD) || defined (sun)
@@ -481,7 +482,7 @@
 	    }
 #elif defined(sgi)
 	    if (ALwritesamps(port,buffer,buf_size/(wd->res/8))==-1) {
-		printf("error while writing port (playlength=%i)!\n",playlength);
+		printf("error while writing port (playlength=%u)!\n",playlength);
 		ALcloseport(port);
 		kill((pid_t) getppid(),SIGUSR1);
 		return;
--- src/edit.c.old	1996-11-08 02:26:29 +0900
+++ src/edit.c	2005-08-26 20:22:09 +0900
@@ -55,7 +55,8 @@
 void begin_up(Widget w, XtPointer client_data, XtPointer call_data)
 {
     Main_Data *md=(Main_Data*) client_data;
-    int beg=0,x=0,nx=0;
+    unsigned int beg=0;
+    int x=0,nx=0;
     
     if (md->wd->markbeg==md->wd->tlength) return;
     
@@ -147,7 +148,8 @@
 void length_up(Widget w, XtPointer client_data, XtPointer call_data)
 {
     Main_Data *md=(Main_Data*) client_data;
-    int length=0,x=0,nx=0;
+    unsigned int length=0;
+    int x=0,nx=0;
     
     if (md->wd->markbeg+md->wd->marklength==md->wd->tlength) return;
     
@@ -186,7 +188,8 @@
 void length_down(Widget w, XtPointer client_data, XtPointer call_data)
 {
     Main_Data *md=(Main_Data*) client_data;
-    int length=0,x=0,nx=0;
+    unsigned int length=0;
+    int x=0,nx=0;
     
     if (md->wd->marklength==0) return;
 
@@ -259,19 +262,19 @@
 
 void begin_enter()
 {
-    int begin,i;
+    unsigned int begin,i;
     Main_Data *md=MD;
     
     if (strlen(begin_text)==0) return;
     
-    begin=atoi(begin_text);
+    begin=strtoul(begin_text,NULL,10);
     
     i=strlen(begin_text)-1;
-    while (i>=0) if (!isdigit(begin_text[i--])) begin=-1;
+    while (i>=0) if (!isdigit(begin_text[i--])) begin=md->wd->tlength;
     
-    if ((begin<0)||(begin>md->wd->tlength)) {
+    if (begin>=md->wd->tlength) {
 	sprintf(md->mw->messages,"%s %i - %i",
-		app_resources.err_input,0,md->wd->tlength);
+		app_resources.err_input,0,md->wd->tlength-1);
 	warn_popup(md->mw->form,md->mw->messages);
 	return;
     }
@@ -304,15 +307,15 @@
 
 void length_enter()
 {
-    int length,begin,i;
+    unsigned int length,begin,i;
     Main_Data *md=MD;
     
     if (strlen(length_text)==0) return;
     
-    length=atoi(length_text);
+    length=strtoul(length_text,NULL,10);
     
     i=strlen(length_text)-1;
-    while (i>=0) if (!isdigit(length_text[i--])) length=-1;
+    while (i>=0) if (!isdigit(length_text[i--])) length=md->wd->tlength-begin+1;
     
     if (length==md->wd->marklength) return;
     
@@ -320,7 +323,7 @@
     
     if (begin<0) begin=0;
     
-    if ((length<0)||(begin+length>md->wd->tlength)) {
+    if (begin+length>md->wd->tlength) {
 	sprintf(md->mw->messages,"%s %i - %i",app_resources.err_input,
 		0,md->wd->tlength-begin);
 	warn_popup(md->mw->form,md->mw->messages);
@@ -388,7 +391,8 @@
     Main_Data *md=(Main_Data *) client_data;
     Wave_Data *wd=md->wd;
     Wave_Data *clip_wd=md->cd->wd;
-    int length,begin,peak,clip_peak;
+    unsigned int length,begin;
+    int peak,clip_peak;
     float factor1,factor2,maxval;
     
     if (!md->mb->isclip) return;
@@ -456,7 +460,8 @@
 	}
     } else {
 	Audio_File af,new_af,clip_af;
-	int i,toread;
+	unsigned int i;
+	int toread;
 	char *oldname=NULL,*outbuf,*clipbuf;
 	
 	
@@ -614,7 +619,8 @@
     Main_Data *md=(Main_Data *) client_data;
     Wave_Data *wd=md->wd;
     Wave_Data *clip_wd=md->cd->wd;
-    int i,toread,length,begin;
+    int toread;
+    unsigned int i,length,begin;
     Audio_File clip_af;
     
     if (!md->mb->isclip) return;
@@ -938,7 +944,7 @@
 	memcpy(wd->buffer,clip_wd->buffer,clip_wd->length);
     } else {
 	Audio_File af,clip_af;
-	int count,i;
+	unsigned int count,i;
 	
 	/* prepare error message for file error */
 	sprintf(md->mw->messages,"%s\n\"%s\" !",app_resources.err_openfile,
@@ -1113,7 +1119,7 @@
 {
     Main_Data *md=(Main_Data *) client_data;
     Wave_Data *wd=md->wd;
-    int beg,length,offset;
+    unsigned int beg,length,offset;
     
     copy_call(w,client_data,call_data);
     
@@ -1156,7 +1162,8 @@
     } else {
 	Audio_File af,new_af;
 	char *oldname;
-	int i,toread;
+	unsigned int i;
+	int toread;
 	
 	oldname=wd->actual_name;
 	
--- src/effects.c.old	1996-11-19 23:57:27 +0900
+++ src/effects.c	2005-08-26 20:16:11 +0900
@@ -48,15 +48,15 @@
 extern Main_Data *MD;
 extern AppResources app_resources;
 
-static void reverse_8(char *buffer,int channels,int length);
-static void reverse_16(short *buffer,int channels,int length);
-static void swap_8(char *buffer,int length);
-static void swap_16(short *buffer,int length);
+static void reverse_8(char *buffer,int channels,unsigned int length);
+static void reverse_16(short *buffer,int channels,unsigned int length);
+static void swap_8(char *buffer,unsigned int length);
+static void swap_16(short *buffer,unsigned int length);
 static void props_return(Sample_Return *sr);
-static void resample_16(int inlength,int infreq,short *inbuf,
-			int outlength,int outfreq,short *outbuf);
-static void resample_8(int inlength,int infreq,byte *inbuf,
-		       int outlength,int outfreq,byte *outbuf);
+static void resample_16(unsigned int inlength,int infreq,short *inbuf,
+			unsigned int outlength,int outfreq,short *outbuf);
+static void resample_8(unsigned int inlength,int infreq,byte *inbuf,
+		       unsigned int outlength,int outfreq,byte *outbuf);
 static void av_return(float mult1,float mult2);
 static void ev_return(float fo_time[MAX_CHANNELS],
 		      float fo_factor[MAX_CHANNELS],
@@ -65,9 +65,9 @@
 		      float fo_factor[MAX_CHANNELS]);
 
 
-void reverse_8(char *buffer,int channels,int length)
+void reverse_8(char *buffer,int channels,unsigned int length)
 {
-    int i,j,hi,lo;
+    unsigned int i,j,hi,lo;
     static char valbuf[MAX_CHANNELS];
     
     if (channels>MAX_CHANNELS) return;
@@ -85,9 +85,9 @@
     }
 }
 
-void reverse_16(short *buffer,int channels,int length)
+void reverse_16(short *buffer,int channels,unsigned int length)
 {
-    int i,j,hi,lo;
+    unsigned int i,j,hi,lo;
     static short valbuf[MAX_CHANNELS];
     
     if (channels>MAX_CHANNELS) return;
@@ -108,7 +108,7 @@
 void reverse_call(Widget w, XtPointer client_data, XtPointer call_data)
 {
     Main_Data *md=(Main_Data*) client_data;
-    int length;
+    unsigned int length;
     char *buf=(char*)md->wd->buffer;
     
     if (!md->wd->inmem) {
@@ -142,9 +142,9 @@
     watch_cursor(False);
 }
 
-void swap_8(char *buffer,int length)
+void swap_8(char *buffer,unsigned int length)
 {
-    int i;
+    unsigned int i;
     char val;
     
     for (i=0;i<length;i+=2) {
@@ -154,9 +154,9 @@
     }
 }
 
-void swap_16(short *buffer,int length)
+void swap_16(short *buffer,unsigned int length)
 {
-    int i;
+    unsigned int i;
     short val;
     
     for (i=0;i<length;i+=2) {
@@ -169,7 +169,7 @@
 void swap_call(Widget w, XtPointer client_data, XtPointer call_data)
 {
     Main_Data *md=(Main_Data*) client_data;
-    int length;
+    unsigned int length;
     char *buf=(char*)md->wd->buffer;
     
     
@@ -224,14 +224,14 @@
 
 void props_return(Sample_Return *sr)
 {
-    int i;
+    unsigned int i;
     Main_Data *md=MD;
     Wave_Data *wd=md->wd;
     
     watch_cursor(True);
     
     if (sr->freq!=wd->freq) {
-	int newlength;
+	unsigned int newlength;
 	char *newbuf,*sbufin=NULL,*sbufout=NULL;
 	
 	newlength=(int)((double)sr->freq/
@@ -453,11 +453,12 @@
     watch_cursor(False);
 }
 
-void resample_16(int inlength,int infreq,short *inbuf,
-		 int outlength,int outfreq,short *outbuf)
+void resample_16(unsigned int inlength,int infreq,short *inbuf,
+		 unsigned int outlength,int outfreq,short *outbuf)
 {
-    int lcmrate,inskip,outskip,intot,outtot;
-    int len,done,val,last;
+    unsigned int lcmrate,inskip,outskip,intot,outtot;
+    unsigned int len,done;
+    int val,last;
     
     lcmrate=lcm(infreq,outfreq);
     inskip=lcmrate/infreq;
@@ -484,11 +485,12 @@
     }
 }
 
-void resample_8(int inlength,int infreq,byte *inbuf,
-		int outlength,int outfreq,byte *outbuf)
+void resample_8(unsigned int inlength,int infreq,byte *inbuf,
+		unsigned int outlength,int outfreq,byte *outbuf)
 {
-    int lcmrate,inskip,outskip,intot,outtot;
-    int len,done,val,last;
+    unsigned int lcmrate,inskip,outskip,intot,outtot;
+    unsigned int len,done;
+    int val,last;
     
     lcmrate=lcm(infreq,outfreq);
     inskip=lcmrate/infreq;
@@ -535,10 +537,11 @@
 
 void av_return(float mult1,float mult2)
 {
-    int i,new_val,max;
+    unsigned int i;
+    int new_val,max;
     Main_Data *md=MD;
     Wave_Data *wd=md->wd;
-    int length=wd->length;
+    unsigned int length=wd->length;
     char *buf=(char*)wd->buffer;
     
     watch_cursor(True);
@@ -645,8 +648,9 @@
     Wave_Data *wd=md->wd;
     char *buf;
     float k;
-    int i,j,value,env,time_wait,time_index,k_index,max,min_amp;
-    int length=wd->length;
+    unsigned int i;
+    int j,value,env,time_wait,time_index,k_index,max,min_amp;
+    unsigned int length=wd->length;
     
     watch_cursor(True);
     
@@ -763,8 +767,9 @@
     Main_Data *md=MD;
     Wave_Data *wd=md->wd;
     char *ring,*buf;
-    int i,j,echo,ring_length,ring_count;
-    int length=wd->length;
+    unsigned int i;
+    int j,echo,ring_length,ring_count;
+    unsigned int length=wd->length;
     float teiler;
     
     watch_cursor(True);
@@ -838,9 +843,10 @@
 
 void find_peak(Wave_Data *wd)
 {
-    int i,peak_r=0,peak_l=0;
+    unsigned int i;
+    int peak_r=0,peak_l=0;
     char *buffer;
-    int begin=0,length=wd->length;
+    unsigned int begin=0,length=wd->length;
     
     if (wd->ismark) {
 	begin=wd->markbeg*wd->bpspl;
@@ -1002,10 +1008,10 @@
 
 
 /* merge buf2 into buf1, buf1 must be bigger than buf2 */
-void merge_8(char *buf1,char *buf2,int length,float factor1,float factor2)
+void merge_8(char *buf1,char *buf2,unsigned int length,float factor1,float factor2)
 {
     char val1,val2;
-    int i;
+    unsigned int i;
     
     if (factor1==factor2) {
 	for (i=0;i<length;i++) {
@@ -1034,10 +1040,10 @@
 }
 
 /* merge buf2 into buf1, buf1 must be bigger than buf2 */
-void merge_16(short *buf1,short *buf2,int length,float factor1,float factor2)
+void merge_16(short *buf1,short *buf2,unsigned int length,float factor1,float factor2)
 {
     short val1,val2;
-    int i;
+    unsigned int i;
     
     if (factor1==factor2) {
 	for (i=0;i<length;i++) {
--- src/effects.h.old	1996-10-19 21:46:44 +0900
+++ src/effects.h	2005-08-26 20:28:00 +0900
@@ -5,7 +5,7 @@
 void props_call(Widget,XtPointer,XtPointer);
 void abs_vol_call(Widget,XtPointer,XtPointer);
 void env_vol_call(Widget,XtPointer,XtPointer);
-void merge_8(char *,char *,int,float,float);
-void merge_16(short *,short *,int,float,float);
+void merge_8(char *,char *,unsigned int,float,float);
+void merge_16(short *,short *,unsigned int,float,float);
 void find_peak(Wave_Data *);
    
--- src/graphics.c.old	1996-11-25 21:33:43 +0900
+++ src/graphics.c	2005-08-26 20:26:48 +0900
@@ -60,12 +60,12 @@
 
 static void update_display_mem(Main_Data*,Display*,Window);
 static void update_display_file(Main_Data*,Display*,Window);
-static void update_canvas_mem(Next_Wave*,Display*,Window,Dimension,int);
-static void update_canvas_mem_1(Next_Wave*,Display*,Window,Dimension,int);
-static void update_canvas_mem_lines(Next_Wave*,Display*,Window,Dimension,int);
-static void update_canvas_file(Next_Wave*,Display*,Window,Dimension,int);
-static void update_canvas_file_1(Next_Wave*,Display*,Window,Dimension,int);
-static void update_canvas_file_lines(Next_Wave*,Display*,Window,Dimension,int);
+static void update_canvas_mem(Next_Wave*,Display*,Window,Dimension,unsigned int);
+static void update_canvas_mem_1(Next_Wave*,Display*,Window,Dimension,unsigned int);
+static void update_canvas_mem_lines(Next_Wave*,Display*,Window,Dimension,unsigned int);
+static void update_canvas_file(Next_Wave*,Display*,Window,Dimension,unsigned int);
+static void update_canvas_file_1(Next_Wave*,Display*,Window,Dimension,unsigned int);
+static void update_canvas_file_lines(Next_Wave*,Display*,Window,Dimension,unsigned int);
 static void set_canvas_mark(Next_Wave *nw);
 static Boolean test_focus(Main_Data*,Widget,Widget);
 static Next_Wave *get_nw(Main_Data*,Widget);
@@ -96,7 +96,7 @@
 
 void update_display_mem(Main_Data *md,Display *dpy,Window win)
 {
-    int i,j,k,l,length,height;
+    unsigned int i,j,k,l,length,height;
     Dimension width;				/* dimension of display */  
     byte *data=NULL,y;			        /* to go through the data */
     char *data16=NULL;
@@ -294,7 +294,7 @@
 
 void update_display_file(Main_Data *md,Display *dpy,Window win)
 {
-    int i,j,k,l,length,height;
+    unsigned int i,j,k,l,length,height;
     Dimension width;				/* dimension of display */  
     byte *data=NULL,y;			        /* to go through the data */
     char *data16=NULL;
@@ -525,7 +525,7 @@
     Window win;
     Display *dpy;
     Dimension width,height;	
-    int length=0;
+    unsigned int length=0;
     float top,shown;					
 
     /* if we get no nw take the one who is actual in main window */
@@ -585,12 +585,13 @@
 }
 
 void update_canvas_mem(Next_Wave *nw,Display *dpy,Window win,
-		       Dimension height,int length)
+		       Dimension height,unsigned int length)
 {
     XPoint *pointsl=NULL,*pointsr=NULL;					
     byte *ispointl=NULL,*ispointr=NULL;		/* for test, if we should set
 						 a point at this x-coord */
-    int i,j,k,l=0,m=0,y=0;
+    unsigned int i,j,k,l=0,m=0;
+    int y=0;
     byte *data=NULL;				/* to go through the data */
     ushort *data16=NULL,value;
     int base,base_s,height_s;
@@ -767,10 +768,11 @@
 }
 
 void update_canvas_mem_1(Next_Wave *nw,Display *dpy,Window win,
-			 Dimension height,int length)
+			 Dimension height,unsigned int length)
 {
     XPoint *pointsl=NULL,*pointsr=NULL;
-    int i,j,y;
+    unsigned int i,j;
+    int y;
     byte *data=NULL;				/* to go through the data */
     unsigned short *data16=NULL,value;
     int base,base_s,height_s;
@@ -857,9 +859,9 @@
 }
 
 void update_canvas_mem_lines(Next_Wave *nw,Display *dpy,Window win,
-			     Dimension height,int length)
+			     Dimension height,unsigned int length)
 {
-    int i,j,k;
+    unsigned int i,j,k;
     ushort *data16=NULL,left_u,left_b,right_u,right_b,y;
     byte *data=NULL;
     int base,base_s,height_s;
@@ -976,12 +978,13 @@
 }
 
 void update_canvas_file(Next_Wave *nw,Display *dpy,Window win,
-			Dimension height,int length)
+			Dimension height,unsigned int length)
 {
     XPoint *pointsl=NULL,*pointsr=NULL;					
     byte *ispointl=NULL,*ispointr=NULL;		/* for test, if we should set
 						 a point at this x-coord */
-    int i,j,k,l=0,m=0,n,y=0;
+    unsigned int i,j,k,l=0,m=0,n;
+    int y=0;
     byte *data=NULL;				/* to go through the data */
     ushort *data16=NULL,value;
     int base,base_s,height_s;
@@ -1181,10 +1184,11 @@
 }
 
 void update_canvas_file_1(Next_Wave *nw,Display *dpy,Window win,
-			  Dimension height,int length)
+			  Dimension height,unsigned int length)
 {
     XPoint *pointsl=NULL,*pointsr=NULL;
-    int i,n,y;
+    unsigned int i,n;
+    int y;
     byte *data=NULL;				/* to go through the data */
     unsigned short *data16=NULL,value;
     int base,base_s,height_s;
@@ -1293,9 +1297,9 @@
 }
 
 void update_canvas_file_lines(Next_Wave *nw,Display *dpy,Window win,
-			      Dimension height,int length)
+			      Dimension height,unsigned int length)
 {
-    int i,j,k,n;
+    unsigned int i,j,k,n;
     ushort *data16=NULL,left_u,left_b,right_u,right_b,y;
     byte *data=NULL;
     int base,base_s,height_s;
@@ -1825,7 +1829,7 @@
     Window win = XtWindow(nw->cw->graph);		/* get window ID */
     Display *dpy=XtDisplay(nw->cw->graph);
     Dimension width,height;
-    int beg,length;
+    unsigned int beg,length;
     
     if (!nw->wd->ismark) return;
     
@@ -1851,7 +1855,8 @@
     XEvent pev;
     XButtonEvent *ev;
     Boolean scrolled=False;
-    int x,firstpos,firstx,pos,beg,length;
+    int x,firstpos,firstx;
+    unsigned int pos,beg,length;
     
     if (md->mb->playing) return;
     /* some windowmanagers doesn't send a message if window got focus */
--- src/types.h.old	1996-11-07 07:41:53 +0900
+++ src/types.h	2005-08-26 20:25:49 +0900
@@ -40,16 +40,16 @@
     byte         *buffer;	   /* the data */
     byte	  bpspl;           /* byte per sample */
     int 	  freq;		   /* frequence */
-    int	          length;	   /* length of data in bytes */
-    int	          markbeg;	   /* the begin of the mark/playline */
-    int	          marklength;	   /* the length of the mark */
-    int 	  tlength;	   /* length / bpspl */
+    unsigned int  length;	   /* length of data in bytes */
+    unsigned int  markbeg;	   /* the begin of the mark/playline */
+    unsigned int  marklength;	   /* the length of the mark */
+    unsigned int  tlength;	   /* length / bpspl */
     int	          fd;		   /* fileno if not complete in mem */
-    int           headoffs;
+    unsigned int  headoffs;
     int           peak_l;
     int           peak_r;
-    int           ind_peak_l;      /* index (position) of peak */
-    int           ind_peak_r;
+    unsigned int  ind_peak_l;      /* index (position) of peak */
+    unsigned int  ind_peak_r;
     ulong         type;            /* AF_TYPE */
     ulong         comp;            /* AF_COMP */
     ulong         oldtype;         /* changed files on hd are saved in raw mode */
@@ -69,6 +69,6 @@
     ulong comp;
     ulong type;
     int freq;
-    int length;
-    int headoffs;
+    unsigned int length;
+    unsigned int headoffs;
 } Audio_File;
--- src/xwave.h.old	1996-10-24 04:26:57 +0900
+++ src/xwave.h	2005-08-26 20:06:23 +0900
@@ -85,13 +85,13 @@
 } Main_Graphic;
 
 typedef struct Canvas_Graphics {
-   GC	  markgc;
-   GC	  gcl;			/* Graphics Context for left */
-   GC	  gcr;			/* Graphics Context for right */
-   int 	  step;			/* actual step */
-   int	  pos;			/* actual pos. in wave */ 
-   int	  width;			
-   Pixmap pixmap; 		/* pixmap for expose */
+   GC		markgc;
+   GC		gcl;		/* Graphics Context for left */
+   GC		gcr;		/* Graphics Context for right */
+   int		step;		/* actual step */
+   unsigned int	pos;		/* actual pos. in wave */ 
+   int		width;			
+   Pixmap	pixmap;		/* pixmap for expose */
 } Canvas_Graphic;
 
 typedef struct Main_Bools {
######## end fix for >2GB files
EOT

/pkg/xwave/
/usr/X11/lib/X11/app-defaults/XWave
/usr/bin/xwave
/usr/man/man1/xwave.1.gz
