From 72b2446899b30213647de3d504f3f9058f49b027 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss <creatorsmithmdt@gmail.com>
Date: Thu, 17 Nov 2022 14:16:08 +1100
Subject: [PATCH 11/56] Re-add handling of Java file extensions (.java, .class,
 .zip, .jar).

gcc/ChangeLog:

	* gcc.cc: Re-add compiler defaults for .java and .zip files.
	* gimple-expr.cc (remove_suffix): Change as there is now a longer extension than 4 letters.
	* opts.cc (strip_off_ending): Change as there is now a longer extension than 4 letters.
---
 gcc/gcc.cc         | 2 ++
 gcc/gimple-expr.cc | 4 ++--
 gcc/opts.cc        | 4 ++--
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index ca1c9e27a94..4f596c63773 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -1421,6 +1421,8 @@ static const struct compiler default_compilers[] =
   {".f03", "#Fortran", 0, 0, 0}, {".F03", "#Fortran", 0, 0, 0},
   {".f08", "#Fortran", 0, 0, 0}, {".F08", "#Fortran", 0, 0, 0},
   {".r", "#Ratfor", 0, 0, 0},
+  {".java", "#Java", 0, 0, 0}, {".class", "#Java", 0, 0, 0},
+  {".zip", "#Java", 0, 0, 0}, {".jar", "#Java", 0, 0, 0},
   {".go", "#Go", 0, 1, 0},
   {".d", "#D", 0, 1, 0}, {".dd", "#D", 0, 1, 0}, {".di", "#D", 0, 1, 0},
   /* Next come the entries for C.  */
diff --git a/gcc/gimple-expr.cc b/gcc/gimple-expr.cc
index 4fbce9369c7..c25d8ee4750 100644
--- a/gcc/gimple-expr.cc
+++ b/gcc/gimple-expr.cc
@@ -393,14 +393,14 @@ copy_var_decl (tree var, tree name, tree type)
 /* Strip off a legitimate source ending from the input string NAME of
    length LEN.  Rather than having to know the names used by all of
    our front ends, we strip off an ending of a period followed by
-   up to four characters.  (like ".cpp".)  */
+   up to five characters.  (Java uses ".class".)  */
 
 static inline void
 remove_suffix (char *name, int len)
 {
   int i;
 
-  for (i = 2;  i < 7 && len > i;  i++)
+  for (i = 2;  i < 8 && len > i;  i++)
     {
       if (name[len - i] == '.')
 	{
diff --git a/gcc/opts.cc b/gcc/opts.cc
index 3797784c865..5df153cc2cb 100644
--- a/gcc/opts.cc
+++ b/gcc/opts.cc
@@ -275,13 +275,13 @@ set_struct_debug_option (struct gcc_options *opts, location_t loc,
 /* Strip off a legitimate source ending from the input string NAME of
    length LEN.  Rather than having to know the names used by all of
    our front ends, we strip off an ending of a period followed by
-   up to fource characters.  (C++ uses ".cpp".)  */
+   up to five characters.  (Java uses ".class".)  */
 
 void
 strip_off_ending (char *name, int len)
 {
   int i;
-  for (i = 2; i < 5 && len > i; i++)
+  for (i = 2; i < 6 && len > i; i++)
     {
       if (name[len - i] == '.')
 	{
-- 
2.38.1

Reply via email to