+ if (utf8_strlen(get_buf_string(&write_buffer)) > MAXGEDCLINELEN) {
+ gedcom_error(_("Line too long"));
+ }
+ else {
+ converted = convert_from_utf8(hndl->conv, get_buf_string(&write_buffer),
+ &conv_fails, &outlen);
+
+ if (converted && (conv_fails == 0))
+ write(hndl->filedesc, converted, outlen);
+ else {
+ hndl->total_conv_fails += conv_fails;
+ gedcom_error
+ (_("Error converting output string: %s (%d conversion failures)"),
+ strerror(errno), conv_fails);
+ }
+ }
+ }
+ return 0;
+}
+
+int supports_continuation(int elt_or_rec, int which_continuation)
+{
+ return tag_data[elt_or_rec].options & which_continuation;
+}
+
+int write_long(Gedcom_write_hndl hndl, int elt_or_rec,
+ int level, char* xref, char* tag, char* value)
+{
+ int prefix_len, value_len, term_len;
+
+ prefix_len = utf8_strlen(tag) + 3; /* for e.g. "0 INDI " */
+ if (level > 9) prefix_len++;
+ if (xref) prefix_len += utf8_strlen(xref) + 1;
+ value_len = utf8_strlen(value);
+ term_len = strlen(hndl->term);
+
+ if (prefix_len + value_len + term_len <= MAXGEDCLINELEN)
+ write_simple(hndl, level, xref, tag, value);
+ else {
+ char* value_ptr = value;
+ char* nl_pos = strchr(value, '\n');
+ if (nl_pos && !supports_continuation(elt_or_rec, OPT_CONT)) {
+ gedcom_error (_("The tag %s doesn't support newlines\n"), tag);
+ return 1;
+ }