Hello,

In ada-mode 5.1.4 I found and fixed a bug in ada-check-current-project.

If:
- the compilation-search-path contains symbolic links to directories
  containing the sources (e.g. /usr/src -> /disk/g/usr/src)
and
- one source file is currently open under its fully-qualified name
  (e.g. /disk/g/usr/src/my-project/my_source_file.adb),

then ada-check-current-project says the visited file does not belong
to the current project; it thinks the visited file,
/disk/g/usr/src/my-project/my_source_file.adb, is not the same as the
corresponding file in the project,
/usr/src/my-project/my_source_file.adb.

Similar problem if the file itself is a symbolic link, e.g.

/tmp/my_source_file.adb -> /usr/src/my-project/my_source_file.adb

and only /usr/src/my-project/ is in the compilation-search-path.

Similar problem in the (rare) case where the source file has several
names (hard links) in different places.

The only correct way to determine if two file names designate the same
file is to compare their inode numbers.  Patch attached.

--
Ludovic Brenta.
--- ada-mode.el.bak     2014-05-30 14:05:52.000204000 +0200
+++ ada-mode.el 2014-05-30 14:21:17.000000000 +0200
@@ -1869,10 +1869,17 @@
   (when (null (car compilation-search-path))
     (error "no file search path defined; set project file?"))
 
-  (unless (string= file-name
-                  (locate-file (file-name-nondirectory file-name)
-                               compilation-search-path))
-    (error "current file not part of current project; wrong project?")))
+  (let* ((visited-file (file-truename file-name))
+         (found-file (file-truename
+                      (locate-file (file-name-nondirectory visited-file)
+                                   compilation-search-path))))
+    (unless found-file
+      (error "current file not part of current project; wrong project?"))
+    (let* ((visited-file-inode (nth 10 (file-attributes visited-file)))
+           (found-file-inode (nth 10 (file-attributes found-file))))
+      (unless (eq visited-file-inode found-file-inode)
+        (error "%s (opened) and %s (found in project) are two different files"
+               file-name found-file)))))
 
 (defun ada-find-other-file-noset (other-window)
   "Same as `ada-find-other-file', but preserve point in the other file,
_______________________________________________
Emacs-ada-mode mailing list
[email protected]
http://host114.hostmonster.com/mailman/listinfo/emacs-ada-mode_stephe-leake.org

Reply via email to