changeset 1506:94d929f91b06

return value of iconv fixed for glibc 2.1.3, using strrchr instead of basename, as basename is buggy
author arpi
date Mon, 13 Aug 2001 18:39:23 +0000
parents 842c29861e25
children 47a49d6d7132
files TOOLS/subfont-c/subfont.c
diffstat 1 files changed, 14 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/TOOLS/subfont-c/subfont.c	Mon Aug 13 18:37:10 2001 +0000
+++ b/TOOLS/subfont-c/subfont.c	Mon Aug 13 18:39:23 2001 +0000
@@ -61,6 +61,7 @@
 
 ////
 char		*command;
+char		*encoding_name;
 char		*font_path;
 //char		*font_metrics;
 int		append_mode = 0;
@@ -117,14 +118,14 @@
     int const max_name = 128;
     char name[max_name];
 
-    snprintf(name, max_name, "%s-b.raw", encoding);
+    snprintf(name, max_name, "%s-b.raw", encoding_name);
     f = fopen(name, "wb");
     if (f==NULL) ERROR("fopen failed.");
     write_header(f);
     fwrite(buffer, 1, width*height, f);
     fclose(f);
 
-    snprintf(name, max_name, "%s-a.raw", encoding);
+    snprintf(name, max_name, "%s-a.raw", encoding_name);
     f = fopen(name, "wb");
     if (f==NULL) ERROR("fopen failed.");
     write_header(f);
@@ -233,7 +234,7 @@
     /* print font.desc header */
     if (append_mode) {
 	fprintf(f, "\n\n# Subtitle font for %s encoding, face \"%s%s%s\", ppem=%i\n",
-		encoding,
+		encoding_name,
 		face->family_name,
 		face->style_name ? " ":"", face->style_name ? face->style_name:"",
 		ppem);
@@ -241,7 +242,7 @@
 	fprintf(f, "# This file was generated with subfont for Mplayer.\n# Subfont by Artur Zaprzala <zybi@fanthom.irc.pl>.\n\n");
 	fprintf(f, "[info]\n");
 	fprintf(f, "name 'Subtitle font for %s encoding, face \"%s%s%s\", ppem=%i'\n",
-		encoding,
+		encoding_name,
 		face->family_name,
 		face->style_name ? " ":"", face->style_name ? face->style_name:"",
 		ppem);
@@ -251,8 +252,8 @@
 	fprintf(f, "height %i\n",		f266toInt(face->size->metrics.height));
     }
     fprintf(f, "\n[files]\n");
-    fprintf(f, "alpha %s-a.raw\n",	encoding);
-    fprintf(f, "bitmap %s-b.raw\n",	encoding);
+    fprintf(f, "alpha %s-a.raw\n",	encoding_name);
+    fprintf(f, "bitmap %s-b.raw\n",	encoding_name);
     fprintf(f, "\n[characters]\n");
 
 
@@ -377,7 +378,8 @@
     int outbytesleft = sizeof(FT_ULong);
 
     size_t count = iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
-    if (count==-1) o = 0;
+//    if (count==-1) o = 0; // not OK, at least my iconv() returns E2BIG for all
+    if (outbytesleft!=0) o = 0;
 
     /* convert unicode BE -> LE */
     o = ((o>>24)&0xff)
@@ -435,7 +437,7 @@
 	    ++charset_size;
 	}
 	fclose(f);
-	encoding = basename(encoding);
+//	encoding = basename(encoding);
     }
     if (charset_size==0) ERROR("No characters to render!");
 }
@@ -661,6 +663,10 @@
 
     if (argv[a][0]!=0)
 	encoding = argv[a];
+    encoding_name = strrchr(encoding, '/');
+    if (!encoding_name) encoding_name=encoding;
+    else ++encoding_name;
+    
     ++a; --argc;
 
     i = atoi(argv[a]);