aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Gladkov <gladkov.alexey@gmail.com>2020-04-12 14:20:30 +0200
committerAlexey Gladkov <gladkov.alexey@gmail.com>2020-04-12 14:23:10 +0200
commit15f9e1071ec616d9970a28073ea899f7c4f5df03 (patch)
tree16b7c9d0c8373775fce7cdd163beee20a9bb6891
parentc45ea61ee386ee1aba9afc4356bd0f872f193df2 (diff)
downloadkbd-15f9e1071ec616d9970a28073ea899f7c4f5df03.tar.gz
Make appendunicodemap() always return a code
Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com>
-rw-r--r--src/kfont.h2
-rw-r--r--src/loadunimap.c29
-rw-r--r--src/setfont.c5
3 files changed, 22 insertions, 14 deletions
diff --git a/src/kfont.h b/src/kfont.h
index 090162ee..33060b27 100644
--- a/src/kfont.h
+++ b/src/kfont.h
@@ -12,7 +12,7 @@ int saveoldmap(struct kfont_context *ctx, int fd, const char *omfil);
int saveunicodemap(struct kfont_context *ctx, int fd, char *oufil); /* save humanly readable */
int loadunicodemap(struct kfont_context *ctx, int fd, const char *ufil);
-void appendunicodemap(struct kfont_context *ctx, int fd, FILE *fp,
+int appendunicodemap(struct kfont_context *ctx, int fd, FILE *fp,
unsigned int ct, int utf8);
/* kdfontop.c */
diff --git a/src/loadunimap.c b/src/loadunimap.c
index ef99e478..00aa3322 100644
--- a/src/loadunimap.c
+++ b/src/loadunimap.c
@@ -383,16 +383,17 @@ saveunicodemap(struct kfont_context *ctx, int fd, char *oufil)
return 0;
}
-void appendunicodemap(struct kfont_context *ctx, int fd, FILE *fp,
- unsigned int fontsize, int utf8)
+int
+appendunicodemap(struct kfont_context *ctx, int fd, FILE *fp,
+ unsigned int fontsize, int utf8)
{
struct unimapdesc unimap_descr = { 0 };
struct unipair *unilist;
unsigned int i;
int j, ret;
- if (getunicodemap(ctx, fd, &unimap_descr) < 0)
- exit(1);
+ if ((ret = getunicodemap(ctx, fd, &unimap_descr)) < 0)
+ return ret;
unilist = unimap_descr.entries;
@@ -408,21 +409,25 @@ void appendunicodemap(struct kfont_context *ctx, int fd, FILE *fp,
#endif
if (debug)
printf("\nchar %03x: ", i);
- for (j = 0; j < unimap_descr.entry_ct; j++)
+
+ for (j = 0; j < unimap_descr.entry_ct; j++) {
if (unilist[j].fontpos == i) {
if (debug)
printf("%04x ", unilist[j].unicode);
- ret = appendunicode(ctx,fp, unilist[j].unicode, utf8);
- if (ret < 0)
- exit(-ret);
+ if ((ret = appendunicode(ctx,fp, unilist[j].unicode, utf8)) < 0)
+ return ret;
}
- ret = appendseparator(ctx, fp, 0, utf8);
- if (ret < 0)
- exit(-ret);
+ }
+
+ if ((ret = appendseparator(ctx, fp, 0, utf8)) < 0)
+ return ret;
}
if (debug)
printf("\n");
+
if (verbose)
- printf(_("Appended Unicode map\n"));
+ INFO(ctx, _("Appended Unicode map"));
+
+ return 0;
}
diff --git a/src/setfont.c b/src/setfont.c
index 46b15bc5..30e9ba82 100644
--- a/src/setfont.c
+++ b/src/setfont.c
@@ -841,6 +841,7 @@ saveoldfont(struct kfont_context *ctx, int fd, const char *ofil)
static void
saveoldfontplusunicodemap(struct kfont_context *ctx, int fd, const char *Ofil)
{
+ int ret;
FILE *fpo = fopen(Ofil, "w");
if (!fpo) {
@@ -852,7 +853,9 @@ saveoldfontplusunicodemap(struct kfont_context *ctx, int fd, const char *Ofil)
unsigned int ct = 0;
do_saveoldfont(ctx, fd, Ofil, fpo, 1, &ct, &utf8);
- appendunicodemap(ctx, fd, fpo, ct, utf8);
+
+ if ((ret = appendunicodemap(ctx, fd, fpo, ct, utf8)) < 0)
+ exit(-ret);
fclose(fpo);
}