Merge release-2019 into master
[alexxy/gromacs.git] / src / gromacs / gmxpreprocess / gmxcpp.cpp
index a8e621ca342a16c925ce0a0cf2bc4f39e872b68f..d232b55dbf109e4f0aae681c6b3cc9999a114990 100644 (file)
@@ -453,6 +453,11 @@ process_directive(gmx_cpp_t         *handlep,
         {
             return eCPP_SYNTAX;
         }
+        // An include needs to be followed by either a '"' or a '<' as a first character.
+        if ((dval[0] != '"') && (dval[0] != '<'))
+        {
+            return eCPP_INVALID_INCLUDE_DELIMITER;
+        }
         for (size_t i1 = 0; i1 < dval.size(); i1++)
         {
             if ((dval[i1] == '"') || (dval[i1] == '<') || (dval[i1] == '>'))
@@ -575,7 +580,7 @@ int cpp_read_line(gmx_cpp_t *handlep, int n, char buf[])
             if (!bEOF)
             {
                 /* Something strange happened, fgets returned NULL,
-                 * but we are not at EOF.
+                 * but we are not at EOF. Maybe wrong line endings?
                  */
                 return eCPP_UNKNOWN;
             }
@@ -734,8 +739,8 @@ char *cpp_error(gmx_cpp_t *handlep, int status)
     char        buf[256];
     const char *ecpp[] = {
         "OK", "File not found", "End of file", "Syntax error", "Interrupted",
-        "Invalid file handle",
-        "File not open", "Unknown error", "Error status out of range"
+        "Invalid file handle", "Invalid delimiter for filename in #include statement",
+        "File not open", "Unknown error, perhaps your text file uses wrong line endings?", "Error status out of range"
     };
     gmx_cpp_t   handle = *handlep;