wdvi

network DVI viewer
Log | Files | Refs

commit f29d5119d2d7759df2d04475381c9acdafc90c49
parent a4916dfd2d20bb454ae083b6788317b23160334c
Author: Kyle Milz <krwmilz@gmail.com>
Date:   Mon, 13 Sep 2021 21:48:03 +0000

hesitantly remove TEXXET support

I like the idea of this code but unfortunately I could not create any
documents to test it. It seems like RTL typesetting has evolved away
(from?) this. Currently it is in the way. Delete it with the prospect
of bringing back RTL typesetting at some point in the future.

Diffstat:
Mdvi-draw.c | 352++++---------------------------------------------------------------------------
Mfont.h | 16----------------
Mxdvi.c | 1-
Mxdvi.h | 2--
4 files changed, 17 insertions(+), 354 deletions(-)

diff --git a/dvi-draw.c b/dvi-draw.c @@ -42,9 +42,6 @@ NOTE: static struct frame frame0; /* dummy head of list */ -#ifdef TEXXET -static struct frame *scan_frame; /* head frame for scanning */ -#endif #define DVI_BUFFER_LEN 512 static ubyte dvi_buffer[DVI_BUFFER_LEN]; @@ -54,12 +51,6 @@ static struct frame *current_frame; geom_scan). */ static struct drawinf *dvi_pointer_frame = NULL; -#ifndef TEXXET -#define DIR 1 -#else -#define DIR currinf.dir -#endif - /* * Explanation of the following constant: * offset_[xy] << 16: margin (defaults to one inch) @@ -236,7 +227,7 @@ xskip(offset) SEEK_CUR); } -static void +static void __attribute__((__noreturn__)) tell_oops(const char *message, ...) { va_list args; @@ -696,24 +687,10 @@ prescan(void) * Routines to print characters. */ -#ifndef TEXXET -#define ERRVAL 0L -#else -#define ERRVAL -#endif - -#ifndef TEXXET long set_char(wide_ubyte ch) -#else -void -set_char(wide_ubyte cmd, wide_ubyte ch) -#endif { struct glyph *g; -#ifdef TEXXET - long dvi_h_sav; -#endif if (ch > maxchar) realloc_font(currinf.fontp, ch); if ((g = &currinf.fontp->glyph[ch])->bitmap.bits == NULL) { @@ -722,10 +699,10 @@ set_char(wide_ubyte cmd, wide_ubyte ch) warnx("Character %d not defined in font '%s'", ch, currinf.fontp->fontname); g->addr = -1; - return ERRVAL; + return 0L; } if (g->addr == -1) - return ERRVAL; /* previously flagged missing char */ + return 0L; /* previously flagged missing char */ if (currinf.fontp->ft == NULL) /* if not freetype font */ { open_font_file(currinf.fontp); @@ -736,11 +713,6 @@ set_char(wide_ubyte cmd, wide_ubyte ch) currinf.fontp->timestamp = ++current_timestamp; } -#ifdef TEXXET - dvi_h_sav = DVI_H; - if (currinf.dir < 0) DVI_H -= g->dvi_adv; - if (scan_frame == NULL) { -#endif if (shrink_factor == 1) put_bitmap(&g->bitmap, PXL_H - g->x, PXL_V - g->y); else { @@ -752,78 +724,39 @@ set_char(wide_ubyte cmd, wide_ubyte ch) } put_image(g, PXL_H - g->x2, PXL_V - g->y2); } -#ifndef TEXXET return g->dvi_adv; -#else - } - if (cmd == PUT1) - DVI_H = dvi_h_sav; - else - if (currinf.dir > 0) DVI_H += g->dvi_adv; -#endif } /* ARGSUSED */ -#ifndef TEXXET static long set_empty_char(wide_ubyte ch) -#else -static void -set_empty_char(wide_ubyte cmd, wide_ubyte ch) -#endif { -#ifndef TEXXET return 0; -#else - return; -#endif } -#ifndef TEXXET long load_n_set_char(wide_ubyte ch) -#else -void -load_n_set_char(wide_ubyte cmd, wide_ubyte ch) -#endif { if (!load_font(currinf.fontp)) { /* if not found */ warnx("Character(s) will be left blank."); currinf.set_char_p = currinf.fontp->set_char_p = set_empty_char; -#ifndef TEXXET return 0; -#else - return; -#endif } maxchar = currinf.fontp->maxchar; currinf.set_char_p = currinf.fontp->set_char_p; -#ifndef TEXXET return (*currinf.set_char_p)(ch); -#else - (*currinf.set_char_p)(cmd, ch); - return; -#endif } -#ifndef TEXXET long set_vf_char(wide_ubyte ch) -#else -void -set_vf_char(wide_ubyte cmd, wide_ubyte ch) -#endif { struct macro *m; struct drawinf oldinfo; ubyte oldmaxchar; static ubyte c; -#ifdef TEXXET - long dvi_h_sav; -#endif if (ch > maxchar) realloc_virtual_font(currinf.fontp, ch); if ((m = &currinf.fontp->macro[ch])->pos == NULL) { @@ -831,13 +764,8 @@ set_vf_char(wide_ubyte cmd, wide_ubyte ch) warnx("Character %d not defined in font '%s'", ch, currinf.fontp->fontname); m->pos = m->end = &c; - return ERRVAL; + return 0L; } -#ifdef TEXXET - dvi_h_sav = DVI_H; - if (currinf.dir < 0) DVI_H -= m->dvi_adv; - if (scan_frame == NULL) { -#endif oldinfo = currinf; if (!currinf.virtual) dvi_pointer_frame = &oldinfo; @@ -856,15 +784,7 @@ set_vf_char(wide_ubyte cmd, wide_ubyte ch) if (!currinf.virtual) dvi_pointer_frame = &currinf; maxchar = oldmaxchar; -#ifndef TEXXET return m->dvi_adv; -#else - } - if (cmd == PUT1) - DVI_H = dvi_h_sav; - else - if (currinf.dir > 0) DVI_H += m->dvi_adv; -#endif } @@ -928,49 +848,28 @@ do_load_freetype_font() currinf.set_char_p = currinf.fontp->set_char_p = set_char; } -# if !TEXXET long set_ft_char(wide_ubyte ch) -# else -void -set_ft_char(wide_ubyte cmd, wide_ubyte ch) -# endif { do_load_freetype_font(); -# if !TEXXET return (*currinf.set_char_p)(ch); -# else - (*currinf.set_char_p)(cmd, ch); - return; -# endif } -#ifndef TEXXET static long set_no_char(wide_ubyte ch) -#else -static void -set_no_char(wide_ubyte cmd, wide_ubyte ch) -#endif { if (currinf.virtual) { currinf.fontp = currinf.virtual->first_font; if (currinf.fontp != NULL) { maxchar = currinf.fontp->maxchar; currinf.set_char_p = currinf.fontp->set_char_p; -#ifndef TEXXET return (*currinf.set_char_p)(ch); -#else - (*currinf.set_char_p)(cmd, ch); - return; -#endif } } tell_oops("attempt to set character of unknown font"); - /* NOTREACHED */ } @@ -982,12 +881,7 @@ static void set_rule(h, w) int h, w; { -#ifndef TEXXET put_rule(PXL_H, PXL_V - h + 1, (unsigned int) w, (unsigned int) h); -#else - put_rule(PXL_H - (currinf.dir < 0 ? w - 1 : 0), PXL_V - h + 1, - (unsigned int) w, (unsigned int) h); -#endif } @@ -1004,29 +898,15 @@ draw_part(minframe, current_dimconv) double current_dimconv; { ubyte ch; -#ifdef TEXXET - struct drawinf oldinfo; - ubyte oldmaxchar; - off_t file_pos; - int refl_count; -#endif currinf.fontp = NULL; currinf.set_char_p = set_no_char; -#ifdef TEXXET - currinf.dir = 1; - scan_frame = NULL; /* indicates we're not scanning */ -#endif for (;;) { ch = xone(); if (debug & DBG_DVI) print_dvi(ch); if (ch <= (ubyte) (SETCHAR0 + 127)) -#ifndef TEXXET DVI_H += (*currinf.set_char_p)(ch); -#else - (*currinf.set_char_p)(ch, ch); -#endif else if (FNTNUM0 <= ch && ch <= (ubyte) (FNTNUM0 + 63)) change_font((unsigned long) (ch - FNTNUM0)); else { @@ -1035,12 +915,8 @@ draw_part(minframe, current_dimconv) switch (ch) { case SET1: case PUT1: -#ifndef TEXXET a = (*currinf.set_char_p)(xone()); if (ch != PUT1) DVI_H += a; -#else - (*currinf.set_char_p)(ch, xone()); -#endif break; case SETRULE: @@ -1049,24 +925,16 @@ draw_part(minframe, current_dimconv) SIGFPE here. */ a = xsfour(); b = xspell_conv(xsfour()); -#ifndef TEXXET if (a > 0 && b > 0) -#else - if (a > 0 && b > 0 && scan_frame == NULL) -#endif set_rule(pixel_round(xspell_conv(a)), pixel_round(b)); - DVI_H += DIR * b; + DVI_H += 1 * b; break; case PUTRULE: a = xspell_conv(xsfour()); b = xspell_conv(xsfour()); -#ifndef TEXXET if (a > 0 && b > 0) -#else - if (a > 0 && b > 0 && scan_frame == NULL) -#endif set_rule(pixel_round(a), pixel_round(b)); break; @@ -1105,78 +973,12 @@ draw_part(minframe, current_dimconv) current_frame = current_frame->prev; break; -#ifdef TEXXET - case SREFL: - if (scan_frame == NULL) { - /* we're not scanning: save some info. */ - oldinfo = currinf; - oldmaxchar = maxchar; - if (!currinf.virtual) - file_pos = xtell(currinf.pos); - scan_frame = current_frame; /* now we're scanning */ - refl_count = 0; - break; - } - /* we are scanning */ - if (current_frame == scan_frame) ++refl_count; - break; - - case EREFL: - if (scan_frame != NULL) { /* if we're scanning */ - if (current_frame == scan_frame && --refl_count < 0) - { - /* we've hit the end of our scan */ - scan_frame = NULL; - /* first: push */ - if (current_frame->next == NULL) { - struct frame *newp = - xmalloc(sizeof(struct frame)); - - current_frame->next = newp; - newp->prev = current_frame; - newp->next = NULL; - } - current_frame = current_frame->next; - current_frame->data = currinf.data; - /* next: restore old file position, XX, etc. */ - if (!currinf.virtual) { - off_t bgn_pos = xtell(dvi_buffer); - - if (file_pos >= bgn_pos) { - oldinfo.pos = dvi_buffer - + (file_pos - bgn_pos); - oldinfo.end = currinf.end; - } - else { - (void) fseek(dvi_file, file_pos, - SEEK_SET); - oldinfo.pos = oldinfo.end; - } - } - currinf = oldinfo; - maxchar = oldmaxchar; - /* and then: recover position info. */ - DVI_H = current_frame->data.dvi_h; - DVI_V = current_frame->data.dvi_v; - PXL_V = current_frame->data.pxl_v; - /* and finally, reverse direction */ - currinf.dir = -currinf.dir; - } - break; - } - /* we're not scanning, */ - /* so just reverse direction and then pop */ - currinf.dir = -currinf.dir; - currinf.data = current_frame->data; - current_frame = current_frame->prev; - break; -#endif /* TEXXET */ case RIGHT1: case RIGHT2: case RIGHT3: case RIGHT4: - DVI_H += DIR * xspell_conv(xsnum(ch - RIGHT1 + 1)); + DVI_H += 1 * xspell_conv(xsnum(ch - RIGHT1 + 1)); break; case W1: @@ -1185,7 +987,7 @@ draw_part(minframe, current_dimconv) case W4: WW = xspell_conv(xsnum(ch - W0)); case W0: - DVI_H += DIR * WW; + DVI_H += 1 * WW; break; case X1: @@ -1194,7 +996,7 @@ draw_part(minframe, current_dimconv) case X4: XX = xspell_conv(xsnum(ch - X0)); case X0: - DVI_H += DIR * XX; + DVI_H += 1 * XX; break; case DOWN1: @@ -1250,10 +1052,8 @@ draw_part(minframe, current_dimconv) xskip(a + (long) xone()); break; -#ifndef TEXXET case SREFL: case EREFL: -#endif case PRE: case POST: case POSTPOST: @@ -1345,9 +1145,6 @@ draw_page() * so the global variables must be separate. */ -#if TEXXET -static struct frame *geom_scan_frame; /* head frame for scanning */ -#endif static struct frame *geom_current_frame; static void geom_scan_part(struct geom_info *, @@ -1410,39 +1207,24 @@ geom_do_char(g_info, ch) if (debug & DBG_BITMAP) print_char((ubyte) ch, g); currinf.fontp->timestamp = ++current_timestamp; } -#if TEXXET - if (geom_scan_frame == NULL) { - long dvi_h_sav = DVI_H; - if (currinf.dir < 0) DVI_H -= g->dvi_adv; -#endif x = G_PXL_H - g->x; y = PXL_V - g->y; g_info->geom_box(g_info, x, y, x + g->bitmap.w - 1, y + g->bitmap.h - 1); -#if TEXXET - DVI_H = dvi_h_sav; - } -#endif - return DIR * g->dvi_adv; + return 1 * g->dvi_adv; } else if (currinf.set_char_p == set_vf_char) { struct macro *m; struct drawinf oldinfo; ubyte oldmaxchar; -#if TEXXET - long dvi_h_sav; -#endif if (ch > maxchar) return 0; /* catch the error later */ - if ((m = &currinf.fontp->macro[ch])->pos == NULL) + if ((m = &currinf.fontp->macro[ch])->pos == NULL) { return 0; /* catch the error later */ -#if TEXXET - dvi_h_sav = DVI_H; - if (currinf.dir < 0) DVI_H -= m->dvi_adv; - if (geom_scan_frame == NULL) { -#endif + } + oldinfo = currinf; oldmaxchar = maxchar; WW = XX = YY = ZZ = 0; @@ -1456,11 +1238,7 @@ geom_do_char(g_info, ch) currinf.fontp->dimconv); currinf = oldinfo; maxchar = oldmaxchar; -#if TEXXET - DVI_H = dvi_h_sav; - } -#endif - return DIR * m->dvi_adv; + return 1 * m->dvi_adv; } else { errx(1, "internal error -- currinf.set_char_p = %p", @@ -1478,20 +1256,11 @@ geom_do_rule(g_info, h, w) long h, w; { long x, y; -#if TEXXET - long dvi_h_save = DVI_H; -#endif -#if TEXXET - if (currinf.dir < 0) DVI_H -= w - 1; -#endif x = G_PXL_H; y = PXL_V; g_info->geom_box(g_info, x, y - xpixel_round(h) + 1, x + xpixel_round(w) - 1, y); -#if TEXXET - DVI_H = dvi_h_save; -#endif } @@ -1507,19 +1276,9 @@ geom_scan_part(g_info, minframe, current_dimconv) double current_dimconv; { ubyte ch; -#if TEXXET - struct drawinf oldinfo; - ubyte oldmaxchar; - off_t file_pos; - int refl_count; -#endif currinf.fontp = NULL; currinf.set_char_p = set_no_char; -#if TEXXET - currinf.dir = 1; - geom_scan_frame = NULL; /* indicates we're not scanning */ -#endif for (;;) { ch = xone(); if (ch <= (ubyte) (SETCHAR0 + 127)) @@ -1542,23 +1301,15 @@ geom_scan_part(g_info, minframe, current_dimconv) SIGFPE here. */ a = xsfour(); b = xspell_conv(xsfour()); -#if TEXXET - if (a >= 0 && b >= 0 && geom_scan_frame == NULL) -#else if (a >= 0 && b >= 0) -#endif geom_do_rule(g_info, xspell_conv(a), b); - DVI_H += DIR * b; + DVI_H += 1 * b; break; case PUTRULE: a = xspell_conv(xsfour()); b = xspell_conv(xsfour()); -#if TEXXET - if (a >= 0 && b >= 0 && geom_scan_frame == NULL) -#else if (a >= 0 && b >= 0) -#endif geom_do_rule(g_info, a, b); break; @@ -1592,79 +1343,12 @@ geom_scan_part(g_info, minframe, current_dimconv) geom_current_frame = geom_current_frame->prev; break; -#if TEXXET - case SREFL: - if (geom_scan_frame == NULL) { - /* we're not scanning: save some info. */ - oldinfo = currinf; - oldmaxchar = maxchar; - if (!currinf.virtual) - file_pos = xtell(currinf.pos); - geom_scan_frame = geom_current_frame; /* start scanning*/ - refl_count = 0; - break; - } - /* we are scanning */ - if (geom_current_frame == geom_scan_frame) ++refl_count; - break; - - case EREFL: - if (geom_scan_frame != NULL) { /* if we're scanning */ - if (geom_current_frame == geom_scan_frame - && --refl_count < 0) - { - /* we've hit the end of our scan */ - geom_scan_frame = NULL; - /* first: push */ - if (geom_current_frame->next == NULL) { - struct frame *newp = - xmalloc(sizeof(struct frame)); - - geom_current_frame->next = newp; - newp->prev = geom_current_frame; - newp->next = NULL; - } - geom_current_frame = geom_current_frame->next; - geom_current_frame->data = currinf.data; - /* next: restore old file position, XX, etc. */ - if (!currinf.virtual) { - off_t bgn_pos = xtell(dvi_buffer); - - if (file_pos >= bgn_pos) { - oldinfo.pos = dvi_buffer - + (file_pos - bgn_pos); - oldinfo.end = currinf.end; - } - else { - (void) fseek(dvi_file, file_pos, - SEEK_SET); - oldinfo.pos = oldinfo.end; - } - } - currinf = oldinfo; - maxchar = oldmaxchar; - /* and then: recover position info. */ - DVI_H = geom_current_frame->data.dvi_h; - DVI_V = geom_current_frame->data.dvi_v; - PXL_V = geom_current_frame->data.pxl_v; - /* and finally, reverse direction */ - currinf.dir = -currinf.dir; - } - break; - } - /* we're not scanning, */ - /* so just reverse direction and then pop */ - currinf.dir = -currinf.dir; - currinf.data = geom_current_frame->data; - geom_current_frame = geom_current_frame->prev; - break; -#endif /* TEXXET */ case RIGHT1: case RIGHT2: case RIGHT3: case RIGHT4: - DVI_H += DIR * xspell_conv(xsnum(ch - RIGHT1 + 1)); + DVI_H += 1 * xspell_conv(xsnum(ch - RIGHT1 + 1)); break; case W1: @@ -1673,7 +1357,7 @@ geom_scan_part(g_info, minframe, current_dimconv) case W4: WW = xspell_conv(xsnum(ch - W0)); case W0: - DVI_H += DIR * WW; + DVI_H += 1 * WW; break; case X1: @@ -1682,7 +1366,7 @@ geom_scan_part(g_info, minframe, current_dimconv) case X4: XX = xspell_conv(xsnum(ch - X0)); case X0: - DVI_H += DIR * XX; + DVI_H += 1 * XX; break; case DOWN1: @@ -1745,10 +1429,8 @@ geom_scan_part(g_info, minframe, current_dimconv) xskip(a + (long) xone()); break; -#if !TEXXET case SREFL: case EREFL: -#endif case PRE: case POST: case POSTPOST: diff --git a/font.h b/font.h @@ -9,8 +9,6 @@ #include "data.h" /* struct bitmap */ -#define TEXXET 1 /* Define to enable right-to-left typesetting. */ - struct frame { struct framedata { long dvi_h, dvi_v, w, x, y, z; @@ -19,11 +17,7 @@ struct frame { struct frame *next, *prev; }; -#ifndef TEXXET typedef long (*set_char_proc)(unsigned char); -#else -typedef void (*set_char_proc)(unsigned char, unsigned char); -#endif struct drawinf { /* this information is saved when using virtual fonts */ struct framedata data; @@ -34,9 +28,6 @@ struct drawinf { /* this information is saved when using virtual fonts */ struct tn *tn_head; unsigned char *pos, *end; struct font *virtual; -#ifdef TEXXET - int dir; -#endif }; struct drawinf currinf; @@ -202,14 +193,7 @@ Boolean load_font(struct font *); void open_font_file(struct font *); void read_encoding(struct avl_enc *); -#ifndef TEXXET long set_char(unsigned char); long load_n_set_char(unsigned char); long set_vf_char(unsigned char); long set_ft_char(unsigned char); -#else -void set_char(unsigned char, unsigned char); -void load_n_set_char(unsigned char, unsigned char); -void set_vf_char(unsigned char, unsigned char); -void set_ft_char(unsigned char, unsigned char); -#endif diff --git a/xdvi.c b/xdvi.c @@ -58,7 +58,6 @@ NOTE: * SHRINK default for -s option (shrink factor) * MFMODE default for -mfmode option * A4 use European size paper, and change default dimension to cm - * TEXXET support reflection dvi codes (right-to-left typesetting) */ #include <ctype.h> /* isdigit() */ diff --git a/xdvi.h b/xdvi.h @@ -47,8 +47,6 @@ NOTE: #define WORDS_BIGENDIAN 1 #endif -#define TEXXET 1 /* Define to enable right-to-left typesetting. */ - #define Printf (void) printf #define Sprintf (void) sprintf #define Fseek (void) fseek