--- src/CodeGenerator/cg.c 2011-02-01 15:13:28.000000000 +0100 +++ src/CodeGenerator/cg.c 2012-07-02 13:50:41.416293751 +0200 @@ -621,6 +621,8 @@ extern int intel_asm; extern int sse_128; #endif +char _local_int_files[25] = "#$@LOCALINT %*&N"; + #ifdef MAIN_CLM # if !(defined (__MWERKS__) && defined (__cplusplus)) # ifdef CG_PPC_XO @@ -752,7 +754,33 @@ int main (int argc,char **argv) abc_file_name=(char*)memory_allocate (file_name_length+5); strcpy (abc_file_name,file_name); strcat (abc_file_name,".abc"); - + + if(_local_int_files[16] == 'Y') + { + //Override file_name so object_file_name and assembly_file_name come in `pwd`/Clean System Files + char *p,*after_last_slash; + + after_last_slash=NULL; + + p=file_name; + char *old_file_name = file_name; + file_name = (char*)malloc(sizeof(char) * 512); + while (*p) + if (*p++=='/') + after_last_slash=p; + + //filename is in after_last_slash + if(after_last_slash == NULL) + { + after_last_slash = old_file_name; + } + + getcwd(file_name, 500); + strcat (file_name, "/Clean System Files/"); + strcat (file_name, after_last_slash); + file_name_length = strlen(file_name); + } + object_file_name_s=(char*)memory_allocate (file_name_length+6); strcpy (object_file_name_s,file_name); --- src/compiler/backendC/CleanCompilerSources/unix_io.c 2011-05-10 15:11:52.000000000 +0200 +++ src/compiler/backendC/CleanCompilerSources/unix_io.c 2012-07-02 13:50:41.416293751 +0200 @@ -217,6 +217,8 @@ static Bool findfilepath (char *fname, F #include <sys/resource.h> #include <sys/stat.h> +char _local_int_files[25] = "#$@LOCALINT %*&N"; + File FOpen (char *wname, FileKind kind, char *mode) { char path[MAXPATHLEN]; @@ -236,33 +238,60 @@ File FOpen (char *wname, FileKind kind, res=findfilepath (wname,iclFile,mode,path); if (res){ - char *p,*after_last_slash; + if(_local_int_files[16] == 'Y') + { + char *cwd = malloc(sizeof(char) * 512); + + getcwd(cwd, 500); + + if (cwd==NULL) + return NULL; - after_last_slash=NULL; + strcpy (cwd, "/"); + + if (use_clean_system_files_folder){ + strcpy (cwd,"Clean System Files"); + + if (access (cwd,F_OK)!=0){ + if (mkdir (cwd,0777)!=0) + return NULL; + } + + strcat (cwd,"/"); + strcat (cwd,wname); + } else + strcpy (cwd,wname); + strcat (cwd,GetFileExtension (kind)); + return fopen(cwd, mode); + } else { //Non-local + char *p,*after_last_slash; + + after_last_slash=NULL; + + p=path; + while (*p) + if (*p++=='/') + after_last_slash=p; + + if (after_last_slash==NULL) + after_last_slash=path; + + if (use_clean_system_files_folder){ + strcpy (after_last_slash,"Clean System Files"); + + if (access (path,F_OK)!=0){ + if (mkdir (path,0777)!=0) + return NULL; + } + + strcat (after_last_slash,"/"); + strcat (after_last_slash,wname); + } else + strcpy (after_last_slash,wname); + strcat (after_last_slash,GetFileExtension (kind)); + return fopen(path, mode); + } - p=path; - while (*p) - if (*p++=='/') - after_last_slash=p; - - if (after_last_slash==NULL) - after_last_slash=path; - - if (use_clean_system_files_folder){ - strcpy (after_last_slash,"Clean System Files"); - - if (access (path,F_OK)!=0){ - if (mkdir (path,0777)!=0) - return NULL; - } - - strcat (after_last_slash,"/"); - strcat (after_last_slash,wname); - } else - strcpy (after_last_slash,wname); - strcat (after_last_slash,GetFileExtension (kind)); - - return fopen (path,mode); } else return NULL; } --- src/tools/clm/clm.c 2011-12-02 12:58:57.000000000 +0100 +++ src/tools/clm/clm.c 2012-07-02 13:53:17.183324398 +0200 @@ -35,6 +35,7 @@ #include <stdio.h> #include <string.h> #include <ctype.h> +#include <dirent.h> #if defined(I486) || defined (SOLARIS) || defined (LINUX) # include <unistd.h> @@ -184,6 +185,10 @@ char Mcrt1_file_name [PATH_NAME_STRING_SIZE] = "/lib/Mcrt1.o"; #endif +char _local_int[25] = "#$@LOCALINT %*&N"; +char _clean_path_list_root[PATH_LIST_STRING_SIZE] = "#$@PATHLISTRT%*&."; +#define clean_path_list_root (&_clean_path_list_root[16]) + /* default options of cocl */ #define DEFAULT_WARNING 1 @@ -1068,6 +1073,18 @@ static int silent=0; { char *p,*last_colon; + if((_local_int[16] == 'Y') && ((strncmp(file_name, "_SystemEnum", strlen("_SystemEnum")) == 0) || (strncmp(file_name, "_SystemArray", strlen("_SystemArray")) == 0) || (file_name[0] != '_'))) //_-files cannot be built again + { + getcwd(path, 500); + strcat(path, "/"); +#ifndef NO_CLEAN_SYSTEM_FILES_FOLDERS + strcat(path, "Clean System Files/"); +#endif + strcat(path, file_name); + strcat(path, extension); + return; + } + last_colon=path; p=path; while (*p){ @@ -1192,8 +1209,16 @@ static void get_paths (void) clean_abc_path=NULL; clean_o_path=NULL; #else - clean_abc_path=getenv ("CLEANABCPATH"); - clean_o_path=getenv ("CLEANOPATH"); + if(_local_int[16] == 'Y') + { + clean_abc_path = malloc(sizeof(char) * 512); + clean_o_path = malloc(sizeof(char) * 512); + getcwd(clean_abc_path, 500); + getcwd(clean_abc_path, 500); + } else { + clean_abc_path=getenv ("CLEANABCPATH"); + clean_o_path=getenv ("CLEANOPATH"); + } #endif #if defined (OS2) && !defined (OMF) @@ -1240,8 +1265,10 @@ static int get_abc_time (P_NODE project_ { struct stat stat_buffer; - if (!find_clean_system_file (project_node->pro_fname,".abc",file_name,clean_abc_path)) + if (!find_clean_system_file (project_node->pro_fname,".abc",file_name,clean_abc_path)){ + project_node->pro_no_abc_file=1; return 0; + } if (stat (file_name,&stat_buffer)<0){ project_node->pro_no_abc_file=1; @@ -4325,6 +4352,29 @@ int main (int argc,char **argv) last_export_file=NULL; get_paths(); + + //Append clean_path_list_root contents to _clean_path_list with strcat after checking all directories + if(clean_path_list_root[0] != '.') + { + DIR *root_dir = opendir(clean_path_list_root); + if(root_dir) + { + struct dirent *dir; + while(dir = readdir(root_dir)) + { + if((dir->d_name != ".") && (dir->d_name != "..")) + { + if (clean_path_list[0]!='\0') + strcat (clean_path_list,":"); + strcat (clean_path_list,clean_path_list_root); + strcat (clean_path_list,"/"); + strcat (clean_path_list,dir->d_name); + } + } + closedir(root_dir); + } + } + for (arg_n=1; arg_n<argc && argv[arg_n][0]=='-'; ++arg_n){ char *argument,*s;