* gettext-tools/src/msgl-header.h (header_set_charset): New declaration.
* gettext-tools/src/msgl-header.c (header_set_charset): New function.
* gettext-tools/src/msgl-iconv.c: Include msgl-header.h.
(iconv_message_list_internal): Use header_set_charset.
* gettext-tools/src/x-po.c: Include msgl-header.h.
(extract): Use header_set_charset.
* gettext-tools/src/FILES: Update.
| Reading of a .desktop file, returning a list-of-messages.
+-------------- Reading PO files
+msgl-header.h
+msgl-header.c
+ Message list header manipulation.
+
msgl-iconv.h
msgl-iconv.c
Convert a list-of-messages to another character encoding.
|
+-------------- The 'msgmerge' program
-msgl-header.h
-msgl-header.c
- Message list header manipulation.
-
msgcomm.c Main source for the 'msgcomm' program.
msgattrib.c Main source for the 'msgattrib' program.
msgcat.c Main source for the 'msgcat' program.
/* Message list header manipulation.
- Copyright (C) 2007, 2016-2017 Free Software Foundation, Inc.
+ Copyright (C) 2007-2024 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2007.
This program is free software: you can redistribute it and/or modify
#define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
+void
+header_set_charset (message_ty *header_mp, const char *charsetstr,
+ const char *value)
+{
+ const char *msgstr = header_mp->msgstr;
+ size_t len, len1, len2, len3;
+ char *new_msgstr;
+
+ len = strcspn (charsetstr, " \t\n");
+
+ len1 = charsetstr - msgstr;
+ len2 = strlen (value);
+ len3 = (msgstr + strlen (msgstr)) - (charsetstr + len);
+ new_msgstr = XNMALLOC (len1 + len2 + len3 + 1, char);
+ memcpy (new_msgstr, msgstr, len1);
+ memcpy (new_msgstr + len1, value, len2);
+ memcpy (new_msgstr + len1 + len2, charsetstr + len, len3 + 1);
+ header_mp->msgstr = new_msgstr;
+ header_mp->msgstr_len = len1 + len2 + len3 + 1;
+}
+
+
/* The known fields in their usual order. */
static const struct
{
/* Message list header manipulation.
- Copyright (C) 2007, 2016 Free Software Foundation, Inc.
+ Copyright (C) 2007-2024 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2007.
This program is free software: you can redistribute it and/or modify
#endif
+/* Set the 'charset' value in the 'Content-Type:' field to the given value.
+ HEADER_MP is a message that satisfies the is_header() predicate.
+ CHARSETSTR is a pointer into its msgstr, right after the "charset=" substring.
+ VALUE is the new charset value. */
+extern void
+ header_set_charset (message_ty *header_mp, const char *charsetstr,
+ const char *value);
+
/* Set the given field to the given value.
The FIELD name ends in a colon.
The VALUE will have a space prepended and a newline appended by this
#include "string-desc.h"
#include "message.h"
#include "po-charset.h"
+#include "msgl-header.h"
#include "xstriconv.h"
#include "xstriconveh.h"
#include "msgl-ascii.h"
freea (charset);
if (update_header)
- {
- size_t len1, len2, len3;
- char *new_header;
-
- len1 = charsetstr - header;
- len2 = strlen (canon_to_code);
- len3 = (header + strlen (header)) - (charsetstr + len);
- new_header = XNMALLOC (len1 + len2 + len3 + 1, char);
- memcpy (new_header, header, len1);
- memcpy (new_header + len1, canon_to_code, len2);
- memcpy (new_header + len1 + len2, charsetstr + len,
- len3 + 1);
- mlp->item[j]->msgstr = new_header;
- mlp->item[j]->msgstr_len = len1 + len2 + len3 + 1;
- }
+ header_set_charset (mlp->item[j], charsetstr, canon_to_code);
}
}
}
#include "read-po.h"
#include "read-properties.h"
#include "read-stringtable.h"
+#include "msgl-header.h"
#include "msgl-iconv.h"
#include "msgl-ascii.h"
#include "po-charset.h"
if (charsetstr != NULL)
{
- size_t len, len1, len2, len3;
- char *new_header;
-
charsetstr += strlen ("charset=");
- len = strcspn (charsetstr, " \t\n");
-
- len1 = charsetstr - header;
- len2 = strlen (header_charset);
- len3 = (header + strlen (header)) - (charsetstr + len);
- new_header = XNMALLOC (len1 + len2 + len3 + 1, char);
- memcpy (new_header, header, len1);
- memcpy (new_header + len1, header_charset, len2);
- memcpy (new_header + len1 + len2, charsetstr + len, len3 + 1);
- mp->msgstr = new_header;
- mp->msgstr_len = len1 + len2 + len3 + 1;
+ header_set_charset (mp, charsetstr, header_charset);
}
}
}