]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
a68: do not try extensionless packet files in a68_get_packet_exports
authorJose E. Marchesi <jose.marchesi@oracle.com>
Wed, 10 Dec 2025 03:30:37 +0000 (04:30 +0100)
committerJose E. Marchesi <jose.marchesi@oracle.com>
Wed, 10 Dec 2025 16:21:38 +0000 (17:21 +0100)
This commit makes ga68 to not look to exports data in files without
extensions, i.e. to not look in a file `foo' for packet Foo. The files
to try are: first foo.m68, then libfoo.so, then libfoo.a, finally
foo.o.

Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>
gcc/algol68/ChangeLog

* a68-imports.cc (a68_try_packet_in_directory): do not try
extensionless packet files.

gcc/algol68/a68-imports.cc

index 6b203b26273b077a2a7b5912ccf125749948969a..eab3dc7f01b87a98fb9c470ba76b5a8af354a483 100644 (file)
@@ -240,29 +240,9 @@ static char *
 a68_try_packet_in_directory (const std::string &filename, size_t *psize)
 {
   std::string found_filename = filename;
-  int fd = open (found_filename.c_str(), O_RDONLY | O_BINARY);
-
-  if (fd >= 0)
-    {
-      struct stat s;
-      if (fstat (fd, &s) >= 0 && S_ISDIR (s.st_mode))
-       {
-         close (fd);
-         fd = -1;
-         errno = EISDIR;
-       }
-    }
-
+  int fd = a68_try_suffixes (&found_filename);
   if (fd < 0)
-    {
-      if (errno != ENOENT && errno != EISDIR)
-       a68_warning (NO_NODE, 0, "cannot open file Z for imports",
-                    filename.c_str ());
-
-      fd = a68_try_suffixes (&found_filename);
-      if (fd < 0)
-       return NULL;
-    }
+    return NULL;
 
   /* The export data may not be in this file.  */
   char *exports = a68_find_export_data (found_filename, fd, psize);
@@ -291,7 +271,8 @@ a68_try_packet_in_directory (const std::string &filename, size_t *psize)
    When FILENAME does start with ./ or ../, we use RELATIVE_IMPORT_PATH as a
    prefix.
 
-   When FILENAME does not exist, we try modifying FILENAME to find the file.
+   When FILENAME does not exist, we try
+   modifying FILENAME to find the file.
    We use the first of these which exists:
 
    - We append ".m68".
@@ -357,7 +338,7 @@ a68_get_packet_exports (const std::string &filename,
     {
       for (std::string path : A68_IMPORT_PATHS)
        {
-         if (path.empty () && path[path.size () - 1] != '/')
+         if (!path.empty () && path[path.size () - 1] != '/')
            path += '/';
          path += fn;
          exports = a68_try_packet_in_directory (path, psize);