Csound Csound-dev Csound-tekno Search About

[CSOUND-DEV:3912] Fixed to ugrw1.c and insert.c

Date2004-01-07 11:04
Fromjpff@codemist.co.uk
Subject[CSOUND-DEV:3912] Fixed to ugrw1.c and insert.c
For someone who understands CVS could these patches be incorporated?

In ugrw1.c replace sprints (line 3007) with the following

/* perform a sprintf-style format  -- matt ingalls */
void sprints(char *outstring, char *fmt, MYFLT **kvals, long numVals)
{
    char strseg[8192];
    int i = 0, j = 0;
    char *segwaiting = 0;
	
    while (*fmt) {		
      if (*fmt == '%') {
h        /* if already a segment waiting, then lets print it */			
        if (segwaiting) {
          double val = *kvals[j];
          strseg[i] = '\0';
          
          switch (*segwaiting) {
          case 'd':
          case 'i':
          case 'o':
          case 'x':
          case 'X':
          case 'u':
          case 'c':
            sprintf(outstring, strseg, (int)floor(val+0.5));
            break;
          case 'h':
            sprintf(outstring, strseg, (short)floor(val+0.5));
            break;
          case 'l':
            sprintf(outstring, strseg, (long)floor(val+0.5));
            break;
            
          default:
            sprintf(outstring, strseg, *kvals[j]);
            break;
          }
          outstring += strlen(outstring);
          
          i = 0;
          segwaiting = 0;
          
          /* prevent potential problems if user didnt give enough input params */
          if (j < numVals-1)
            j++;
        }
        
        /* copy the '%' */
        strseg[i++] = *fmt++;
        
        /* find the format code */
        segwaiting = fmt;
        while (*segwaiting && !isalpha(*segwaiting))
          segwaiting++;
      }
      else
        strseg[i++] = *fmt++;
    }
    
    if (i) {
      strseg[i] = '\0';
      if (segwaiting) {
        double val = *kvals[j];
        switch (*segwaiting) {
        case 'd':
        case 'i':
        case 'o':
        case 'x':
        case 'X':
        case 'u':
        case 'c':
          sprintf(outstring, strseg, (int)floor(val+0.5));
          break;
        case 'h':
          sprintf(outstring, strseg, (short)floor(val+0.5));
          break;
        case 'l':
          sprintf(outstring, strseg, (long)floor(val+0.5));
          break;
          
        default:
          sprintf(outstring, strseg, *kvals[j]);
          break;
        }
      }
      else
        sprintf(outstring, strseg);
    }
}


------------------------------------------------------------------------
in insert.c replace ingoto (lines 800-805) with

/* an 'if-then' variant of 'if-goto' */
void ingoto(CGOTO *p)
{
    if (!*p->cond)
      ids = p->lblblk->prvi;    /* Surely this should be ids/prvi not pds/pvrp */
}

Thanks

==John ffitch

Date2004-01-07 11:54
Fromramsdell@mitre.org (John D. Ramsdell)
Subject[CSOUND-DEV:3913] Re: Fixed to ugrw1.c and insert.c
jpff@codemist.co.uk writes:

> For someone who understands CVS could these patches be incorporated?

I committed the changes you request, but have yet to compile and test
them.  I have enclosed the diffs for you to check.

John

sh-2.05b$ sfcvs csound diff -u
ramsdell@cvs.csound.sourceforge.net's password:

cvs server: Diffing .
cvs server: Diffing CsoundVST
cvs server: Diffing CsoundVST/examples
cvs server: Diffing CsoundVST/index_files
cvs server: Diffing CsoundVSTWin
cvs server: Diffing OSC-Kit
cvs server: Diffing OSC-Kit/send+dump
cvs server: Diffing anal
cvs server: Diffing anal/adsyn
cvs server: Diffing anal/convol
cvs server: Diffing anal/lpc
cvs server: Diffing anal/pvoc
cvs server: Diffing cscofils
cvs server: Diffing csound
Index: csound/insert.c
===================================================================
RCS file: /cvsroot/csound/csound/csound/insert.c,v
retrieving revision 1.2
diff -u -r1.2 insert.c
--- csound/insert.c	1 Dec 2003 05:06:40 -0000	1.2
+++ csound/insert.c	7 Jan 2004 11:52:19 -0000
@@ -808,7 +808,7 @@
 void ingoto(CGOTO *p)
 {
     if (!*p->cond)
-      pds = p->lblblk->prvp;
+      ids = p->lblblk->prvi;    /* Surely this should be ids/prvi not pds/pvrp */
 }
 
 void kngoto(CGOTO *p)
