X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;ds=sidebyside;f=backend%2Fdvi%2Fmdvi-lib%2Fdviread.c;h=d01432056518ac6ae3518ed3eec5f5705159f02f;hb=33d9b680db507280f1d8fbb31c01d31de6531046;hp=d696d8a6f26248d94bf435bb491d79362c43bddd;hpb=14def5e0c1c11cee1523e10c72df74f4cf5e451d;p=evince.git diff --git a/backend/dvi/mdvi-lib/dviread.c b/backend/dvi/mdvi-lib/dviread.c index d696d8a6..d0143205 100644 --- a/backend/dvi/mdvi-lib/dviread.c +++ b/backend/dvi/mdvi-lib/dviread.c @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include @@ -359,7 +359,7 @@ static int sort_down(const void *p1, const void *p2) } static int sort_random(const void *p1, const void *p2) { - return (random() % 1) ? -1 : 1; + return (rand() % 1) ? -1 : 1; } static int sort_dvi_up(const void *p1, const void *p2) { @@ -684,7 +684,7 @@ DviContext *mdvi_init_context(DviParams *par, DviPageSpec *spec, const char *fil perror(file); return NULL; } - p = fopen(filename, "r"); + p = fopen(filename, "rb"); if(p == NULL) { perror(file); mdvi_free(filename); @@ -1008,7 +1008,7 @@ int mdvi_dopage(DviContext *dvi, int pageno) again: if(dvi->in == NULL) { /* try reopening the file */ - dvi->in = fopen(dvi->filename, "r"); + dvi->in = fopen(dvi->filename, "rb"); if(dvi->in == NULL) { mdvi_warning(_("%s: could not reopen file (%s)\n"), dvi->filename, @@ -1166,43 +1166,13 @@ static void inline fix_after_horizontal(DviContext *dvi) (a), (b) > 0 ? '+' : '-', \ (b) > 0 ? (b) : -(b), (c) -/* - * Draw rules with some sort of antialias support. Usefult for high-rate - * scale factors. - */ - static void draw_shrink_rule (DviContext *dvi, int x, int y, Uint w, Uint h, int f) { - int hs, vs, npixels; Ulong fg, bg; - Ulong *pixels; - - hs = dvi->params.hshrink; - vs = dvi->params.vshrink; + fg = dvi->curr_fg; bg = dvi->curr_bg; - if (MDVI_ENABLED(dvi, MDVI_PARAM_ANTIALIASED)) { - npixels = vs * hs + 1; - pixels = get_color_table(&dvi->device, npixels, bg, fg, - dvi->params.gamma, dvi->params.density); - - if (pixels) { - int color; - - /* Lines with width 1 should be perfectly visible - * in shrink about 15. That is the reason of constant - */ - - color = (pow (vs / h * hs, 2) + pow (hs / w * vs, 2)) / 225; - if (color < npixels) { - fg = pixels[color]; - } else { - fg = pixels[npixels - 1]; - } - } - } - mdvi_push_color (dvi, fg, bg); dvi->device.draw_rule(dvi, x, y, w, h, f); mdvi_pop_color (dvi); @@ -1537,6 +1507,10 @@ int special(DviContext *dvi, int opcode) Int32 arg; arg = dugetn(dvi, opcode - DVI_XXX1 + 1); + if (arg <= 0) { + dvierr(dvi, _("malformed special length\n")); + return -1; + } s = mdvi_malloc(arg + 1); dread(dvi, s, arg); s[arg] = 0;