- /* If the filename ends in .c or .i, put options around it.
- But not if a specified -x option is currently active. */
- len = strlen (argv[i]);
- if (len > 2
- && (argv[i][len - 1] == 'c' || argv[i][len - 1] == 'i')
- && argv[i][len - 2] == '.')
- {
- args[i] |= LANGSPEC;
- added += 2;
- }
+ if (saw_speclang)
+ {
+ saw_speclang = 0;
+ continue;
+ }
+
+ /* If the filename ends in .[chi], put options around it.
+ But not if a specified -x option is currently active. */
+ len = strlen (arg);
+ if (len > 2
+ && (arg[len - 1] == 'c'
+ || arg[len - 1] == 'i'
+ || arg[len - 1] == 'h')
+ && arg[len - 2] == '.')
+ {
+ args[i] |= LANGSPEC;
+ added += 2;
+ }
+
+ /* If we don't know that this is a header file, we might
+ need to be linking in the libraries. */
+ if (library == 0)
+ {
+ if ((len <= 2 || strcmp (arg + (len - 2), ".H") != 0)
+ && (len <= 2 || strcmp (arg + (len - 2), ".h") != 0)
+ && (len <= 4 || strcmp (arg + (len - 4), ".hpp") != 0)
+ && (len <= 3 || strcmp (arg + (len - 3), ".hp") != 0)
+ && (len <= 4 || strcmp (arg + (len - 4), ".hxx") != 0)
+ && (len <= 4 || strcmp (arg + (len - 4), ".h++") != 0)
+ && (len <= 4 || strcmp (arg + (len - 4), ".HPP") != 0)
+ && (len <= 4 || strcmp (arg + (len - 4), ".tcc") != 0)
+ && (len <= 3 || strcmp (arg + (len - 3), ".hh") != 0))
+ library = 1;
+ }
+ }
+ break;