summaryrefslogtreecommitdiff
path: root/enc/mktable.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-12-10 17:47:04 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-12-10 17:47:04 +0000
commit2873edeafb6f6df1fc99bb9b1167591b99dd378c (patch)
treedeb58ca3dc6d6cd71c1740e62aa7e47bea5ed37e /enc/mktable.c
parent42a677c895f82bcd611db2773fbe68b0558b142d (diff)
Merge Onigmo 6.0.0
* https://github.com/k-takata/Onigmo/blob/Onigmo-6.0.0/HISTORY * fix for ruby 2.4: https://github.com/k-takata/Onigmo/pull/78 * suppress warning: https://github.com/k-takata/Onigmo/pull/79 * include/ruby/oniguruma.h: include onigmo.h. * template/encdb.h.tmpl: ignore duplicated definition of EUC-CN in enc/euc_kr.c. It is defined in enc/gb2313.c with CRuby macro. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57045 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enc/mktable.c')
-rw-r--r--enc/mktable.c42
1 files changed, 32 insertions, 10 deletions
diff --git a/enc/mktable.c b/enc/mktable.c
index 49acf62..4edd5a0 100644
--- a/enc/mktable.c
+++ b/enc/mktable.c
@@ -2,7 +2,7 @@
mktable.c
**********************************************************************/
/*-
- * Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
+ * Copyright (c) 2002-2016 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,7 +31,10 @@
#include <stdio.h>
#include <locale.h>
+#ifndef __USE_ISOC99
#define __USE_ISOC99
+#endif
+
#include <ctype.h>
#include "regenc.h"
@@ -1108,11 +1111,13 @@ static int exec(FILE* fp, ENC_INFO* einfo)
#define NCOL 8
int c, val, enc;
+ int r;
enc = einfo->num;
- fprintf(fp, "static const unsigned short Enc%s_CtypeTable[256] = {\n",
- einfo->name);
+ r = fprintf(fp, "static const unsigned short Enc%s_CtypeTable[256] = {\n",
+ einfo->name);
+ if (r < 0) return -1;
for (c = 0; c < 256; c++) {
val = 0;
@@ -1131,20 +1136,33 @@ static int exec(FILE* fp, ENC_INFO* einfo)
if (IsWord (enc, c)) val |= BIT_CTYPE_WORD;
if (IsAscii (enc, c)) val |= BIT_CTYPE_ASCII;
- if (c % NCOL == 0) fputs(" ", fp);
- fprintf(fp, "0x%04x", val);
- if (c != 255) fputs(",", fp);
+ if (c % NCOL == 0) {
+ r = fputs(" ", fp);
+ if (r < 0) return -1;
+ }
+ r = fprintf(fp, "0x%04x", val);
+ if (r < 0) return -1;
+
+ if (c != 255) {
+ r = fputs(",", fp);
+ if (r < 0) return -1;
+ }
if (c != 0 && c % NCOL == (NCOL-1))
- fputs("\n", fp);
+ r = fputs("\n", fp);
else
- fputs(" ", fp);
+ r = fputs(" ", fp);
+
+ if (r < 0) return -1;
}
- fprintf(fp, "};\n");
+ r = fprintf(fp, "};\n");
+ if (r < 0) return -1;
+
return 0;
}
extern int main(int argc ARG_UNUSED, char* argv[] ARG_UNUSED)
{
+ int r;
int i;
FILE* fp = stdout;
@@ -1155,7 +1173,11 @@ extern int main(int argc ARG_UNUSED, char* argv[] ARG_UNUSED)
/* setlocale(LC_ALL, "fr_FR.iso88591"); */
for (i = 0; i < (int )(sizeof(Info)/sizeof(ENC_INFO)); i++) {
- exec(fp, &Info[i]);
+ r = exec(fp, &Info[i]);
+ if (r < 0) {
+ fprintf(stderr, "FAIL exec(): %d\n", r);
+ return -1;
+ }
}
return 0;