diff options
Diffstat (limited to 'Build')
5 files changed, 54 insertions, 29 deletions
diff --git a/Build/source/texk/web2c/luatexdir/lua/lnewtokenlib.c b/Build/source/texk/web2c/luatexdir/lua/lnewtokenlib.c index 68bd21199b5..f51e1e47bff 100644 --- a/Build/source/texk/web2c/luatexdir/lua/lnewtokenlib.c +++ b/Build/source/texk/web2c/luatexdir/lua/lnewtokenlib.c @@ -58,7 +58,6 @@ typedef struct saved_tex_scanner { cur_tok = a.save_tok; \ } while (0) - #define TEX_ORIGIN 0 /* not used yet */ #define LUA_ORIGIN 1 @@ -69,11 +68,10 @@ static lua_token *check_istoken(lua_State * L, int ud); #define DEBUG 0 #define DEBUG_OUT stdout - #define DEFAULT_SCAN_CODE_SET 2048 + 4096 /* default: letter and other */ - /* two core helpers */ + #define is_active_string(s) (strlen((char *)s)>3 && *s==0xEF && *(s+1)==0xBF && *(s+2)==0xBF) static unsigned char *get_cs_text(int cs) @@ -86,8 +84,6 @@ static unsigned char *get_cs_text(int cs) return (unsigned char *) makecstring(cs_text(cs)); } - - /* maybe this qualify as a macro, not function */ static lua_token *maybe_istoken(lua_State * L, int ud) @@ -141,7 +137,6 @@ static void push_token(lua_State * L, int tok) lua_setmetatable(L, -2); } - /* static int run_get_cs_offset(lua_State * L) */ /* { */ /* lua_pushnumber(L, cs_token_flag); */ @@ -196,6 +191,26 @@ static int run_scan_keyword(lua_State * L) return 1; } +static int run_scan_csname(lua_State * L) +{ + unsigned char *s; + int t; + saved_tex_scanner texstate; + save_tex_scanner(texstate); + get_next(); + t = (cur_cs ? cs_token_flag + cur_cs : token_val(cur_cmd, cur_chr)); + if (t >= cs_token_flag && ((s = get_cs_text(t - cs_token_flag)) != (unsigned char *) NULL)) { + if (is_active_string(s)) + lua_pushstring(L, (char *) (s + 3)); + else + lua_pushstring(L, (char *) s); + } else { + lua_pushnil(L); + } + unsave_tex_scanner(texstate); + return 1; +} + static int run_scan_int(lua_State * L) { saved_tex_scanner texstate; @@ -208,7 +223,6 @@ static int run_scan_int(lua_State * L) return 1; } - static int run_scan_dimen(lua_State * L) { saved_tex_scanner texstate; @@ -233,9 +247,6 @@ static int run_scan_dimen(lua_State * L) } } - - - static int run_scan_glue(lua_State * L) { saved_tex_scanner texstate; @@ -252,7 +263,6 @@ static int run_scan_glue(lua_State * L) return 1; } - static int run_scan_toks(lua_State * L) { saved_tex_scanner texstate; @@ -354,8 +364,6 @@ static int run_scan_word(lua_State * L) /* HH */ return 1; } - - static int run_scan_code(lua_State * L) /* HH */ { saved_tex_scanner texstate; @@ -384,14 +392,12 @@ static int run_scan_code(lua_State * L) /* HH */ return 1; } - static int lua_tokenlib_is_token(lua_State * L) /* HH */ { lua_pushboolean(L,maybe_istoken(L,1)==NULL ? 0 : 1); return 1; } - /* static int run_expand(lua_State * L) */ /* { */ /* (void) L; */ @@ -399,7 +405,6 @@ static int lua_tokenlib_is_token(lua_State * L) /* HH */ /* return 0; */ /* } */ - static int run_lookup(lua_State * L) { const char *s; @@ -590,7 +595,6 @@ static int lua_tokenlib_type(lua_State * L) return 1; } - static int run_scan_token(lua_State * L) { saved_tex_scanner texstate; @@ -728,7 +732,6 @@ static int set_macro(lua_State * L) return 0; } - static const struct luaL_Reg tokenlib[] = { {"is_token", lua_tokenlib_is_token}, {"get_next", run_get_next}, @@ -740,6 +743,7 @@ static const struct luaL_Reg tokenlib[] = { {"scan_code", run_scan_code}, {"scan_string", run_scan_string}, {"scan_word", run_scan_word}, + {"scan_csname", run_scan_csname}, {"type", lua_tokenlib_type}, {"create", run_build}, {"scan_token", run_scan_token}, /* expands next token if needed */ @@ -759,8 +763,6 @@ static const struct luaL_Reg tokenlib_m[] = { {NULL, NULL} /* sentinel */ }; - - int luaopen_token(lua_State * L) { /* the main metatable of token userdata */ diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/encoding.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/encoding.c index acaf51264b9..8b42a186b2b 100644 --- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/encoding.c +++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/encoding.c @@ -541,6 +541,8 @@ return( NULL ); base = 256; else if ( enc->char_cnt<=0x10000 ) base = 0x10000; + if (base==0) +return( NULL ); encoded = galloc(base*sizeof(int)); memset(encoded,-1,base*sizeof(int)); unencoded = galloc(sf->glyphcnt*sizeof(int)); diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/macbinary.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/macbinary.c index 0b9be587a59..ca8ceed899f 100644 --- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/macbinary.c +++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/macbinary.c @@ -303,7 +303,10 @@ static SplineFont *SearchPostscriptResources(FILE * f, long rlistpos, exit(1); } } - fread(buffer, 1, rlen, f); + if(fread(buffer, 1, rlen, f) != ((size_t)rlen) ) { + LogError(_("Unable to read %u bytes for buffer\n"),rlen); + exit(1); + } fwrite(buffer, 1, rlen, pfb); } free(buffer); @@ -580,7 +583,9 @@ static FOND *BuildFondList(FILE * f, long rlistpos, int subcnt, long rdata_pos, if (rname != -1) { fseek(f, name_list + rname, SEEK_SET); ch1 = getc(f); - fread(name, 1, ch1, f); + if( fread(name, 1, ch1, f) != ((size_t)ch1)) { + LogError(_("Unable to read %u bytes for name, but going on.\n"),ch1); + } name[ch1] = '\0'; cur->fondname = copy(name); } @@ -1043,7 +1048,9 @@ static SplineFont *IsResourceInBinary(FILE * f, char *filename, int flags, /* Look for a bare truetype font in a binhex/macbinary wrapper */ if (dlen != 0 && rlen <= dlen) { int pos = ftell(f); - fread(header, 1, 4, f); + if (fread(header, 1, 4, f) != ((size_t)4)) { + LogError(_("Unable to read 4 bytes for header, but going on.\n")); + } header[5] = '\0'; if (strcmp((char *) header, "OTTO") == 0 || strcmp((char *) header, "true") == 0 @@ -1141,7 +1148,10 @@ static SplineFont *IsResourceInHex(FILE * f, char *filename, int flags, fclose(binary); return (NULL); } - fread(header, 1, 20, binary); + if ( fread(header, 1, 20, binary) != 20 ) { + LogError(_("Can't read 20 bytes for header\n")); + return (NULL); + } dlen = (header[10] << 24) | (header[11] << 16) | (header[12] << 8) | header[13]; @@ -1151,7 +1161,10 @@ static SplineFont *IsResourceInHex(FILE * f, char *filename, int flags, /* Look for a bare truetype font in a binhex/macbinary wrapper */ if (dlen != 0 && rlen < dlen) { int pos = ftell(binary); - fread(header, 1, 4, binary); + if (fread(header, 1, 4, binary) != 4) { + LogError(_("Can't read 4 bytes for header\n")); + return (NULL); + } header[5] = '\0'; if (strcmp((char *) header, "OTTO") == 0 || strcmp((char *) header, "true") == 0 diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettf.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettf.c index 7586416fb16..5a3d3b58d20 100644 --- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettf.c +++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettf.c @@ -3860,7 +3860,8 @@ static int readtyp1glyphs(FILE *ttf,struct ttfinfo *info) { /* it's not exactly 20. I've seen 22 and 24. So see if we can find "%!PS-Adobe" */ /* in the first few bytes of the file, and skip to there if found */ { char buffer[41]; - fread(buffer,1,sizeof(buffer),ttf); + if(fread(buffer,1,sizeof(buffer),ttf) != sizeof(buffer)) +return( false ); buffer[40] = '\0'; for ( i=39; i>=0; --i ) if ( buffer[i]=='%' && buffer[i+1]=='!' ) @@ -5336,7 +5337,12 @@ return; tab->len = len; tab->data = galloc(len); fseek(ttf,start,SEEK_SET); - fread(tab->data,1,len,ttf); + if (fread(tab->data,1,len,ttf) != (size_t)len) { + LogError( _("Unable to read %u bytes for data, so I'm ignoring it.\n"), len ); + if (tab->data !=NULL) free(tab->data); + if (tab !=NULL) free(tab); +return; + } tab->next = info->tabs; info->tabs = tab; } diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/gutils/fsys.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/gutils/fsys.c index 648c1e8f009..ba846e2c571 100644 --- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/gutils/fsys.c +++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/gutils/fsys.c @@ -49,7 +49,8 @@ char *GFileGetAbsoluteName(char *name, char *result, int rsiz) { char *pt, *spt, *rpt, *bpt; if ( dirname_[0]=='\0' ) { - getcwd(dirname_,sizeof(dirname_)); + if (getcwd(dirname_,sizeof(dirname_)) == NULL) +return(result); } strcpy(buffer,dirname_); if ( buffer[strlen(buffer)-1]!='/' ) @@ -278,7 +279,8 @@ unichar_t *u_GFileGetAbsoluteName(unichar_t *name, unichar_t *result, int rsiz) unichar_t *pt, *spt, *rpt, *bpt; if ( dirname_[0]=='\0' ) { - getcwd(dirname_,sizeof(dirname_)); + if (getcwd(dirname_,sizeof(dirname_)) == NULL) +return(result); } uc_strcpy(buffer,dirname_); if ( buffer[u_strlen(buffer)-1]!='/' ) |