diff --git a/src/grid2fits.c b/src/grid2fits.c index b80a091..e9e10fd 100644 --- a/src/grid2fits.c +++ b/src/grid2fits.c @@ -413,7 +413,7 @@ Note that data types in all capitals are defined in fitsio.h. int status=0, colI=0, i, di, maxNumCols; LONGLONG firstRow=1, firstElem=1; char genericComment[80]; - char genericKwd[numKwdChars], message[80]; + char genericKwd[numKwdChars], message[STR_LEN_1]; char colName[numColNameChars]; char **allColNames=NULL; int *allColNumbers=NULL, *colDataTypes=NULL; @@ -615,7 +615,7 @@ Ok we have a bit of a tricky situation here in that the number of columns we wri if(collPartNames!=NULL){ if(gridInfo.nDensities>maxNumCollPart){ if(!silent){ - sprintf(message, "There seem to be %d collision partners but keywords can only be written for %d.", (int)gridInfo.nDensities, (int)maxNumCollPart); + snprintf(message, STR_LEN_1, "There seem to be %d collision partners but keywords can only be written for %d.", (int)gridInfo.nDensities, (int)maxNumCollPart); warning(message); } localNumCollPart = maxNumCollPart; @@ -820,7 +820,7 @@ Note that data types in all capitals are defined in fitsio.h. const unsigned int totalNumGridPoints = gridInfo.nInternalPoints+gridInfo.nSinkPoints; unsigned int i_ui; int status=0, xi; - char extname[13]; + char extname[STR_LEN_0];//***[13]; float *row=NULL; int bitpix = FLOAT_IMG; const long naxis = 2; /* i.e. 2-dimensional image */ @@ -895,14 +895,14 @@ countColsBasePlusInt(fitsfile *fptr, char *baseName){ /*....................................................................*/ int countKeywords(fitsfile *fptr, char *baseName){ - char kwdName[9]; + char kwdName[STR_LEN_0];//***[9]; int i, status; - char kwdValue[80]; + char kwdValue[STR_LEN_0]; i = 0; status = 0; while(!status){ - sprintf(kwdName, "%s%d", baseName, i+1); + snprintf(kwdName, STR_LEN_0, "%s%d", baseName, i+1); fits_read_key(fptr, TSTRING, kwdName, kwdValue, NULL, &status); i++; } @@ -918,7 +918,7 @@ readKeywordsFromFITS(fitsfile *fptr, struct keywordType *kwds\ , const int numKeywords){ int i, status; - char message[80]; + char message[STR_LEN_0]; for(i=0;inDims!=DIM){ if(!silent){ - sprintf(message, "%d Xn columns read, but there should be %d.", (int)gridInfoRead->nDims, DIM); + snprintf(message, STR_LEN_0, "%d Xn columns read, but there should be %d.", (int)gridInfoRead->nDims, DIM); bail_out(message); } exit(1); diff --git a/src/grid_aux.c b/src/grid_aux.c index 97d659d..5fa9ba6 100644 --- a/src/grid_aux.c +++ b/src/grid_aux.c @@ -54,14 +54,14 @@ void checkGridDensities(configInfo *par, struct grid *gp){ /* This checks that none of the density samples is too small. */ int i; static _Bool warningAlreadyIssued=0; - char errStr[80]; + char errStr[STR_LEN_1]; if(!silent){ /* Warn if any densities too low. */ i = 0; while(ipIntensity && !warningAlreadyIssued){ if(gp[i].dens[0]=(*numCells) && neighbourNotFound){ if(!silent){ - sprintf(message, "Something weird going on. Cannot find a cell with ID %lu", (unsigned long)(neighbor->id)); + snprintf(message, STR_LEN_1, "Something weird going on. Cannot find a cell with ID %lu", (unsigned long)(neighbor->id)); bail_out(message); } exit(1); diff --git a/src/lime_config.h b/src/lime_config.h index ea6ecaa..f0d1736 100644 --- a/src/lime_config.h +++ b/src/lime_config.h @@ -22,6 +22,7 @@ #define MAX_N_COLL_PART 20 #define TYPICAL_ISM_DENS 1000.0 #define STR_LEN_0 80 +#define STR_LEN_1 127 #define DENSITY_POWER 0.2 #define MAX_N_HIGH 10 diff --git a/src/messages.c b/src/messages.c index 1a69d33..cb6f9fb 100644 --- a/src/messages.c +++ b/src/messages.c @@ -251,7 +251,8 @@ goodnight(int initime){ } void -printMessage(char message[STR_LEN_0]){ +printMessage(char *message){ +//printMessage(char message[STR_LEN_0]){ #ifdef NO_NCURSES if(strlen(message)>0) { @@ -264,7 +265,8 @@ printMessage(char message[STR_LEN_0]){ } void -warning(char message[STR_LEN_0]){ +warning(char *message){ +//warning(char message[STR_LEN_0]){ #ifdef NO_NCURSES if(strlen(message)>0) { @@ -282,7 +284,8 @@ void error(char message[STR_LEN_0]){ } void -bail_out(char message[STR_LEN_0]){ +bail_out(char *message){ +//bail_out(char message[STR_LEN_0]){ #ifdef NO_NCURSES printf("Error: %s\n", message ); #else diff --git a/src/run.c b/src/run.c index eddc440..61148af 100644 --- a/src/run.c +++ b/src/run.c @@ -37,17 +37,17 @@ reportInfAtOrigin(const double value, const char *funcName){ void reportInfsAtOrigin(const int numElements, const double *values, const char *funcName){ int i; - char message[STR_LEN_0]; + char message[STR_LEN_1]; if(numElements<=0){ if((isinf(*values) || isnan(*values)) && !silent){ - snprintf(message, STR_LEN_0, "You have a singularity at the origin of your %s() function.", funcName); + snprintf(message, STR_LEN_1, "You have a singularity at the origin of your %s() function.", funcName); warning(message); } }else{ for(i=0;inSpecies;id++){ if((fp=fopen(par->moldatfile[id], "r"))==NULL){ if(!silent){ - snprintf(message, STR_LEN_0, "Moldat file %s not found locally - fetching it from LAMDA", par->moldatfile[id]); + snprintf(message, STR_LEN_1, "Moldat file %s not found locally - fetching it from LAMDA", par->moldatfile[id]); printMessage(message); } openSocket(par->moldatfile[id]); @@ -482,7 +482,7 @@ exit(1); status = countDensityCols(par->gridInFile, &(par->numDensities)); if (status){ if(!silent){ - snprintf(message, STR_LEN_0, "countDensityCols() status return %d", status); + snprintf(message, STR_LEN_1, "countDensityCols() status return %d", status); bail_out(message); } exit(1); @@ -656,7 +656,7 @@ The cutoff will be the value of abs(x) for which the error in the exact expressi } (*img)[i].imgunits[j-1] = (int)strtol(pch, &pch_end, 0); if(*pch_end){ - snprintf(message, STR_LEN_0, "Image %d: units string contains '%s' which could not be converted to an integer", i, pch_end); + snprintf(message, STR_LEN_1, "Image %d: units string contains '%s' which could not be converted to an integer", i, pch_end); if(!silent) bail_out(message); exit(1); } @@ -680,14 +680,14 @@ exit(1); if((*img)[i].freq<0){ if(!silent){ - snprintf(message, STR_LEN_0, "Image %d: you must set freq for a continuum image.", i); + snprintf(message, STR_LEN_1, "Image %d: you must set freq for a continuum image.", i); bail_out(message); } exit(1); } if(!silent && ((*img)[i].trans>-1 || (*img)[i].bandwidth>-1.0)){ - snprintf(message, STR_LEN_0, "Image %d: bandwidth and trans are ignored for a continuum image.", i); + snprintf(message, STR_LEN_1, "Image %d: bandwidth and trans are ignored for a continuum image.", i); warning(message); } (*img)[i].doline=0; @@ -705,13 +705,13 @@ The presence of one of these combinations at least is checked here, although the */ if((*img)[i].bandwidth > 0 && (*img)[i].velres > 0){ if(!silent && (*img)[i].nchan > 0){ - snprintf(message, STR_LEN_0, "Image %d: your nchan value will be overwritten.", i); + snprintf(message, STR_LEN_1, "Image %d: your nchan value will be overwritten.", i); warning(message); } }else if((*img)[i].nchan <= 0 || ((*img)[i].bandwidth <= 0 && (*img)[i].velres <= 0)) { if(!silent){ - snprintf(message, STR_LEN_0, "Image %d: insufficient info to calculate nchan, velres and bandwidth.", i); + snprintf(message, STR_LEN_1, "Image %d: insufficient info to calculate nchan, velres and bandwidth.", i); bail_out(message); } exit(1); @@ -721,20 +721,20 @@ exit(1); */ if((*img)[i].trans>-1){ /* => user has set trans, possibly also freq. */ if(!silent && (*img)[i].freq > 0){ - snprintf(message, STR_LEN_0, "Image %d: you set trans, so I'm ignoring freq.", i); + snprintf(message, STR_LEN_1, "Image %d: you set trans, so I'm ignoring freq.", i); warning(message); } if((*img)[i].molI < 0){ if(!silent && par->nSpecies>1){ - snprintf(message, STR_LEN_0, "Image %d: you did not set molI, so I'm assuming the 1st molecule.", i); + snprintf(message, STR_LEN_1, "Image %d: you did not set molI, so I'm assuming the 1st molecule.", i); warning(message); } (*img)[i].molI = 0; } }else if((*img)[i].freq<0){ /* => user has set neither trans nor freq. */ if(!silent){ - snprintf(message, STR_LEN_0, "Image %d: you must set either freq or trans (plus optionally molI).", i); + snprintf(message, STR_LEN_1, "Image %d: you must set either freq or trans (plus optionally molI).", i); bail_out(message); } exit(1); @@ -745,7 +745,7 @@ exit(1); if((*img)[i].imgres<0.0){ if(!silent){ - snprintf(message, STR_LEN_0, "Image %d: you must set imgres.", i); + snprintf(message, STR_LEN_1, "Image %d: you must set imgres.", i); bail_out(message); } exit(1); @@ -753,7 +753,7 @@ exit(1); if((*img)[i].pxls<0){ if(!silent){ - snprintf(message, STR_LEN_0, "Image %d: you must set pxls.", i); + snprintf(message, STR_LEN_1, "Image %d: you must set pxls.", i); bail_out(message); } exit(1); @@ -761,7 +761,7 @@ exit(1); if((*img)[i].distance<0.0){ if(!silent){ - snprintf(message, STR_LEN_0, "Image %d: you must set distance.", i); + snprintf(message, STR_LEN_1, "Image %d: you must set distance.", i); bail_out(message); } exit(1); @@ -950,7 +950,7 @@ exit(1); }else{ if((fp=fopen(par->dust, "r"))==NULL){ if(!silent){ - snprintf(message, STR_LEN_0, "Couldn't open dust opacity data file %s", par->dust); + snprintf(message, STR_LEN_1, "Couldn't open dust opacity data file %s", par->dust); bail_out(message); } exit(1);