Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ SET (IS_RELEASE FALSE CACHE BOOL "Indicate if we are building w
SET (SAC2C_EXTRA_INC
-DHAVE_CONFIG_H
-I${PROJECT_BINARY_DIR}/include
-I${PROJECT_SOURCE_DIR}/include)
-I${PROJECT_SOURCE_DIR}/include
-I${PROJECT_SOURCE_DIR}
)

SET (SAC2C_CPP_INC
-DHAVE_CONFIG_H
-cppI${PROJECT_BINARY_DIR}/include
-cppI${PROJECT_SOURCE_DIR}/include)
-cppI${PROJECT_SOURCE_DIR}/include
-cppI${PROJECT_SOURCE_DIR})

# Check whether sac2c is operational
LIST (APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake-common")
Expand Down
20 changes: 10 additions & 10 deletions src/stdio/FibreIO.sac
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,23 @@ external double FibreScanDouble(File &stream);
#pragma linkobj "src/FibreIO/ScanDbl.o"

external int[*] FibreScanIntArray(File &stream);
#pragma refcounting [0]
#pragma linksign [1,2]
#pragma linksign [0, 1]
#pragma sacarg [0]
#pragma linkobj "src/FibreIO/ScanIntArr.o"

external float[*] FibreScanFloatArray(File &stream);
#pragma refcounting [0]
#pragma linksign [1,2]
#pragma linksign [0, 1]
#pragma sacarg [0]
#pragma linkobj "src/FibreIO/ScanFltArr.o"

external double[*] FibreScanDoubleArray(File &stream);
#pragma refcounting [0]
#pragma linksign [1,2]
#pragma linksign [0, 1]
#pragma sacarg [0]
#pragma linkobj "src/FibreIO/ScanDblArr.o"

external stringArray FibreScanStringArray(File &stream);
#pragma refcounting [0]
#pragma linksign [1,2]
#pragma linksign [0, 1]
#pragma sacarg [0]
#pragma linkobj "src/FibreIO/ScanStringArr.o"

/******************************************************************************
Expand Down Expand Up @@ -106,8 +106,8 @@ external float[*] FibreScanFloatArrayStr(string stream);
#pragma linkobj "src/FibreIO/ScanFltArr.o"

external double[*] FibreScanDoubleArrayStr(string stream);
#pragma refcounting [0]
#pragma linksign [1,2]
#pragma linksign [0, 1]
#pragma sacarg [0, 1]
#pragma linkobj "src/FibreIO/ScanDblArr.o"

external stringArray FibreScanStringArrayStr(string stream);
Expand Down
2 changes: 1 addition & 1 deletion src/stdio/src/BinFile/binfWriteDblArr.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void SACbinfWriteDoubleArray(int fd, int dim, int *shp, double* array)

res = write(fd,array,size*sizeof(double));
if( res != (ssize_t) (size*sizeof(double))) {
SAC_RuntimeWarning( "only managed to write %d bytes of a %d byte array of doubles",
SAC_RuntimeWarning( "only managed to write %zd bytes of a %"PRIisac" byte array of doubles",
res, size*sizeof(double));
}
}
Expand Down
59 changes: 30 additions & 29 deletions src/stdio/src/FibreIO/FibrePrint.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@

#include "../../../structures/src/StringArray/StringArray.h"

#define INT 1
#define FLOAT 2
#define DOUBLE 3
#define STRING 4
#define BYTE 5
#define SHORT 6
#define LONG 7
#define LONGLONG 8
#define UBYTE 9
#define USHORT 10
#define UINT 11
#define ULONG 12
#define ULONGLONG 13

typedef enum {
INT,
FLOAT,
DOUBLE,
STRING,
BYTE,
SHORT,
LONG,
LONGLONG,
UBYTE,
USHORT,
UINT,
ULONG,
ULONGLONG
} typeflag_t;

#define INDENT(stream, ind) \
{ \
Expand All @@ -30,15 +31,13 @@
}




int FibreWriteAll(FILE *stream, int dim, int *shp, void *arr,
int typeflag, int indent, int done)
sac_int FibreWriteAll(FILE *stream, sac_int dim, sac_int *shp, void *arr,
typeflag_t typeflag, int indent, sac_int done)
{
int i;
sac_int i;

INDENT(stream, indent);
fprintf(stream, "[ 0,%d:\n", (*shp) - 1);
fprintf(stream, "[ 0,%" PRIisac ":\n", (*shp) - 1);

if (dim==1)
{
Expand All @@ -56,7 +55,7 @@ int FibreWriteAll(FILE *stream, int dim, int *shp, void *arr,
break;
case INT:
INDENT(stream, indent+1);
fprintf(stream, "%i\n", ((int*)arr)[done + i]);
fprintf(stream, "%" PRIisac "\n", ((sac_int*)arr)[done + i]);
break;
case LONG:
INDENT(stream, indent+1);
Expand Down Expand Up @@ -104,10 +103,12 @@ int FibreWriteAll(FILE *stream, int dim, int *shp, void *arr,
break;
case STRING:
INDENT(stream, indent+1);
fprintf(stream, "\"%s\"\n", ((array*)arr)->data[done + i]);
const char *str = SACARGgetSharedData(SAC__String__string,
((array*)arr)->elems[done + i]);
fprintf(stream, "\"%s\"\n", str);
break;
default:
SAC_RuntimeError ("illegal typeflag %d", typeflag);
SAC_RuntimeError ("illegal typeflag (int)%d", typeflag);
}
}
done+=*shp;
Expand All @@ -127,7 +128,7 @@ int FibreWriteAll(FILE *stream, int dim, int *shp, void *arr,
typeflag, indent+1, done);
break;
case INT:
done = FibreWriteAll(stream, dim-1, shp+1, ((int*)arr),
done = FibreWriteAll(stream, dim-1, shp+1, ((sac_int*)arr),
typeflag, indent+1, done);
break;
case LONG:
Expand Down Expand Up @@ -183,31 +184,31 @@ int FibreWriteAll(FILE *stream, int dim, int *shp, void *arr,
}


void FibrePrintIntArray( FILE *stream, int dim, int *shape, int *array)
void FibrePrintIntArray(FILE *stream, sac_int dim, sac_int *shape, sac_int *array)
{
(void) FibreWriteAll(stream, dim, shape, array, INT, 0, 0);
}


void FibrePrintFloatArray( FILE *stream, int dim, int *shape, float *array)
void FibrePrintFloatArray( FILE *stream, sac_int dim, sac_int *shape, float *array)
{
(void) FibreWriteAll(stream, dim, shape, array, FLOAT, 0, 0);
}


void FibrePrintDoubleArray( FILE *stream, int dim, int *shape, double *array)
void FibrePrintDoubleArray( FILE *stream, sac_int dim, sac_int *shape, double *array)
{
(void) FibreWriteAll(stream, dim, shape, array, DOUBLE, 0, 0);
}

void FibrePrintStringArray( FILE *stream, int dim, int *shape, array *array)
void FibrePrintStringArray( FILE *stream, sac_int dim, sac_int *shape, array *array)
{
(void) FibreWriteAll(stream, dim, shape, array, STRING, 0, 0);
}

#define PRINTARR(type,alias,switchname) \
\
void FibrePrint##alias##Array( FILE *stream, int dim, int *shape, type *array) \
void FibrePrint##alias##Array( FILE *stream, sac_int dim, sac_int *shape, type *array) \
{ \
(void) FibreWriteAll(stream, dim, shape, array, switchname, 0, 0); \
}
Expand Down
15 changes: 8 additions & 7 deletions src/stdio/src/FibreIO/FibreScan.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>

#include "sac.h"
#include "sacinterface.h"


#define yyFlexLexer FibreScanFlexLexer
Expand Down Expand Up @@ -51,10 +52,10 @@ extern int start_token;
extern int FibreScanlex(void);
extern void doScan( FILE *stream);

extern int boolval;
extern bool boolval;
extern char byteval;
extern short shortval;
extern int intval;
extern sac_int intval;
extern long longval;
extern long long longlongval;
extern unsigned char ubyteval;
Expand All @@ -69,7 +70,7 @@ extern double *doublearray;
extern float *floatarray;
extern char *bytearray;
extern short *shortarray;
extern int *intarray;
extern sac_int *intarray;
extern long *longarray;
extern long long *longlongarray;
extern unsigned char *ubytearray;
Expand All @@ -80,7 +81,7 @@ extern unsigned long long *ulonglongarray;
extern char **stringarray;

extern int got_scaler;
extern int size;
extern int dims;
extern int shape[ MAXDIM];
extern sac_int size;
extern sac_int dims;
extern sac_int shp[ MAXDIM];

Loading