@b4n commented on this pull request.


> +     if (source_file->lang == TM_PARSER_C || source_file->lang == 
> TM_PARSER_CPP)
+       {
+               const gchar **ext;
+               const gchar *common_src_exts[] =
+                       {".c", ".C", ".cc", ".cp", ".cpp", ".cxx", ".c++", 
".CPP", ".CXX", NULL};
+
+               for (ext = common_src_exts; *ext; ext++)
+               {
+                       if (g_str_has_suffix(source_file->short_name, *ext))
+                       {
+                               source_file->is_c_source = TRUE;
+                               break;
+                       }
+               }
+       }
+

wouldn't it be simpler to have `source_file->is_source`, initialize it to 
`TRUE` and use it for all languages, and make it `FALSE` for C and C++ if the 
extension doesn't match any of those?

```C
        source_file->is_source = TRUE;

        if (source_file->lang == TM_PARSER_C || source_file->lang == 
TM_PARSER_CPP)
        {
                const gchar *ext = strrchr(source_file->short_name, '.');

                if (! ext)
                        source_file->is_source = FALSE;
                else
                {
                        int i;
                        const gchar *common_src_exts[] =
                                {"c", "C", "cc", "cp", "cpp", "cxx", "c++", 
"CPP", "CXX"};

                        for (i = 0; i < G_N_ELEMENTS(common_src_exts); i++)
                        {
                                if (strcmp(ext + 1, common_src_exts[i]) == 0)
                                        break
                        }

                        source_file->is_source = (i < 
G_N_ELEMENTS(common_src_exts));
                }
        }
```
note: code above is entirely untested.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3490#pullrequestreview-1417482752
You are receiving this because you are subscribed to this thread.

Message ID: <geany/geany/pull/3490/review/[email protected]>

Reply via email to