dlugolecki.net.pl
Dziennik
Polecane
Software
projects
/
gedcom-parse.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Document the new cross-reference handling functions.
[gedcom-parse.git]
/
gedcom
/
xref.c
diff --git
a/gedcom/xref.c
b/gedcom/xref.c
index 1b8420deb6017441757d917a181ba945e44f2b9c..dfd79bf8b5272fbe697e2cab0973556d234121b6 100644
(file)
--- a/
gedcom/xref.c
+++ b/
gedcom/xref.c
@@
-246,9
+246,15
@@
struct xref_value *gedcom_parse_xref(const char *raw_value,
/* Functions for retrieving, modifying and deleting cross-references */
/* Functions for retrieving, modifying and deleting cross-references */
+int is_valid_pointer(const char *key)
+{
+ return (strlen(key) <= 22 &&
+ gedcom_check_token(key, STATE_NORMAL, POINTER) == 0);
+}
+
struct xref_value* gedcom_get_by_xref(const char *key)
{
struct xref_value* gedcom_get_by_xref(const char *key)
{
- if (
gedcom_check_token(key, STATE_NORMAL, POINTER) != 0
) {
+ if (
!is_valid_pointer(key)
) {
gedcom_error(_("String '%s' is not a valid cross-reference key"), key);
return NULL;
}
gedcom_error(_("String '%s' is not a valid cross-reference key"), key);
return NULL;
}
@@
-268,7
+274,7
@@
struct xref_value* gedcom_add_xref(Xref_type type, const char* xrefstr,
{
struct xref_node *xr = NULL;
{
struct xref_node *xr = NULL;
- if (
gedcom_check_token(xrefstr, STATE_NORMAL, POINTER) != 0
) {
+ if (
!is_valid_pointer(xrefstr)
) {
gedcom_error(_("String '%s' is not a valid cross-reference key"), xrefstr);
}
else {
gedcom_error(_("String '%s' is not a valid cross-reference key"), xrefstr);
}
else {
@@
-292,7
+298,7
@@
struct xref_value* gedcom_link_xref(Xref_type type, const char* xrefstr)
{
struct xref_node *xr = NULL;
{
struct xref_node *xr = NULL;
- if (
gedcom_check_token(xrefstr, STATE_NORMAL, POINTER) != 0
) {
+ if (
!is_valid_pointer(xrefstr)
) {
gedcom_error(_("String '%s' is not a valid cross-reference key"), xrefstr);
}
else {
gedcom_error(_("String '%s' is not a valid cross-reference key"), xrefstr);
}
else {
@@
-316,7
+322,7
@@
struct xref_value* gedcom_link_xref(Xref_type type, const char* xrefstr)
struct xref_value* gedcom_unlink_xref(Xref_type type, const char* xrefstr)
{
struct xref_node *xr = NULL;
struct xref_value* gedcom_unlink_xref(Xref_type type, const char* xrefstr)
{
struct xref_node *xr = NULL;
- if (
gedcom_check_token(xrefstr, STATE_NORMAL, POINTER) != 0
) {
+ if (
!is_valid_pointer(xrefstr)
) {
gedcom_error(_("String '%s' is not a valid cross-reference key"), xrefstr);
}
else {
gedcom_error(_("String '%s' is not a valid cross-reference key"), xrefstr);
}
else {
@@
-347,7
+353,7
@@
int gedcom_delete_xref(const char* xrefstr)
struct xref_node *xr = NULL;
int result = 1;
struct xref_node *xr = NULL;
int result = 1;
- if (
gedcom_check_token(xrefstr, STATE_NORMAL, POINTER) != 0
) {
+ if (
!is_valid_pointer(xrefstr)
) {
gedcom_error(_("String '%s' is not a valid cross-reference key"), xrefstr);
}
else {
gedcom_error(_("String '%s' is not a valid cross-reference key"), xrefstr);
}
else {