Check-in [5d98ab1f44]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix compilation with Werror and libiconv vs POSIX iconv(3) implementation
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 5d98ab1f44387936daa3d12c5e6b21680e4ea541
User & Date: bapt 2010-03-01 12:28:55
Context
2010-12-02
20:43
Merge branch 'master' of etoilebsd.net:cplanet

Conflicts: Makefile cplanet.c check-in: 1de0cb1b8f user: bapt tags: trunk

2010-03-01
12:28
Fix compilation with Werror and libiconv vs POSIX iconv(3) implementation check-in: 5d98ab1f44 user: bapt tags: trunk
2010-02-24
13:02
Attempt to fix compilation on linux check-in: bcaf0a613c user: bapt tags: trunk
Changes

Changes to cplanet.c.

141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
...
156
157
158
159
160
161
162



163

164
165
166
167
168
169
170
	size_t outsize;
	size_t ret;
	char *output;
	if (!strcmp(source_encoding, "UTF-8"))
		return str;

	iconv_t conv;
	const char * inptr = str;
	conv = iconv_open("UTF-8", source_encoding);
	if (conv == (iconv_t)-1) {
		cplanet_warn("Conversion from '%s' to UTF-8 not available", source_encoding);
		return str;
	}
	if (str == NULL)
		return str;
................................................................................
	insize = strlen(str);
	outsize = 4 * insize + 2;
	output = malloc(outsize);
	if ( output == NULL )
		cplanet_err(ENOMEM, "malloc");
	memset(output, 0, outsize);
	char *outputptr = output;



	ret = iconv(conv, (const char**) &inptr, &insize, &outputptr, &outsize);

	if (ret == (size_t)-1) {
		cplanet_warn("Conversion Failed");
		free(output);
		iconv_close(conv);
		return str;
	}
	iconv_close(conv);







<







 







>
>
>
|
>







141
142
143
144
145
146
147

148
149
150
151
152
153
154
...
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
	size_t outsize;
	size_t ret;
	char *output;
	if (!strcmp(source_encoding, "UTF-8"))
		return str;

	iconv_t conv;

	conv = iconv_open("UTF-8", source_encoding);
	if (conv == (iconv_t)-1) {
		cplanet_warn("Conversion from '%s' to UTF-8 not available", source_encoding);
		return str;
	}
	if (str == NULL)
		return str;
................................................................................
	insize = strlen(str);
	outsize = 4 * insize + 2;
	output = malloc(outsize);
	if ( output == NULL )
		cplanet_err(ENOMEM, "malloc");
	memset(output, 0, outsize);
	char *outputptr = output;
#ifdef _LIBICONV_H
	ret = iconv(conv, (const char **) &str, &insize, &outputptr, &outsize);
#else
	ret = iconv(conv, &str, &insize, &outputptr, &outsize);
#endif
	if (ret == (size_t)-1) {
		cplanet_warn("Conversion Failed");
		free(output);
		iconv_close(conv);
		return str;
	}
	iconv_close(conv);

Changes to cplanet.h.

13
14
15
16
17
18
19


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#ifndef CPLANET_H
#define CPLANET_H 1



#include <errno.h>
#include <err.h>
#include <iconv.h>
#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <syslog.h>
#define _XOPEN_SOURCE
#include <time.h>
#include <locale.h>
#include <unistd.h>

/* libmrss */
#include <mrss.h>








>
>









<







13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

31
32
33
34
35
36
37
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#ifndef CPLANET_H
#define CPLANET_H 1

#define _XOPEN_SOURCE
#define _BSD_SOURCE
#include <errno.h>
#include <err.h>
#include <iconv.h>
#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <syslog.h>

#include <time.h>
#include <locale.h>
#include <unistd.h>

/* libmrss */
#include <mrss.h>