|
From: <and...@us...> - 2009-09-23 09:36:55
|
Revision: 10457
http://plplot.svn.sourceforge.net/plplot/?rev=10457&view=rev
Author: andrewross
Date: 2009-09-23 09:36:41 +0000 (Wed, 23 Sep 2009)
Log Message:
-----------
Large patch to standardise the coding style in src/ using uncrustify. This is entirely cosmetic with no code changes.
This required a small amount of hand editing of multi-line #define statements. Now this has been done you can safely run uncrustify again without upsetting the results.
Modified Paths:
--------------
trunk/src/ltdl_win32.c
trunk/src/mt19937ar.c
trunk/src/mt19937ar.h
trunk/src/pdfutils.c
trunk/src/plarc.c
trunk/src/plargs.c
trunk/src/plbox.c
trunk/src/plbuf.c
trunk/src/plcont.c
trunk/src/plcore.c
trunk/src/plctrl.c
trunk/src/plcvt.c
trunk/src/pldeprecated.c
trunk/src/pldtik.c
trunk/src/plfill.c
trunk/src/plfreetype.c
trunk/src/plgridd.c
trunk/src/plhist.c
trunk/src/plimage.c
trunk/src/plline.c
trunk/src/plmap.c
trunk/src/plot3d.c
trunk/src/plsdef.c
trunk/src/plshade.c
trunk/src/plstdio.c
trunk/src/plstripc.c
trunk/src/plsym.c
trunk/src/pltick.c
trunk/src/pltime.c
trunk/src/plvect.c
trunk/src/plvpor.c
trunk/src/plwind.c
Modified: trunk/src/ltdl_win32.c
===================================================================
--- trunk/src/ltdl_win32.c 2009-09-22 14:37:18 UTC (rev 10456)
+++ trunk/src/ltdl_win32.c 2009-09-23 09:36:41 UTC (rev 10457)
@@ -1,34 +1,34 @@
/* $Id$
+ *
+ * Contains all prototypes for driver functions.
+ *
+ * Copyright (C) 2008 Werner Smekal
+ *
+ * This file is part of PLplot.
+ *
+ * PLplot 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 Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * PLplot is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with PLplot; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
- Contains all prototypes for driver functions.
-
- Copyright (C) 2008 Werner Smekal
-
- This file is part of PLplot.
-
- PLplot 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 Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- PLplot is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with PLplot; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-*/
-
#include <windows.h>
#include <stdlib.h>
#include "ltdl_win32.h"
/* (static) pointer to the last handle, which contains a pointer
- to a possible previous handle */
-lt_dlhandle lastHandle=NULL;
+ * to a possible previous handle */
+lt_dlhandle lastHandle = NULL;
/* buffer for error messages */
char errortext[512];
@@ -37,74 +37,77 @@
/* initialise variables */
void lt_dlinit( void )
{
- lastHandle=NULL;
+ lastHandle = NULL;
}
/* on exit free library handles and release allocate memory */
void lt_dlexit( void )
{
- lt_dlhandle prev;
-
- while( lastHandle!=NULL ) {
- if( lastHandle->hinstLib )
- FreeLibrary( lastHandle->hinstLib );
- prev=lastHandle->previousHandle;
- free( lastHandle );
- lastHandle=prev;
- }
+ lt_dlhandle prev;
+
+ while ( lastHandle != NULL )
+ {
+ if ( lastHandle->hinstLib )
+ FreeLibrary( lastHandle->hinstLib );
+ prev = lastHandle->previousHandle;
+ free( lastHandle );
+ lastHandle = prev;
+ }
}
/* try to open shared library with given dllname. If there is
- no extension given LoadLibrary() assumes .dll. The library
- must be somewhere in the path or in the current directory. */
+ * no extension given LoadLibrary() assumes .dll. The library
+ * must be somewhere in the path or in the current directory. */
lt_dlhandle lt_dlopenext( char* dllname )
{
- lt_dlhandle dlhandle=malloc( sizeof(struct __dlhandle) );
- memset( dlhandle, '\0', sizeof(struct __dlhandle) );
+ lt_dlhandle dlhandle = malloc( sizeof ( struct __dlhandle ));
+ memset( dlhandle, '\0', sizeof ( struct __dlhandle ));
- dlhandle->hinstLib = LoadLibrary( dllname );
- if( !dlhandle->hinstLib ) {
- free( dlhandle );
- return NULL;
- }
+ dlhandle->hinstLib = LoadLibrary( dllname );
+ if ( !dlhandle->hinstLib )
+ {
+ free( dlhandle );
+ return NULL;
+ }
- dlhandle->previousHandle = lastHandle;
- lastHandle = dlhandle;
-
- return dlhandle;
+ dlhandle->previousHandle = lastHandle;
+ lastHandle = dlhandle;
+
+ return dlhandle;
}
/* return last error occured. Needs some work :). */
const char* lt_dlerror()
{
- strncpy( errortext, "No error information", 512 );
-
- return errortext;
+ strncpy( errortext, "No error information", 512 );
+
+ return errortext;
}
/* load symbol from library */
void* lt_dlsym( lt_dlhandle dlhandle, const char* symbol )
{
- if( dlhandle->hinstLib ) {
-#ifdef __BORLANDC__
- unsigned int bufferLength = strlen(symbol)+2;
- char* buffer = (char*)malloc(bufferLength);
- void* retPointer;
-
- buffer[0]='_';
- strncpy( &buffer[1], symbol, bufferLength-2 );
- buffer[bufferLength-1]='\0';
- retPointer=GetProcAddress( dlhandle->hinstLib, buffer );
- free(buffer);
- return retPointer;
+ if ( dlhandle->hinstLib )
+ {
+#ifdef __BORLANDC__
+ unsigned int bufferLength = strlen( symbol ) + 2;
+ char * buffer = (char*) malloc( bufferLength );
+ void * retPointer;
+
+ buffer[0] = '_';
+ strncpy( &buffer[1], symbol, bufferLength - 2 );
+ buffer[bufferLength - 1] = '\0';
+ retPointer = GetProcAddress( dlhandle->hinstLib, buffer );
+ free( buffer );
+ return retPointer;
#else
- return GetProcAddress( dlhandle->hinstLib, symbol );
+ return GetProcAddress( dlhandle->hinstLib, symbol );
#endif
- } else
- return NULL;
-
+ }
+ else
+ return NULL;
}
Modified: trunk/src/mt19937ar.c
===================================================================
--- trunk/src/mt19937ar.c 2009-09-22 14:37:18 UTC (rev 10456)
+++ trunk/src/mt19937ar.c 2009-09-23 09:36:41 UTC (rev 10457)
@@ -1,68 +1,69 @@
-/*
- A C-program for MT19937, with initialization improved 2002/1/26.
- Coded by Takuji Nishimura and Makoto Matsumoto.
+/*
+ * A C-program for MT19937, with initialization improved 2002/1/26.
+ * Coded by Takuji Nishimura and Makoto Matsumoto.
+ *
+ * Before using, initialize the state by using init_genrand(seed)
+ * or init_by_array(init_key, key_length).
+ *
+ * Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
+ * All rights reserved.
+ * Copyright (C) 2005, Mutsuo Saito,
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. The names of its contributors may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * Any feedback is very welcome.
+ * http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
+ * email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)
+ */
- Before using, initialize the state by using init_genrand(seed)
- or init_by_array(init_key, key_length).
-
- Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
- All rights reserved.
- Copyright (C) 2005, Mutsuo Saito,
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- 3. The names of its contributors may not be used to endorse or promote
- products derived from this software without specific prior written
- permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
- Any feedback is very welcome.
- http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
- email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)
-*/
-
#include <stdio.h>
#include "mt19937ar.h"
-/* Period parameters */
-#define N 624
-#define M 397
-#define MATRIX_A 0x9908b0dfUL /* constant vector a */
-#define UPPER_MASK 0x80000000UL /* most significant w-r bits */
-#define LOWER_MASK 0x7fffffffUL /* least significant r bits */
+/* Period parameters */
+#define N 624
+#define M 397
+#define MATRIX_A 0x9908b0dfUL /* constant vector a */
+#define UPPER_MASK 0x80000000UL /* most significant w-r bits */
+#define LOWER_MASK 0x7fffffffUL /* least significant r bits */
-static unsigned long mt[N]; /* the array for the state vector */
-static int mti=N+1; /* mti==N+1 means mt[N] is not initialized */
+static unsigned long mt[N]; /* the array for the state vector */
+static int mti = N + 1; /* mti==N+1 means mt[N] is not initialized */
/* initializes mt[N] with a seed */
-void init_genrand(unsigned long s)
+void init_genrand( unsigned long s )
{
- mt[0]= s & 0xffffffffUL;
- for (mti=1; mti<N; mti++) {
- mt[mti] =
- (1812433253UL * (mt[mti-1] ^ (mt[mti-1] >> 30)) + mti);
+ mt[0] = s & 0xffffffffUL;
+ for ( mti = 1; mti < N; mti++ )
+ {
+ mt[mti] =
+ ( 1812433253UL * ( mt[mti - 1] ^ ( mt[mti - 1] >> 30 )) + mti );
/* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
/* In the previous versions, MSBs of the seed affect */
/* only MSBs of the array mt[]. */
@@ -76,100 +77,111 @@
/* init_key is the array for initializing keys */
/* key_length is its length */
/* slight change for C++, 2004/2/26 */
-void init_by_array(unsigned long init_key[], int key_length)
+void init_by_array( unsigned long init_key[], int key_length )
{
int i, j, k;
- init_genrand(19650218UL);
- i=1; j=0;
- k = (N>key_length ? N : key_length);
- for (; k; k--) {
- mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1664525UL))
- + init_key[j] + j; /* non linear */
- mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */
+ init_genrand( 19650218UL );
+ i = 1; j = 0;
+ k = ( N > key_length ? N : key_length );
+ for (; k; k-- )
+ {
+ mt[i] = ( mt[i] ^ (( mt[i - 1] ^ ( mt[i - 1] >> 30 )) * 1664525UL ))
+ + init_key[j] + j; /* non linear */
+ mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */
i++; j++;
- if (i>=N) { mt[0] = mt[N-1]; i=1; }
- if (j>=key_length) j=0;
+ if ( i >= N )
+ {
+ mt[0] = mt[N - 1]; i = 1;
+ }
+ if ( j >= key_length ) j = 0;
}
- for (k=N-1; k; k--) {
- mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1566083941UL))
- - i; /* non linear */
+ for ( k = N - 1; k; k-- )
+ {
+ mt[i] = ( mt[i] ^ (( mt[i - 1] ^ ( mt[i - 1] >> 30 )) * 1566083941UL ))
+ - i; /* non linear */
mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */
i++;
- if (i>=N) { mt[0] = mt[N-1]; i=1; }
+ if ( i >= N )
+ {
+ mt[0] = mt[N - 1]; i = 1;
+ }
}
- mt[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */
+ mt[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */
}
/* generates a random number on [0,0xffffffff]-interval */
-unsigned long genrand_int32(void)
+unsigned long genrand_int32( void )
{
- unsigned long y;
- static unsigned long mag01[2]={0x0UL, MATRIX_A};
+ unsigned long y;
+ static unsigned long mag01[2] = { 0x0UL, MATRIX_A };
/* mag01[x] = x * MATRIX_A for x=0,1 */
- if (mti >= N) { /* generate N words at one time */
+ if ( mti >= N ) /* generate N words at one time */
+ {
int kk;
- if (mti == N+1) /* if init_genrand() has not been called, */
- init_genrand(5489UL); /* a default initial seed is used */
+ if ( mti == N + 1 ) /* if init_genrand() has not been called, */
+ init_genrand( 5489UL ); /* a default initial seed is used */
- for (kk=0;kk<N-M;kk++) {
- y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);
- mt[kk] = mt[kk+M] ^ (y >> 1) ^ mag01[y & 0x1UL];
+ for ( kk = 0; kk < N - M; kk++ )
+ {
+ y = ( mt[kk] & UPPER_MASK ) | ( mt[kk + 1] & LOWER_MASK );
+ mt[kk] = mt[kk + M] ^ ( y >> 1 ) ^ mag01[y & 0x1UL];
}
- for (;kk<N-1;kk++) {
- y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);
- mt[kk] = mt[kk+(M-N)] ^ (y >> 1) ^ mag01[y & 0x1UL];
+ for (; kk < N - 1; kk++ )
+ {
+ y = ( mt[kk] & UPPER_MASK ) | ( mt[kk + 1] & LOWER_MASK );
+ mt[kk] = mt[kk + ( M - N )] ^ ( y >> 1 ) ^ mag01[y & 0x1UL];
}
- y = (mt[N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK);
- mt[N-1] = mt[M-1] ^ (y >> 1) ^ mag01[y & 0x1UL];
+ y = ( mt[N - 1] & UPPER_MASK ) | ( mt[0] & LOWER_MASK );
+ mt[N - 1] = mt[M - 1] ^ ( y >> 1 ) ^ mag01[y & 0x1UL];
mti = 0;
}
-
+
y = mt[mti++];
/* Tempering */
- y ^= (y >> 11);
- y ^= (y << 7) & 0x9d2c5680UL;
- y ^= (y << 15) & 0xefc60000UL;
- y ^= (y >> 18);
+ y ^= ( y >> 11 );
+ y ^= ( y << 7 ) & 0x9d2c5680UL;
+ y ^= ( y << 15 ) & 0xefc60000UL;
+ y ^= ( y >> 18 );
return y;
}
/* generates a random number on [0,0x7fffffff]-interval */
-long genrand_int31(void)
+long genrand_int31( void )
{
- return (long)(genrand_int32()>>1);
+ return (long) ( genrand_int32() >> 1 );
}
/* generates a random number on [0,1]-real-interval */
-double genrand_real1(void)
+double genrand_real1( void )
{
- return genrand_int32()*(1.0/4294967295.0);
- /* divided by 2^32-1 */
+ return genrand_int32() * ( 1.0 / 4294967295.0 );
+ /* divided by 2^32-1 */
}
/* generates a random number on [0,1)-real-interval */
-double genrand_real2(void)
+double genrand_real2( void )
{
- return genrand_int32()*(1.0/4294967296.0);
+ return genrand_int32() * ( 1.0 / 4294967296.0 );
/* divided by 2^32 */
}
/* generates a random number on (0,1)-real-interval */
-double genrand_real3(void)
+double genrand_real3( void )
{
- return (((double)genrand_int32()) + 0.5)*(1.0/4294967296.0);
+ return (((double) genrand_int32()) + 0.5 ) * ( 1.0 / 4294967296.0 );
/* divided by 2^32 */
}
/* generates a random number on [0,1) with 53-bit resolution*/
-double genrand_res53(void)
-{
- unsigned long a=genrand_int32()>>5, b=genrand_int32()>>6;
- return(a*67108864.0+b)*(1.0/9007199254740992.0);
-}
+double genrand_res53( void )
+{
+ unsigned long a = genrand_int32() >> 5, b = genrand_int32() >> 6;
+ return ( a * 67108864.0 + b ) * ( 1.0 / 9007199254740992.0 );
+}
/* These real versions are due to Isaku Wada, 2002/01/09 added */
Modified: trunk/src/mt19937ar.h
===================================================================
--- trunk/src/mt19937ar.h 2009-09-22 14:37:18 UTC (rev 10456)
+++ trunk/src/mt19937ar.h 2009-09-23 09:36:41 UTC (rev 10457)
@@ -1,72 +1,72 @@
-/*
- A C-program for MT19937, with initialization improved 2002/1/26.
- Coded by Takuji Nishimura and Makoto Matsumoto.
+/*
+ * A C-program for MT19937, with initialization improved 2002/1/26.
+ * Coded by Takuji Nishimura and Makoto Matsumoto.
+ *
+ * Before using, initialize the state by using init_genrand(seed)
+ * or init_by_array(init_key, key_length).
+ *
+ * Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
+ * All rights reserved.
+ * Copyright (C) 2005, Mutsuo Saito
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. The names of its contributors may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * Any feedback is very welcome.
+ * http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
+ * email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)
+ */
- Before using, initialize the state by using init_genrand(seed)
- or init_by_array(init_key, key_length).
-
- Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
- All rights reserved.
- Copyright (C) 2005, Mutsuo Saito
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- 3. The names of its contributors may not be used to endorse or promote
- products derived from this software without specific prior written
- permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
- Any feedback is very welcome.
- http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
- email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)
-*/
-
/* initializes mt[N] with a seed */
-void init_genrand(unsigned long s);
+void init_genrand( unsigned long s );
/* initialize by an array with array-length */
/* init_key is the array for initializing keys */
/* key_length is its length */
/* slight change for C++, 2004/2/26 */
-void init_by_array(unsigned long init_key[], int key_length);
+void init_by_array( unsigned long init_key[], int key_length );
/* generates a random number on [0,0xffffffff]-interval */
-unsigned long genrand_int32(void);
+unsigned long genrand_int32( void );
/* generates a random number on [0,0x7fffffff]-interval */
-long genrand_int31(void);
+long genrand_int31( void );
/* These real versions are due to Isaku Wada, 2002/01/09 added */
/* generates a random number on [0,1]-real-interval */
-double genrand_real1(void);
+double genrand_real1( void );
/* generates a random number on [0,1)-real-interval */
-double genrand_real2(void);
+double genrand_real2( void );
/* generates a random number on (0,1)-real-interval */
-double genrand_real3(void);
+double genrand_real3( void );
/* generates a random number on [0,1) with 53-bit resolution*/
-double genrand_res53(void);
+double genrand_res53( void );
Modified: trunk/src/pdfutils.c
===================================================================
--- trunk/src/pdfutils.c 2009-09-22 14:37:18 UTC (rev 10456)
+++ trunk/src/pdfutils.c 2009-09-23 09:36:41 UTC (rev 10457)
@@ -1,42 +1,42 @@
/* $Id$
+ *
+ * pdf_utils.c
+ *
+ * Copyright (C) 1992, 1993, 1994, 1995
+ * Maurice LeBrun mj...@di...
+ * Institute for Fusion Studies University of Texas at Austin
+ *
+ * Copyright (C) 2004 Joao Cardoso
+ * Copyright (C) 2004 Alan W. Irwin
+ * Copyright (C) 2004 Andrew Ross
+ *
+ * This file is part of PLplot.
+ *
+ * PLplot is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Library Public License as published
+ * by the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * PLplot is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with PLplot; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ * These functions do the low-level reading/writing of portable data files.
+ * Data can be written to/read from either a file handle or memory buffer.
+ */
- pdf_utils.c
-
- Copyright (C) 1992, 1993, 1994, 1995
- Maurice LeBrun mj...@di...
- Institute for Fusion Studies University of Texas at Austin
-
- Copyright (C) 2004 Joao Cardoso
- Copyright (C) 2004 Alan W. Irwin
- Copyright (C) 2004 Andrew Ross
-
- This file is part of PLplot.
-
- PLplot is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Library Public License as published
- by the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- PLplot is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with PLplot; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-
- These functions do the low-level reading/writing of portable data files.
- Data can be written to/read from either a file handle or memory buffer.
-*/
-
#define NEED_PLDEBUG
#include "plplotP.h"
-static void print_ieeef (void *, void *);
-static int pdf_wrx (const U_CHAR *x, long nitems, PDFstrm *pdfs);
+static void print_ieeef( void *, void * );
+static int pdf_wrx( const U_CHAR *x, long nitems, PDFstrm *pdfs );
static int debug = 0;
@@ -44,13 +44,13 @@
* void pdf_set (string, value)
*
* Set an option. Pretty sparse right now but you never know.
-\*--------------------------------------------------------------------------*/
+ \*--------------------------------------------------------------------------*/
void
-pdf_set(char *option, int value)
+pdf_set( char *option, int value )
{
- if ( ! strcmp(option, "debug"))
- debug = value;
+ if ( !strcmp( option, "debug" ))
+ debug = value;
}
/*--------------------------------------------------------------------------*\
@@ -58,56 +58,67 @@
*
* Initializes a PDFstrm for a file oriented device.
* Used exactly like fopen().
-\*--------------------------------------------------------------------------*/
+ \*--------------------------------------------------------------------------*/
PDFstrm *
-pdf_fopen(const char *filename, const char *mode)
+pdf_fopen( const char *filename, const char *mode )
{
PDFstrm *pdfs;
- dbug_enter("pdf_fopen");
+ dbug_enter( "pdf_fopen" );
- pdfs = (PDFstrm *) malloc(sizeof(PDFstrm));
+ pdfs = (PDFstrm *) malloc( sizeof ( PDFstrm ));
- if (pdfs != NULL) {
- pdfs->buffer = NULL;
- pdfs->file = NULL;
- pdfs->bp = 0;
+ if ( pdfs != NULL )
+ {
+ pdfs->buffer = NULL;
+ pdfs->file = NULL;
+ pdfs->bp = 0;
#ifdef PLPLOT_USE_TCL_CHANNELS
- pdfs->tclChan = NULL;
- if (1) {
- char new_mode[3];
- int binary = 0;
- char *m, *p;
+ pdfs->tclChan = NULL;
+ if ( 1 )
+ {
+ char new_mode[3];
+ int binary = 0;
+ char *m, *p;
- /* Copy over the mode, removing 'b' if needed */
- for (m = mode, p = new_mode; *m != 0; m++) {
- if (*m == 'b') {
- binary = 1;
- } else {
- *p = *m;
- p++;
- }
- }
- *p = 0;
+ /* Copy over the mode, removing 'b' if needed */
+ for ( m = mode, p = new_mode; *m != 0; m++ )
+ {
+ if ( *m == 'b' )
+ {
+ binary = 1;
+ }
+ else
+ {
+ *p = *m;
+ p++;
+ }
+ }
+ *p = 0;
- pdfs->tclChan = Tcl_OpenFileChannel(NULL, filename, new_mode, 0);
- if (pdfs->tclChan == NULL) {
- pdf_close(pdfs);
- pdfs = NULL;
- } else {
- if (binary) {
- Tcl_SetChannelOption(NULL, pdfs->tclChan, "-translation",
- "binary");
- }
- }
- }
+ pdfs->tclChan = Tcl_OpenFileChannel( NULL, filename, new_mode, 0 );
+ if ( pdfs->tclChan == NULL )
+ {
+ pdf_close( pdfs );
+ pdfs = NULL;
+ }
+ else
+ {
+ if ( binary )
+ {
+ Tcl_SetChannelOption( NULL, pdfs->tclChan, "-translation",
+ "binary" );
+ }
+ }
+ }
#else
- pdfs->file = fopen(filename, mode);
- if (pdfs->file == NULL) {
- pdf_close(pdfs);
- pdfs = NULL;
- }
+ pdfs->file = fopen( filename, mode );
+ if ( pdfs->file == NULL )
+ {
+ pdf_close( pdfs );
+ pdfs = NULL;
+ }
#endif
}
@@ -119,40 +130,44 @@
*
* Initializes a PDFstrm for reading/writing to a memory buffer.
* If buffer is NULL, a standard buffer is allocated.
-\*--------------------------------------------------------------------------*/
+ \*--------------------------------------------------------------------------*/
PDFstrm *
-pdf_bopen(U_CHAR *buffer, long bufmax)
+pdf_bopen( U_CHAR *buffer, long bufmax )
{
PDFstrm *pdfs;
- dbug_enter("pdf_bopen");
+ dbug_enter( "pdf_bopen" );
- pdfs = (PDFstrm *) malloc(sizeof(PDFstrm));
+ pdfs = (PDFstrm *) malloc( sizeof ( PDFstrm ));
- if (pdfs != NULL) {
- pdfs->file = NULL;
+ if ( pdfs != NULL )
+ {
+ pdfs->file = NULL;
#ifdef PLPLOT_USE_TCL_CHANNELS
- pdfs->tclChan = NULL;
+ pdfs->tclChan = NULL;
#endif
- pdfs->bp = 0;
+ pdfs->bp = 0;
- if (buffer == NULL) {
- if (bufmax > 0)
- pdfs->bufmax = bufmax;
- else
- pdfs->bufmax = 2048;
+ if ( buffer == NULL )
+ {
+ if ( bufmax > 0 )
+ pdfs->bufmax = bufmax;
+ else
+ pdfs->bufmax = 2048;
- pdfs->buffer = (U_CHAR *) malloc(pdfs->bufmax);
- if (pdfs->buffer == NULL) {
- pdf_close(pdfs);
- pdfs = NULL;
- }
- }
- else {
- pdfs->bufmax = bufmax;
- pdfs->buffer = buffer;
- }
+ pdfs->buffer = (U_CHAR *) malloc( pdfs->bufmax );
+ if ( pdfs->buffer == NULL )
+ {
+ pdf_close( pdfs );
+ pdfs = NULL;
+ }
+ }
+ else
+ {
+ pdfs->bufmax = bufmax;
+ pdfs->buffer = buffer;
+ }
}
return pdfs;
@@ -163,24 +178,25 @@
*
* Initializes a PDFstrm for a file oriented device.
* Like pdf_fopen() but an existing file handle is specified.
-\*--------------------------------------------------------------------------*/
+ \*--------------------------------------------------------------------------*/
PDFstrm *
-pdf_finit(FILE *file)
+pdf_finit( FILE *file )
{
PDFstrm *pdfs;
- dbug_enter("pdf_finit");
+ dbug_enter( "pdf_finit" );
- pdfs = (PDFstrm *) malloc(sizeof(PDFstrm));
+ pdfs = (PDFstrm *) malloc( sizeof ( PDFstrm ));
- if (pdfs != NULL) {
- pdfs->buffer = NULL;
- pdfs->file = file;
+ if ( pdfs != NULL )
+ {
+ pdfs->buffer = NULL;
+ pdfs->file = file;
#ifdef PLPLOT_USE_TCL_CHANNELS
- pdfs->tclChan = NULL;
+ pdfs->tclChan = NULL;
#endif
- pdfs->bp = 0;
+ pdfs->bp = 0;
}
return pdfs;
@@ -191,24 +207,30 @@
*
* Closes a PDFstrm.
* Used exactly like fclose().
-\*--------------------------------------------------------------------------*/
+ \*--------------------------------------------------------------------------*/
int
-pdf_close(PDFstrm *pdfs)
+pdf_close( PDFstrm *pdfs )
{
- dbug_enter("pdf_close");
+ dbug_enter( "pdf_close" );
- if (pdfs != NULL) {
- if (pdfs->file != NULL) {
- fclose(pdfs->file);
+ if ( pdfs != NULL )
+ {
+ if ( pdfs->file != NULL )
+ {
+ fclose( pdfs->file );
#ifdef PLPLOT_USE_TCL_CHANNELS
- } else if (pdfs->tclChan != NULL) {
- Tcl_Close(NULL, pdfs->tclChan);
+ }
+ else if ( pdfs->tclChan != NULL )
+ {
+ Tcl_Close( NULL, pdfs->tclChan );
#endif
- } else if (pdfs->buffer != NULL) {
- free ((void *) pdfs->buffer);
- }
- free((void *) pdfs);
+ }
+ else if ( pdfs->buffer != NULL )
+ {
+ free((void *) pdfs->buffer );
+ }
+ free((void *) pdfs );
}
return 0;
}
@@ -217,36 +239,44 @@
* int pdf_putc()
*
* Writes a single character.
-\*--------------------------------------------------------------------------*/
+ \*--------------------------------------------------------------------------*/
int
-pdf_putc(int c, PDFstrm *pdfs)
+pdf_putc( int c, PDFstrm *pdfs )
{
int result = EOF;
- if (pdfs->file != NULL) {
- result = putc(c, pdfs->file);
- pdfs->bp++;
+ if ( pdfs->file != NULL )
+ {
+ result = putc( c, pdfs->file );
+ pdfs->bp++;
#ifdef PLPLOT_USE_TCL_CHANNELS
- } else if (pdfs->tclChan != NULL) {
- result = Tcl_WriteChars(pdfs->tclChan, &c, 1);
- pdfs->bp++;
+ }
+ else if ( pdfs->tclChan != NULL )
+ {
+ result = Tcl_WriteChars( pdfs->tclChan, &c, 1 );
+ pdfs->bp++;
#endif
- } else if (pdfs->buffer != NULL) {
- if (pdfs->bp >= pdfs->bufmax) {
- pldebug("pdf_putc",
- "Increasing buffer to %d bytes\n", pdfs->bufmax);
- pdfs->bufmax += 512;
- if ((pdfs->buffer = (U_CHAR *) realloc((void *) pdfs->buffer, pdfs->bufmax))==NULL)
+ }
+ else if ( pdfs->buffer != NULL )
+ {
+ if ( pdfs->bp >= pdfs->bufmax )
{
- plexit("pdf_putc: Insufficient memory");
+ pldebug( "pdf_putc",
+ "Increasing buffer to %d bytes\n", pdfs->bufmax );
+ pdfs->bufmax += 512;
+ if (( pdfs->buffer =
+ (U_CHAR *) realloc((void *) pdfs->buffer,
+ pdfs->bufmax )) == NULL )
+ {
+ plexit( "pdf_putc: Insufficient memory" );
+ }
}
- }
- pdfs->buffer[pdfs->bp++] = c;
- result = c;
+ pdfs->buffer[pdfs->bp++] = c;
+ result = c;
}
else
- plexit("pdf_putc: Illegal operation");
+ plexit( "pdf_putc: Illegal operation" );
return result;
}
@@ -255,27 +285,32 @@
* int pdf_getc()
*
* Reads a single character.
-\*--------------------------------------------------------------------------*/
+ \*--------------------------------------------------------------------------*/
int
-pdf_getc(PDFstrm *pdfs)
+pdf_getc( PDFstrm *pdfs )
{
int result = EOF;
- if (pdfs->file != NULL) {
- result = getc(pdfs->file);
- pdfs->bp++;
+ if ( pdfs->file != NULL )
+ {
+ result = getc( pdfs->file );
+ pdfs->bp++;
#ifdef PLPLOT_USE_TCL_CHANNELS
- } else if (pdfs->tclChan != NULL) {
- result = Tcl_Read(pdfs->tclChan, &result, 1);
- pdfs->bp++;
+ }
+ else if ( pdfs->tclChan != NULL )
+ {
+ result = Tcl_Read( pdfs->tclChan, &result, 1 );
+ pdfs->bp++;
#endif
- } else if (pdfs->buffer != NULL) {
- if (pdfs->bp < pdfs->bufmax)
- result = pdfs->buffer[pdfs->bp++];
}
+ else if ( pdfs->buffer != NULL )
+ {
+ if ( pdfs->bp < pdfs->bufmax )
+ result = pdfs->buffer[pdfs->bp++];
+ }
else
- plexit("pdf_getc: Illegal operation");
+ plexit( "pdf_getc: Illegal operation" );
return result;
}
@@ -284,31 +319,37 @@
* int pdf_ungetc()
*
* Push back the last command read.
-\*--------------------------------------------------------------------------*/
+ \*--------------------------------------------------------------------------*/
int
-pdf_ungetc(int c, PDFstrm *pdfs)
+pdf_ungetc( int c, PDFstrm *pdfs )
{
int result = EOF;
- if (pdfs->file != NULL) {
- result = ungetc(c, pdfs->file);
- if (pdfs->bp > 0)
- pdfs->bp--;
+ if ( pdfs->file != NULL )
+ {
+ result = ungetc( c, pdfs->file );
+ if ( pdfs->bp > 0 )
+ pdfs->bp--;
#ifdef PLPLOT_USE_TCL_CHANNELS
- } else if (pdfs->tclChan != NULL) {
- result = Tcl_Ungets(pdfs->tclChan, &c, 1, 0);
- if (pdfs->bp > 0)
- pdfs->bp--;
+ }
+ else if ( pdfs->tclChan != NULL )
+ {
+ result = Tcl_Ungets( pdfs->tclChan, &c, 1, 0 );
+ if ( pdfs->bp > 0 )
+ pdfs->bp--;
#endif
- } else if (pdfs->buffer != NULL) {
- if (pdfs->bp > 0) {
- pdfs->buffer[--pdfs->bp] = c;
- result = c;
- }
}
+ else if ( pdfs->buffer != NULL )
+ {
+ if ( pdfs->bp > 0 )
+ {
+ pdfs->buffer[--pdfs->bp] = c;
+ result = c;
+ }
+ }
else
- plexit("pdf_ungetc: Illegal operation");
+ plexit( "pdf_ungetc: Illegal operation" );
return result;
}
@@ -317,37 +358,45 @@
* int pdf_wrx()
*
* Writes a record.
-\*--------------------------------------------------------------------------*/
+ \*--------------------------------------------------------------------------*/
static int
-pdf_wrx(const U_CHAR *x, long nitems, PDFstrm *pdfs)
+pdf_wrx( const U_CHAR *x, long nitems, PDFstrm *pdfs )
{
int i, result = 0;
- if (pdfs->file != NULL) {
- result = fwrite(x, 1, nitems, pdfs->file);
- pdfs->bp += nitems;
+ if ( pdfs->file != NULL )
+ {
+ result = fwrite( x, 1, nitems, pdfs->file );
+ pdfs->bp += nitems;
#ifdef PLPLOT_USE_TCL_CHANNELS
- } else if (pdfs->tclChan != NULL) {
- result = Tcl_Write(pdfs->tclChan, x, nitems);
- pdfs->bp += nitems;
+ }
+ else if ( pdfs->tclChan != NULL )
+ {
+ result = Tcl_Write( pdfs->tclChan, x, nitems );
+ pdfs->bp += nitems;
#endif
- } else if (pdfs->buffer != NULL) {
- for (i = 0; i < nitems; i++) {
- if (pdfs->bp >= pdfs->bufmax) {
- pldebug("pdf_wrx",
- "Increasing buffer to %d bytes\n", pdfs->bufmax);
- pdfs->bufmax += 512;
- if ((pdfs->buffer = (U_CHAR *)
- realloc((void *) (pdfs->buffer), pdfs->bufmax))==NULL)
- {
- plexit("pdf_wrx: Insufficient memory");
- }
- }
- pdfs->buffer[pdfs->bp++] = x[i];
- }
- result = i;
}
+ else if ( pdfs->buffer != NULL )
+ {
+ for ( i = 0; i < nitems; i++ )
+ {
+ if ( pdfs->bp >= pdfs->bufmax )
+ {
+ pldebug( "pdf_wrx",
+ "Increasing buffer to %d bytes\n", pdfs->bufmax );
+ pdfs->bufmax += 512;
+ if (( pdfs->buffer = (U_CHAR *)
+ realloc((void *) ( pdfs->buffer ),
+ pdfs->bufmax )) == NULL )
+ {
+ plexit( "pdf_wrx: Insufficient memory" );
+ }
+ }
+ pdfs->buffer[pdfs->bp++] = x[i];
+ }
+ result = i;
+ }
return result;
}
@@ -356,29 +405,35 @@
* int pdf_rdx()
*
* Reads a record.
-\*--------------------------------------------------------------------------*/
+ \*--------------------------------------------------------------------------*/
int
-pdf_rdx(U_CHAR *x, long nitems, PDFstrm *pdfs)
+pdf_rdx( U_CHAR *x, long nitems, PDFstrm *pdfs )
{
int i, result = 0;
- if (pdfs->file != NULL) {
- result = fread(x, 1, nitems, pdfs->file);
- pdfs->bp += nitems;
+ if ( pdfs->file != NULL )
+ {
+ result = fread( x, 1, nitems, pdfs->file );
+ pdfs->bp += nitems;
#ifdef PLPLOT_USE_TCL_CHANNELS
- } else if (pdfs->tclChan != NULL) {
- result = Tcl_ReadRaw(pdfs->tclChan, x, nitems);
- pdfs->bp += nitems;
+ }
+ else if ( pdfs->tclChan != NULL )
+ {
+ result = Tcl_ReadRaw( pdfs->tclChan, x, nitems );
+ pdfs->bp += nitems;
#endif
- } else if (pdfs->buffer != NULL) {
- for (i = 0; i < nitems; i++) {
- if (pdfs->bp > pdfs->bufmax)
- break;
- x[i] = pdfs->buffer[pdfs->bp++];
- }
- result = i;
}
+ else if ( pdfs->buffer != NULL )
+ {
+ for ( i = 0; i < nitems; i++ )
+ {
+ if ( pdfs->bp > pdfs->bufmax )
+ break;
+ x[i] = pdfs->buffer[pdfs->bp++];
+ }
+ result = i;
+ }
return result;
}
@@ -389,23 +444,24 @@
* Writes a header string. Input string must be NULL-terminated. The
* written string is terminated by a new-line, not a NULL. This is done
* so you can type e.g. "% strings <file> | head" and get sensible output.
-\*--------------------------------------------------------------------------*/
+ \*--------------------------------------------------------------------------*/
int
-pdf_wr_header(PDFstrm *pdfs, char *header)
+pdf_wr_header( PDFstrm *pdfs, char *header )
{
int i;
- dbug_enter("pdf_wr_header");
+ dbug_enter( "pdf_wr_header" );
- for (i = 0; i < 79; i++) {
- if (header[i] == '\0')
- break;
- if (pdf_putc(header[i], pdfs) == EOF)
- return PDF_WRERR;
+ for ( i = 0; i < 79; i++ )
+ {
+ if ( header[i] == '\0' )
+ break;
+ if ( pdf_putc( header[i], pdfs ) == EOF )
+ return PDF_WRERR;
}
- if (pdf_putc('\n', pdfs) == EOF)
- return PDF_WRERR;
+ if ( pdf_putc( '\n', pdfs ) == EOF )
+ return PDF_WRERR;
return 0;
}
@@ -415,24 +471,25 @@
*
* Reads a newline-terminated header string from PDFstrm *pdfs, and
* converts to a usual NULL-terminated string. 80 chars maximum assumed.
-\*--------------------------------------------------------------------------*/
+ \*--------------------------------------------------------------------------*/
int
-pdf_rd_header(PDFstrm *pdfs, char *header)
+pdf_rd_header( PDFstrm *pdfs, char *header )
{
int i, c;
- dbug_enter("pdf_rd_header");
+ dbug_enter( "pdf_rd_header" );
- for (i = 0; i < 79; i++) {
- if ((c = pdf_getc(pdfs)) == EOF)
- return PDF_RDERR;
+ for ( i = 0; i < 79; i++ )
+ {
+ if (( c = pdf_getc( pdfs )) == EOF )
+ return PDF_RDERR;
- header[i] = c;
- if (header[i] == '\n')
- break;
+ header[i] = c;
+ if ( header[i] == '\n' )
+ break;
}
- header[i] = '\0'; /* NULL terminate */
+ header[i] = '\0'; /* NULL terminate */
return 0;
}
@@ -440,18 +497,19 @@
* pdf_wr_string()
*
* Writes a null-terminated string.
-\*--------------------------------------------------------------------------*/
+ \*--------------------------------------------------------------------------*/
int
-pdf_wr_string(PDFstrm *pdfs, const char *string)
+pdf_wr_string( PDFstrm *pdfs, const char *string )
{
int i;
- dbug_enter("pdf_wr_string");
+ dbug_enter( "pdf_wr_string" );
- for (i = 0; i <= (int) strlen(string); i++) {
- if (pdf_putc(string[i], pdfs) == EOF)
- return PDF_WRERR;
+ for ( i = 0; i <= (int) strlen( string ); i++ )
+ {
+ if ( pdf_putc( string[i], pdfs ) == EOF )
+ return PDF_WRERR;
}
return 0;
@@ -462,24 +520,25 @@
*
* Reads a null-terminated string from PDFstrm *pdfs.
* A max of nmax chars are read.
-\*--------------------------------------------------------------------------*/
+ \*--------------------------------------------------------------------------*/
int
-pdf_rd_string(PDFstrm *pdfs, char *string, int nmax)
+pdf_rd_string( PDFstrm *pdfs, char *string, int nmax )
{
int i, c;
- dbug_enter("pdf_rd_string");
+ dbug_enter( "pdf_rd_string" );
- for (i = 0; i < nmax; i++) {
- if ((c = pdf_getc(pdfs)) == EOF)
- return PDF_RDERR;
+ for ( i = 0; i < nmax; i++ )
+ {
+ if (( c = pdf_getc( pdfs )) == EOF )
+ return PDF_RDERR;
- string[i] = c;
- if (c == '\0')
- break;
+ string[i] = c;
+ if ( c == '\0' )
+ break;
}
- string[i] = '\0'; /* handle boundary case */
+ string[i] = '\0'; /* handle boundary case */
return 0;
}
@@ -487,16 +546,16 @@
* int pdf_wr_1byte()
*
* Writes a U_CHAR as a single byte.
-\*--------------------------------------------------------------------------*/
+ \*--------------------------------------------------------------------------*/
int
-pdf_wr_1byte(PDFstrm *pdfs, U_CHAR s)
+pdf_wr_1byte( PDFstrm *pdfs, U_CHAR s )
{
U_CHAR x[1];
x[0] = s;
- if (pdf_wrx(x, 1, pdfs) != 1)
- return PDF_WRERR;
+ if ( pdf_wrx( x, 1, pdfs ) != 1 )
+ return PDF_WRERR;
return 0;
}
@@ -505,17 +564,17 @@
* int pdf_rd_1byte()
*
* Reads a single byte, storing into a U_CHAR.
-\*--------------------------------------------------------------------------*/
+ \*--------------------------------------------------------------------------*/
int
-pdf_rd_1byte(PDFstrm *pdfs, U_CHAR *ps)
+pdf_rd_1byte( PDFstrm *pdfs, U_CHAR *ps )
{
U_CHAR x[1];
- if ( ! pdf_rdx(x, 1, pdfs))
- return PDF_RDERR;
+ if ( !pdf_rdx( x, 1, pdfs ))
+ return PDF_RDERR;
- *ps = ((U_CHAR) x[0]);
+ *ps = ((U_CHAR) x[0] );
return 0;
}
@@ -523,18 +582,18 @@
* pdf_wr_2bytes()
*
* Writes a U_SHORT as two single bytes, low end first.
-\*--------------------------------------------------------------------------*/
+ \*--------------------------------------------------------------------------*/
int
-pdf_wr_2bytes(PDFstrm *pdfs, U_SHORT s)
+pdf_wr_2bytes( PDFstrm *pdfs, U_SHORT s )
{
U_CHAR x[2];
- x[0] = (U_CHAR) ((U_LONG) (s & (U_LONG) 0x00FF));
- x[1] = (U_CHAR) ((U_LONG) (s & (U_LONG) 0xFF00) >> 8);
+ x[0] = (U_CHAR) ((U_LONG) ( s & (U_LONG) 0x00FF ));
+ x[1] = (U_CHAR) ((U_LONG) ( s & (U_LONG) 0xFF00 ) >> 8 );
- if (pdf_wrx(x, 2, pdfs) != 2)
- return PDF_WRERR;
+ if ( pdf_wrx( x, 2, pdfs ) != 2 )
+ return PDF_WRERR;
return 0;
}
@@ -543,17 +602,17 @@
* pdf_rd_2bytes()
*
* Reads a U_SHORT from two single bytes, low end first.
-\*--------------------------------------------------------------------------*/
+ \*--------------------------------------------------------------------------*/
int
-pdf_rd_2bytes(PDFstrm *pdfs, U_SHORT *ps)
+pdf_rd_2bytes( PDFstrm *pdfs, U_SHORT *ps )
{
U_CHAR x[2];
- if ( ! pdf_rdx(x, 2, pdfs))
- return PDF_RDERR;
+ if ( !pdf_rdx( x, 2, pdfs ))
+ return PDF_RDERR;
- *ps = 0;
+ *ps = 0;
*ps |= (U_LONG) x[0];
*ps |= (U_LONG) x[1] << 8;
@@ -564,20 +623,21 @@
* pdf_wr_2nbytes()
*
* Writes n U_SHORT's as 2n single bytes, low end first.
-\*--------------------------------------------------------------------------*/
+ \*--------------------------------------------------------------------------*/
int
-pdf_wr_2nbytes(PDFstrm *pdfs, U_SHORT *s, PLINT n)
+pdf_wr_2nbytes( PDFstrm *pdfs, U_SHORT *s, PLINT n )
{
- PLINT i;
+ PLINT i;
U_CHAR x[2];
- for (i = 0; i < n; i++) {
- x[0] = (U_CHAR) ((U_LONG) (s[i] & (U_LONG) 0x00FF));
- x[1] = (U_CHAR) ((U_LONG) (s[i] & (U_LONG) 0xFF00) >> 8);
+ for ( i = 0; i < n; i++ )
+ {
+ x[0] = (U_CHAR) ((U_LONG) ( s[i] & (U_LONG) 0x00FF ));
+ x[1] = (U_CHAR) ((U_LONG) ( s[i] & (U_LONG) 0xFF00 ) >> 8 );
- if (pdf_wrx(x, 2, pdfs) != 2)
- return PDF_WRERR;
+ if ( pdf_wrx( x, 2, pdfs ) != 2 )
+ return PDF_WRERR;
}
return 0;
}
@@ -586,21 +646,22 @@
* pdf_rd_2nbytes()
*
* Reads n U_SHORT's from 2n single bytes, low end first.
-\*--------------------------------------------------------------------------*/
+ \*--------------------------------------------------------------------------*/
int
-pdf_rd_2nbytes(PDFstrm *pdfs, U_SHORT *s, PLINT n)
+pdf_rd_2nbytes( PDFstrm *pdfs, U_SHORT *s, PLINT n )
{
- PLINT i;
+ PLINT i;
U_CHAR x[2];
- for (i = 0; i < n; i++) {
- if ( ! pdf_rdx(x, 2, pdfs))
- return PDF_RDERR;
+ for ( i = 0; i < n; i++ )
+ {
+ if ( !pdf_rdx( x, 2, pdfs ))
+ return PDF_RDERR;
- s[i] = 0;
- s[i] |= (U_SHORT) x[0];
- s[i] |= (U_SHORT) x[1] << 8;
+ s[i] = 0;
+ s[i] |= (U_SHORT) x[0];
+ s[i] |= (U_SHORT) x[1] << 8;
}
return 0;
}
@@ -609,20 +670,20 @@
* pdf_wr_4bytes()
*
* Writes an unsigned long as four single bytes, low end first.
-\*--------------------------------------------------------------------------*/
+ \*--------------------------------------------------------------------------*/
int
-pdf_wr_4bytes(PDFstrm *pdfs, U_LONG s)
+pdf_wr_4bytes( PDFstrm *pdfs, U_LONG s )
{
U_CHAR x[4];
- x[0] = (U_CHAR) ((s & (U_LONG) 0x000000FF));
- x[1] = (U_CHAR) ((s & (U_LONG) 0x0000FF00) >> 8);
- x[2] = (U_CHAR) ((s & (U_LONG) 0x00FF0000) >> 16);
- x[3] = (U_CHAR) ((s & (U_LONG) 0xFF000000) >> 24);
+ x[0] = (U_CHAR) (( s & (U_LONG) 0x000000FF ));
+ x[1] = (U_CHAR) (( s & (U_LONG) 0x0000FF00 ) >> 8 );
+ x[2] = (U_CHAR) (( s & (U_LONG) 0x00FF0000 ) >> 16 );
+ x[3] = (U_CHAR) (( s & (U_LONG) 0xFF000000 ) >> 24 );
- if (pdf_wrx(x, 4, pdfs) != 4)
- return PDF_WRERR;
+ if ( pdf_wrx( x, 4, pdfs ) != 4 )
+ return PDF_WRERR;
return 0;
}
@@ -631,17 +692,17 @@
* pdf_rd_4bytes()
*
* Reads an unsigned long from 4 single bytes, low end first.
-\*--------------------------------------------------------------------------*/
+ \*--------------------------------------------------------------------------*/
int
-pdf_rd_4bytes(PDFstrm *pdfs, U_LONG *ps)
+pdf_rd_4bytes( PDFstrm *pdfs, U_LONG *ps )
{
U_CHAR x[4];
- if ( ! pdf_rdx(x, 4, pdfs))
- return PDF_RDERR;
+ if ( !pdf_rdx( x, 4, pdfs ))
+ return PDF_RDERR;
- *ps = 0;
+ *ps = 0;
*ps |= (U_LONG) x[0];
*ps |= (U_LONG) x[1] << 8;
*ps |= (U_LONG) x[2] << 16;
@@ -703,54 +764,58 @@
*
* (Thanks to: Tom Bjorkholm(TBJ...@ab...))
*
-\*--------------------------------------------------------------------------*/
+ \*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*\
* int pdf_wr_ieeef()
*
* Writes a float in IEEE single precision (32 bit) format.
-\*--------------------------------------------------------------------------*/
+ \*--------------------------------------------------------------------------*/
int
-pdf_wr_ieeef(PDFstrm *pdfs, float f)
+pdf_wr_ieeef( PDFstrm *pdfs, float f )
{
double fdbl, fmant, f_new;
- float fsgl, f_tmp;
- int istat, exp, e_new, e_off, bias = 127;
+ float fsgl, f_tmp;
+ int istat, exp, e_new, e_off, bias = 127;
U_LONG value, s_ieee, e_ieee, f_ieee;
- if (f == 0.0) {
- value = 0;
- return (pdf_wr_4bytes(pdfs, value));
+ if ( f == 0.0 )
+ {
+ value = 0;
+ return ( pdf_wr_4bytes( pdfs, value ));
}
- fdbl = f;
- fsgl = (float)fdbl;
- fmant = frexp(fdbl, &exp);
+ fdbl = f;
+ fsgl = (float) fdbl;
+ fmant = frexp( fdbl, &exp );
- if (fmant < 0)
- s_ieee = 1;
+ if ( fmant < 0 )
+ s_ieee = 1;
else
- s_ieee = 0;
+ s_ieee = 0;
- fmant = fabs(fmant);
+ fmant = fabs( fmant );
f_new = 2 * fmant;
e_new = exp - 1;
- if (e_new < 1 - bias) {
- e_off = e_new - (1 - bias);
- e_ieee = 0;
- f_tmp = (float)(f_new * pow((double) 2.0, (double) e_off));
+ if ( e_new < 1 - bias )
+ {
+ e_off = e_new - ( 1 - bias );
+ e_ieee = 0;
+ f_tmp = (float) ( f_new * pow((double) 2.0, (double) e_off ));
}
- else {
- e_ieee = e_new + bias;
- f_tmp = (float)(f_new - 1);
+ else
+ {
+ e_ieee = e_new + bias;
+ f_tmp = (float) ( f_new - 1 );
}
- f_ieee = (U_LONG)(f_tmp * 8388608); /* multiply by 2^23 */
+ f_ieee = (U_LONG) ( f_tmp * 8388608 ); /* multiply by 2^23 */
- if (e_ieee > 255) {
- if (debug)
- fprintf(stderr, "pdf_wr_ieeef: Warning -- overflow\n");
- e_ieee = 255;
+ if ( e_ieee > 255 )
+ {
+ if ( debug )
+ fprintf( stderr, "pdf_wr_ieeef: Warning -- overflow\n" );
+ e_ieee = 255;
}
s_ieee = s_ieee << 31;
@@ -758,12 +823,13 @@
value = s_ieee | e_ieee | f_ieee;
- if ((istat = pdf_wr_4bytes(pdfs, value)))
- return (istat);
+ if (( istat = pdf_wr_4bytes( pdfs, value )))
+ return ( istat );
- if (debug) {
- fprintf(stderr, "Float value (written): %g\n", fsgl);
- print_ieeef(&fsgl, &value);
+ if ( debug )
+ {
+ fprintf( stderr, "Float value (written): %g\n", fsgl );
+ print_ieeef( &fsgl, &value );
}
return 0;
@@ -773,43 +839,46 @@
* int pdf_rd_ieeef()
*
* Reads a float from a IEEE single precision (32 bit) format.
-\*--------------------------------------------------------------------------*/
+ \*--------------------------------------------------------------------------*/
int
-pdf_rd_ieeef(PDFstrm *pdfs, float *pf)
+pdf_rd_ieeef( PDFstrm *pdfs, float *pf )
{
double f_new, f_tmp;
- float fsgl;
- int istat, exp, bias = 127;
+ float fsgl;
+ int istat, exp, bias = 127;
U_LONG value, s_ieee, e_ieee, f_ieee;
- if ((istat = pdf_rd_4bytes(pdfs, &value)))
- return (istat);
+ if (( istat = pdf_rd_4bytes( pdfs, &value )))
+ return ( istat );
- s_ieee = (value & (U_LONG) 0x80000000) >> 31;
- e_ieee = (value & (U_LONG) 0x7F800000) >> 23;
- f_ieee = (value & (U_LONG) 0x007FFFFF);
+ s_ieee = ( value & (U_LONG) 0x80000000 ) >> 31;
+ e_ieee = ( value & (U_LONG) 0x7F800000 ) >> 23;
+ f_ieee = ( value & (U_LONG) 0x007FFFFF );
- f_tmp = (double) f_ieee / 8388608.0; /* divide by 2^23 */
+ f_tmp = (double) f_ieee / 8388608.0; /* divide by 2^23 */
- if (e_ieee == 0) {
- exp = 1 - bias;
- f_new = f_tmp;
+ if ( e_ieee == 0 )
+ {
+ exp = 1 - bias;
+ f_new = f_tmp;
}
- else {
- exp = (int) e_ieee - bias;
- f_new = 1.0 + f_tmp;
+ else
+ {
+ exp = (int) e_ieee - bias;
+ f_new = 1.0 + f_tmp;
}
- fsgl = (float)(f_new * pow(2.0, (double) exp));
- if (s_ieee == 1)
- fsgl = -fsgl;
+ fsgl = (float) ( f_new * pow( 2.0, (double) exp ));
+ if ( s_ieee == 1 )
+ fsgl = -fsgl;
*pf = fsgl;
- if (debug) {
- fprintf(stderr, "Float value (read): %g\n", fsgl);
- print_ieeef(&fsgl, &value);
+ if ( debug )
+ {
+ fprintf( stderr, "Float value (read): %g\n", fsgl );
+ print_ieeef( &fsgl, &value );
}
return 0;
@@ -822,38 +891,40 @@
* The first argument is the original float, the second is the
* IEEE representation. They should be the same on any machine that
* uses IEEE floats.
-\*--------------------------------------------------------------------------*/
+ \*--------------------------------------------------------------------------*/
static void
-print_ieeef(void *vx, void *vy)
+print_ieeef( void *vx, void *vy )
{
- int i;
+ int i;
U_LONG f, *x = (U_LONG *) vx, *y = (U_LONG *) vy;
- char bitrep[33];
+ char bitrep[33];
bitrep[32] = '\0';
f = *x;
- for (i = 0; i < 32; i++) {
- if (f & 1)
- bitrep[32 - i - 1] = '1';
- else
- bitrep[32 - i - 1] = '0';
- f = f >> 1;
+ for ( i = 0; i < 32; i++ )
+ {
+ if ( f & 1 )
+ bitrep[32 - i - 1] = '1';
+ else
+ bitrep[32 - i - 1] = '0';
+ f = f >> 1;
}
- fprintf(stderr, "Binary representation: ");
- fprintf(stderr, "%s\n", bitrep);
+ fprintf( stderr, "Binary representation: " );
+ fprintf( stderr, "%s\n", bitrep );
f = *y;
- for (i = 0; i < 32; i++) {
- if (f & 1)
- bitrep[32 - i - 1] = '1';
- else
- bitrep[32 - i - 1] = '0';
- f = f >> 1;
+ for ( i = 0; i < 32; i++ )
+ {
+ if ( f & 1 )
+ bitrep[32 - i - 1] = '1';
+ else
+ bitrep[32 - i - 1] = '0';
+ f = f >> 1;
}
- fprintf(stderr, "Converted representation: ");
- fprintf(stderr, "%s\n\n", bitrep);
+ fprintf( stderr, "Converted representation: " );
+ fprintf( stderr, "%s\n\n", bitrep );
return;
}
@@ -871,38 +942,38 @@
* PLFLT **z;
*
* Alloc2dGrid(&z, XPTS, YPTS);
-\*--------------------------------------------------------------------------*/
+ \*--------------------------------------------------------------------------*/
void
-plAlloc2dGrid(PLFLT ***f, PLINT nx, PLINT ny)
+plAlloc2dGrid( PLFLT ***f, PLINT nx, PLINT ny )
{
PLINT i;
- if ((*f = (PLFLT **) calloc(nx, sizeof(PLFLT *)))==NULL)
- plexit("Memory allocation error in \"plAlloc2dGrid\"");
+ if (( *f = (PLFLT **) calloc( nx, sizeof ( PLFLT * ))) == NULL )
+ plexit( "Memory allocation error in \"plAlloc2dGrid\"" );
- for (i = 0; i < nx; i++) {
- if (((*f)[i] = (PLFLT *) calloc(ny ,sizeof(PLFLT)))==NULL)
- plexit("Memory allocation error in \"plAlloc2dGrid\"");
+ for ( i = 0; i < nx; i++ )
+ {
+ if ((( *f )[i] = (PLFLT *) calloc( ny, sizeof ( PLFLT ))) == NULL )
+ plexit( "Memory allocation error in \"plAlloc2dGrid\"" );
}
-
}
/*--------------------------------------------------------------------------*\
* Free2dGrid()
*
* Frees a block of memory allocated with Alloc2dGrid().
-\*--------------------------------------------------------------------------*/
+ \*--------------------------------------------------------------------------*/
void
-plFree2dGrid(PLFLT **f, PLINT nx, PLINT ny)
+plFree2dGrid( PLFLT **f, PLINT nx, PLINT ny )
{
PLINT i;
- for (i = 0; i < nx; i++)
- free((void *) f[i]);
+ for ( i = 0; i < nx; i++ )
+ free((void *) f[i] );
- free((void *) f);
+ free((void *) f );
}
/*--------------------------------------------------------------------------*\
@@ -910,27 +981,30 @@
*
* Finds the maximum and minimum of a 2d matrix allocated with plAllc2dGrid().
* NaN and +/- infinity values are ignored.
-\*--------------------------------------------------------------------------*/
+ \*--------------------------------------------------------------------------*/
void
-plMinMax2dGrid(PLFLT **f, PLINT nx, PLINT ny, PLFLT *fmax, PLFLT *fmin)
+plMinMax2dGrid( PLFLT **f, PLINT nx, PLINT ny, PLFLT *fmax, PLFLT *fmin )
{
- int i, j;
+ int i, j;
PLFLT m, M;
- if (!finite(f[0][0])) {
+ if ( !finite( f[0][0] ))
+ {
M = -HUGE_VAL;
m = HUGE_VAL;
}
else
M = m = f[0][0];
- for (i = 0; i < nx; i++) {
- for (j = 0; j < ny; j++) {
- if (!finite(f[i][j])) continue;
- if (f[i][j] > M) M = f[i][j];
- if (f[i][j] < m) m = f[i][j];
- }
+ for ( i = 0; i < nx; i++ )
+ {
+ for ( j = 0; j < ny; j++ )
+ {
+ if ( !finite( f[i][j] )) continue;
+ if ( f[i][j] > M ) M = f[i][j];
+ if ( f[i][j] < m ) m = f[i][j];
+ }
}
*fmax = M;
*fmin = m;
Modified: trunk/src/plarc.c
===================================================================
--- trunk/src/plarc.c 2009-09-22 14:37:18 UTC (rev 10456)
+++ trunk/src/plarc.c 2009-09-23 09:36:41 UTC (rev 10457)
@@ -21,11 +21,11 @@
#include "plplotP.h"
-#define CIRCLE_SEGMENTS PL_MAXPOLY
-#define DEG_TO...
[truncated message content] |