Index: csound/ugrw1.c
===================================================================
RCS file: /cvsroot/csound/csound/csound/ugrw1.c,v
retrieving revision 1.1
diff -u -r1.1 ugrw1.c
--- csound/ugrw1.c	29 Nov 2003 18:33:21 -0000	1.1
+++ csound/ugrw1.c	7 Jan 2004 11:52:20 -0000
@@ -3002,7 +3002,6 @@
     }
 }
 
-
 /* perform a sprintf-style format  -- matt ingalls */
 void sprints(char *outstring, char *fmt, MYFLT **kvals, long numVals)
 {
@@ -3012,8 +3011,9 @@
 	
     while (*fmt) {		
       if (*fmt == '%') {
-        /* if already a segment waiting, then lets print it */			
+        /* if already a segment waiting, then lets print it */
         if (segwaiting) {
+          double val = *kvals[j];
           strseg[i] = '\0';
           
           switch (*segwaiting) {
@@ -3024,13 +3024,13 @@
           case 'X':
           case 'u':
           case 'c':
-            sprintf(outstring, strseg, (int)(*kvals[j]+.5));
+            sprintf(outstring, strseg, (int)floor(val+0.5));
             break;
           case 'h':
-            sprintf(outstring, strseg, (short)(*kvals[j]+.5));
+            sprintf(outstring, strseg, (short)floor(val+0.5));
             break;
           case 'l':
-            sprintf(outstring, strseg, (long)(*kvals[j]+.5));
+            sprintf(outstring, strseg, (long)floor(val+0.5));
             break;
             
           default:
@@ -3062,6 +3062,7 @@
     if (i) {
       strseg[i] = '\0';
       if (segwaiting) {
+        double val = *kvals[j];
         switch (*segwaiting) {
         case 'd':
         case 'i':
@@ -3070,13 +3071,13 @@
         case 'X':
         case 'u':
         case 'c':
-          sprintf(outstring, strseg, (int)(*kvals[j]+.5));
+          sprintf(outstring, strseg, (int)floor(val+0.5));
           break;
         case 'h':
-          sprintf(outstring, strseg, (short)(*kvals[j]+.5));
+          sprintf(outstring, strseg, (short)floor(val+0.5));
           break;
         case 'l':
-          sprintf(outstring, strseg, (long)(*kvals[j]+.5));
+          sprintf(outstring, strseg, (long)floor(val+0.5));
           break;
           
         default:
cvs server: Diffing pyrun
cvs server: Diffing soundfonts
cvs server: Diffing soundfonts/fluidOpcodes
cvs server: Diffing util1
cvs server: Diffing util1/cscore
cvs server: Diffing util1/scot
cvs server: Diffing util1/sortex
cvs server: Diffing util2
cvs server: Diffing util2/dnoise
cvs server: Diffing util2/dnoise.dir
cvs server: Diffing util2/envext
cvs server: Diffing util2/exports
cvs server: Diffing util2/mixer
cvs server: Diffing util2/mkgraph
cvs server: Diffing util2/pvlook
cvs server: Diffing util2/pvlook.dir
cvs server: Diffing util2/scale
cvs server: Diffing util2/scale.dir
cvs server: Diffing util2/sndinfo
sh-2.05b$ 

Date2004-01-07 16:22
Fromjpff@cs.bath.ac.uk
Subject[CSOUND-DEV:3914] Re: Fixed to ugrw1.c and insert.c
Yes those diffs are correct.  Sorry but i had lost the original by the
time I realised I ought to do as diff.
==John ffitch