Skip to content

Commit

Permalink
Fix bug in deleted_list_init; fix ez_delimited_read dates without tim…
Browse files Browse the repository at this point in the history
…es; remove many C warnings - mostly unused variables but also invalid match of scan format to args

git-svn-id: file:///home/users/tmap/svn/repos/ferret/trunk@24162 fdbf22ae-c210-0410-be80-ca943da6b8f8
  • Loading branch information
karlmsmith committed Aug 31, 2017
1 parent b0d7dbe commit 8da6458
Show file tree
Hide file tree
Showing 23 changed files with 39 additions and 203 deletions.
22 changes: 6 additions & 16 deletions fer/ccr/EF_InternalUtil.c
Original file line number Diff line number Diff line change
Expand Up @@ -1281,7 +1281,6 @@ static int continue_efcn_scan(int gfcn_num_internal) {
char allpaths[8192]="";
char cmd[EF_MAX_DESCRIPTION_LENGTH]="";
int count=0;
int status=LIST_OK;
int i_intEF;
char *extension;

Expand Down Expand Up @@ -1964,8 +1963,7 @@ void FORTRAN(efcn_get_custom_axes)( int *id_ptr, int *cx_list_ptr, int *status )

canjump = 1;

sprintf(tempText, "");
strcat(tempText, ef_ptr->name);
strcpy(tempText, ef_ptr->name);
strcat(tempText, "_custom_axes_");

if (!internally_linked) {
Expand Down Expand Up @@ -2114,8 +2112,7 @@ void FORTRAN(efcn_get_result_limits)( int *id_ptr, int *mr_list_ptr, int *cx_lis
canjump = 1;


sprintf(tempText, "");
strcat(tempText, ef_ptr->name);
strcpy(tempText, ef_ptr->name);
strcat(tempText, "_result_limits_");

if (!internally_linked) {
Expand Down Expand Up @@ -2214,7 +2211,7 @@ void FORTRAN(efcn_compute)( int *id_ptr, int *narg_ptr, int *cx_list_ptr, int *m
ExternalFunction *ef_ptr=NULL;
ExternalFunctionInternals *i_ptr=NULL;
DFTYPE *arg_ptr[EF_MAX_COMPUTE_ARGS];
int xyzt=0, i=0, j=0;
int i=0, j=0;
int size=0;
int nargs=0;
char tempText[EF_MAX_NAME_LENGTH]="";
Expand Down Expand Up @@ -2335,8 +2332,7 @@ void FORTRAN(efcn_compute)( int *id_ptr, int *narg_ptr, int *cx_list_ptr, int *m

} else if (i_ptr->num_work_arrays > 0) {

sprintf(tempText, "");
strcat(tempText, ef_ptr->name);
strcpy(tempText, ef_ptr->name);
strcat(tempText, "_work_size_");

if (!internally_linked) {
Expand Down Expand Up @@ -2451,8 +2447,7 @@ void FORTRAN(efcn_compute)( int *id_ptr, int *narg_ptr, int *cx_list_ptr, int *m
* Now go ahead and call the external function's "_compute_" function,
* prototyping it for the number of arguments expected.
*/
sprintf(tempText, "");
strcat(tempText, ef_ptr->name);
strcpy(tempText, ef_ptr->name);
strcat(tempText, "_compute_");

switch ( i_ptr->num_reqd_args + i_ptr->num_work_arrays ) {
Expand Down Expand Up @@ -2937,7 +2932,6 @@ int FORTRAN(efcn_get_id)( char name[] )
int FORTRAN(efcn_match_template)( int *id_ptr, char template[] )
{
ExternalFunction *ef_ptr=NULL;
int status=LIST_OK;
int EF_LT_MT_return;

static int return_val=0; /* static because it needs to exist after the return statement */
Expand Down Expand Up @@ -3405,7 +3399,7 @@ void FORTRAN(ef_err_bail_out)(int *id_ptr, char *text)
int EF_New( ExternalFunction *this )
{
ExternalFunctionInternals *i_ptr=NULL;
int status=LIST_OK, i=0, j=0;
int i=0, j=0;

static int return_val=0; /* static because it needs to exist after the return statement */

Expand Down Expand Up @@ -3476,13 +3470,10 @@ int EF_New( ExternalFunction *this )
void EF_store_globals(int *mr_list_ptr, int *cx_list_ptr,
int *mres_ptr, DFTYPE *bad_flag_ptr)
{
int i=0;

GLOBAL_mr_list_ptr = mr_list_ptr;
GLOBAL_cx_list_ptr = cx_list_ptr;
GLOBAL_mres_ptr = mres_ptr;
GLOBAL_bad_flag_ptr = bad_flag_ptr;

}
void FORTRAN(efcn_pass_arg_ptr)(int *iarg, DFTYPE *arg_ptr)
{
Expand Down Expand Up @@ -3527,7 +3518,6 @@ ExternalFunction *ef_ptr_from_id_ptr(int *id_ptr)

int EF_ListTraverse_fprintf( char *data, char *curr )
{
FILE *File_ptr=(FILE *)data;
ExternalFunction *ef_ptr=(ExternalFunction *)curr;

fprintf(stderr, "path = \"%s\", name = \"%s\", id = %d, internals_ptr = %ld\n",
Expand Down
11 changes: 2 additions & 9 deletions fer/ccr/binaryRead.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,6 @@ static FileInfo *createBinaryReader(char *name, int lengths[MAXDIMS], int permut
return fi;
}

static void deleteVar(VarInfo *theVar) {
/* paranoia */
memset(theVar, 0, sizeof(VarInfo));
FerMem_Free(theVar, __FILE__, __LINE__);
}

static void deleteBinaryReader(FileInfo *fi){
FerMem_Free(fi->vars, __FILE__, __LINE__);
fi->vars = NULL;
Expand All @@ -200,7 +194,6 @@ static void deleteBinaryReader(FileInfo *fi){

static int addVar(FileInfo *fi, DFTYPE *data, int type, int doRead){
VarInfo *theVar = 0;
int i;

if (fi->vars == (VarInfo *)0){
fi->vars = FerMem_Malloc(sizeof(VarInfo), __FILE__, __LINE__);
Expand Down Expand Up @@ -247,7 +240,7 @@ static void SWAP(unsigned char *p1, unsigned char *p2)
}

/* switch the order of the bytes in a long integer */
static int SWAP32(void *i_in)
static void SWAP32(void *i_in)
{
unsigned char *inptr = (unsigned char *)i_in;
SWAP(inptr, &inptr[3]);
Expand All @@ -261,7 +254,7 @@ static void SWAP16(void *i_in)
SWAP(inptr, &inptr[1]);
}

static double SWAP64(void *i_in)
static void SWAP64(void *i_in)
{
unsigned char *inptr = (unsigned char *)i_in;
SWAP(inptr, &inptr[7]);
Expand Down
10 changes: 2 additions & 8 deletions fer/ccr/copy_buffered_window.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,9 @@

void FORTRAN(copy_buffered_window)(int *ws_id, int *anim_id)
{
WS_STATE_ENTRY *ws, *anim, *temp_win;
WS_STATE_ENTRY *ws, *anim;
unsigned width, height;
XWindowAttributes win_info, anim_win_info;
int src_absx, src_absy, dest_absx, dest_absy;
int screen, tmp_id;
Window dummywin;
Pixmap pixmap;
XWindowAttributes win_info;

/* determine the XGKS ws state entry structure from ws_id */
ws = OPEN_WSID (*ws_id);
Expand All @@ -69,8 +65,6 @@ void FORTRAN(copy_buffered_window)(int *ws_id, int *anim_id)
exit(1);
}

screen = DefaultScreen(ws->dpy);

width = win_info.width;
height = win_info.height;

Expand Down
4 changes: 0 additions & 4 deletions fer/ccr/fermain_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ int main(int oargc, char *oargv[])
int journalfile = 1;
int verify_flag = 1;
int len_str;
int uvar_dset;
int bat_mode;

its_script = 0;
Expand Down Expand Up @@ -418,9 +417,7 @@ static void command_line_run()
FILE *fp = 0;
char init_command[2176], script_file[2048], *home = getenv("HOME");
int ipath = 0;
int len_str = 0;
int script_resetmem = 0;
double rmem_size;

/* turn on ^C interrupts */
/* 10/97 *kob* add check for gui now that there is only one main program */
Expand Down Expand Up @@ -462,7 +459,6 @@ static void command_line_run()
strcat( init_command, " ");
}
if (arg_pos !=0) {
len_str = strlen(init_command);
strcat( init_command, script_args );
}
strcat( init_command, "; EXIT/PROGRAM");
Expand Down
1 change: 0 additions & 1 deletion fer/ccr/ferret_dispatch_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ void ferret_dispatch_c(char *init_command, smPtr sBuffer)
{
int flag_buff_size = NUMFLAGS;
int TEXTLENGTH_size = TEXTLENGTH;
int NUMDOUBLES_size = NUMDOUBLES;

/* call the FORTRAN program that actually does the FERRET command */
/* all arguments must be pointers for FORTRAN */
Expand Down
66 changes: 5 additions & 61 deletions fer/ccr/grab_image_xwd.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,53 +125,32 @@

#define FEEP_VOLUME 0

#include "ferret.h"
#include "FerMem.h"

/* Setable Options */

static int format = ZPixmap;
static Bool nobdrs = False;
static Bool on_root = False;
static Bool standard_out = True;
/* static Bool debug = False; */
static Bool use_installed = False;
static long add_pixel_value = 0;

static int Image_Size(XImage *image);
static int Get_XColors(XWindowAttributes *win_info, XImage *image, XColor **colors, Display *dpy);

static int endian_type (void)
{
return (*(short *) "AZ")& 255;
}

static long parse_long(char *s)
{
char *fmt = "%lu";
long retval = 0L;
int thesign = 1;

if (s && s[0]) {
if (s[0] == '-') s++, thesign = -1;
if (s[0] == '0') s++, fmt = "%lo";
if (s[0] == 'x' || s[0] == 'X') s++, fmt = "%lx";
(void) sscanf (s, fmt, &retval);
}
return (thesign * retval);
}

/*
* Window_Dump: dump a window to a file which must already be open for
* writting.
*/

void Window_Dump(Window window, Display *dpy, char *outfile, char *type)
{
unsigned long swaptest = 1;
XColor *colors = NULL;
unsigned buffer_size;
int win_name_size;
int header_size;
int ncolors, i;
char *win_name;
Bool got_win_name;
Expand All @@ -181,7 +160,6 @@ void Window_Dump(Window window, Display *dpy, char *outfile, char *type)
int absx, absy, x, y;
unsigned width, height;
int dwidth, dheight;
int bw;
Window dummywin;
int *r, *g, *b;
void (*func)();
Expand Down Expand Up @@ -227,19 +205,7 @@ void Window_Dump(Window window, Display *dpy, char *outfile, char *type)
win_info.y = absy;
width = win_info.width;
height = win_info.height;
bw = 0;

/* If borders are taken into account with unmapped windows, things crash.
this check on borders in xwd code not needed here.
if (!nobdrs) {
absx -= win_info.border_width;
absy -= win_info.border_width;
bw = win_info.border_width;
width += (2 * bw);
height += (2 * bw);
}

*/
dwidth = DisplayWidth (dpy, screen);
dheight = DisplayHeight (dpy, screen);

Expand All @@ -258,9 +224,6 @@ void Window_Dump(Window window, Display *dpy, char *outfile, char *type)
got_win_name = True;
}

/* sizeof(char) is included for the null string terminator. */
win_name_size = strlen(win_name) + sizeof(char);

/*
* Snarf the pixmap with XGetImage.
*/
Expand Down Expand Up @@ -294,11 +257,6 @@ void Window_Dump(Window window, Display *dpy, char *outfile, char *type)

if (add_pixel_value != 0) XAddPixel (image, add_pixel_value);

/*
* Determine the pixmap size.
*/
buffer_size = Image_Size(image);

/* if (debug) outl("xwd: Getting Colors.\n");*/

ncolors = Get_XColors(&win_info, image, &colors,dpy);
Expand Down Expand Up @@ -376,18 +334,6 @@ void Window_Dump(Window window, Display *dpy, char *outfile, char *type)
XDestroyImage(image);
}

/*
* Determine the pixmap size.
*/

static int Image_Size(XImage *image)
{
if (image->format != ZPixmap)
return(image->bytes_per_line * image->height * image->depth);

return(image->bytes_per_line * image->height);
}

#define lowbit(x) ((x) & (~(x) + 1))
#define lowbyte(x) ((x) & (~(x) + 8))

Expand All @@ -400,8 +346,6 @@ static int Get_XColors(XWindowAttributes *win_info, XImage *image, XColor **colo
unsigned long pixel;
unsigned char *cptr,tmp_cptr;

Pixel pmask = 0xff000000;

Bool reverse_bytes;

Colormap cmap = win_info->colormap;
Expand All @@ -426,7 +370,7 @@ static int Get_XColors(XWindowAttributes *win_info, XImage *image, XColor **colo
win_info->visual->class == TrueColor) {

int nunique_colors;
char ind;
int ind;
char *color_indices = (char *) image->data;
unsigned int *color_values = (unsigned int *) image->data;
/* int npixels = image->bytes_per_line * image->height; */
Expand Down Expand Up @@ -462,18 +406,18 @@ static int Get_XColors(XWindowAttributes *win_info, XImage *image, XColor **colo
/* see if this pixel matches a known color index */
ind = 0;

while ( (ind < (int) nunique_colors)
while ( (ind < nunique_colors)
&& (color_values[i] != (*colors)[ind].pixel) ) ind++;

/* store unique color just found */
if (ind == (int)nunique_colors ) {
if (ind == nunique_colors ) {
(*colors)[ind].pixel = color_values[i];
nunique_colors++;
}

/* replace color with index pointer in image structure */
/* (Read the image as color_values. Write it as color_indices) */
color_indices[i] = ind;
color_indices[i] = (char) ind;
}


Expand Down
8 changes: 0 additions & 8 deletions fer/ccr/put_frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,10 @@
void FORTRAN(put_frame)(int *ws_id, char *filename, char *errstr, char *format, int *status)
{
WS_STATE_ENTRY *ws;
Display *mydisplay;
Window mywindow;

/* determine the XGKS ws state entry structure from ws_id */
ws = OPEN_WSID (*ws_id);

/* the next 2 lines are diagnostic
mydisplay = ws->dpy;
mywindow = ws->win;
*/

/* call up the capture routine */
/* Errors internal to Window_Dump com out in errstr */
Window_Dump(ws->win,ws->dpy,filename,format);
Expand All @@ -92,7 +85,6 @@ void FORTRAN(put_frame)(int *ws_id, char *filename, char *errstr, char *format,
void FORTRAN(put_frame_batch)(int *ws_id, char *filename, char *format, int *transp,
DFTYPE *red, DFTYPE *green, DFTYPE *blue, char *errmsg, int *status)
{
char oldfilename[BUFSIZ];
WS_STATE_ENTRY *ws = OPEN_WSID(*ws_id);
*status = 0;

Expand Down
1 change: 0 additions & 1 deletion fer/ccr/replace_bad_data_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
void FORTRAN(replace_bad_data_sub)(DFTYPE *old_bad, DFTYPE *src, int *size, DFTYPE *new_bad)
{
int i;
double tmp;

if (isnan(*old_bad)) {
for (i=0; i<*size; i++)
Expand Down
Loading

0 comments on commit 8da6458

Please sign in to comment.