Csound Csound-dev Csound-tekno Search About

some 3.481 bug fix patches offered

Date1998-05-29 11:24
FromNicola Bernardini
Subjectsome 3.481 bug fix patches offered
I had to make some fixes in order to have my students finish projects
etc. We use linux systems so the patches were done on Linux systems
we the tools that we have available there (context diffs, patch, etc.)
The reported bugs seem to be fixed, but I don't know if the patches
break something else (a typical trend...). I post them in the hope they
can help.

Nicola

P.S. The patch on sread.c should fix the '#'-inside-comments problem reported
     in some previous mails.

------------------------------------------------------------------------
Nicola Bernardini
E-mail: nicb@axnet.it
 
Re graphics: A picture is worth 10K words -- but only those to describe
the picture.  Hardly any sets of 10K words can be adequately described
with pictures.

------------------------------------------------------------------------

opcode diskin:

1) skip time did not work at all, and file sample rate was incorrectely
   displayed (maybe Linux-specific, at any rate the code was wrong)

2) when transposition factor < 0, sound did not play if skiptime == 0

context-diff patch:
*** diskin.c.orig	Sat May 23 13:08:59 1998
--- diskin.c	Tue May 26 09:36:45 1998
***************
*** 140,146 ****
      hdrsize = hdr->hdrsize;
      p->filetyp = hdr->filetyp;  		/* copy type from headata */
      p->aiffdata = hdr->aiffdata;
!     p->sr = (short)hdr->sr;
      p->nchnls = (short)hdr->nchnls;
    }
    else {                                  /* no hdr:  find info elsewhere */
--- 140,146 ----
      hdrsize = hdr->hdrsize;
      p->filetyp = hdr->filetyp;  		/* copy type from headata */
      p->aiffdata = hdr->aiffdata;
!     p->sr = (long)hdr->sr;
      p->nchnls = (short)hdr->nchnls;
    }
    else {                                  /* no hdr:  find info elsewhere */
***************
*** 220,226 ****
      }
      else {
        p->begfile = TRUE;
!       if (*p->ktransp < 0) p->endfile = TRUE;
      }
  	 	    
      if ((n = sreadinew(sinfd,p->inbuf,SNDINEWBUFSIZ,p)) == 0) /* now rd fulbuf */
--- 220,226 ----
      }
      else {
        p->begfile = TRUE;
!       if (*p->ktransp < 0 && nbytes == p->audrem) p->endfile = TRUE;
      }
  	 	    
      if ((n = sreadinew(sinfd,p->inbuf,SNDINEWBUFSIZ,p)) == 0) /* now rd fulbuf */
------------------------------------------------------------------------

score reader:

comments get evaluated by recursive getscochar()/flushin() calls, and
special characters inside comments get evaluated (probably not what was
intended, I guess). To see what i mean, just try a sco file with a comment
like this:

; this [is] a comment

The square brackets get evaluated and the compiler stops.  The fix is not
very nice but I was scared to break something else.

