OSDN Git Service

compiler-calculated maximum value for `m_SourceDefs` (#966)
authorSimon Sobisch <simonsobisch@web.de>
Mon, 13 Sep 2021 10:08:18 +0000 (12:08 +0200)
committerGitHub <noreply@github.com>
Mon, 13 Sep 2021 10:08:18 +0000 (19:08 +0900)
removing the need to manually adjust the size when `TextType` is adjusted

Externals/crystaledit/editlib/parsers/crystallineparser.h

index 05b6b7e..1098cdd 100644 (file)
@@ -68,7 +68,7 @@ struct TEXTBLOCK
 \r
 typedef enum\r
 {\r
-       SRC_PLAIN,\r
+       SRC_PLAIN = 0,\r
        SRC_ASP,\r
        SRC_AUTOIT,\r
        SRC_BASIC,\r
@@ -108,7 +108,8 @@ typedef enum
        SRC_TEX,\r
        SRC_VERILOG,\r
        SRC_VHDL,\r
-       SRC_XML\r
+       SRC_XML,\r
+       SRC_MAX_ENTRY   /* always last entry, used for bound checking */\r
 }\r
 TextType;\r
 \r
@@ -129,7 +130,7 @@ struct TextDefinition
        unsigned encoding;\r
 };\r
 \r
-extern TextDefinition m_SourceDefs[41];\r
+extern TextDefinition m_SourceDefs[SRC_MAX_ENTRY];\r
 \r
 bool IsXKeyword(const TCHAR *pszKey, size_t nKeyLen, const TCHAR *pszKeywordList[], size_t nKeywordListCount, int(*compare)(const TCHAR *, const TCHAR *, size_t));\r
 bool IsXNumber(const TCHAR* pszChars, int nLength);\r