www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2007/12/26/20:21:49

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp AT delorie DOT com
Date: Wed, 26 Dec 2007 20:20:44 -0500
From: Ethan Rosenberg <ethros AT earthlink DOT net>
Subject: Re: Splint startup
In-reply-to: <f8917a89-2ded-41eb-a348-eeb0f9ac8c01@e25g2000prg.googlegro
ups.com>
To: djgpp AT delorie DOT com
Message-id: <0JTO00KXYP2V4UM0@mta3.srv.hcvlny.cv.net>
MIME-version: 1.0
X-Mailer: QUALCOMM Windows Eudora Version 7.1.0.9
References: <0JTM002HO7ZOWZQ0 AT mta4 DOT srv DOT hcvlny DOT cv DOT net>
<f8917a89-2ded-41eb-a348-eeb0f9ac8c01 AT e25g2000prg DOT googlegroups DOT com>
Reply-To: djgpp AT delorie DOT com

At 05:01 PM 12/26/2007, you wrote:


>Ethan Rosenberg schrieb:
> > Dear List -
> >
> > When I start to run splint, I get the error message:  Temporary file
> > for preprocessor output already exists. Trying to open
> > c:\temp\c182000.c **cannot continue.
> >
> > Advice please.
> >
> > Thanks.
> >
> > Ethan
>
>
>Hello,
>
>is this failure still an issue or have you been able to solve it?
>That failure is really strange.  It is not clear to me why splint
>should not be able to open a temporary file?  With such a
>failure not a single test case of the testsuite would have
>passed on my machine.  If it is still an issue, please send
>my a minimal file that produces the failure and a complete
>list of your environment variables.
>
>Regards,
>Juan M. Guerrero

++++++
Juan -

Thank you.

The following two statements are in my autoexec.bat

SET LARCH_PATH=C:\D\SPLINT\SHARE\SPLINT\LIB
SET LCLIMPORTDIR=C:\D\SPLINT\SHARE\SPLINT\IMPORTS

Do I have to explicitly declare a temp file?

The text of the program is:

/*================================ file = lr.c ===============================
//=  Function to calculate linear regression equation for <x, y> data       =
//==========================================================================

//----- Include files ----------------------------------------------------*/
#include <stdio.h>  /* Needed for printf() and feof() */
#include <stdlib.h>  /* Needed for atof()           */
#include <math.h>    /* Needed for sqrt() and pow() */
#include <string.h>

FILE *fptr1, *fptr2;
extern FILE *fptr16;
extern char string2[81];
/*========================================================================*/
//=  Main program                                                          =
//========================================================================*/
void lr2(char infile[18], char outfile[18], char title[25])

{
     static double   x;                 /* Value of x read in from the file */
     static double   y;                 /* Value of y read in from the file */
     static double   instring[2];      /* Temporary input 
string              */
     static long int count;             /* Counter for number of <x, 
y> pairs  */
     static double   accum_x;           /* Accumulator for the sum of 
the x's  */
     static double   accum_y;           /* Accumulator for the sum of 
the y's  */
     static double   accum_xy;          /* Accumulator for the sum of 
(x*y)    */
     static double   accum_x_squared;   /* Accumulator for the sum of 
the x's squared */
     static double   accum_y_squared;   /* Accumulator for the sum of 
the y's squared *  double   numerator;         /* Work variable for 
numerator                */
     static double   denominator;       /* Work variable for 
denominator              */
     static double   linear_corr;       /* Linear correlation 
coefficient             */
     static double   slope;             /* Slope of the linear 
regression             */
     static double   intercept;         /* Intercept of the linear 
regression         */
     static double   numerator;          /* Work variable for 
numerator                */
     static short int   valid;          /* number of items read in 
fread              */
     static long  num_read;
     static double last_minute;            /* The last minute in the 
data file    */
     static double last_value;          /* Value of y = mx + b, where 
x is the last minute */
   /* Output a banner
     printf("---------------------------------------------------- 
lr.c ----- \n");

   /* Main loop to read <x, y> values and compute accumulated values         */
     count = 0;
     valid = 0;
     x = 0.0;
     y = 0.0;
     accum_x = 0.0;
     accum_y = 0.0;
     accum_xy = 0.0;
     accum_x_squared = 0.0;
     accum_y_squared = 0.0;
     numerator = 0.0;
     denominator = 0.0;
     linear_corr = 0.0;
     slope = 0.0;
     intercept = 0.0;
     instring[0] = 0.0;
     instring[1] = 0.0;
     num_read = 0;
     last_minute = 0.0;
         last_value = 0.0;

     fptr1 = fopen(infile, "rb");
     fptr2 = fopen(outfile, "a");

     while (1)
     {
     /* Read the input values from stdin checking for invalid entry 
condition       */
     num_read = fread(&instring[0], 2,(long)sizeof(double), fptr1);
         if(num_read < 2)
             break;
          x = instring[0];
          y = instring[1];
         last_minute = instring[0];
         count++;

     /* Accumulate the applicable values from the input file                 */
         accum_x         = accum_x + x;             /* Sum of 
x                  */
         accum_y         = accum_y + y;             /* Sum of 
y                  */
         accum_xy        = accum_xy + (x*y);        /* Sum of 
x*y                */
         accum_x_squared = accum_x_squared + (x*x); /* Sum of x 
squared          */
         accum_y_squared = accum_y_squared + (y*y); /* Sum of y 
squared          */
     }
   /* Calculate the slope and intercept of the linear regression line        */
     numerator   = (count * accum_xy) - (accum_x * accum_y);
     denominator = (count * accum_x_squared) - (accum_x * accum_x);
     slope       = numerator / denominator;
     intercept   = (accum_y / count) - (slope * (accum_x / count));

   /* Calculate the linear correlation coefficient                           */
     numerator   = (count * accum_xy) - (accum_x * accum_y);
     denominator = sqrt((count * accum_x_squared) - (accum_x * accum_x)) *
                 sqrt((count * accum_y_squared) - (accum_y * accum_y));
     linear_corr = numerator / denominator;
         last_value  = slope * last_minute + intercept;

   /* Output results (R^2 is the coefficient of determiniation)              */
     printf("\n%s\n", title);
     printf("  Number of <x, y> pairs = %ld \n", count);
     printf("  Y = %f*x + %f   (R^2 = %f) \n",
     slope, intercept, pow(linear_corr, 2.0));
     printf("Last Point = %f\n", last_value);
     fprintf(fptr2, "\n\n\"%s\" \"No.pairs = \" %ld\n", title, count);
     fprintf(fptr2, "\"Intercept = \" %f  \"Slope = \"%f \"CorrCoef = 
\" %f\n",  intercept, \
          slope, pow(linear_corr, 2.0));
     fprintf(fptr2, "\"Last Point = \"%f\"", last_value);
         fprintf(fptr16,"\"%s\" %ld %f %f %f %f", title, count, 
intercept, slope,\
         pow(linear_corr, 2.0),last_value);
/* 
printf("--------------------------------------------------------------- \n");*/
   fclose(fptr1);
   fclose(fptr2);
}

Ethan


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019