From: Peter Verthez Date: Sun, 15 Sep 2002 18:25:42 +0000 (+0000) Subject: Taking care of const correctness. X-Git-Url: https://git.dlugolecki.net.pl/?a=commitdiff_plain;h=5fe34c1f751845fb0912834069c8e357a4cc0d6d;p=gedcom-parse.git Taking care of const correctness. --- diff --git a/gedcom/gedcom.y b/gedcom/gedcom.y index b10e0c2..4381102 100644 --- a/gedcom/gedcom.y +++ b/gedcom/gedcom.y @@ -162,7 +162,7 @@ char *line_item_buf_ptr; /* These are defined at the bottom of the file */ void push_countarray(); -void set_parenttag(char* tag); +void set_parenttag(const char* tag); char* get_parenttag(int offset); void set_parentctxt(Gedcom_ctxt ctxt); Gedcom_ctxt get_parentctxt(int offset); @@ -3816,7 +3816,7 @@ void push_countarray() } } -void set_parenttag(char* tag) +void set_parenttag(const char* tag) { strncpy(tag_stack[count_level+1], tag, MAXSTDTAGLEN+1); } diff --git a/gedcom/gedcom_internal.h b/gedcom/gedcom_internal.h index 5a199dd..e343181 100644 --- a/gedcom/gedcom_internal.h +++ b/gedcom/gedcom_internal.h @@ -57,7 +57,7 @@ struct tag_struct { int gedcom_parse(); int gedcom_lex(); -void gedcom_mem_error(char *filename, int line); +void gedcom_mem_error(const char *filename, int line); #define MEMORY_ERROR gedcom_mem_error(__FILE__, __LINE__) diff --git a/gedcom/gedcom_lex_common.c b/gedcom/gedcom_lex_common.c index 0a01f15..3785da2 100644 --- a/gedcom/gedcom_lex_common.c +++ b/gedcom/gedcom_lex_common.c @@ -51,7 +51,7 @@ void message_handler(Gedcom_msg_type type, char *msg) fprintf(stderr, "(%d) %s\n", type, msg); } -int test_loop(ENCODING enc, char* code) +int test_loop(ENCODING enc, const char* code) { int tok, res; init_encodings(); @@ -109,18 +109,18 @@ static void error_level_too_high(int level_diff) level_diff); } -static void error_tag_too_long(char *tag) +static void error_tag_too_long(const char *tag) { gedcom_error(_("Tag '%s' too long, max %d characters allowed"), tag, MAXGEDCTAGLEN); } -static void error_invalid_character(char *str, char ch) +static void error_invalid_character(const char *str, char ch) { gedcom_error(_("Invalid character for encoding: '%s' (0x%02x)"), str, ch); } -static void error_pointer_too_long(char *ptr) +static void error_pointer_too_long(const char *ptr) { gedcom_error(_("Pointer '%s' too long, max %d characters allowed"), ptr, MAXGEDCPTRLEN); @@ -131,7 +131,7 @@ static void error_at_character() gedcom_error(_("'@' character should be written as '@@' in values")); } -static void error_unexpected_character(char* str, char ch) +static void error_unexpected_character(const char* str, char ch) { gedcom_error(_("Unexpected character: '%s' (0x%02x)"), str, ch); } diff --git a/gedcom/interface.c b/gedcom/interface.c index 0522f05..d22f8e6 100644 --- a/gedcom/interface.c +++ b/gedcom/interface.c @@ -102,10 +102,10 @@ void end_element(Gedcom_elt elt, Gedcom_ctxt parent, Gedcom_ctxt self, (*cb)(elt, parent, self, parsed_value); } -char* val_type_str[] = { N_("null value"), - N_("character string"), - N_("date"), - N_("cross-reference") }; +const char* val_type_str[] = { N_("null value"), + N_("character string"), + N_("date"), + N_("cross-reference") }; void gedcom_cast_error(const char* file, int line, Gedcom_val_type tried_type, diff --git a/gedcom/message.c b/gedcom/message.c index 62954b4..738bcd0 100644 --- a/gedcom/message.c +++ b/gedcom/message.c @@ -140,7 +140,7 @@ int gedcom_error(const char* s, ...) return res; } -void gedcom_mem_error(char *filename, int line) +void gedcom_mem_error(const char *filename, int line) { gedcom_error(_("Could not allocate memory at %s, %d"), filename, line); } diff --git a/gedcom/xref.c b/gedcom/xref.c index d07f387..a997918 100644 --- a/gedcom/xref.c +++ b/gedcom/xref.c @@ -28,17 +28,17 @@ struct xref_value def_xref_val = { XREF_NONE, "", NULL }; static hash_t *xrefs = NULL; -char* xref_type_str[] = { N_("nothing"), - N_("a family"), - N_("an individual"), - N_("a note"), - N_("a multimedia object"), - N_("a source repository"), - N_("a source"), - N_("a submitter"), - N_("a submission record"), - N_("an application-specific record"), - }; +const char* xref_type_str[] = { N_("nothing"), + N_("a family"), + N_("an individual"), + N_("a note"), + N_("a multimedia object"), + N_("a source repository"), + N_("a source"), + N_("a submitter"), + N_("a submission record"), + N_("an application-specific record"), + }; struct xref_node { struct xref_value xref; @@ -144,7 +144,7 @@ struct xref_value *gedcom_get_by_xref(const char *key) return NULL; } -struct xref_value *gedcom_parse_xref(char *raw_value, +struct xref_value *gedcom_parse_xref(const char *raw_value, Xref_ctxt ctxt, Xref_type xref_type) { struct xref_node *xr = NULL; @@ -154,7 +154,7 @@ struct xref_value *gedcom_parse_xref(char *raw_value, xr = (struct xref_node *)hnode_get(node); } else { - char *key = strdup(raw_value); + const char *key = strdup(raw_value); if (key) { xr = make_xref_node(); xr->xref.type = xref_type; diff --git a/gedcom/xref.h b/gedcom/xref.h index a60a4ec..373680f 100644 --- a/gedcom/xref.h +++ b/gedcom/xref.h @@ -34,7 +34,7 @@ typedef enum _XREF_CTXT { void make_xref_table(); int check_xref_table(); -struct xref_value *gedcom_parse_xref(char *raw_value, +struct xref_value *gedcom_parse_xref(const char *raw_value, Xref_ctxt ctxt, Xref_type type); #define GEDCOM_MAKE_XREF_PTR(VAR, XREF) \