Browse Source

src/drivers/opencl/driver_opencl_utils.c: deal with cases when no directory is found

Nathalie Furmento 13 years ago
parent
commit
dc3ed7d4eb
1 changed files with 5 additions and 2 deletions
  1. 5 2
      src/drivers/opencl/driver_opencl_utils.c

+ 5 - 2
src/drivers/opencl/driver_opencl_utils.c

@@ -73,7 +73,8 @@ int _starpu_opencl_locate_file(const char *source_file_name, char *located_file_
 	}
 	else {
 		char *last = strrchr(located_file_name, '/');
-		if (last) {
+		if (!last) strcpy(located_dir_name, "");
+		else {
 			sprintf(located_dir_name, "%s", located_file_name);
 			located_dir_name[strlen(located_file_name)-strlen(last)+1] = '\0';
 		}
@@ -215,7 +216,9 @@ int starpu_opencl_load_opencl_from_file(const char *source_file_name, struct sta
         if(!opencl_program_source)
                 _STARPU_ERROR("Failed to load compute program from file <%s>!\n", located_file_name);
 
-	if (build_options)
+	if (!strcmp(located_dir_name, ""))
+		strcpy(new_build_options, build_options);
+	else if (build_options)
 		sprintf(new_build_options, "-I %s %s", located_dir_name, build_options);
 	else
 		sprintf(new_build_options, "-I %s", located_dir_name);