Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

formatting edits to make code layout more consistent - remove white space around various constructs #1986

Merged
merged 13 commits into from
Aug 13, 2024
Merged
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
31 changes: 25 additions & 6 deletions Source/shared/file_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ int FFLUSH(void){

/* ------------------ PRINTF ------------------------ */

int PRINTF(const char * format, ...){
int PRINTF(const char *format, ...){
va_list args;
int return_val=0;

Expand Down Expand Up @@ -818,7 +818,7 @@ int GetFileListSize(const char *path, char *filter, int mode){
if(dp == NULL)return 0;
d_type = DT_REG;
if(mode==DIR_MODE)d_type = DT_DIR;
while( (entry = readdir(dp))!=NULL ){
while((entry = readdir(dp))!=NULL){
if(((entry->d_type==d_type||entry->d_type==DT_UNKNOWN)&&MatchWild(entry->d_name,filter)==1)){
if(strcmp(entry->d_name,".")==0||strcmp(entry->d_name,"..")==0)continue;
maxfiles++;
Expand Down Expand Up @@ -947,7 +947,7 @@ int MakeFileList(const char *path, char *filter, int maxfiles, int sort_files, f
NewMemory((void **)&flist,maxfiles*sizeof(filelistdata));
d_type = DT_REG;
if(mode==DIR_MODE)d_type = DT_DIR;
while( (entry = readdir(dp))!=NULL&&nfiles<maxfiles ){
while((entry = readdir(dp))!=NULL&&nfiles<maxfiles){
if((entry->d_type==d_type||entry->d_type==DT_UNKNOWN)&&MatchWild(entry->d_name,filter)==1){
char *file;
filelistdata *flisti;
Expand Down Expand Up @@ -1070,12 +1070,15 @@ char *GetFloatFileSizeLabel(float size, char *sizelabel){
}

#ifdef _WIN32

/* ------------------ GetBinPath - windows ------------------------ */

char *GetBinPath(){
size_t MAX_BUFFER_SIZE = MAX_PATH * 20;
char *buffer;
size_t buffer_size = MAX_PATH * sizeof(char);
NEWMEMORY(buffer, buffer_size);
for (;;){
for(;;){
GetModuleFileNameA(NULL, buffer, buffer_size);
DWORD dw = GetLastError();
if(dw == ERROR_SUCCESS){
Expand All @@ -1093,6 +1096,8 @@ char *GetBinPath(){
}
}

/* ------------------ GetBinDir - windows ------------------------ */

char *GetBinDir(){
char *buffer = GetBinPath();
// NB: This uses on older function in order to support "char *".
Expand All @@ -1101,12 +1106,15 @@ char *GetBinDir(){
return buffer;
}
#elif __linux__

/* ------------------ GetBinPath - linux ------------------------ */

char *GetBinPath(){
size_t MAX_BUFFER_SIZE = 2048 * 20;
char *buffer;
size_t buffer_size = 256 * sizeof(char);
NEWMEMORY(buffer, buffer_size);
for (;;){
for(;;){
int ret = readlink("/proc/self/exe", buffer, buffer_size);
if(ret < buffer_size){
buffer[ret] = '\0';
Expand All @@ -1124,18 +1132,23 @@ char *GetBinPath(){
}
}

/* ------------------ GetBinDir - linux ------------------------ */

char *GetBinDir(){
char *buffer = GetBinPath();
dirname(buffer);
return buffer;
}
#else

/* ------------------ GetBinPath - osx ------------------------ */

char *GetBinPath(){
uint32_t MAX_BUFFER_SIZE = 2048 * 20;
char *buffer;
uint32_t buffer_size = 256 * sizeof(char);
NEWMEMORY(buffer, buffer_size);
for (;;){
for(;;){
int ret = _NSGetExecutablePath(buffer, &buffer_size);
if(ret == 0){
return buffer;
Expand All @@ -1152,6 +1165,8 @@ char *GetBinPath(){
}
}

/* ------------------ GetBinDir - osx ------------------------ */

char *GetBinDir(){
char *buffer = GetBinPath();
// The BSD and OSX version of dirname uses an internal buffer, therefore we
Expand All @@ -1168,6 +1183,8 @@ char *GetBinDir(){
/// GetSmvRootDir.
char *smv_root_override = NULL;

/* ------------------ SetSmvRootOverride ------------------------ */

void SetSmvRootOverride(const char *path){
FREEMEMORY(smv_root_override);
if(path == NULL) return;
Expand All @@ -1179,6 +1196,8 @@ void SetSmvRootOverride(const char *path){
}
}

/* ------------------ GetSmvRootDir ------------------------ */

char *GetSmvRootDir(){
char *envar_path = getenv("SMV_ROOT_OVERRIDE");
if(smv_root_override != NULL){
Expand Down
50 changes: 25 additions & 25 deletions Source/shared/getdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ void getzonesize(const char *zonefilename, int *nzonet, int *nrooms,
rewind(file);
return;
}
while (1){
while(1){
exit_all = 0;
*error = fortread(&dummy, sizeof(dummy), 1, file);
if(*error != 0){
Expand All @@ -159,7 +159,7 @@ void getzonesize(const char *zonefilename, int *nzonet, int *nrooms,
uint32_t dummies[4];

int i;
for (i = 0; i < *nrooms; i++){
for(i = 0; i < *nrooms; i++){
*error = fortread(dummies, sizeof(*dummies), 4, file);
if(*error == 0) continue;
*error = 0;
Expand All @@ -169,7 +169,7 @@ void getzonesize(const char *zonefilename, int *nzonet, int *nrooms,
if(exit_all == 1) break;
// TODO: technically float is not fixed width here.
float fdummies[2];
for (i = 0; i < *nfires; i++){
for(i = 0; i < *nfires; i++){
*error = fortread(fdummies, sizeof(*fdummies), 2, file);
if(*error == 0) continue;
*error = 0;
Expand Down Expand Up @@ -221,7 +221,7 @@ void getpatchsizes2(FILE *file, int version, int npatch, int *npatchsize,
*npatchsize = 0;

int n;
for (n = 0; n < npatch; n++){
for(n = 0; n < npatch; n++){
if(version == 0){
fortread(ijkp, sizeof(*ijkp), 6, file);
} else{
Expand Down Expand Up @@ -443,7 +443,7 @@ void getboundaryheader2(FILE *file, int version, int npatch, int *pi1, int *pi2,
uint32_t ijk[9];

int n;
for (n = 0; n < npatch; n++){
for(n = 0; n < npatch; n++){
if(version == 0){
fortread(ijk, sizeof(*ijk), 6, file);
} else{
Expand Down Expand Up @@ -491,7 +491,7 @@ FILE *openboundary(const char *boundaryfilename, int version, int *error){
uint32_t ijk[9] = {0};

int n;
for (n = 0; n < npatch; n++){
for(n = 0; n < npatch; n++){
if(version == 0){
if(*error == 0){
*error = fortread(ijk, sizeof(*ijk), 6, file);
Expand Down Expand Up @@ -536,14 +536,14 @@ void getpartheader2(FILE *file, int nclasses, int *nquantities, int *size){
*size = 0;

int i;
for (i = 0; i < nclasses; i++){
for(i = 0; i < nclasses; i++){
int t[2] = {0};
fortread(t, sizeof(*t), 2, file);
nquantities[i] = t[0];
*size += 4 + 2 * nquantities[i] * (4 + 30 + 4);

int j;
for (j = 0; j < nquantities[i]; j++){
for(j = 0; j < nquantities[i]; j++){
fortread(clabel, 30, 1, file);
fortread(clabel, 30, 1, file);
}
Expand All @@ -568,7 +568,7 @@ void getpartdataframe(FILE *file, int nclasses, int *nquantities, int *npoints,
if(*error != 0) return;

int i;
for (i = 0; i < nclasses; i++){
for(i = 0; i < nclasses; i++){
*error = fortread(&nparticles, sizeof(nparticles), 1, file);
if(*error != 0) return;
npoints[i] = nparticles;
Expand Down Expand Up @@ -619,11 +619,11 @@ void getzonedata(const char *zonefilename, int *nzonet, int *nrooms,
ii2 = 0;

int j;
for (j = 0; j < *nzonet; j++){
for(j = 0; j < *nzonet; j++){
*error = fortread(&zonet[j], sizeof(zonet[j]), 1, file);

int i;
for (i = 0; i < *nrooms; i++){
for(i = 0; i < *nrooms; i++){
float zonevals[4];
*error = fortread(zonevals, sizeof(*zonevals), 4, file);
zonepr[ii] = zonevals[0];
Expand All @@ -638,7 +638,7 @@ void getzonedata(const char *zonefilename, int *nzonet, int *nrooms,
return;
}
}
for (i = 1; i <= *nfires; i++){
for(i = 1; i <= *nfires; i++){
ii2 = ii2 + 1;
float qdot_arr[2];
*error = fortread(&qdot_arr, sizeof(*qdot_arr), 2, file);
Expand Down Expand Up @@ -674,7 +674,7 @@ void getpatchdata(FILE *file, int npatch, int *pi1, int *pi2, int *pj1,
*npqq = 0;

int i;
for (i = 0; i < npatch; i++){
for(i = 0; i < npatch; i++){
i1 = pi1[i];
i2 = pi2[i];
j1 = pj1[i];
Expand Down Expand Up @@ -722,14 +722,14 @@ void getdata1(FILE *file, int *ipart, int *error){
int idummy[7];

int i;
for (i = 1; i <= nb1; i++){
for(i = 1; i <= nb1; i++){
*error = fortread(idummy, sizeof(*idummy), 7, file);
if(*error != 0) return;
}

*error = fortread(&nv, sizeof(nv), 1, file);
if(*error != 0) return;
for (i = 1; i <= nv; i++){
for(i = 1; i <= nv; i++){
*error = fortread(idummy, sizeof(*idummy), 7, file);
if(*error != 0) return;
}
Expand All @@ -738,7 +738,7 @@ void getdata1(FILE *file, int *ipart, int *error){
if(*error != 0) return;

float dummy[3];
for (i = 1; i <= nspr; i++){
for(i = 1; i <= nspr; i++){
*error = fortread(dummy, sizeof(*dummy), 3, file);
if(*error != 0) return;
}
Expand Down Expand Up @@ -782,7 +782,7 @@ void writeslicedata(const char *slicefilename, int is1, int is2, int js1,
nframe = nxsp * nysp * nzsp;
if(redirect_flag == 0) printf("output slice data to %s\n", slicefilename);
int i;
for (i = 0; i < ntimes; i++){
for(i = 0; i < ntimes; i++){
fortwrite(times + i, sizeof(float), 1, file);
fortwrite(qdata + i*nframe, sizeof(float), nframe, file);
}
Expand All @@ -809,15 +809,15 @@ void getsliceframe(FILE *file, int is1, int is2, int js1, int js2, int ks1,
if(testslice == 2) factor = 1.1;

size_t k;
for (k = 0; k < nzsp; k++){
for(k = 0; k < nzsp; k++){
float kk = 2.0 * ((nzsp - 1) / 2.0 - k) / (nzsp - 1.0);

size_t j;
for (j = 0; j < nysp; j++){
for(j = 0; j < nysp; j++){
float jj = 2.0 * ((nysp - 1) / 2.0 - j) / (nysp - 1.0);

size_t i;
for (i = 0; i < nxsp; i++){
for(i = 0; i < nxsp; i++){
float ii = 2.0 * ((nxsp - 1) / 2.0 - i) / (nxsp - 1.0);
float val =
factor * (*time - 20.0) * (ii * ii + jj * jj + kk * kk) / 20.0;
Expand Down Expand Up @@ -891,7 +891,7 @@ void outboundaryheader(const char *boundaryfilename, FILE **file, int npatches,
uint32_t ijk[7] = {0};

int n;
for (n = 0; n < npatches; n++){
for(n = 0; n < npatches; n++){
ijk[0] = pi1[n];
ijk[1] = pi2[n];
ijk[2] = pj1[n];
Expand All @@ -915,7 +915,7 @@ void outpatchframe(FILE *file, int npatch, int *pi1, int *pi2, int *pj1,
ibeg = 1;

int i;
for (i = 0; i < npatch; i++){
for(i = 0; i < npatch; i++){
i1 = pi1[i];
i2 = pi2[i];
j1 = pj1[i];
Expand Down Expand Up @@ -976,13 +976,13 @@ void getplot3dq(const char *qfilename, int nx, int ny, int nz, float *qq, float
}
else{
int i;
for (i = 0; i < nx; i++){
for(i = 0; i < nx; i++){

int j;
for (j = 0; j < ny; j++){
for(j = 0; j < ny; j++){

int k;
for (k = 0; k < nz; k++){
for(k = 0; k < nz; k++){
qval = pow(i - nx / 2, 2) + pow(j - ny / 2, 2) + pow(k - nz / 2, 2);
qval = sqrt(qval);
if(isotest == 1){
Expand Down
8 changes: 4 additions & 4 deletions Source/shared/isobox.c
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ int GetIsoSurface(isosurface *surface,

/* ------------------ CompareIsoNodes ------------------------ */

int CompareIsoNodes( const void *arg1, const void *arg2 ){
int CompareIsoNodes(const void *arg1, const void *arg2){
sortdata *sdi, *sdj;
unsigned short *vi, *vj;

Expand All @@ -937,7 +937,7 @@ int CompareIsoNodes( const void *arg1, const void *arg2 ){

/* ------------------ ComputeRank ------------------------ */

int ComputeRank( const void *arg1, const void *arg2 ){
int ComputeRank(const void *arg1, const void *arg2){
rankdata *rdi, *rdj;
int sorti, sortj;

Expand All @@ -952,7 +952,7 @@ int ComputeRank( const void *arg1, const void *arg2 ){

/* ------------------ OrderClosestNodes ------------------------ */

int OrderClosestNodes( const void *arg1, const void *arg2 ){
int OrderClosestNodes(const void *arg1, const void *arg2){
orderdata *oi, *oj;
int ii, jj;

Expand Down Expand Up @@ -1830,7 +1830,7 @@ void CCIsoSurfaceT2File(char *isofile, float *t, float *data, int *data2flag, fl
float *yplt, int *ny,
float *zplt, int *nz,
int *reduce_triangles, int *error
){
){
isosurface surface;
int i;
FILE *isostream=NULL;
Expand Down
Loading
Loading