context-diff patch:
*** ./sread.c.orig	Mon Apr 13 19:45:00 1998
--- ./sread.c	Wed May 27 12:48:36 1998
***************
*** 651,667 ****
  	linpos = 0;
  }
  
  static int sget1(void)		/* get first non-white, non-comment char */
  {
  	int c;
  
! srch:   while ((c = getscochar()) == SP || c == '\t' || c == LF)
  		if (c == LF) {
  			lincnt++;
  			linpos = 0;
  		}
          if (c == ';' || c == 'c') {
! 		flushlin();
  		goto srch;
  	}
          if (c == '\\') {            /* Deal with continuations and specials */
--- 651,687 ----
  	linpos = 0;
  }
  
+ /*
+  * getscochar() does so much evaluation now that we cannot use flushlin()
+  * anymore to flush comment lines (otherwise they end up being evaluated too)
+  * so I added this one just to flush comment lines; this
+  * solution is ugly as hell but hey! I'm too afraid to break things in this
+  * glass house...
+  * [nicb@axnet.it]
+  */
+ static void flushcomments(void)
+ {
+ 	int c;
+ 
+ 	while ((c = getc(str->file)) != LF && c != EOF)
+ 		;
+ 	lincnt++;
+ 	linpos = 0;
+ }
+ 
  static int sget1(void)		/* get first non-white, non-comment char */
  {
  	int c;
  
! srch:	if (c == ';' || c == 'c')	/* line-beginning comments */
! 		flushcomments();
! 	while ((c = getscochar()) == SP || c == '\t' || c == LF)
  		if (c == LF) {
  			lincnt++;
  			linpos = 0;
  		}
          if (c == ';' || c == 'c') {
! 		flushcomments();
  		goto srch;
  	}
          if (c == '\\') {            /* Deal with continuations and specials */
------------------------------------------------------------------------

mixer ancillary program:

did'nt even compile under Linux

context-diff patch:
*** util2/mixer/mixer.c.orig	Wed May 27 11:18:28 1998
--- util2/mixer/mixer.c	Wed May 27 11:19:04 1998
***************
*** 260,266 ****
                  case '8':
                      if (OO.outformat) goto outform;
                      outformch = c;
!                     OO.outformat = AE_BYTE;     /* 8-bit unsigned char file */
                      break;
                  case 'a':
                      if (OO.outformat) goto outform;
--- 260,266 ----
                  case '8':
                      if (OO.outformat) goto outform;
                      outformch = c;
!                     OO.outformat = AE_UNCH;     /* 8-bit unsigned char file */
                      break;
                  case 'a':
                      if (OO.outformat) goto outform;
***************
*** 434,440 ****
          spoutran = floatran;
          floutbuf = (float *)outbuf;
          break;
!     case AE_BYTE: 
          spoutran = bytetran;
          choutbuf = outbuf;
          break;
--- 434,440 ----
          spoutran = floatran;
          floutbuf = (float *)outbuf;
          break;
!     case AE_UNCH: 
          spoutran = bytetran;
          choutbuf = outbuf;
          break;
------------------------------------------------------------------------

function duplications (maybe Linux-specific):

we tried to build a dynamically linked library and small executables for
csound and ancillary programs under linux; the process breaks in many
places because of function duplications; the main.c file needed some
small re-organization too. I think these changes should be incorporated
if anybody else under any other system will want to build a dynamically
linked library (a .dll, in Windowese). They should not affect the code
at all if statically linked.

context-diff patches:
*** ./util2/exports/het_export.c.orig	Fri May  8 09:37:30 1998
--- ./util2/exports/het_export.c	Fri May  8 09:38:19 1998
***************
*** 23,28 ****
--- 23,29 ----
      exit(1);
  }
  
+ #if 0	/* this is in the CSOUND LIBRARY!!!! (remove from here!) */
  void err_printf(char *fmt, ...)
  {
      va_list a;
***************
*** 38,43 ****
--- 39,45 ----
      vfprintf(stdout, fmt, a);
      va_end(a);
  }
+ #endif
  
  int main(int argc, char **argv)
  {
*** ./util2/exports/pv_export.c.orig	Fri May  8 09:38:40 1998
--- ./util2/exports/pv_export.c	Fri May  8 09:39:01 1998
***************
*** 12,18 ****
  #include "pvoc.h"
  
  void usage(int);
! 
  int err_printf(char *fmt, ...)
  {
      va_list a;
--- 12,19 ----
  #include "pvoc.h"
  
  void usage(int);
!  
! #if 0
  int err_printf(char *fmt, ...)
  {
      va_list a;
***************
*** 20,25 ****
--- 21,27 ----
      vfprintf(stderr, fmt, a);
      va_end(a);
  }
+ #endif
  
  void mfree(void *p)
  {
*** ./main.c.orig	Tue Apr 28 01:18:31 1998
--- ./main.c	Fri May  8 09:39:50 1998
***************
*** 10,30 ****
  unsigned int _stack = 0xFFF0U;
  #endif
  
  static  int     ScotScore = 0, stdinassgn = 0;
- /*static*/  char        *scorename = NULL;
  static  char    *xfilename = NULL;
  static  char    *sortedscore = "score.srt";
  static  char    *xtractedscore = "score.xtr";
  static  char    *playscore = "score.srt";     /* unless we extract */
  static  FILE    *scorin, *scorout, *xfile;
-         FILE    *dribble;
  static  void    dieu(char *), usage(void);
- extern  OPARMS  O;
- char    *orchname = NULL;  /* used by rdorch */
- #ifdef LINUX
- int midi_out;
- extern void openMIDIout(void);
- #endif
  
  #define FIND(MSG)   if (*s == '\0')  \
                          if (!(--argc) || ((s = *++argv) != NULL) && *s == '-') \
--- 10,40 ----
  unsigned int _stack = 0xFFF0U;
  #endif
  
+ #if !defined(CSOUND_MAIN)
+ 	extern  OPARMS  O;
+ 	char    *orchname = NULL;	/* used by rdorch */
+ 	char	*scorename = NULL;
+         FILE    *dribble;
+ #ifdef LINUX
+ int midi_out;
+ extern void openMIDIout(void);
+ #endif
+ #else /* defined(CSOUND_MAIN) */
+ 	extern 	char *orchname; 	 /* used by rdorch */
+ 	extern 	char *scorename;
+ #ifdef LINUX
+ extern int midi_out;
+ #endif
+ #endif /* !defined(CSOUND_MAIN) */
+ 
+ #if defined(CSOUND_MAIN)
  static  int     ScotScore = 0, stdinassgn = 0;
  static  char    *xfilename = NULL;
  static  char    *sortedscore = "score.srt";
  static  char    *xtractedscore = "score.xtr";
  static  char    *playscore = "score.srt";     /* unless we extract */
  static  FILE    *scorin, *scorout, *xfile;
  static  void    dieu(char *), usage(void);
  
  #define FIND(MSG)   if (*s == '\0')  \
                          if (!(--argc) || ((s = *++argv) != NULL) && *s == '-') \
***************
*** 34,40 ****
--- 44,52 ----
  void dialog_arguments(void);
  #include 
  extern int cwin_atexit(void (*)(void));
+ #endif /* CWIN */
  
+ #if defined(CWIN)
  int cwin_main(int argc, char **argv)
  #else
  int main(int argc, char **argv)
***************
*** 532,537 ****
--- 544,552 ----
  #endif
          exit(1);
  }
+ #endif /* defined(CSOUND_MAIN) */
+ 
+ #if !defined(CSOUND_MAIN)
  
  #ifdef CWIN
  int args_OK = 0;
***************
*** 573,575 ****
--- 588,591 ----
      }
  }
  #endif
+ #endif /* !defined(CSOUND_MAIN) */