aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2020-06-26 00:17:52 -0400
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2020-07-04 10:05:34 -0400
commit610c4d2b83ee9298956095bd54fedea367a13bf5 (patch)
tree6c2d80ee4ae1e346cd8b710e1fb360e1966e7b27
parentedaff441de1015068d7cee64c222f3c65fcd7dc6 (diff)
downloadrneovim-610c4d2b83ee9298956095bd54fedea367a13bf5.tar.gz
rneovim-610c4d2b83ee9298956095bd54fedea367a13bf5.tar.bz2
rneovim-610c4d2b83ee9298956095bd54fedea367a13bf5.zip
'clang/Logic error': use enums to avoid undefined array subscript
-rw-r--r--src/nvim/hardcopy.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c
index f1f84e63be..4a64cc31b1 100644
--- a/src/nvim/hardcopy.c
+++ b/src/nvim/hardcopy.c
@@ -210,10 +210,25 @@ struct prt_ps_mbfont_S {
char *defcs;
};
+// Types of PS resource file currently used
+typedef enum {
+ PRT_RESOURCE_TYPE_PROCSET = 0,
+ PRT_RESOURCE_TYPE_ENCODING = 1,
+ PRT_RESOURCE_TYPE_CMAP = 2,
+} PrtResourceType;
+
+// String versions of PS resource types
+static const char *const prt_resource_types[] =
+{
+ [PRT_RESOURCE_TYPE_PROCSET] = "procset",
+ [PRT_RESOURCE_TYPE_ENCODING] = "encoding",
+ [PRT_RESOURCE_TYPE_CMAP] = "cmap",
+};
+
struct prt_ps_resource_S {
char_u name[64];
char_u filename[MAXPATHL + 1];
- int type;
+ PrtResourceType type;
char_u title[256];
char_u version[256];
};
@@ -1171,11 +1186,6 @@ static struct prt_ps_mbfont_S prt_ps_mbfonts[] =
}
};
-// Types of PS resource file currently used
-#define PRT_RESOURCE_TYPE_PROCSET (0)
-#define PRT_RESOURCE_TYPE_ENCODING (1)
-#define PRT_RESOURCE_TYPE_CMAP (2)
-
/* The PS prolog file version number has to match - if the prolog file is
* updated, increment the number in the file and here. Version checking was
* added as of VIM 6.2.
@@ -1189,16 +1199,6 @@ static struct prt_ps_mbfont_S prt_ps_mbfonts[] =
#define PRT_PROLOG_VERSION ((char_u *)"1.4")
#define PRT_CID_PROLOG_VERSION ((char_u *)"1.0")
-/* String versions of PS resource types - indexed by constants above so don't
- * re-order!
- */
-static char *prt_resource_types[] =
-{
- "procset",
- "encoding",
- "cmap"
-};
-
// Strings to look for in a PS resource file
#define PRT_RESOURCE_HEADER "%!PS-Adobe-"
#define PRT_RESOURCE_RESOURCE "Resource-"
@@ -1845,10 +1845,11 @@ static void prt_dsc_ints(char *comment, int count, int *ints)
}
static void prt_dsc_resources(
- char *comment, // if NULL add to previous
- char *type,
- char *string
+ const char *comment, // if NULL add to previous
+ const char *type,
+ const char *string
)
+ FUNC_ATTR_NONNULL_ARG(2, 3)
{
if (comment != NULL)
vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),