diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-01-14 12:08:53 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-01-14 12:10:41 -0800 |
commit | f1762e6d2964705887b924b824568aeff352dd46 (patch) | |
tree | 48a8304865ae5db0d2087dfe3a3173a93639f7d7 | |
parent | 81e3522d79efdc629cd1815b451dac39208673b0 (diff) |
Convert to X.Org standard code style
Mostly via util/modular/x-indent-all.sh, plus some manual cleanup
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | Dvi.c | 570 | ||||
-rw-r--r-- | DviChar.c | 1233 | ||||
-rw-r--r-- | DviChar.h | 35 | ||||
-rw-r--r-- | DviP.h | 249 | ||||
-rw-r--r-- | Menu.h | 6 | ||||
-rw-r--r-- | XFontName.c | 271 | ||||
-rw-r--r-- | draw.c | 396 | ||||
-rw-r--r-- | font.c | 533 | ||||
-rw-r--r-- | lex.c | 89 | ||||
-rw-r--r-- | page.c | 75 | ||||
-rw-r--r-- | parse.c | 651 | ||||
-rw-r--r-- | xditview.c | 568 |
12 files changed, 2333 insertions, 2343 deletions
@@ -61,7 +61,7 @@ from the X Consortium. * therefore it has been split in two and assigned to resources * in the ClassInitialize routine. */ -static const char *default_font_map_1 = "\ +static const char *default_font_map_1 = "\ R -*-times-medium-r-normal--*-*-*-*-*-*-iso8859-1\n\ I -*-times-medium-i-normal--*-*-*-*-*-*-iso8859-1\n\ B -*-times-bold-r-normal--*-*-*-*-*-*-iso8859-1\n\ @@ -80,7 +80,7 @@ HO -*-helvetica-medium-o-normal--*-*-*-*-*-*-iso8859-1\n\ HB -*-helvetica-bold-r-normal--*-*-*-*-*-*-iso8859-1\n\ HF -*-helvetica-bold-o-normal--*-*-*-*-*-*-iso8859-1\n\ "; -static const char *default_font_map_2 = "\ +static const char *default_font_map_2 = "\ N -*-new century schoolbook-medium-r-normal--*-*-*-*-*-*-iso8859-1\n\ NI -*-new century schoolbook-medium-i-normal--*-*-*-*-*-*-iso8859-1\n\ NB -*-new century schoolbook-bold-r-normal--*-*-*-*-*-*-iso8859-1\n\ @@ -95,111 +95,113 @@ S2 -*-symbol-medium-r-normal--*-*-*-*-*-*-adobe-fontspecific\n\ #define offset(field) XtOffsetOf(DviRec, field) -static XtResource resources[] = { - {XtNfontMap, XtCFontMap, XtRString, sizeof (char *), - offset(dvi.font_map_string), XtRString, NULL /* set in code */}, - {XtNforeground, XtCForeground, XtRPixel, sizeof (unsigned long), - offset(dvi.foreground), XtRString, XtDefaultForeground}, - {XtNpageNumber, XtCPageNumber, XtRInt, sizeof (int), - offset(dvi.requested_page), XtRImmediate, (XtPointer) 1}, - {XtNlastPageNumber, XtCLastPageNumber, XtRInt, sizeof (int), - offset (dvi.last_page), XtRImmediate, (XtPointer) 0}, - {XtNfile, XtCFile, XtRFile, sizeof (FILE *), - offset (dvi.file), XtRFile, (char *) 0}, - {XtNseek, XtCSeek, XtRBoolean, sizeof (Boolean), - offset(dvi.seek), XtRImmediate, (XtPointer) False}, - {XtNfont, XtCFont, XtRFontStruct, sizeof (XFontStruct *), - offset(dvi.default_font), XtRString, XtDefaultFont}, - {XtNbackingStore, XtCBackingStore, XtRBackingStore, sizeof (int), - offset(dvi.backing_store), XtRString, "default"}, - {XtNnoPolyText, XtCNoPolyText, XtRBoolean, sizeof (Boolean), - offset(dvi.noPolyText), XtRImmediate, (XtPointer) False}, - {XtNscreenResolution, XtCScreenResolution, XtRInt, sizeof (int), - offset(dvi.screen_resolution), XtRImmediate, (XtPointer) 75}, - {XtNpageWidth, XtCPageWidth, XtRFloat, sizeof (float), - offset(dvi.page_width), XtRString, "8.5"}, - {XtNpageHeight, XtCPageHeight, XtRFloat, sizeof (float), - offset(dvi.page_height), XtRString, "11"}, - {XtNsizeScale, XtCSizeScale, XtRInt, sizeof (int), - offset(dvi.size_scale_set), XtRImmediate, (XtPointer) 0}, +static XtResource resources[] = { + {XtNfontMap, XtCFontMap, XtRString, sizeof(char *), + offset(dvi.font_map_string), XtRString, NULL /* set in code */ }, + {XtNforeground, XtCForeground, XtRPixel, sizeof(unsigned long), + offset(dvi.foreground), XtRString, XtDefaultForeground}, + {XtNpageNumber, XtCPageNumber, XtRInt, sizeof(int), + offset(dvi.requested_page), XtRImmediate, (XtPointer) 1}, + {XtNlastPageNumber, XtCLastPageNumber, XtRInt, sizeof(int), + offset(dvi.last_page), XtRImmediate, (XtPointer) 0}, + {XtNfile, XtCFile, XtRFile, sizeof(FILE *), + offset(dvi.file), XtRFile, (char *) 0}, + {XtNseek, XtCSeek, XtRBoolean, sizeof(Boolean), + offset(dvi.seek), XtRImmediate, (XtPointer) False}, + {XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *), + offset(dvi.default_font), XtRString, XtDefaultFont}, + {XtNbackingStore, XtCBackingStore, XtRBackingStore, sizeof(int), + offset(dvi.backing_store), XtRString, "default"}, + {XtNnoPolyText, XtCNoPolyText, XtRBoolean, sizeof(Boolean), + offset(dvi.noPolyText), XtRImmediate, (XtPointer) False}, + {XtNscreenResolution, XtCScreenResolution, XtRInt, sizeof(int), + offset(dvi.screen_resolution), XtRImmediate, (XtPointer) 75}, + {XtNpageWidth, XtCPageWidth, XtRFloat, sizeof(float), + offset(dvi.page_width), XtRString, "8.5"}, + {XtNpageHeight, XtCPageHeight, XtRFloat, sizeof(float), + offset(dvi.page_height), XtRString, "11"}, + {XtNsizeScale, XtCSizeScale, XtRInt, sizeof(int), + offset(dvi.size_scale_set), XtRImmediate, (XtPointer) 0}, }; #undef offset -static void ClassInitialize(void); -static void Initialize(Widget, Widget, ArgList, Cardinal *); -static void Realize(Widget, XtValueMask *, XSetWindowAttributes *); -static void Destroy(Widget); -static void Redisplay(Widget, XEvent *, Region); -static Boolean SetValues(Widget, Widget, Widget, ArgList , Cardinal *); -static Boolean SetValuesHook(Widget, ArgList, Cardinal *); -static XtGeometryResult QueryGeometry(Widget, - XtWidgetGeometry *, XtWidgetGeometry *); -static void RequestDesiredSize(DviWidget); -static void ShowDvi(DviWidget); -static void CloseFile(DviWidget); -static void OpenFile(DviWidget); +static void ClassInitialize(void); +static void Initialize(Widget, Widget, ArgList, Cardinal *); +static void Realize(Widget, XtValueMask *, XSetWindowAttributes *); +static void Destroy(Widget); +static void Redisplay(Widget, XEvent *, Region); +static Boolean SetValues(Widget, Widget, Widget, ArgList, Cardinal *); +static Boolean SetValuesHook(Widget, ArgList, Cardinal *); +static XtGeometryResult QueryGeometry(Widget, + XtWidgetGeometry *, XtWidgetGeometry *); +static void RequestDesiredSize(DviWidget); +static void ShowDvi(DviWidget); +static void CloseFile(DviWidget); +static void OpenFile(DviWidget); #define SuperClass ((SimpleWidgetClass)&simpleClassRec) DviClassRec dviClassRec = { -{ - (WidgetClass) SuperClass, /* superclass */ - "Dvi", /* class_name */ - sizeof(DviRec), /* size */ - ClassInitialize, /* class_initialize */ - NULL, /* class_part_initialize */ - FALSE, /* class_inited */ - Initialize, /* initialize */ - NULL, /* initialize_hook */ - Realize, /* realize */ - NULL, /* actions */ - 0, /* num_actions */ - resources, /* resources */ - XtNumber(resources), /* resource_count */ - NULLQUARK, /* xrm_class */ - FALSE, /* compress_motion */ - XtExposeCompressMaximal, /* compress_exposure */ - TRUE, /* compress_enterleave */ - FALSE, /* visible_interest */ - Destroy, /* destroy */ - NULL, /* resize */ - Redisplay, /* expose */ - SetValues, /* set_values */ - SetValuesHook, /* set_values_hook */ - XtInheritSetValuesAlmost, /* set_values_almost */ - NULL, /* get_values_hook */ - NULL, /* accept_focus */ - XtVersion, /* version */ - NULL, /* callback_private */ - NULL, /* tm_table */ - QueryGeometry, /* query_geometry */ - XtInheritDisplayAccelerator, /* display_accelerator */ - NULL, /* extension */ -}, /* CoreClass fields initialization */ -{ - XtInheritChangeSensitive /* change_sensitive */ -}, /* SimpleClass fields initialization */ -{ - 0, /* field not used */ -}, /* DviClass fields initialization */ + { + (WidgetClass) SuperClass, /* superclass */ + "Dvi", /* class_name */ + sizeof(DviRec), /* size */ + ClassInitialize, /* class_initialize */ + NULL, /* class_part_initialize */ + FALSE, /* class_inited */ + Initialize, /* initialize */ + NULL, /* initialize_hook */ + Realize, /* realize */ + NULL, /* actions */ + 0, /* num_actions */ + resources, /* resources */ + XtNumber(resources), /* resource_count */ + NULLQUARK, /* xrm_class */ + FALSE, /* compress_motion */ + XtExposeCompressMaximal, /* compress_exposure */ + TRUE, /* compress_enterleave */ + FALSE, /* visible_interest */ + Destroy, /* destroy */ + NULL, /* resize */ + Redisplay, /* expose */ + SetValues, /* set_values */ + SetValuesHook, /* set_values_hook */ + XtInheritSetValuesAlmost, /* set_values_almost */ + NULL, /* get_values_hook */ + NULL, /* accept_focus */ + XtVersion, /* version */ + NULL, /* callback_private */ + NULL, /* tm_table */ + QueryGeometry, /* query_geometry */ + XtInheritDisplayAccelerator, /* display_accelerator */ + NULL, /* extension */ + }, /* CoreClass fields initialization */ + { + XtInheritChangeSensitive /* change_sensitive */ + }, /* SimpleClass fields initialization */ + { + 0, /* field not used */ + }, /* DviClass fields initialization */ }; WidgetClass dviWidgetClass = (WidgetClass) &dviClassRec; static void -ClassInitialize (void) +ClassInitialize(void) { - int len1 = strlen(default_font_map_1); - int len2 = strlen(default_font_map_2); - char *dfm = XtMalloc(len1 + len2 + 1); - char *ptr = dfm; - strcpy(ptr, default_font_map_1); ptr += len1; - strcpy(ptr, default_font_map_2); - resources[0].default_addr = dfm; - - XtAddConverter( XtRString, XtRBackingStore, XmuCvtStringToBackingStore, - NULL, 0 ); + int len1 = strlen(default_font_map_1); + int len2 = strlen(default_font_map_2); + char *dfm = XtMalloc(len1 + len2 + 1); + char *ptr = dfm; + + strcpy(ptr, default_font_map_1); + ptr += len1; + strcpy(ptr, default_font_map_2); + resources[0].default_addr = dfm; + + XtAddConverter(XtRString, XtRBackingStore, XmuCvtStringToBackingStore, + NULL, 0); } /**************************************************************** @@ -212,7 +214,7 @@ ClassInitialize (void) static void Initialize(Widget request, Widget new, ArgList args, Cardinal *num_args) { - DviWidget dw = (DviWidget) new; + DviWidget dw = (DviWidget) new; dw->dvi.tmpFile = NULL; dw->dvi.readingTmp = 0; @@ -232,62 +234,58 @@ Initialize(Widget request, Widget new, ArgList args, Cardinal *num_args) dw->dvi.scale = 0.0; dw->dvi.state = NULL; dw->dvi.cache.index = 0; - dw->dvi.cache.font = NULL; + dw->dvi.cache.font = NULL; dw->dvi.size_scale = 0; dw->dvi.size_scale_set = 0; - RequestDesiredSize (dw); + RequestDesiredSize(dw); } static void -Realize(Widget w, XtValueMask *valueMask, XSetWindowAttributes *attrs) +Realize(Widget w, XtValueMask * valueMask, XSetWindowAttributes *attrs) { - DviWidget dw = (DviWidget) w; - XGCValues values; + DviWidget dw = (DviWidget) w; + XGCValues values; if (dw->dvi.backing_store != Always + WhenMapped + NotUseful) { - attrs->backing_store = dw->dvi.backing_store; - *valueMask |= CWBackingStore; + attrs->backing_store = dw->dvi.backing_store; + *valueMask |= CWBackingStore; } - XtCreateWindow (w, (unsigned)InputOutput, (Visual *) CopyFromParent, - *valueMask, attrs); + XtCreateWindow(w, (unsigned) InputOutput, (Visual *) CopyFromParent, + *valueMask, attrs); values.foreground = dw->dvi.foreground; - dw->dvi.normal_GC = XCreateGC (XtDisplay (w), XtWindow (w), - GCForeground, &values); + dw->dvi.normal_GC = XCreateGC(XtDisplay(w), XtWindow(w), + GCForeground, &values); #ifdef USE_XFT { - int scr; - Visual *visual; - Colormap cmap; - XRenderColor black; - - scr = XScreenNumberOfScreen (dw->core.screen); - visual = DefaultVisual (XtDisplay (w), scr); - cmap = DefaultColormap (XtDisplay (w), scr); - dw->dvi.draw = XftDrawCreate (XtDisplay (w), XtWindow (w), - visual, cmap); - - black.red = black.green = black.blue = 0; - black.alpha = 0xffff; - XftColorAllocValue (XtDisplay (w), visual, cmap, - &black, &dw->dvi.black); - dw->dvi.default_font = XftFontOpenName (XtDisplay (w), - scr, - "serif-12"); + int scr; + Visual *visual; + Colormap cmap; + XRenderColor black; + + scr = XScreenNumberOfScreen(dw->core.screen); + visual = DefaultVisual(XtDisplay(w), scr); + cmap = DefaultColormap(XtDisplay(w), scr); + dw->dvi.draw = XftDrawCreate(XtDisplay(w), XtWindow(w), visual, cmap); + + black.red = black.green = black.blue = 0; + black.alpha = 0xffff; + XftColorAllocValue(XtDisplay(w), visual, cmap, &black, &dw->dvi.black); + dw->dvi.default_font = XftFontOpenName(XtDisplay(w), scr, "serif-12"); } #endif if (dw->dvi.file) - OpenFile (dw); - ParseFontMap (dw); + OpenFile(dw); + ParseFontMap(dw); } static void Destroy(Widget w) { - DviWidget dw = (DviWidget) w; + DviWidget dw = (DviWidget) w; - XFreeGC (XtDisplay (w), dw->dvi.normal_GC); - DestroyFontMap (dw->dvi.font_map); - DestroyFileMap (dw->dvi.file_map); + XFreeGC(XtDisplay(w), dw->dvi.normal_GC); + DestroyFontMap(dw->dvi.font_map); + DestroyFileMap(dw->dvi.file_map); } /* @@ -298,42 +296,39 @@ Destroy(Widget w) static void Redisplay(Widget w, XEvent *event, Region region) { - DviWidget dw = (DviWidget) w; + DviWidget dw = (DviWidget) w; + #ifndef USE_XFT - XRectangle extents; + XRectangle extents; #endif - + #ifdef USE_XFT - XClearArea (XtDisplay (dw), - XtWindow (dw), - 0, 0, 0, 0, False); - dw->dvi.extents.x1 = 0; - dw->dvi.extents.y1 = 0; - dw->dvi.extents.x2 = dw->core.width; - dw->dvi.extents.y2 = dw->core.height; + XClearArea(XtDisplay(dw), XtWindow(dw), 0, 0, 0, 0, False); + dw->dvi.extents.x1 = 0; + dw->dvi.extents.y1 = 0; + dw->dvi.extents.x2 = dw->core.width; + dw->dvi.extents.y2 = dw->core.height; #else - XClipBox (region, &extents); - dw->dvi.extents.x1 = extents.x; - dw->dvi.extents.y1 = extents.y; - dw->dvi.extents.x2 = extents.x + extents.width; - dw->dvi.extents.y2 = extents.y + extents.height; + XClipBox(region, &extents); + dw->dvi.extents.x1 = extents.x; + dw->dvi.extents.y1 = extents.y; + dw->dvi.extents.x2 = extents.x + extents.width; + dw->dvi.extents.y2 = extents.y + extents.height; #endif - ShowDvi (dw); + ShowDvi(dw); } static void -RequestDesiredSize (DviWidget dw) +RequestDesiredSize(DviWidget dw) { - XtWidgetGeometry req, rep; + XtWidgetGeometry req, rep; - dw->dvi.desired_width = dw->dvi.page_width * - dw->dvi.screen_resolution; - dw->dvi.desired_height = dw->dvi.page_height * - dw->dvi.screen_resolution; - req.request_mode = CWWidth|CWHeight; + dw->dvi.desired_width = dw->dvi.page_width * dw->dvi.screen_resolution; + dw->dvi.desired_height = dw->dvi.page_height * dw->dvi.screen_resolution; + req.request_mode = CWWidth | CWHeight; req.width = dw->dvi.desired_width; req.height = dw->dvi.desired_height; - XtMakeGeometryRequest ((Widget) dw, &req, &rep); + XtMakeGeometryRequest((Widget) dw, &req, &rep); } /* @@ -341,58 +336,54 @@ RequestDesiredSize (DviWidget dw) */ /* ARGSUSED */ static Boolean -SetValues (Widget wcurrent, Widget wrequest, Widget wnew, - ArgList args, Cardinal *num_args) +SetValues(Widget wcurrent, Widget wrequest, Widget wnew, + ArgList args, Cardinal *num_args) { - DviWidget current = (DviWidget) wcurrent; - DviWidget request = (DviWidget) wrequest; - DviWidget new = (DviWidget) wnew; - Boolean redisplay = FALSE; - char *new_map; - int cur, req; + DviWidget current = (DviWidget) wcurrent; + DviWidget request = (DviWidget) wrequest; + DviWidget new = (DviWidget) wnew; + Boolean redisplay = FALSE; + char *new_map; + int cur, req; req = request->dvi.requested_page; cur = current->dvi.requested_page; if (cur != req) { - if (req < 1) - req = 1; - if (request->dvi.file) - { - if (current->dvi.last_page != 0 && - req > current->dvi.last_page) - req = current->dvi.last_page; - } - if (cur != req) - redisplay = TRUE; - new->dvi.requested_page = req; + if (req < 1) + req = 1; + if (request->dvi.file) { + if (current->dvi.last_page != 0 && req > current->dvi.last_page) + req = current->dvi.last_page; + } + if (cur != req) + redisplay = TRUE; + new->dvi.requested_page = req; } - + if (current->dvi.font_map_string != request->dvi.font_map_string) { - new_map = XtMalloc (strlen (request->dvi.font_map_string) + 1); - if (new_map) { - redisplay = TRUE; - strcpy (new_map, request->dvi.font_map_string); - new->dvi.font_map_string = new_map; - if (current->dvi.font_map_string) - XtFree (current->dvi.font_map_string); - current->dvi.font_map_string = NULL; - ParseFontMap (new); - } + new_map = XtMalloc(strlen(request->dvi.font_map_string) + 1); + if (new_map) { + redisplay = TRUE; + strcpy(new_map, request->dvi.font_map_string); + new->dvi.font_map_string = new_map; + if (current->dvi.font_map_string) + XtFree(current->dvi.font_map_string); + current->dvi.font_map_string = NULL; + ParseFontMap(new); + } } - if (current->dvi.screen_resolution != request->dvi.screen_resolution) - { - ResetFonts (new); - new->dvi.line_width = -1; + if (current->dvi.screen_resolution != request->dvi.screen_resolution) { + ResetFonts(new); + new->dvi.line_width = -1; } if (request->dvi.device_resolution) - new->dvi.scale = ((double) request->dvi.screen_resolution) / - ((double) request->dvi.device_resolution); - if (current->dvi.page_width != request->dvi.page_width || - current->dvi.page_height != request->dvi.page_height || - current->dvi.screen_resolution != request->dvi.screen_resolution) - { - RequestDesiredSize (new); - redisplay = TRUE; + new->dvi.scale = ((double) request->dvi.screen_resolution) / + ((double) request->dvi.device_resolution); + if (current->dvi.page_width != request->dvi.page_width || + current->dvi.page_height != request->dvi.page_height || + current->dvi.screen_resolution != request->dvi.screen_resolution) { + RequestDesiredSize(new); + redisplay = TRUE; } return redisplay; } @@ -403,131 +394,132 @@ SetValues (Widget wcurrent, Widget wrequest, Widget wnew, */ static Boolean -SetValuesHook (Widget widget, ArgList args, Cardinal *num_argsp) +SetValuesHook(Widget widget, ArgList args, Cardinal *num_argsp) { - DviWidget dw = (DviWidget) widget; - Cardinal i; - - for (i = 0; i < *num_argsp; i++) { - if (!strcmp (args[i].name, XtNfile)) { - CloseFile (dw); - OpenFile (dw); - return TRUE; - } - } - return FALSE; + DviWidget dw = (DviWidget) widget; + Cardinal i; + + for (i = 0; i < *num_argsp; i++) { + if (!strcmp(args[i].name, XtNfile)) { + CloseFile(dw); + OpenFile(dw); + return TRUE; + } + } + return FALSE; } static void -CloseFile (DviWidget dw) +CloseFile(DviWidget dw) { if (dw->dvi.tmpFile) - fclose (dw->dvi.tmpFile); - ForgetPagePositions (dw); + fclose(dw->dvi.tmpFile); + ForgetPagePositions(dw); } static void -OpenFile (DviWidget dw) +OpenFile(DviWidget dw) { dw->dvi.tmpFile = NULL; if (!dw->dvi.seek) { - char tmpName[] = "/tmp/dviXXXXXX"; + char tmpName[] = "/tmp/dviXXXXXX"; #ifndef HAS_MKSTEMP - mktemp (tmpName); - dw->dvi.tmpFile = fopen (tmpName, "w+"); + mktemp(tmpName); + dw->dvi.tmpFile = fopen(tmpName, "w+"); #else - int fd = mkstemp(tmpName); - if (fd != -1) { - dw->dvi.tmpFile = fdopen(fd, "w+"); - if (dw->dvi.tmpFile == NULL) - close(fd); - } + int fd = mkstemp(tmpName); + + if (fd != -1) { + dw->dvi.tmpFile = fdopen(fd, "w+"); + if (dw->dvi.tmpFile == NULL) + close(fd); + } #endif - remove (tmpName); + remove(tmpName); } if (dw->dvi.requested_page < 1) - dw->dvi.requested_page = 1; + dw->dvi.requested_page = 1; dw->dvi.last_page = 0; } static XtGeometryResult -QueryGeometry (Widget w, XtWidgetGeometry *request, - XtWidgetGeometry *geometry_return) +QueryGeometry(Widget w, XtWidgetGeometry *request, + XtWidgetGeometry *geometry_return) { - XtGeometryResult ret; - DviWidget dw = (DviWidget) w; - - ret = XtGeometryYes; - if ((int)request->width < dw->dvi.desired_width - || (int)request->height < dw->dvi.desired_height) - ret = XtGeometryAlmost; - geometry_return->width = dw->dvi.desired_width; - geometry_return->height = dw->dvi.desired_height; - geometry_return->request_mode = CWWidth|CWHeight; - return ret; + XtGeometryResult ret; + DviWidget dw = (DviWidget) w; + + ret = XtGeometryYes; + if ((int) request->width < dw->dvi.desired_width + || (int) request->height < dw->dvi.desired_height) + ret = XtGeometryAlmost; + geometry_return->width = dw->dvi.desired_width; + geometry_return->height = dw->dvi.desired_height; + geometry_return->request_mode = CWWidth | CWHeight; + return ret; } void -SetDeviceResolution (DviWidget dw, int resolution) +SetDeviceResolution(DviWidget dw, int resolution) { if (resolution != dw->dvi.device_resolution) { - dw->dvi.device_resolution = resolution; - dw->dvi.scale = ((double) dw->dvi.screen_resolution) / - ((double) resolution); + dw->dvi.device_resolution = resolution; + dw->dvi.scale = ((double) dw->dvi.screen_resolution) / + ((double) resolution); } } static void -ShowDvi (DviWidget dw) +ShowDvi(DviWidget dw) { - long file_position; - - if (!dw->dvi.file) - return; - - if (dw->dvi.requested_page < 1) - dw->dvi.requested_page = 1; - - if (dw->dvi.last_page != 0 && dw->dvi.requested_page > dw->dvi.last_page) - dw->dvi.requested_page = dw->dvi.last_page; - - file_position = SearchPagePosition (dw, dw->dvi.requested_page); - if (file_position != -1) { - FileSeek(dw, file_position); - dw->dvi.current_page = dw->dvi.requested_page; - } else { - int i; - - for (i = dw->dvi.requested_page; i > 0; i--) { - file_position = SearchPagePosition (dw, i); - if (file_position != -1) - break; - } - if (file_position == -1) - file_position = 0; - FileSeek (dw, file_position); - - dw->dvi.current_page = i; - - dw->dvi.display_enable = 0; - while (dw->dvi.current_page != dw->dvi.requested_page) { - dw->dvi.current_page = ParseInput (dw); - /* - * at EOF, seek back to the beginning of this page. - */ - if (feof (dw->dvi.file)) { - file_position = SearchPagePosition (dw, - dw->dvi.current_page); - if (file_position != -1) - FileSeek (dw, file_position); - break; - } - } - } - - dw->dvi.display_enable = 1; - ParseInput (dw); - if (dw->dvi.last_page && dw->dvi.requested_page > dw->dvi.last_page) - dw->dvi.requested_page = dw->dvi.last_page; + long file_position; + + if (!dw->dvi.file) + return; + + if (dw->dvi.requested_page < 1) + dw->dvi.requested_page = 1; + + if (dw->dvi.last_page != 0 && dw->dvi.requested_page > dw->dvi.last_page) + dw->dvi.requested_page = dw->dvi.last_page; + + file_position = SearchPagePosition(dw, dw->dvi.requested_page); + if (file_position != -1) { + FileSeek(dw, file_position); + dw->dvi.current_page = dw->dvi.requested_page; + } + else { + int i; + + for (i = dw->dvi.requested_page; i > 0; i--) { + file_position = SearchPagePosition(dw, i); + if (file_position != -1) + break; + } + if (file_position == -1) + file_position = 0; + FileSeek(dw, file_position); + + dw->dvi.current_page = i; + + dw->dvi.display_enable = 0; + while (dw->dvi.current_page != dw->dvi.requested_page) { + dw->dvi.current_page = ParseInput(dw); + /* + * at EOF, seek back to the beginning of this page. + */ + if (feof(dw->dvi.file)) { + file_position = SearchPagePosition(dw, dw->dvi.current_page); + if (file_position != -1) + FileSeek(dw, file_position); + break; + } + } + } + + dw->dvi.display_enable = 1; + ParseInput(dw); + if (dw->dvi.last_page && dw->dvi.requested_page > dw->dvi.last_page) + dw->dvi.requested_page = dw->dvi.last_page; } @@ -5,665 +5,668 @@ * font indexes and back */ -# include <X11/Intrinsic.h> -# include "DviChar.h" +#include <X11/Intrinsic.h> +#include "DviChar.h" -# define allocHash() ((DviCharNameHash *) XtMalloc (sizeof (DviCharNameHash))) +#define allocHash() ((DviCharNameHash *) XtMalloc (sizeof (DviCharNameHash))) struct map_list { - struct map_list *next; - DviCharNameMap *map; + struct map_list *next; + DviCharNameMap *map; }; -static struct map_list *world; +static struct map_list *world; -static int standard_maps_loaded = 0; -static void load_standard_maps (void); -static int hash_name (const char *name); -static void dispose_hash(DviCharNameMap *map); -static void compute_hash(DviCharNameMap *map); +static int standard_maps_loaded = 0; +static void load_standard_maps(void); +static int hash_name(const char *name); +static void dispose_hash(DviCharNameMap *map); +static void compute_hash(DviCharNameMap *map); DviCharNameMap * -DviFindMap (const char *encoding) +DviFindMap(const char *encoding) { - if (!standard_maps_loaded) - load_standard_maps (); - for (struct map_list *m = world; m; m=m->next) - if (!strcmp (m->map->encoding, encoding)) - return m->map; - return NULL; + if (!standard_maps_loaded) + load_standard_maps(); + for (struct map_list * m = world; m; m = m->next) { + if (!strcmp(m->map->encoding, encoding)) + return m->map; + } + return NULL; } void -DviRegisterMap (DviCharNameMap *map) +DviRegisterMap(DviCharNameMap *map) { - struct map_list *m; + struct map_list *m; - if (!standard_maps_loaded) - load_standard_maps (); - for (m = world; m; m = m->next) - if (!strcmp (m->map->encoding, map->encoding)) - break; - if (!m) { - m = (struct map_list *) XtMalloc (sizeof *m); - m->next = world; - world = m; - } - dispose_hash (map); - m->map = map; - compute_hash (map); + if (!standard_maps_loaded) + load_standard_maps(); + for (m = world; m; m = m->next) { + if (!strcmp(m->map->encoding, map->encoding)) + break; + } + if (!m) { + m = (struct map_list *) XtMalloc(sizeof *m); + m->next = world; + world = m; + } + dispose_hash(map); + m->map = map; + compute_hash(map); } static void -dispose_hash (DviCharNameMap *map) +dispose_hash(DviCharNameMap *map) { - DviCharNameHash **buckets; + DviCharNameHash **buckets; - buckets = map->buckets; - for (int i = 0; i < DVI_HASH_SIZE; i++) { - DviCharNameHash *next; + buckets = map->buckets; + for (int i = 0; i < DVI_HASH_SIZE; i++) { + DviCharNameHash *next; - for (DviCharNameHash *h = buckets[i]; h; h = next) { - next = h->next; - XtFree ((char *) h); - } - } + for (DviCharNameHash * h = buckets[i]; h; h = next) { + next = h->next; + XtFree((char *) h); + } + } } static int -hash_name (const char *name) +hash_name(const char *name) { - int i = 0; + int i = 0; - while (*name) - i = (i << 1) ^ *name++; - if (i < 0) - i = -i; - return i; + while (*name) + i = (i << 1) ^ *name++; + if (i < 0) + i = -i; + return i; } static void -compute_hash (DviCharNameMap *map) +compute_hash(DviCharNameMap *map) { - DviCharNameHash **buckets; + DviCharNameHash **buckets; - buckets = map->buckets; - for (int i = 0; i < DVI_HASH_SIZE; i++) - buckets[i] = NULL; - for (int c = 0; c < DVI_MAP_SIZE; c++) { - for (int s = 0; s < DVI_MAX_SYNONYMS; s++) { - DviCharNameHash *h; - int i; + buckets = map->buckets; + for (int i = 0; i < DVI_HASH_SIZE; i++) { + buckets[i] = NULL; + } + for (int c = 0; c < DVI_MAP_SIZE; c++) { + for (int s = 0; s < DVI_MAX_SYNONYMS; s++) { + DviCharNameHash *h; + int i; - if (!map->dvi_names[c][s]) - break; - i = hash_name (map->dvi_names[c][s]) % DVI_HASH_SIZE; - h = allocHash (); - h->next = buckets[i]; - buckets[i] = h; - h->name = map->dvi_names[c][s]; - h->position = c; - } - } + if (!map->dvi_names[c][s]) + break; + i = hash_name(map->dvi_names[c][s]) % DVI_HASH_SIZE; + h = allocHash(); + h->next = buckets[i]; + buckets[i] = h; + h->name = map->dvi_names[c][s]; + h->position = c; + } + } } int -DviCharIndex (DviCharNameMap *map, const char *name) +DviCharIndex(DviCharNameMap *map, const char *name) { - int i; - DviCharNameHash *h; + int i; + DviCharNameHash *h; - i = hash_name (name) % DVI_HASH_SIZE; - for (h = map->buckets[i]; h; h=h->next) - if (!strcmp (h->name, name)) - return h->position; - return -1; + i = hash_name(name) % DVI_HASH_SIZE; + for (h = map->buckets[i]; h; h = h->next) { + if (!strcmp(h->name, name)) + return h->position; + } + return -1; } static DviCharNameMap ISO8859_1_map = { - "iso8859-1", - 0, -{ -{ NULL, /* 0 */}, -{ NULL, /* 1 */}, -{ NULL, /* 2 */}, -{ NULL, /* 3 */}, -{ NULL, /* 4 */}, -{ NULL, /* 5 */}, -{ NULL, /* 6 */}, -{ NULL, /* 7 */}, -{ NULL, /* 8 */}, -{ NULL, /* 9 */}, -{ NULL, /* 10 */}, -{ NULL, /* 11 */}, -{ NULL, /* 12 */}, -{ NULL, /* 13 */}, -{ NULL, /* 14 */}, -{ NULL, /* 15 */}, -{ NULL, /* 16 */}, -{ NULL, /* 17 */}, -{ NULL, /* 18 */}, -{ NULL, /* 19 */}, -{ NULL, /* 20 */}, -{ NULL, /* 21 */}, -{ NULL, /* 22 */}, -{ NULL, /* 23 */}, -{ NULL, /* 24 */}, -{ NULL, /* 25 */}, -{ NULL, /* 26 */}, -{ NULL, /* 27 */}, -{ NULL, /* 28 */}, -{ NULL, /* 29 */}, -{ NULL, /* 30 */}, -{ NULL, /* 31 */}, -{ NULL, /* 32 */}, -{ "!", /* 33 */}, -{ "\"", /* 34 */}, -{ "#", /* 35 */}, -{ "$", /* 36 */}, -{ "%", /* 37 */}, -{ "&", /* 38 */}, -{ "'", /* 39 */}, -{ "(", /* 40 */}, -{ ")", /* 41 */}, -{ "*", /* 42 */}, -{ "+", /* 43 */}, -{ ",", /* 44 */}, -{ "-","\\-", /* 45 */}, -{ ".", /* 46 */}, -{ "/","sl", /* 47 */}, -{ "0", /* 48 */}, -{ "1", /* 49 */}, -{ "2", /* 50 */}, -{ "3", /* 51 */}, -{ "4", /* 52 */}, -{ "5", /* 53 */}, -{ "6", /* 54 */}, -{ "7", /* 55 */}, -{ "8", /* 56 */}, -{ "9", /* 57 */}, -{ ":", /* 58 */}, -{ ";", /* 59 */}, -{ "<", /* 60 */}, -{ "=","eq", /* 61 */}, -{ ">", /* 62 */}, -{ "?", /* 63 */}, -{ "@", /* 64 */}, -{ "A", /* 65 */}, -{ "B", /* 66 */}, -{ "C", /* 67 */}, -{ "D", /* 68 */}, -{ "E", /* 69 */}, -{ "F", /* 70 */}, -{ "G", /* 71 */}, -{ "H", /* 72 */}, -{ "I", /* 73 */}, -{ "J", /* 74 */}, -{ "K", /* 75 */}, -{ "L", /* 76 */}, -{ "M", /* 77 */}, -{ "N", /* 78 */}, -{ "O", /* 79 */}, -{ "P", /* 80 */}, -{ "Q", /* 81 */}, -{ "R", /* 82 */}, -{ "S", /* 83 */}, -{ "T", /* 84 */}, -{ "U", /* 85 */}, -{ "V", /* 86 */}, -{ "W", /* 87 */}, -{ "X", /* 88 */}, -{ "Y", /* 89 */}, -{ "Z", /* 90 */}, -{ "[", /* 91 */}, -{ "\\", /* 92 */}, -{ "]", /* 93 */}, -{ "a^", /* 94 */}, -{ "_","ru","ul", /* 95 */}, -{ "`", /* 96 */}, -{ "a", /* 97 */}, -{ "b", /* 98 */}, -{ "c", /* 99 */}, -{ "d", /* 100 */}, -{ "e", /* 101 */}, -{ "f", /* 102 */}, -{ "g", /* 103 */}, -{ "h", /* 104 */}, -{ "i", /* 105 */}, -{ "j", /* 106 */}, -{ "k", /* 107 */}, -{ "l", /* 108 */}, -{ "m", /* 109 */}, -{ "n", /* 110 */}, -{ "o", /* 111 */}, -{ "p", /* 112 */}, -{ "q", /* 113 */}, -{ "r", /* 114 */}, -{ "s", /* 115 */}, -{ "t", /* 116 */}, -{ "u", /* 117 */}, -{ "v", /* 118 */}, -{ "w", /* 119 */}, -{ "x", /* 120 */}, -{ "y", /* 121 */}, -{ "z", /* 122 */}, -{ "{", /* 123 */}, -{ "|","or" /* 124 */}, -{ "}", /* 125 */}, -{ "a~","ap" /* 126 */}, -{ NULL, /* 127 */}, -{ NULL, /* 128 */}, -{ NULL, /* 129 */}, -{ NULL, /* 130 */}, -{ NULL, /* 131 */}, -{ NULL, /* 132 */}, -{ NULL, /* 133 */}, -{ NULL, /* 134 */}, -{ NULL, /* 135 */}, -{ NULL, /* 136 */}, -{ NULL, /* 137 */}, -{ NULL, /* 138 */}, -{ NULL, /* 139 */}, -{ NULL, /* 140 */}, -{ NULL, /* 141 */}, -{ NULL, /* 142 */}, -{ NULL, /* 143 */}, -{ NULL, /* 144 */}, -{ NULL, /* 145 */}, -{ NULL, /* 146 */}, -{ NULL, /* 147 */}, -{ NULL, /* 148 */}, -{ NULL, /* 149 */}, -{ NULL, /* 150 */}, -{ NULL, /* 151 */}, -{ NULL, /* 152 */}, -{ NULL, /* 153 */}, -{ NULL, /* 154 */}, -{ NULL, /* 155 */}, -{ NULL, /* 156 */}, -{ NULL, /* 157 */}, -{ NULL, /* 158 */}, -{ NULL, /* 159 */}, -{ NULL, /* 160 */}, -{ "I!", /* 161 */}, -{ "ct", /* 162 */}, -{ "po", /* 163 */}, -{ "cu", /* 164 */}, -{ "$J", /* 165 */}, -{ NULL, /* 166 */}, -{ "sc", /* 167 */}, -{ NULL, /* 168 */}, -{ "co", /* 169 */}, -{ NULL, /* 170 */}, -{ "d<", /* 171 */}, -{ "no", /* 172 */}, -{ "hy", /* 173 */}, -{ "rg", /* 174 */}, -{ "ma", /* 175 */}, -{ "de", /* 176 */}, -{ "+-", /* 177 */}, -{ NULL, /* 178 */}, -{ NULL, /* 179 */}, -{ "aa", /* 180 */}, -{ "*m", /* 181 */}, -{ "pp", /* 182 */}, -{ NULL, /* 183 */}, -{ "cd", /* 184 */}, -{ NULL, /* 185 */}, -{ NULL, /* 186 */}, -{ "d>", /* 187 */}, -{ "14", /* 188 */}, -{ "12", /* 189 */}, -{ "34", /* 190 */}, -{ "I?", /* 191 */}, -{ NULL, /* 192 */}, -{ NULL, /* 193 */}, -{ NULL, /* 194 */}, -{ NULL, /* 195 */}, -{ NULL, /* 196 */}, -{ NULL, /* 197 */}, -{ "AE", /* 198 */}, -{ NULL, /* 199 */}, -{ NULL, /* 200 */}, -{ NULL, /* 201 */}, -{ NULL, /* 202 */}, -{ NULL, /* 203 */}, -{ NULL, /* 204 */}, -{ NULL, /* 205 */}, -{ NULL, /* 206 */}, -{ NULL, /* 207 */}, -{ NULL, /* 208 */}, -{ NULL, /* 209 */}, -{ NULL, /* 210 */}, -{ NULL, /* 211 */}, -{ NULL, /* 212 */}, -{ NULL, /* 213 */}, -{ NULL, /* 214 */}, -{ "mu", /* 215 */}, -{ "O/", /* 216 */}, -{ NULL, /* 217 */}, -{ NULL, /* 218 */}, -{ NULL, /* 219 */}, -{ NULL, /* 220 */}, -{ NULL, /* 221 */}, -{ NULL, /* 222 */}, -{ "ss", /* 223 */}, -{ NULL, /* 224 */}, -{ NULL, /* 225 */}, -{ NULL, /* 226 */}, -{ NULL, /* 227 */}, -{ NULL, /* 228 */}, -{ NULL, /* 229 */}, -{ "ae", /* 230 */}, -{ NULL, /* 231 */}, -{ NULL, /* 232 */}, -{ NULL, /* 233 */}, -{ NULL, /* 234 */}, -{ NULL, /* 235 */}, -{ NULL, /* 236 */}, -{ NULL, /* 237 */}, -{ NULL, /* 238 */}, -{ NULL, /* 239 */}, -{ NULL, /* 240 */}, -{ NULL, /* 241 */}, -{ NULL, /* 242 */}, -{ NULL, /* 243 */}, -{ NULL, /* 244 */}, -{ NULL, /* 245 */}, -{ NULL, /* 246 */}, -{ NULL, /* 247 */}, -{ NULL, /* 248 */}, -{ NULL, /* 249 */}, -{ NULL, /* 250 */}, -{ NULL, /* 251 */}, -{ NULL, /* 252 */}, -{ NULL, /* 253 */}, -{ NULL, /* 254 */}, -{ NULL, /* 255 */}, -}, -{ -{ "fi", "fi", }, -{ "fl", "fl", }, -{ "ff", "ff", }, -{ "Fi", "ffi", }, -{ "Fl", "ffl", }, -{ NULL, NULL, }, -}, -{} + "iso8859-1", + 0, + { + {NULL, /* 0 */ }, + {NULL, /* 1 */ }, + {NULL, /* 2 */ }, + {NULL, /* 3 */ }, + {NULL, /* 4 */ }, + {NULL, /* 5 */ }, + {NULL, /* 6 */ }, + {NULL, /* 7 */ }, + {NULL, /* 8 */ }, + {NULL, /* 9 */ }, + {NULL, /* 10 */ }, + {NULL, /* 11 */ }, + {NULL, /* 12 */ }, + {NULL, /* 13 */ }, + {NULL, /* 14 */ }, + {NULL, /* 15 */ }, + {NULL, /* 16 */ }, + {NULL, /* 17 */ }, + {NULL, /* 18 */ }, + {NULL, /* 19 */ }, + {NULL, /* 20 */ }, + {NULL, /* 21 */ }, + {NULL, /* 22 */ }, + {NULL, /* 23 */ }, + {NULL, /* 24 */ }, + {NULL, /* 25 */ }, + {NULL, /* 26 */ }, + {NULL, /* 27 */ }, + {NULL, /* 28 */ }, + {NULL, /* 29 */ }, + {NULL, /* 30 */ }, + {NULL, /* 31 */ }, + {NULL, /* 32 */ }, + {"!", /* 33 */ }, + {"\"", /* 34 */ }, + {"#", /* 35 */ }, + {"$", /* 36 */ }, + {"%", /* 37 */ }, + {"&", /* 38 */ }, + {"'", /* 39 */ }, + {"(", /* 40 */ }, + {")", /* 41 */ }, + {"*", /* 42 */ }, + {"+", /* 43 */ }, + {",", /* 44 */ }, + {"-", "\\-", /* 45 */ }, + {".", /* 46 */ }, + {"/", "sl", /* 47 */ }, + {"0", /* 48 */ }, + {"1", /* 49 */ }, + {"2", /* 50 */ }, + {"3", /* 51 */ }, + {"4", /* 52 */ }, + {"5", /* 53 */ }, + {"6", /* 54 */ }, + {"7", /* 55 */ }, + {"8", /* 56 */ }, + {"9", /* 57 */ }, + {":", /* 58 */ }, + {";", /* 59 */ }, + {"<", /* 60 */ }, + {"=", "eq", /* 61 */ }, + {">", /* 62 */ }, + {"?", /* 63 */ }, + {"@", /* 64 */ }, + {"A", /* 65 */ }, + {"B", /* 66 */ }, + {"C", /* 67 */ }, + {"D", /* 68 */ }, + {"E", /* 69 */ }, + {"F", /* 70 */ }, + {"G", /* 71 */ }, + {"H", /* 72 */ }, + {"I", /* 73 */ }, + {"J", /* 74 */ }, + {"K", /* 75 */ }, + {"L", /* 76 */ }, + {"M", /* 77 */ }, + {"N", /* 78 */ }, + {"O", /* 79 */ }, + {"P", /* 80 */ }, + {"Q", /* 81 */ }, + {"R", /* 82 */ }, + {"S", /* 83 */ }, + {"T", /* 84 */ }, + {"U", /* 85 */ }, + {"V", /* 86 */ }, + {"W", /* 87 */ }, + {"X", /* 88 */ }, + {"Y", /* 89 */ }, + {"Z", /* 90 */ }, + {"[", /* 91 */ }, + {"\\", /* 92 */ }, + {"]", /* 93 */ }, + {"a^", /* 94 */ }, + {"_", "ru", "ul", /* 95 */ }, + {"`", /* 96 */ }, + {"a", /* 97 */ }, + {"b", /* 98 */ }, + {"c", /* 99 */ }, + {"d", /* 100 */ }, + {"e", /* 101 */ }, + {"f", /* 102 */ }, + {"g", /* 103 */ }, + {"h", /* 104 */ }, + {"i", /* 105 */ }, + {"j", /* 106 */ }, + {"k", /* 107 */ }, + {"l", /* 108 */ }, + {"m", /* 109 */ }, + {"n", /* 110 */ }, + {"o", /* 111 */ }, + {"p", /* 112 */ }, + {"q", /* 113 */ }, + {"r", /* 114 */ }, + {"s", /* 115 */ }, + {"t", /* 116 */ }, + {"u", /* 117 */ }, + {"v", /* 118 */ }, + {"w", /* 119 */ }, + {"x", /* 120 */ }, + {"y", /* 121 */ }, + {"z", /* 122 */ }, + {"{", /* 123 */ }, + {"|", "or" /* 124 */ }, + {"}", /* 125 */ }, + {"a~", "ap" /* 126 */ }, + {NULL, /* 127 */ }, + {NULL, /* 128 */ }, + {NULL, /* 129 */ }, + {NULL, /* 130 */ }, + {NULL, /* 131 */ }, + {NULL, /* 132 */ }, + {NULL, /* 133 */ }, + {NULL, /* 134 */ }, + {NULL, /* 135 */ }, + {NULL, /* 136 */ }, + {NULL, /* 137 */ }, + {NULL, /* 138 */ }, + {NULL, /* 139 */ }, + {NULL, /* 140 */ }, + {NULL, /* 141 */ }, + {NULL, /* 142 */ }, + {NULL, /* 143 */ }, + {NULL, /* 144 */ }, + {NULL, /* 145 */ }, + {NULL, /* 146 */ }, + {NULL, /* 147 */ }, + {NULL, /* 148 */ }, + {NULL, /* 149 */ }, + {NULL, /* 150 */ }, + {NULL, /* 151 */ }, + {NULL, /* 152 */ }, + {NULL, /* 153 */ }, + {NULL, /* 154 */ }, + {NULL, /* 155 */ }, + {NULL, /* 156 */ }, + {NULL, /* 157 */ }, + {NULL, /* 158 */ }, + {NULL, /* 159 */ }, + {NULL, /* 160 */ }, + {"I!", /* 161 */ }, + {"ct", /* 162 */ }, + {"po", /* 163 */ }, + {"cu", /* 164 */ }, + {"$J", /* 165 */ }, + {NULL, /* 166 */ }, + {"sc", /* 167 */ }, + {NULL, /* 168 */ }, + {"co", /* 169 */ }, + {NULL, /* 170 */ }, + {"d<", /* 171 */ }, + {"no", /* 172 */ }, + {"hy", /* 173 */ }, + {"rg", /* 174 */ }, + {"ma", /* 175 */ }, + {"de", /* 176 */ }, + {"+-", /* 177 */ }, + {NULL, /* 178 */ }, + {NULL, /* 179 */ }, + {"aa", /* 180 */ }, + {"*m", /* 181 */ }, + {"pp", /* 182 */ }, + {NULL, /* 183 */ }, + {"cd", /* 184 */ }, + {NULL, /* 185 */ }, + {NULL, /* 186 */ }, + {"d>", /* 187 */ }, + {"14", /* 188 */ }, + {"12", /* 189 */ }, + {"34", /* 190 */ }, + {"I?", /* 191 */ }, + {NULL, /* 192 */ }, + {NULL, /* 193 */ }, + {NULL, /* 194 */ }, + {NULL, /* 195 */ }, + {NULL, /* 196 */ }, + {NULL, /* 197 */ }, + {"AE", /* 198 */ }, + {NULL, /* 199 */ }, + {NULL, /* 200 */ }, + {NULL, /* 201 */ }, + {NULL, /* 202 */ }, + {NULL, /* 203 */ }, + {NULL, /* 204 */ }, + {NULL, /* 205 */ }, + {NULL, /* 206 */ }, + {NULL, /* 207 */ }, + {NULL, /* 208 */ }, + {NULL, /* 209 */ }, + {NULL, /* 210 */ }, + {NULL, /* 211 */ }, + {NULL, /* 212 */ }, + {NULL, /* 213 */ }, + {NULL, /* 214 */ }, + {"mu", /* 215 */ }, + {"O/", /* 216 */ }, + {NULL, /* 217 */ }, + {NULL, /* 218 */ }, + {NULL, /* 219 */ }, + {NULL, /* 220 */ }, + {NULL, /* 221 */ }, + {NULL, /* 222 */ }, + {"ss", /* 223 */ }, + {NULL, /* 224 */ }, + {NULL, /* 225 */ }, + {NULL, /* 226 */ }, + {NULL, /* 227 */ }, + {NULL, /* 228 */ }, + {NULL, /* 229 */ }, + {"ae", /* 230 */ }, + {NULL, /* 231 */ }, + {NULL, /* 232 */ }, + {NULL, /* 233 */ }, + {NULL, /* 234 */ }, + {NULL, /* 235 */ }, + {NULL, /* 236 */ }, + {NULL, /* 237 */ }, + {NULL, /* 238 */ }, + {NULL, /* 239 */ }, + {NULL, /* 240 */ }, + {NULL, /* 241 */ }, + {NULL, /* 242 */ }, + {NULL, /* 243 */ }, + {NULL, /* 244 */ }, + {NULL, /* 245 */ }, + {NULL, /* 246 */ }, + {NULL, /* 247 */ }, + {NULL, /* 248 */ }, + {NULL, /* 249 */ }, + {NULL, /* 250 */ }, + {NULL, /* 251 */ }, + {NULL, /* 252 */ }, + {NULL, /* 253 */ }, + {NULL, /* 254 */ }, + {NULL, /* 255 */ }, + }, + { + {"fi", "fi",}, + {"fl", "fl",}, + {"ff", "ff",}, + {"Fi", "ffi",}, + {"Fl", "ffl",}, + {NULL, NULL,}, + }, + {} }; static DviCharNameMap Adobe_Symbol_map = { - "adobe-fontspecific", - 1, -{ -{ NULL, /* 0 */}, -{ NULL, /* 1 */}, -{ NULL, /* 2 */}, -{ NULL, /* 3 */}, -{ NULL, /* 4 */}, -{ NULL, /* 5 */}, -{ NULL, /* 6 */}, -{ NULL, /* 7 */}, -{ NULL, /* 8 */}, -{ NULL, /* 9 */}, -{ NULL, /* 10 */}, -{ NULL, /* 11 */}, -{ NULL, /* 12 */}, -{ NULL, /* 13 */}, -{ NULL, /* 14 */}, -{ NULL, /* 15 */}, -{ NULL, /* 16 */}, -{ NULL, /* 17 */}, -{ NULL, /* 18 */}, -{ NULL, /* 19 */}, -{ NULL, /* 20 */}, -{ NULL, /* 21 */}, -{ NULL, /* 22 */}, -{ NULL, /* 23 */}, -{ NULL, /* 24 */}, -{ NULL, /* 25 */}, -{ NULL, /* 26 */}, -{ NULL, /* 27 */}, -{ NULL, /* 28 */}, -{ NULL, /* 29 */}, -{ NULL, /* 30 */}, -{ NULL, /* 31 */}, -{ NULL, /* 32 */}, -{ "!", /* 33 */}, -{ "fa", /* 34 */}, -{ "#", /* 35 */}, -{ "te", /* 36 */}, -{ "%", /* 37 */}, -{ "&", /* 38 */}, -{ "cm", /* 39 */}, -{ "(", /* 40 */}, -{ ")", /* 41 */}, -{ "**", /* 42 */}, -{ "+","pl", /* 43 */}, -{ ",", /* 44 */}, -{ "-","mi","\\-", /* 45 */}, -{ ".", /* 46 */}, -{ "/","sl", /* 47 */}, -{ "0", /* 48 */}, -{ "1", /* 49 */}, -{ "2", /* 50 */}, -{ "3", /* 51 */}, -{ "4", /* 52 */}, -{ "5", /* 53 */}, -{ "6", /* 54 */}, -{ "7", /* 55 */}, -{ "8", /* 56 */}, -{ "9", /* 57 */}, -{ ":", /* 58 */}, -{ ";", /* 59 */}, -{ "<", /* 60 */}, -{ "=","eq", /* 61 */}, -{ ">", /* 62 */}, -{ "?", /* 63 */}, -{ "=~", /* 64 */}, -{ "*A", /* 65 */}, -{ "*B", /* 66 */}, -{ "*C", /* 67 */}, -{ "*D", /* 68 */}, -{ "*E", /* 69 */}, -{ "*F", /* 70 */}, -{ "*G", /* 71 */}, -{ "*Y", /* 72 */}, -{ "*I", /* 73 */}, -{ NULL, /* 74 */}, -{ "*K", /* 75 */}, -{ "*L", /* 76 */}, -{ "*M", /* 77 */}, -{ "*N", /* 78 */}, -{ "*O", /* 79 */}, -{ "*P", /* 80 */}, -{ "*H", /* 81 */}, -{ "*R", /* 82 */}, -{ "*S", /* 83 */}, -{ "*T", /* 84 */}, -{ "*U", /* 85 */}, -{ "ts", /* 86 */}, -{ "*W", /* 87 */}, -{ "*C", /* 88 */}, -{ "*Q", /* 89 */}, -{ "*Z", /* 90 */}, -{ "[", /* 91 */}, -{ "tf", /* 92 */}, -{ "]", /* 93 */}, -{ "bt", /* 94 */}, -{ "ul", /* 95 */}, -{ "rn", /* 96 */}, -{ "*a", /* 97 */}, -{ "*b", /* 98 */}, -{ "*x", /* 99 */}, -{ "*d", /* 100 */}, -{ "*e", /* 101 */}, -{ "*f", /* 102 */}, -{ "*g", /* 103 */}, -{ "*y", /* 104 */}, -{ "*i", /* 105 */}, -{ NULL, /* 106 */}, -{ "*k", /* 107 */}, -{ "*l", /* 108 */}, -{ "*m", /* 109 */}, -{ "*n", /* 110 */}, -{ "*o", /* 111 */}, -{ "*p", /* 112 */}, -{ "*h", /* 113 */}, -{ "*r", /* 114 */}, -{ "*s", /* 115 */}, -{ "*t", /* 116 */}, -{ "*u", /* 117 */}, -{ NULL, /* 118 */}, -{ "*w", /* 119 */}, -{ "*c", /* 120 */}, -{ "*q", /* 121 */}, -{ "*z", /* 122 */}, -{ "{", /* 123 */}, -{ "|", /* 124 */}, -{ "}", /* 125 */}, -{ "a~","ap", /* 126 */}, -{ NULL, /* 127 */}, -{ NULL, /* 128 */}, -{ NULL, /* 129 */}, -{ NULL, /* 130 */}, -{ NULL, /* 131 */}, -{ NULL, /* 132 */}, -{ NULL, /* 133 */}, -{ NULL, /* 134 */}, -{ NULL, /* 135 */}, -{ NULL, /* 136 */}, -{ NULL, /* 137 */}, -{ NULL, /* 138 */}, -{ NULL, /* 139 */}, -{ NULL, /* 140 */}, -{ NULL, /* 141 */}, -{ NULL, /* 142 */}, -{ NULL, /* 143 */}, -{ NULL, /* 144 */}, -{ NULL, /* 145 */}, -{ NULL, /* 146 */}, -{ NULL, /* 147 */}, -{ NULL, /* 148 */}, -{ NULL, /* 149 */}, -{ NULL, /* 150 */}, -{ NULL, /* 151 */}, -{ NULL, /* 152 */}, -{ NULL, /* 153 */}, -{ NULL, /* 154 */}, -{ NULL, /* 155 */}, -{ NULL, /* 156 */}, -{ NULL, /* 157 */}, -{ NULL, /* 158 */}, -{ NULL, /* 159 */}, -{ NULL, /* 160 */}, -{ NULL, /* 161 */}, -{ "fm","mt", /* 162 */}, -{ "<=", /* 163 */}, -{ "/","sl" /* 164 */}, -{ "if", /* 165 */}, -{ NULL, /* 166 */}, -{ "Cc", /* 167 */}, -{ "Cd", /* 168 */}, -{ "Ch", /* 169 */}, -{ "Cs", /* 170 */}, -{ "<>", /* 171 */}, -{ "<-", /* 172 */}, -{ "ua", /* 173 */}, -{ "->", /* 174 */}, -{ "da", /* 175 */}, -{ "de", /* 176 */}, -{ "+-", /* 177 */}, -{ "sd", /* 178 */}, -{ ">=", /* 179 */}, -{ "mu", /* 180 */}, -{ "pt", /* 181 */}, -{ "pd", /* 182 */}, -{ "bu", /* 183 */}, -{ "di", /* 184 */}, -{ "!=", /* 185 */}, -{ "==", /* 186 */}, -{ "~=", /* 187 */}, -{ "..", /* 188 */}, -{ "br", /* 189 */}, -{ "em", /* 190 */}, -{ "cr", /* 191 */}, -{ "al", /* 192 */}, -{ NULL, /* 193 */}, -{ NULL, /* 194 */}, -{ NULL, /* 195 */}, -{ "ax", /* 196 */}, -{ "a+", /* 197 */}, -{ "es", /* 198 */}, -{ "ca", /* 199 */}, -{ "cu", /* 200 */}, -{ "sp", /* 201 */}, -{ "ip", /* 202 */}, -{ "!s", /* 203 */}, -{ "sb", /* 204 */}, -{ "ib", /* 205 */}, -{ "mo", /* 206 */}, -{ "!m", /* 207 */}, -{ "ag", /* 208 */}, -{ "gr", /* 209 */}, -{ NULL, /* 210 */}, -{ NULL, /* 211 */}, -{ NULL, /* 212 */}, -{ NULL, /* 213 */}, -{ "sr", /* 214 */}, -{ "m.", /* 215 */}, -{ "no", /* 216 */}, -{ "an", /* 217 */}, -{ "lo", /* 218 */}, -{ "io", /* 219 */}, -{ "<:", /* 220 */}, -{ "u=", /* 221 */}, -{ ":>", /* 222 */}, -{ "d=", /* 223 */}, -{ "dm", /* 224 */}, -{ "L<", /* 225 */}, -{ "rg", /* 226 */}, -{ "co", /* 227 */}, -{ "tm", /* 228 */}, -{ NULL, /* 229 */}, -{ NULL, /* 230 */}, -{ NULL, /* 231 */}, -{ NULL, /* 232 */}, -{ "lc", /* 233 */}, -{ NULL, /* 234 */}, -{ "lf", /* 235 */}, -{ "lt", /* 236 */}, -{ "lk", /* 237 */}, -{ "lb", /* 238 */}, -{ "bv", /* 239 */}, -{ "AL", /* 240 */}, -{ "R>", /* 241 */}, -{ "is", /* 242 */}, -{ NULL, /* 243 */}, -{ NULL, /* 244 */}, -{ NULL, /* 245 */}, -{ NULL, /* 246 */}, -{ NULL, /* 247 */}, -{ NULL, /* 248 */}, -{ "rc", /* 249 */}, -{ NULL, /* 250 */}, -{ "rf", /* 251 */}, -{ "rt", /* 252 */}, -{ "rk", /* 253 */}, -{ "rb", /* 254 */}, -{ NULL, /* 255 */}, -}, -{ -{ NULL, NULL }, -}, -{} + "adobe-fontspecific", + 1, + { + {NULL, /* 0 */ }, + {NULL, /* 1 */ }, + {NULL, /* 2 */ }, + {NULL, /* 3 */ }, + {NULL, /* 4 */ }, + {NULL, /* 5 */ }, + {NULL, /* 6 */ }, + {NULL, /* 7 */ }, + {NULL, /* 8 */ }, + {NULL, /* 9 */ }, + {NULL, /* 10 */ }, + {NULL, /* 11 */ }, + {NULL, /* 12 */ }, + {NULL, /* 13 */ }, + {NULL, /* 14 */ }, + {NULL, /* 15 */ }, + {NULL, /* 16 */ }, + {NULL, /* 17 */ }, + {NULL, /* 18 */ }, + {NULL, /* 19 */ }, + {NULL, /* 20 */ }, + {NULL, /* 21 */ }, + {NULL, /* 22 */ }, + {NULL, /* 23 */ }, + {NULL, /* 24 */ }, + {NULL, /* 25 */ }, + {NULL, /* 26 */ }, + {NULL, /* 27 */ }, + {NULL, /* 28 */ }, + {NULL, /* 29 */ }, + {NULL, /* 30 */ }, + {NULL, /* 31 */ }, + {NULL, /* 32 */ }, + {"!", /* 33 */ }, + {"fa", /* 34 */ }, + {"#", /* 35 */ }, + {"te", /* 36 */ }, + {"%", /* 37 */ }, + {"&", /* 38 */ }, + {"cm", /* 39 */ }, + {"(", /* 40 */ }, + {")", /* 41 */ }, + {"**", /* 42 */ }, + {"+", "pl", /* 43 */ }, + {",", /* 44 */ }, + {"-", "mi", "\\-", /* 45 */ }, + {".", /* 46 */ }, + {"/", "sl", /* 47 */ }, + {"0", /* 48 */ }, + {"1", /* 49 */ }, + {"2", /* 50 */ }, + {"3", /* 51 */ }, + {"4", /* 52 */ }, + {"5", /* 53 */ }, + {"6", /* 54 */ }, + {"7", /* 55 */ }, + {"8", /* 56 */ }, + {"9", /* 57 */ }, + {":", /* 58 */ }, + {";", /* 59 */ }, + {"<", /* 60 */ }, + {"=", "eq", /* 61 */ }, + {">", /* 62 */ }, + {"?", /* 63 */ }, + {"=~", /* 64 */ }, + {"*A", /* 65 */ }, + {"*B", /* 66 */ }, + {"*C", /* 67 */ }, + {"*D", /* 68 */ }, + {"*E", /* 69 */ }, + {"*F", /* 70 */ }, + {"*G", /* 71 */ }, + {"*Y", /* 72 */ }, + {"*I", /* 73 */ }, + {NULL, /* 74 */ }, + {"*K", /* 75 */ }, + {"*L", /* 76 */ }, + {"*M", /* 77 */ }, + {"*N", /* 78 */ }, + {"*O", /* 79 */ }, + {"*P", /* 80 */ }, + {"*H", /* 81 */ }, + {"*R", /* 82 */ }, + {"*S", /* 83 */ }, + {"*T", /* 84 */ }, + {"*U", /* 85 */ }, + {"ts", /* 86 */ }, + {"*W", /* 87 */ }, + {"*C", /* 88 */ }, + {"*Q", /* 89 */ }, + {"*Z", /* 90 */ }, + {"[", /* 91 */ }, + {"tf", /* 92 */ }, + {"]", /* 93 */ }, + {"bt", /* 94 */ }, + {"ul", /* 95 */ }, + {"rn", /* 96 */ }, + {"*a", /* 97 */ }, + {"*b", /* 98 */ }, + {"*x", /* 99 */ }, + {"*d", /* 100 */ }, + {"*e", /* 101 */ }, + {"*f", /* 102 */ }, + {"*g", /* 103 */ }, + {"*y", /* 104 */ }, + {"*i", /* 105 */ }, + {NULL, /* 106 */ }, + {"*k", /* 107 */ }, + {"*l", /* 108 */ }, + {"*m", /* 109 */ }, + {"*n", /* 110 */ }, + {"*o", /* 111 */ }, + {"*p", /* 112 */ }, + {"*h", /* 113 */ }, + {"*r", /* 114 */ }, + {"*s", /* 115 */ }, + {"*t", /* 116 */ }, + {"*u", /* 117 */ }, + {NULL, /* 118 */ }, + {"*w", /* 119 */ }, + {"*c", /* 120 */ }, + {"*q", /* 121 */ }, + {"*z", /* 122 */ }, + {"{", /* 123 */ }, + {"|", /* 124 */ }, + {"}", /* 125 */ }, + {"a~", "ap", /* 126 */ }, + {NULL, /* 127 */ }, + {NULL, /* 128 */ }, + {NULL, /* 129 */ }, + {NULL, /* 130 */ }, + {NULL, /* 131 */ }, + {NULL, /* 132 */ }, + {NULL, /* 133 */ }, + {NULL, /* 134 */ }, + {NULL, /* 135 */ }, + {NULL, /* 136 */ }, + {NULL, /* 137 */ }, + {NULL, /* 138 */ }, + {NULL, /* 139 */ }, + {NULL, /* 140 */ }, + {NULL, /* 141 */ }, + {NULL, /* 142 */ }, + {NULL, /* 143 */ }, + {NULL, /* 144 */ }, + {NULL, /* 145 */ }, + {NULL, /* 146 */ }, + {NULL, /* 147 */ }, + {NULL, /* 148 */ }, + {NULL, /* 149 */ }, + {NULL, /* 150 */ }, + {NULL, /* 151 */ }, + {NULL, /* 152 */ }, + {NULL, /* 153 */ }, + {NULL, /* 154 */ }, + {NULL, /* 155 */ }, + {NULL, /* 156 */ }, + {NULL, /* 157 */ }, + {NULL, /* 158 */ }, + {NULL, /* 159 */ }, + {NULL, /* 160 */ }, + {NULL, /* 161 */ }, + {"fm", "mt", /* 162 */ }, + {"<=", /* 163 */ }, + {"/", "sl" /* 164 */ }, + {"if", /* 165 */ }, + {NULL, /* 166 */ }, + {"Cc", /* 167 */ }, + {"Cd", /* 168 */ }, + {"Ch", /* 169 */ }, + {"Cs", /* 170 */ }, + {"<>", /* 171 */ }, + {"<-", /* 172 */ }, + {"ua", /* 173 */ }, + {"->", /* 174 */ }, + {"da", /* 175 */ }, + {"de", /* 176 */ }, + {"+-", /* 177 */ }, + {"sd", /* 178 */ }, + {">=", /* 179 */ }, + {"mu", /* 180 */ }, + {"pt", /* 181 */ }, + {"pd", /* 182 */ }, + {"bu", /* 183 */ }, + {"di", /* 184 */ }, + {"!=", /* 185 */ }, + {"==", /* 186 */ }, + {"~=", /* 187 */ }, + {"..", /* 188 */ }, + {"br", /* 189 */ }, + {"em", /* 190 */ }, + {"cr", /* 191 */ }, + {"al", /* 192 */ }, + {NULL, /* 193 */ }, + {NULL, /* 194 */ }, + {NULL, /* 195 */ }, + {"ax", /* 196 */ }, + {"a+", /* 197 */ }, + {"es", /* 198 */ }, + {"ca", /* 199 */ }, + {"cu", /* 200 */ }, + {"sp", /* 201 */ }, + {"ip", /* 202 */ }, + {"!s", /* 203 */ }, + {"sb", /* 204 */ }, + {"ib", /* 205 */ }, + {"mo", /* 206 */ }, + {"!m", /* 207 */ }, + {"ag", /* 208 */ }, + {"gr", /* 209 */ }, + {NULL, /* 210 */ }, + {NULL, /* 211 */ }, + {NULL, /* 212 */ }, + {NULL, /* 213 */ }, + {"sr", /* 214 */ }, + {"m.", /* 215 */ }, + {"no", /* 216 */ }, + {"an", /* 217 */ }, + {"lo", /* 218 */ }, + {"io", /* 219 */ }, + {"<:", /* 220 */ }, + {"u=", /* 221 */ }, + {":>", /* 222 */ }, + {"d=", /* 223 */ }, + {"dm", /* 224 */ }, + {"L<", /* 225 */ }, + {"rg", /* 226 */ }, + {"co", /* 227 */ }, + {"tm", /* 228 */ }, + {NULL, /* 229 */ }, + {NULL, /* 230 */ }, + {NULL, /* 231 */ }, + {NULL, /* 232 */ }, + {"lc", /* 233 */ }, + {NULL, /* 234 */ }, + {"lf", /* 235 */ }, + {"lt", /* 236 */ }, + {"lk", /* 237 */ }, + {"lb", /* 238 */ }, + {"bv", /* 239 */ }, + {"AL", /* 240 */ }, + {"R>", /* 241 */ }, + {"is", /* 242 */ }, + {NULL, /* 243 */ }, + {NULL, /* 244 */ }, + {NULL, /* 245 */ }, + {NULL, /* 246 */ }, + {NULL, /* 247 */ }, + {NULL, /* 248 */ }, + {"rc", /* 249 */ }, + {NULL, /* 250 */ }, + {"rf", /* 251 */ }, + {"rt", /* 252 */ }, + {"rk", /* 253 */ }, + {"rb", /* 254 */ }, + {NULL, /* 255 */ }, + }, + { + {NULL, NULL}, + }, + {} }; static void -load_standard_maps (void) +load_standard_maps(void) { - standard_maps_loaded = 1; - DviRegisterMap (&ISO8859_1_map); - DviRegisterMap (&Adobe_Symbol_map); + standard_maps_loaded = 1; + DviRegisterMap(&ISO8859_1_map); + DviRegisterMap(&Adobe_Symbol_map); } - @@ -15,30 +15,31 @@ #include "Dvi.h" -# define DVI_MAX_SYNONYMS 10 -# define DVI_MAP_SIZE 256 -# define DVI_HASH_SIZE 256 -# define DVI_MAX_LIGATURES 16 +#define DVI_MAX_SYNONYMS 10 +#define DVI_MAP_SIZE 256 +#define DVI_HASH_SIZE 256 +#define DVI_MAX_LIGATURES 16 typedef struct _dviCharNameHash { - struct _dviCharNameHash *next; - const char *name; - int position; + struct _dviCharNameHash *next; + const char *name; + int position; } DviCharNameHash; typedef struct _dviCharNameMap { - const char * encoding; - int special; - const char * const dvi_names[DVI_MAP_SIZE][DVI_MAX_SYNONYMS]; - const char * const ligatures[DVI_MAX_LIGATURES][2]; - DviCharNameHash *buckets[DVI_HASH_SIZE]; + const char *encoding; + int special; + const char *const dvi_names[DVI_MAP_SIZE][DVI_MAX_SYNONYMS]; + const char *const ligatures[DVI_MAX_LIGATURES][2]; + DviCharNameHash *buckets[DVI_HASH_SIZE]; } DviCharNameMap; -extern DviCharNameMap *DviFindMap (const char *); -extern void DviRegisterMap (DviCharNameMap *); +extern DviCharNameMap *DviFindMap(const char *); +extern void DviRegisterMap(DviCharNameMap *); + #define DviCharName(map,index,synonym) ((map)->dvi_names[index][synonym]) -extern int DviCharIndex (DviCharNameMap *, const char *); -extern unsigned char *DviCharIsLigature (DviCharNameMap *, const char *); -extern void ResetFonts (DviWidget); +extern int DviCharIndex(DviCharNameMap *, const char *); +extern unsigned char *DviCharIsLigature(DviCharNameMap *, const char *); +extern void ResetFonts(DviWidget); #endif @@ -30,7 +30,7 @@ */ typedef struct _DviClass { - int makes_compiler_happy; /* not used */ + int makes_compiler_happy; /* not used */ } DviClassPart; /* @@ -38,9 +38,9 @@ typedef struct _DviClass { */ typedef struct _DviClassRec { - CoreClassPart core_class; - SimpleClassPart simple_class; - DviClassPart command_class; + CoreClassPart core_class; + SimpleClassPart simple_class; + DviClassPart command_class; } DviClassRec; extern DviClassRec dviClassRec; @@ -56,33 +56,33 @@ extern DviClassRec dviClassRec; */ typedef struct _dviFontSizeList { - struct _dviFontSizeList *next; - int size; - char *x_name; + struct _dviFontSizeList *next; + int size; + char *x_name; #ifdef USE_XFT - XftFont *font; - Bool core; + XftFont *font; + Bool core; #else - XFontStruct *font; + XFontStruct *font; #endif - int doesnt_exist; + int doesnt_exist; } DviFontSizeList; typedef struct _dviFontList { - struct _dviFontList *next; - char *dvi_name; - char *x_name; - int dvi_number; - Boolean initialized; - Boolean scalable; - DviFontSizeList *sizes; - DviCharNameMap *char_map; + struct _dviFontList *next; + char *dvi_name; + char *x_name; + int dvi_number; + Boolean initialized; + Boolean scalable; + DviFontSizeList *sizes; + DviCharNameMap *char_map; } DviFontList; typedef struct _dviFontMap { - struct _dviFontMap *next; - char *dvi_name; - char *x_name; + struct _dviFontMap *next; + char *dvi_name; + char *x_name; } DviFontMap; #define DVI_TEXT_CACHE_SIZE 256 @@ -90,49 +90,49 @@ typedef struct _dviFontMap { #ifdef USE_XFT typedef struct _dviTextItem { - char *chars; - int nchars; - int x; - XftFont *font; + char *chars; + int nchars; + int x; + XftFont *font; } DviTextItem; #endif typedef struct _dviCharCache { #ifdef USE_XFT - DviTextItem cache[DVI_TEXT_CACHE_SIZE]; + DviTextItem cache[DVI_TEXT_CACHE_SIZE]; #else - XTextItem cache[DVI_TEXT_CACHE_SIZE]; + XTextItem cache[DVI_TEXT_CACHE_SIZE]; #endif - char char_cache[DVI_CHAR_CACHE_SIZE]; - int index; - int max; - int char_index; - int font_size; - int font_number; + char char_cache[DVI_CHAR_CACHE_SIZE]; + int index; + int max; + int char_index; + int font_size; + int font_number; #ifdef USE_XFT - XftFont *font; + XftFont *font; #else - XFontStruct *font; + XFontStruct *font; #endif - int start_x, start_y; - int x, y; + int start_x, start_y; + int x, y; } DviCharCache; typedef struct _dviState { - struct _dviState *next; - int font_size; - int font_bound; - int font_number; - int line_style; - int line_width; - int x; - int y; + struct _dviState *next; + int font_size; + int font_bound; + int font_number; + int line_style; + int line_width; + int x; + int y; } DviState; typedef struct _dviFileMap { - struct _dviFileMap *next; - long position; - int page_number; + struct _dviFileMap *next; + long position; + int page_number; } DviFileMap; /* @@ -140,64 +140,64 @@ typedef struct _dviFileMap { */ typedef struct { - /* - * resource specifiable items - */ - char *font_map_string; - unsigned long foreground; - int requested_page; - int last_page; - FILE *file; - Boolean seek; /* file is "seekable" */ + /* + * resource specifiable items + */ + char *font_map_string; + unsigned long foreground; + int requested_page; + int last_page; + FILE *file; + Boolean seek; /* file is "seekable" */ #ifdef USE_XFT - XftFont *default_font; + XftFont *default_font; #else - XFontStruct *default_font; + XFontStruct *default_font; #endif - int backing_store; - Boolean noPolyText; - int screen_resolution; - float page_width; - float page_height; - int size_scale_set; - /* - * private state - */ - FILE *tmpFile; /* used when reading stdin */ - char readingTmp; /* reading now from tmp */ - char ungot; /* have ungetc'd a char */ - GC normal_GC; + int backing_store; + Boolean noPolyText; + int screen_resolution; + float page_width; + float page_height; + int size_scale_set; + /* + * private state + */ + FILE *tmpFile; /* used when reading stdin */ + char readingTmp; /* reading now from tmp */ + char ungot; /* have ungetc'd a char */ + GC normal_GC; #ifdef USE_XFT - XftDraw *draw; - XftColor black; + XftDraw *draw; + XftColor black; #endif - DviFileMap *file_map; - DviFontList *fonts; - DviFontMap *font_map; - int current_page; - int font_size; - int font_number; - int device_resolution; - int line_width; - int line_style; - int desired_width; - int desired_height; - int size_scale; /* font size scale */ + DviFileMap *file_map; + DviFontList *fonts; + DviFontMap *font_map; + int current_page; + int font_size; + int font_number; + int device_resolution; + int line_width; + int line_style; + int desired_width; + int desired_height; + int size_scale; /* font size scale */ #ifdef USE_XFT - XftFont *font; + XftFont *font; #else - XFontStruct *font; + XFontStruct *font; #endif - int display_enable; - double scale; /* device coordinates to pixels */ - struct ExposedExtents { - int x1, y1, x2, y2; - } extents; - DviState *state; - DviCharCache cache; + int display_enable; + double scale; /* device coordinates to pixels */ + struct ExposedExtents { + int x1, y1, x2, y2; + } extents; + DviState *state; + DviCharCache cache; } DviPart; -extern int DviGetAndPut(DviWidget, int *); +extern int DviGetAndPut(DviWidget, int *); #define DviGetIn(dw,cp)\ (dw->dvi.tmpFile ? (\ @@ -238,9 +238,9 @@ extern int DviGetAndPut(DviWidget, int *); */ typedef struct _DviRec { - CorePart core; - SimplePart simple; - DviPart dvi; + CorePart core; + SimplePart simple; + DviPart dvi; } DviRec; /* previously in draw.c */ @@ -269,41 +269,42 @@ VerticalGoto(DviWidget dw, int NewPosition) } /* draw.c */ -extern void FlushCharCache(DviWidget); -extern void SetGCForDraw(DviWidget); -extern void DrawLine(DviWidget, int, int); -extern void DrawCircle(DviWidget, int); -extern void DrawEllipse(DviWidget, int, int); -extern void DrawArc(DviWidget, int, int, int, int); -extern void DrawSpline(DviWidget, const char *, int); +extern void FlushCharCache(DviWidget); +extern void SetGCForDraw(DviWidget); +extern void DrawLine(DviWidget, int, int); +extern void DrawCircle(DviWidget, int); +extern void DrawEllipse(DviWidget, int, int); +extern void DrawArc(DviWidget, int, int, int, int); +extern void DrawSpline(DviWidget, const char *, int); /* font.c */ -extern void ParseFontMap(DviWidget); -extern void DestroyFontMap(DviFontMap *); -extern void SetFontPosition(DviWidget, int, const char *, const char *); +extern void ParseFontMap(DviWidget); +extern void DestroyFontMap(DviFontMap *); +extern void SetFontPosition(DviWidget, int, const char *, const char *); + #ifdef USE_XFT -extern XftFont * QueryFont(DviWidget, int, int); +extern XftFont *QueryFont(DviWidget, int, int); #else -extern XFontStruct * QueryFont(DviWidget, int, int); +extern XFontStruct *QueryFont(DviWidget, int, int); #endif -extern DviCharNameMap * QueryFontMap(DviWidget, int); +extern DviCharNameMap *QueryFontMap(DviWidget, int); /* lex.c */ -extern char * GetLine(DviWidget, char *, int); -extern char * GetWord(DviWidget, char *, int); -extern int GetNumber(DviWidget); +extern char *GetLine(DviWidget, char *, int); +extern char *GetWord(DviWidget, char *, int); +extern int GetNumber(DviWidget); /* page.c */ -extern void DestroyFileMap(DviFileMap *); -extern void ForgetPagePositions(DviWidget); -extern void RememberPagePosition(DviWidget, int); -extern long SearchPagePosition(DviWidget, int); -extern void FileSeek(DviWidget, long); +extern void DestroyFileMap(DviFileMap *); +extern void ForgetPagePositions(DviWidget); +extern void RememberPagePosition(DviWidget, int); +extern long SearchPagePosition(DviWidget, int); +extern void FileSeek(DviWidget, long); /* parse.c */ -extern int ParseInput(DviWidget); +extern int ParseInput(DviWidget); /* Dvi.c */ -extern void SetDeviceResolution(DviWidget, int); +extern void SetDeviceResolution(DviWidget, int); -#endif /* _XtDviP_h */ +#endif /* _XtDviP_h */ @@ -32,11 +32,11 @@ #define XtCPadding "Padding" #define XtCSelection "Selection" -typedef struct _MenuRec *MenuWidget; /* completely defined in MenuPrivate.h */ -typedef struct _MenuClassRec *MenuWidgetClass; /* completely defined in MenuPrivate.h */ +typedef struct _MenuRec *MenuWidget; /* completely defined in MenuPrivate.h */ +typedef struct _MenuClassRec *MenuWidgetClass; /* completely defined in MenuPrivate.h */ extern WidgetClass menuWidgetClass; -extern Widget XawMenuCreate (); +extern Widget XawMenuCreate(); #endif /* _XtMenu_h */ /* DON'T ADD STUFF AFTER THIS #endif */ diff --git a/XFontName.c b/XFontName.c index 3a70f2a..dc4c1fa 100644 --- a/XFontName.c +++ b/XFontName.c @@ -4,134 +4,127 @@ * build/parse X Font name strings */ -# include <X11/Xlib.h> -# include <X11/Intrinsic.h> -# include "XFontName.h" +#include <X11/Xlib.h> +#include <X11/Intrinsic.h> +#include "XFontName.h" #include <ctype.h> static char * -extractStringField ( - char *name, - char *buffer, - int size, - unsigned int *attrp, - unsigned int bit) +extractStringField(char *name, char *buffer, int size, + unsigned int *attrp, unsigned int bit) { - char *buf = buffer; - - if (!*name) - return NULL; - while (*name && *name != '-' && size > 0) { - *buf++ = *name++; - --size; - } - if (size <= 0) - return NULL; - *buf = '\0'; - if (buffer[0] != '*' || buffer[1] != '\0') - *attrp |= bit; - if (*name == '-') - return name+1; - return name; + char *buf = buffer; + + if (!*name) + return NULL; + while (*name && *name != '-' && size > 0) { + *buf++ = *name++; + --size; + } + if (size <= 0) + return NULL; + *buf = '\0'; + if (buffer[0] != '*' || buffer[1] != '\0') + *attrp |= bit; + if (*name == '-') + return name + 1; + return name; } static char * -extractUnsignedField ( - char *name, - unsigned int *result, - unsigned int *attrp, - unsigned int bit) +extractUnsignedField(char *name, unsigned int *result, + unsigned int *attrp, unsigned int bit) { - char buf[256]; - unsigned int i; - - name = extractStringField (name, buf, sizeof (buf), attrp, bit); - if (!name) - return NULL; - if (!(*attrp & bit)) - return name; - i = 0; - for (char *c = buf; *c; c++) { - if (!isdigit (*c)) - return NULL; - i = i * 10 + (*c - '0'); - } - *result = i; - return name; + char buf[256]; + unsigned int i; + + name = extractStringField(name, buf, sizeof(buf), attrp, bit); + if (!name) + return NULL; + if (!(*attrp & bit)) + return name; + i = 0; + for (char *c = buf; *c; c++) { + if (!isdigit(*c)) + return NULL; + i = i * 10 + (*c - '0'); + } + *result = i; + return name; } Bool -XParseFontName (XFontNameString fontNameString, XFontName *fontName, - unsigned int *fontNameAttributes) +XParseFontName(XFontNameString fontNameString, XFontName *fontName, + unsigned int *fontNameAttributes) { - char *name = fontNameString; - XFontName temp; - unsigned int attributes = 0; + char *name = fontNameString; + XFontName temp; + unsigned int attributes = 0; -#define GetString(field,bit)\ +#define GetString(field,bit) do { \ if (!(name = extractStringField \ (name, temp.field, sizeof (temp.field),\ &attributes, bit))) \ - return False; + return False; \ + } while(0) -#define GetUnsigned(field,bit)\ +#define GetUnsigned(field,bit) do { \ if (!(name = extractUnsignedField \ (name, &temp.field, \ &attributes, bit))) \ - return False; - - GetString (Registry, FontNameRegistry) - GetString (Foundry, FontNameFoundry) - GetString (FamilyName, FontNameFamilyName) - GetString (WeightName, FontNameWeightName) - GetString (Slant, FontNameSlant) - GetString (SetwidthName, FontNameSetwidthName) - GetString (AddStyleName, FontNameAddStyleName) - GetUnsigned (PixelSize, FontNamePixelSize) - GetUnsigned (PointSize, FontNamePointSize) - GetUnsigned (ResolutionX, FontNameResolutionX) - GetUnsigned (ResolutionY, FontNameResolutionY) - GetString (Spacing, FontNameSpacing) - GetUnsigned (AverageWidth, FontNameAverageWidth) - GetString (CharSetRegistry, FontNameCharSetRegistry) - if (!*name) { - temp.CharSetEncoding[0] = '\0'; - attributes |= FontNameCharSetEncoding; - } else { - GetString (CharSetEncoding, FontNameCharSetEncoding) - } - *fontName = temp; - *fontNameAttributes = attributes; - return True; + return False; \ + } while(0) + + GetString(Registry, FontNameRegistry); + GetString(Foundry, FontNameFoundry); + GetString(FamilyName, FontNameFamilyName); + GetString(WeightName, FontNameWeightName); + GetString(Slant, FontNameSlant); + GetString(SetwidthName, FontNameSetwidthName); + GetString(AddStyleName, FontNameAddStyleName); + GetUnsigned(PixelSize, FontNamePixelSize); + GetUnsigned(PointSize, FontNamePointSize); + GetUnsigned(ResolutionX, FontNameResolutionX); + GetUnsigned(ResolutionY, FontNameResolutionY); + GetString(Spacing, FontNameSpacing); + GetUnsigned(AverageWidth, FontNameAverageWidth); + GetString(CharSetRegistry, FontNameCharSetRegistry); + if (!*name) { + temp.CharSetEncoding[0] = '\0'; + attributes |= FontNameCharSetEncoding; + } + else { + GetString(CharSetEncoding, FontNameCharSetEncoding); + } + *fontName = temp; + *fontNameAttributes = attributes; + return True; } static char * -utoa ( - unsigned int u, - char *s, - int size) +utoa(unsigned int u, char *s, int size) { - char *t; - - t = s + size; - *--t = '\0'; - do - *--t = (u % 10) + '0'; - while (u /= 10); - return t; + char *t; + + t = s + size; + *--t = '\0'; + do + *--t = (u % 10) + '0'; + while (u /= 10); + return t; } Bool -XFormatFontName (XFontName *fontName, unsigned int fontNameAttributes, - XFontNameString fontNameString) +XFormatFontName(XFontName *fontName, unsigned int fontNameAttributes, + XFontNameString fontNameString) { - XFontNameString tmp; - char *name = tmp; - const char *f; - int left = sizeof (tmp) - 1; - char number[32]; + XFontNameString tmp; + char *name = tmp; + const char *f; + int left = sizeof(tmp) - 1; + char number[32]; -#define PutString(field, bit)\ +#define PutString(field, bit) do { \ f = (fontNameAttributes & bit) ? \ fontName->field \ : "*"; \ @@ -139,51 +132,55 @@ XFormatFontName (XFontName *fontName, unsigned int fontNameAttributes, return False; \ while (*f) \ if ((*name++ = *f++) == '-') \ - return False; -#define PutHyphen()\ + return False; \ + } while(0) + +#define PutHyphen() do { \ if (--left < 0) \ return False; \ - *name++ = '-'; + *name++ = '-'; \ + } while(0) -#define PutUnsigned(field, bit) \ +#define PutUnsigned(field, bit) do { \ f = (fontNameAttributes & bit) ? \ utoa (fontName->field, number, sizeof (number)) \ : "*"; \ if ((left -= strlen (f)) < 0) \ return False; \ while (*f) \ - *name++ = *f++; - - PutString (Registry, FontNameRegistry) - PutHyphen (); - PutString (Foundry, FontNameFoundry) - PutHyphen (); - PutString (FamilyName, FontNameFamilyName) - PutHyphen (); - PutString (WeightName, FontNameWeightName) - PutHyphen (); - PutString (Slant, FontNameSlant) - PutHyphen (); - PutString (SetwidthName, FontNameSetwidthName) - PutHyphen (); - PutString (AddStyleName, FontNameAddStyleName) - PutHyphen (); - PutUnsigned (PixelSize, FontNamePixelSize) - PutHyphen (); - PutUnsigned (PointSize, FontNamePointSize) - PutHyphen (); - PutUnsigned (ResolutionX, FontNameResolutionX) - PutHyphen (); - PutUnsigned (ResolutionY, FontNameResolutionY) - PutHyphen (); - PutString (Spacing, FontNameSpacing) - PutHyphen (); - PutUnsigned (AverageWidth, FontNameAverageWidth) - PutHyphen (); - PutString (CharSetRegistry, FontNameCharSetRegistry) - PutHyphen (); - PutString (CharSetEncoding, FontNameCharSetEncoding) - *name = '\0'; - strcpy (fontNameString, tmp); - return True; + *name++ = *f++; \ + } while(0) + + PutString(Registry, FontNameRegistry); + PutHyphen(); + PutString(Foundry, FontNameFoundry); + PutHyphen(); + PutString(FamilyName, FontNameFamilyName); + PutHyphen(); + PutString(WeightName, FontNameWeightName); + PutHyphen(); + PutString(Slant, FontNameSlant); + PutHyphen(); + PutString(SetwidthName, FontNameSetwidthName); + PutHyphen(); + PutString(AddStyleName, FontNameAddStyleName); + PutHyphen(); + PutUnsigned(PixelSize, FontNamePixelSize); + PutHyphen(); + PutUnsigned(PointSize, FontNamePointSize); + PutHyphen(); + PutUnsigned(ResolutionX, FontNameResolutionX); + PutHyphen(); + PutUnsigned(ResolutionY, FontNameResolutionY); + PutHyphen(); + PutString(Spacing, FontNameSpacing); + PutHyphen(); + PutUnsigned(AverageWidth, FontNameAverageWidth); + PutHyphen(); + PutString(CharSetRegistry, FontNameCharSetRegistry); + PutHyphen(); + PutString(CharSetEncoding, FontNameCharSetEncoding); + *name = '\0'; + strcpy(fontNameString, tmp); + return True; } @@ -54,72 +54,70 @@ in this Software without prior written authorization from the X Consortium. /* the following are for use in the spline approximation algorithm */ -typedef struct Point { - double x; - double y; - struct Point *next; +typedef struct Point { + double x; + double y; + struct Point *next; } Point; -#define ITERATIONS 10 /* iterations to approximate spline */ +#define ITERATIONS 10 /* iterations to approximate spline */ -#define midx(p,q) ((p->x + q->x) / 2) /* mid x point on pq */ -#define midy(p,q) ((p->y + q->y) / 2) /* mid y point on pq */ +#define midx(p,q) ((p->x + q->x) / 2) /* mid x point on pq */ +#define midy(p,q) ((p->y + q->y) / 2) /* mid y point on pq */ #define length(p,q) sqrt(((q->x - p->x)*(q->x - p->x)) \ + ((q->y - p->y)*(q->y - p->y))) /* length of pq */ -static Point *spline = (Point *)NULL; /* head of spline linked list */ +static Point *spline = (Point *) NULL; /* head of spline linked list */ -static void ApproxSpline(int n); -static void DeletePoint(Point *p); -static void DrawSplineSegments(DviWidget dw); -static int GetSpline(const char *s); -static void InsertPoint(Point *p, Point *q); -static void LineApprox(Point *p1, Point *p2, Point *p3); -static Point * MakePoint(double x, double y); +static void ApproxSpline(int n); +static void DeletePoint(Point *p); +static void DrawSplineSegments(DviWidget dw); +static int GetSpline(const char *s); +static void InsertPoint(Point *p, Point *q); +static void LineApprox(Point *p1, Point *p2, Point *p3); +static Point * MakePoint(double x, double y); #ifdef USE_XFT static void -DrawText (DviWidget dw) +DrawText(DviWidget dw) { XftFont *font; font = dw->dvi.cache.font; - for (int i = 0; i <= dw->dvi.cache.index; i++) - { - if (dw->dvi.cache.cache[i].font) - font = dw->dvi.cache.cache[i].font; - XftDrawString8 (dw->dvi.draw, &dw->dvi.black, - font, - dw->dvi.cache.cache[i].x, - dw->dvi.cache.start_y, - (unsigned char *) dw->dvi.cache.cache[i].chars, - dw->dvi.cache.cache[i].nchars); + for (int i = 0; i <= dw->dvi.cache.index; i++) { + if (dw->dvi.cache.cache[i].font) + font = dw->dvi.cache.cache[i].font; + XftDrawString8(dw->dvi.draw, &dw->dvi.black, + font, + dw->dvi.cache.cache[i].x, + dw->dvi.cache.start_y, + (unsigned char *) dw->dvi.cache.cache[i].chars, + dw->dvi.cache.cache[i].nchars); } } #endif void -FlushCharCache (DviWidget dw) +FlushCharCache(DviWidget dw) { - int xx, yx; + int xx, yx; xx = ToX(dw, dw->dvi.state->x); yx = ToX(dw, dw->dvi.state->y); - if (dw->dvi.cache.char_index != 0) - { + if (dw->dvi.cache.char_index != 0) { #ifdef USE_XFT - DrawText (dw); + DrawText(dw); #else - XDrawText (XtDisplay (dw), XtWindow (dw), dw->dvi.normal_GC, - dw->dvi.cache.start_x, dw->dvi.cache.start_y, - dw->dvi.cache.cache, dw->dvi.cache.index + 1); + XDrawText(XtDisplay(dw), XtWindow(dw), dw->dvi.normal_GC, + dw->dvi.cache.start_x, dw->dvi.cache.start_y, + dw->dvi.cache.cache, dw->dvi.cache.index + 1); #endif } dw->dvi.cache.index = 0; dw->dvi.cache.max = DVI_TEXT_CACHE_SIZE; if (dw->dvi.noPolyText) - dw->dvi.cache.max = 1; + dw->dvi.cache.max = 1; dw->dvi.cache.char_index = 0; dw->dvi.cache.cache[0].nchars = 0; dw->dvi.cache.start_x = dw->dvi.cache.x = xx; @@ -127,66 +125,65 @@ FlushCharCache (DviWidget dw) } void -SetGCForDraw (DviWidget dw) +SetGCForDraw(DviWidget dw) { if (dw->dvi.state->line_style != dw->dvi.line_style || - dw->dvi.state->line_width != dw->dvi.line_width) - { - int lw = ToX(dw, dw->dvi.state->line_width); - if (lw <= 1) - lw = 0; - XSetLineAttributes (XtDisplay (dw), dw->dvi.normal_GC, - lw, LineSolid, CapButt, JoinMiter); - dw->dvi.line_style = dw->dvi.state->line_style; - dw->dvi.line_width = dw->dvi.state->line_width; + dw->dvi.state->line_width != dw->dvi.line_width) { + int lw = ToX(dw, dw->dvi.state->line_width); + + if (lw <= 1) + lw = 0; + XSetLineAttributes(XtDisplay(dw), dw->dvi.normal_GC, + lw, LineSolid, CapButt, JoinMiter); + dw->dvi.line_style = dw->dvi.state->line_style; + dw->dvi.line_width = dw->dvi.state->line_width; } } void -DrawLine (DviWidget dw, int x, int y) +DrawLine(DviWidget dw, int x, int y) { if (dw->dvi.display_enable) - XDrawLine (XtDisplay (dw), XtWindow (dw), dw->dvi.normal_GC, - ToX(dw, dw->dvi.state->x), ToX(dw, dw->dvi.state->y), - ToX(dw, dw->dvi.state->x + x), ToX(dw,dw->dvi.state->y + y)); + XDrawLine(XtDisplay(dw), XtWindow(dw), dw->dvi.normal_GC, + ToX(dw, dw->dvi.state->x), ToX(dw, dw->dvi.state->y), + ToX(dw, dw->dvi.state->x + x), ToX(dw, dw->dvi.state->y + y)); dw->dvi.state->x += x; dw->dvi.state->y += y; } void -DrawCircle (DviWidget dw, int diameter) +DrawCircle(DviWidget dw, int diameter) { if (dw->dvi.display_enable) - XDrawArc (XtDisplay (dw), XtWindow (dw), dw->dvi.normal_GC, - ToX(dw, dw->dvi.state->x), - ToX(dw, dw->dvi.state->y - (diameter / 2)), - ToX(dw, diameter), ToX(dw, diameter), 0, 360 * 64); + XDrawArc(XtDisplay(dw), XtWindow(dw), dw->dvi.normal_GC, + ToX(dw, dw->dvi.state->x), + ToX(dw, dw->dvi.state->y - (diameter / 2)), + ToX(dw, diameter), ToX(dw, diameter), 0, 360 * 64); dw->dvi.state->x += diameter; } void -DrawEllipse (DviWidget dw, int a, int b) +DrawEllipse(DviWidget dw, int a, int b) { if (dw->dvi.display_enable) - XDrawArc (XtDisplay (dw), XtWindow (dw), dw->dvi.normal_GC, - ToX(dw, dw->dvi.state->x), ToX(dw, dw->dvi.state->y - (b / 2)), - ToX(dw,a), ToX(dw,b), 0, 360 * 64); + XDrawArc(XtDisplay(dw), XtWindow(dw), dw->dvi.normal_GC, + ToX(dw, dw->dvi.state->x), ToX(dw, dw->dvi.state->y - (b / 2)), + ToX(dw, a), ToX(dw, b), 0, 360 * 64); dw->dvi.state->x += a; } - /* Convert angle in degrees to 64ths of a degree */ static int ConvertAngle(int theta) { - return(theta * 64); + return (theta * 64); } void -DrawArc (DviWidget dw, int x0, int y0, int x1, int y1) +DrawArc(DviWidget dw, int x0, int y0, int x1, int y1) { - int xc, yc, x2, y2; + int xc, yc, x2, y2; /* centre */ xc = dw->dvi.state->x + x0; @@ -200,56 +197,55 @@ DrawArc (DviWidget dw, int x0, int y0, int x1, int y1) dw->dvi.state->y = y2; if (dw->dvi.display_enable) { - int angle1, angle2; - - /* radius */ - int r = (int)sqrt((float) x1 * x1 + (float) y1 * y1); - - /* start and finish angles */ - if (x0 == 0) { - if (y0 >= 0) - angle1 = 90; - else - angle1 = 270; - } - else { - angle1 = (int) (atan((double)(y0) / (double)(x0)) * 180 / M_PI); - if (x0 > 0) - angle1 = 180 - angle1; - else - angle1 = -angle1; - } - - if (x1 == 0) { - if (y1 <= 0) - angle2 = 90; - else - angle2 = 270; - } - else { - angle2 = (int) (atan((double)(y1) / (double)(x1)) * 180 / M_PI); - if (x1 < 0) - angle2 = 180 - angle2; - else - angle2 = -angle2; - } - - if (angle1 < 0) - angle1 += 360; - if (angle2 < 0) - angle2 += 360; - - if (angle2 < angle1) - angle1 -= 360; - angle2 = angle2 - angle1; - - angle1 = ConvertAngle(angle1); - angle2 = ConvertAngle(angle2); - - XDrawArc (XtDisplay (dw), XtWindow (dw), dw->dvi.normal_GC, - ToX(dw, xc - r), ToX(dw, yc - r), - ToX(dw, 2 * r), ToX(dw, 2 * r), - angle1, angle2); + int angle1, angle2; + + /* radius */ + int r = (int) sqrt((float) x1 * x1 + (float) y1 * y1); + + /* start and finish angles */ + if (x0 == 0) { + if (y0 >= 0) + angle1 = 90; + else + angle1 = 270; + } + else { + angle1 = (int) (atan((double) (y0) / (double) (x0)) * 180 / M_PI); + if (x0 > 0) + angle1 = 180 - angle1; + else + angle1 = -angle1; + } + + if (x1 == 0) { + if (y1 <= 0) + angle2 = 90; + else + angle2 = 270; + } + else { + angle2 = (int) (atan((double) (y1) / (double) (x1)) * 180 / M_PI); + if (x1 < 0) + angle2 = 180 - angle2; + else + angle2 = -angle2; + } + + if (angle1 < 0) + angle1 += 360; + if (angle2 < 0) + angle2 += 360; + + if (angle2 < angle1) + angle1 -= 360; + angle2 = angle2 - angle1; + + angle1 = ConvertAngle(angle1); + angle2 = ConvertAngle(angle2); + + XDrawArc(XtDisplay(dw), XtWindow(dw), dw->dvi.normal_GC, + ToX(dw, xc - r), ToX(dw, yc - r), + ToX(dw, 2 * r), ToX(dw, 2 * r), angle1, angle2); } } @@ -259,29 +255,28 @@ static const char * getstr(const char *p, char *temp) { while (*p == ' ' || *p == '\t' || *p == '\n') - p++; + p++; if (*p == '\0') { - temp[0] = 0; - return((char *)NULL); + temp[0] = 0; + return ((char *) NULL); } while (*p != ' ' && *p != '\t' && *p != '\n' && *p != '\0') - *temp++ = *p++; + *temp++ = *p++; *temp = '\0'; - return(p); + return (p); } - /* Draw a spline by approximating with short lines. */ /*ARGSUSED*/ void -DrawSpline (DviWidget dw, const char *s, int len) +DrawSpline(DviWidget dw, const char *s, int len) { - int n; + int n; /* get coordinate pairs into spline linked list */ if ((n = GetSpline(s)) <= 0) - return; + return; ApproxSpline(n); @@ -295,38 +290,38 @@ DrawSpline (DviWidget dw, const char *s, int len) static int GetSpline(const char *s) { - double x, y; - int n = 0; - Point *pt; - const char *p = s; - char d[10]; + double x, y; + int n = 0; + Point *pt; + const char *p = s; + char d[10]; if (!*p) - return(n); + return (n); pt = spline = MakePoint(0.0, 0.0); n = 1; x = y = 0.0; p = s; while (p && *p) { - double x1, y1; - - if ((p = getstr(p, d)) == (const char *)NULL) - break; - x1 = x + atof(d); - if ((p = getstr(p, d)) == (const char *)NULL) - break; - y1 = y + atof(d); - pt->next = MakePoint(x1, y1); - pt = pt->next; - x = pt->x; - y = pt->y; - n++; + double x1, y1; + + if ((p = getstr(p, d)) == (const char *) NULL) + break; + x1 = x + atof(d); + if ((p = getstr(p, d)) == (const char *) NULL) + break; + y1 = y + atof(d); + pt->next = MakePoint(x1, y1); + pt = pt->next; + x = pt->x; + y = pt->y; + n++; } /* number of pairs of points */ - return(n); + return (n); } /* Approximate a spline by lines generated by iterations of the */ @@ -335,49 +330,48 @@ GetSpline(const char *s) static void ApproxSpline(int n) { - int mid; - Point *p1, *p2, *p3, *p; + int mid; + Point *p1, *p2, *p3, *p; if (n < 3) - return; + return; /* number of mid-points to calculate */ mid = n - 3; /* remember original points are stored as an array of n points */ - /* so I can index it directly to calculate mid-points only. */ + /* so I can index it directly to calculate mid-points only. */ if (mid > 0) { - int j; - - p = spline->next; - j = 1; - while (j < n-2) { - p1 = p; - p = p->next; - p2 = p; - InsertPoint(p1, MakePoint(midx(p1, p2), midy(p1, p2))); - j++; - } + int j; + + p = spline->next; + j = 1; + while (j < n - 2) { + p1 = p; + p = p->next; + p2 = p; + InsertPoint(p1, MakePoint(midx(p1, p2), midy(p1, p2))); + j++; + } } - /* Now approximate curve by line segments. */ + /* Now approximate curve by line segments. */ /* There *should* be the correct number of points now! */ p = spline; - while (p != (Point *)NULL) { - p1 = p; - if ((p = p->next) == (Point *)NULL) - break; - p2 = p; - if ((p = p->next) == (Point *)NULL) - break; - p3 = p; /* This point becomes first point of next curve */ - - LineApprox(p1, p2, p3); + while (p != (Point *) NULL) { + p1 = p; + if ((p = p->next) == (Point *) NULL) + break; + p2 = p; + if ((p = p->next) == (Point *) NULL) + break; + p3 = p; /* This point becomes first point of next curve */ + + LineApprox(p1, p2, p3); } } - /* p1, p2, and p3 are initially 3 *consecutive* points on the curve. */ /* For each adjacent pair of points find the mid-point, insert this */ /* in the linked list, delete the first of the two used (unless it */ @@ -387,18 +381,18 @@ ApproxSpline(int n) static void LineApprox(Point *p1, Point *p2, Point *p3) { - int reps = ITERATIONS; + int reps = ITERATIONS; while (reps) { - for (Point *p = p1; p != (Point *)NULL && p != p3; ) { - Point *p4 = MakePoint( midx(p,p->next), midy(p,p->next) ); - - InsertPoint(p, p4); - if (p != p1) - DeletePoint(p); - p = p4->next; /* skip inserted point! */ - } - reps--; + for (Point *p = p1; p != (Point *) NULL && p != p3;) { + Point *p4 = MakePoint(midx(p, p->next), midy(p, p->next)); + + InsertPoint(p, p4); + if (p != p1) + DeletePoint(p); + p = p4->next; /* skip inserted point! */ + } + reps--; } } @@ -410,9 +404,9 @@ LineApprox(Point *p1, Point *p2, Point *p3) static void DrawSplineSegments(DviWidget dw) { - Point *p; - double x1, y1; - double xpos, ypos; + Point *p; + double x1, y1; + double xpos, ypos; p = spline; @@ -423,41 +417,41 @@ DrawSplineSegments(DviWidget dw) x1 = y1 = 0.0; - while (p != (Point *)NULL) { - int dx = p->x - x1 + 0.5; - int dy = p->y - y1 + 0.5; - DrawLine (dw, dx, dy); + while (p != (Point *) NULL) { + int dx = p->x - x1 + 0.5; + int dy = p->y - y1 + 0.5; + + DrawLine(dw, dx, dy); - x1 = p->x; - y1 = p->y; - dw->dvi.state->x = xpos + x1; - dw->dvi.state->y = ypos + y1; + x1 = p->x; + y1 = p->y; + dw->dvi.state->x = xpos + x1; + dw->dvi.state->y = ypos + y1; - Point *q = p; - p = p->next; - XtFree((char *)q); + Point *q = p; + + p = p->next; + XtFree((char *) q); } - spline = (Point *)NULL; + spline = (Point *) NULL; } - /* Malloc memory for a Point, and initialise the elements to x, y, NULL */ /* Return a pointer to the new Point. */ static Point * MakePoint(double x, double y) { - Point *p; + Point *p; - p = (Point *) XtMalloc (sizeof (Point)); + p = (Point *) XtMalloc(sizeof(Point)); p->x = x; p->y = y; - p->next = (Point *)NULL; + p->next = (Point *) NULL; - return(p); + return (p); } - /* Insert point q in linked list after point p. */ static void @@ -475,11 +469,11 @@ InsertPoint(Point *p, Point *q) static void DeletePoint(Point *p) { - Point *tmp; + Point *tmp; tmp = p->next; p->x = p->next->x; p->y = p->next->y; p->next = p->next->next; - XtFree((char *)tmp); + XtFree((char *) tmp); } @@ -14,164 +14,161 @@ #include "XFontName.h" static char * -savestr (const char *s) +savestr(const char *s) { - char *n; - - if (!s) - return NULL; - n = XtMalloc (strlen (s) + 1); - if (n) - strcpy (n, s); - return n; + char *n; + + if (!s) + return NULL; + n = XtMalloc(strlen(s) + 1); + if (n) + strcpy(n, s); + return n; } static DviFontList * -LookupFontByPosition (DviWidget dw, int position) +LookupFontByPosition(DviWidget dw, int position) { - DviFontList *f; + DviFontList *f; - for (f = dw->dvi.fonts; f; f=f->next) - if (f->dvi_number == position) - break; - return f; + for (f = dw->dvi.fonts; f; f = f->next) { + if (f->dvi_number == position) + break; + } + return f; } static DviFontSizeList * -LookupFontSizeBySize (DviWidget dw, DviFontList *f, int size) +LookupFontSizeBySize(DviWidget dw, DviFontList *f, int size) { - DviFontSizeList *best = NULL; - - if (f->scalable) - { - char fontNameString[2048]; - XFontName fontName; - unsigned int fontNameAttributes; - - for (best = f->sizes; best; best = best->next) - if (best->size == size) - return best; - best = (DviFontSizeList *) XtMalloc (sizeof *best); - best->next = f->sizes; - best->size = size; - XParseFontName (f->x_name, &fontName, &fontNameAttributes); - fontNameAttributes &= ~(FontNamePixelSize|FontNameAverageWidth); - fontNameAttributes |= FontNameResolutionX; - fontNameAttributes |= FontNameResolutionY; - fontNameAttributes |= FontNamePointSize; - fontName.ResolutionX = dw->dvi.screen_resolution; - fontName.ResolutionY = dw->dvi.screen_resolution; - fontName.PointSize = size * 10 / dw->dvi.size_scale; - XFormatFontName (&fontName, fontNameAttributes, fontNameString); - best->x_name = savestr (fontNameString); + DviFontSizeList *best = NULL; + + if (f->scalable) { + char fontNameString[2048]; + XFontName fontName; + unsigned int fontNameAttributes; + + for (best = f->sizes; best; best = best->next) { + if (best->size == size) + return best; + } + best = (DviFontSizeList *) XtMalloc(sizeof *best); + best->next = f->sizes; + best->size = size; + XParseFontName(f->x_name, &fontName, &fontNameAttributes); + fontNameAttributes &= ~(FontNamePixelSize | FontNameAverageWidth); + fontNameAttributes |= FontNameResolutionX; + fontNameAttributes |= FontNameResolutionY; + fontNameAttributes |= FontNamePointSize; + fontName.ResolutionX = dw->dvi.screen_resolution; + fontName.ResolutionY = dw->dvi.screen_resolution; + fontName.PointSize = size * 10 / dw->dvi.size_scale; + XFormatFontName(&fontName, fontNameAttributes, fontNameString); + best->x_name = savestr(fontNameString); #ifdef USE_XFT - /* - * Force a match of a core font for adobe-fontspecific - * encodings; we don't have a scalable font in - * the right encoding - */ - best->core = False; - if (!strcmp (fontName.CharSetRegistry, "adobe") && - !strcmp (fontName.CharSetEncoding, "fontspecific")) - { - best->core = True; - } + /* + * Force a match of a core font for adobe-fontspecific + * encodings; we don't have a scalable font in + * the right encoding + */ + best->core = False; + if (!strcmp(fontName.CharSetRegistry, "adobe") && + !strcmp(fontName.CharSetEncoding, "fontspecific")) { + best->core = True; + } #endif - best->doesnt_exist = 0; - best->font = NULL; - f->sizes = best; + best->doesnt_exist = 0; + best->font = NULL; + f->sizes = best; } - else - { - int bestdist = 65536; - - for (DviFontSizeList *fs = f->sizes; fs; fs=fs->next) { - int dist = size - fs->size; - if (dist < 0) - dist = -dist * 16; - if (dist < bestdist) - { - best = fs; - bestdist = dist; - } - } + else { + int bestdist = 65536; + + for (DviFontSizeList * fs = f->sizes; fs; fs = fs->next) { + int dist = size - fs->size; + + if (dist < 0) + dist = -dist * 16; + if (dist < bestdist) { + best = fs; + bestdist = dist; + } + } } return best; } static char * -SkipFontNameElement (char *n) +SkipFontNameElement(char *n) { - while (*n != '-') - if (!*++n) - return NULL; - return n+1; + while (*n != '-') { + if (!*++n) + return NULL; + } + return n + 1; } -# define SizePosition 8 -# define EncodingPosition 13 +#define SizePosition 8 +#define EncodingPosition 13 #ifndef USE_XFT static int -ConvertFontNameToSize (char *n) +ConvertFontNameToSize(char *n) { - int i, size; - - for (i = 0; i < SizePosition; i++) { - n = SkipFontNameElement (n); - if (!n) - return -1; - } - size = atoi (n); - return size/10; + int i, size; + + for (i = 0; i < SizePosition; i++) { + n = SkipFontNameElement(n); + if (!n) + return -1; + } + size = atoi(n); + return size / 10; } #endif static char * -ConvertFontNameToEncoding (char *n) +ConvertFontNameToEncoding(char *n) { - for (int i = 0; i < EncodingPosition; i++) { - n = SkipFontNameElement (n); - if (!n) - return NULL; - } - return n; + for (int i = 0; i < EncodingPosition; i++) { + n = SkipFontNameElement(n); + if (!n) + return NULL; + } + return n; } static void -DisposeFontSizes (DviWidget dw, DviFontSizeList *fs) +DisposeFontSizes(DviWidget dw, DviFontSizeList *fs) { - DviFontSizeList *next; - - for (; fs; fs=next) { - next = fs->next; - if (fs->x_name) - XtFree (fs->x_name); - if (fs->font) - { + DviFontSizeList *next; + + for (; fs; fs = next) { + next = fs->next; + if (fs->x_name) + XtFree(fs->x_name); + if (fs->font) { #ifdef USE_XFT - XftFontClose (XtDisplay (dw), fs->font); + XftFontClose(XtDisplay(dw), fs->font); #else - XUnloadFont (XtDisplay (dw), fs->font->fid); - XFree ((char *)fs->font); + XUnloadFont(XtDisplay(dw), fs->font->fid); + XFree((char *) fs->font); #endif - } - XtFree ((char *) fs); + } + XtFree((char *) fs); } } void -ResetFonts (DviWidget dw) +ResetFonts(DviWidget dw) { - for (DviFontList *f = dw->dvi.fonts; f; f = f->next) - { - if (f->initialized) - { - DisposeFontSizes (dw, f->sizes); - f->sizes = NULL; - f->initialized = FALSE; - f->scalable = FALSE; - } + for (DviFontList *f = dw->dvi.fonts; f; f = f->next) { + if (f->initialized) { + DisposeFontSizes(dw, f->sizes); + f->sizes = NULL; + f->initialized = FALSE; + f->scalable = FALSE; + } } /* * force requery of fonts @@ -183,14 +180,14 @@ ResetFonts (DviWidget dw) } static DviFontSizeList * -InstallFontSizes (DviWidget dw, char *x_name, Boolean *scalablep) +InstallFontSizes(DviWidget dw, char *x_name, Boolean *scalablep) { #ifndef USE_XFT - char fontNameString[2048]; - char **fonts; - int count; - XFontName fontName; - unsigned int fontNameAttributes; + char fontNameString[2048]; + char **fonts; + int count; + XFontName fontName; + unsigned int fontNameAttributes; #endif DviFontSizeList *sizes; @@ -199,75 +196,79 @@ InstallFontSizes (DviWidget dw, char *x_name, Boolean *scalablep) *scalablep = TRUE; #else *scalablep = FALSE; - if (!XParseFontName (x_name, &fontName, &fontNameAttributes)) - return NULL; - - fontNameAttributes &= ~(FontNamePixelSize|FontNamePointSize); + if (!XParseFontName(x_name, &fontName, &fontNameAttributes)) + return NULL; + + fontNameAttributes &= ~(FontNamePixelSize | FontNamePointSize); fontNameAttributes |= FontNameResolutionX; fontNameAttributes |= FontNameResolutionY; fontName.ResolutionX = dw->dvi.screen_resolution; fontName.ResolutionY = dw->dvi.screen_resolution; - XFormatFontName (&fontName, fontNameAttributes, fontNameString); - fonts = XListFonts (XtDisplay (dw), fontNameString, 10000000, &count); + XFormatFontName(&fontName, fontNameAttributes, fontNameString); + fonts = XListFonts(XtDisplay(dw), fontNameString, 10000000, &count); for (int i = 0; i < count; i++) { - int size = ConvertFontNameToSize (fonts[i]); - - if (size == 0) - { - DisposeFontSizes (dw, sizes); - *scalablep = TRUE; - sizes = NULL; - break; - } - if (size != -1) { - DviFontSizeList *new = (DviFontSizeList *) XtMalloc (sizeof *new); - new->next = sizes; - new->size = size; - new->x_name = savestr (fonts[i]); - new->doesnt_exist = 0; - new->font = NULL; - sizes = new; - } + int size = ConvertFontNameToSize(fonts[i]); + + if (size == 0) { + DisposeFontSizes(dw, sizes); + *scalablep = TRUE; + sizes = NULL; + break; + } + if (size != -1) { + DviFontSizeList *new = (DviFontSizeList *) XtMalloc(sizeof *new); + + new->next = sizes; + new->size = size; + new->x_name = savestr(fonts[i]); + new->doesnt_exist = 0; + new->font = NULL; + sizes = new; + } } - XFreeFontNames (fonts); + XFreeFontNames(fonts); #endif return sizes; } static DviFontList * -InstallFont (DviWidget dw, int position, const char *dvi_name, const char *x_name) +InstallFont(DviWidget dw, int position, const char *dvi_name, + const char *x_name) { - DviFontList *f; + DviFontList *f; - f = LookupFontByPosition (dw, position); + f = LookupFontByPosition(dw, position); if (f) { - /* - * ignore gratuitous font loading - */ - if (!strcmp (f->dvi_name, dvi_name) && !strcmp (f->x_name, x_name)) - return f; - - DisposeFontSizes (dw, f->sizes); - if (f->dvi_name) - XtFree (f->dvi_name); - if (f->x_name) - XtFree (f->x_name); - } else { - f = (DviFontList *) XtMalloc (sizeof (*f)); - f->next = dw->dvi.fonts; - dw->dvi.fonts = f; + /* + * ignore gratuitous font loading + */ + if (!strcmp(f->dvi_name, dvi_name) && !strcmp(f->x_name, x_name)) + return f; + + DisposeFontSizes(dw, f->sizes); + if (f->dvi_name) + XtFree(f->dvi_name); + if (f->x_name) + XtFree(f->x_name); + } + else { + f = (DviFontList *) XtMalloc(sizeof(*f)); + f->next = dw->dvi.fonts; + dw->dvi.fonts = f; } f->initialized = FALSE; - f->dvi_name = savestr (dvi_name); - f->x_name = savestr (x_name); + f->dvi_name = savestr(dvi_name); + f->x_name = savestr(x_name); f->dvi_number = position; f->sizes = NULL; f->scalable = FALSE; if (f->x_name) { - const char *encoding = ConvertFontNameToEncoding (f->x_name); - f->char_map = DviFindMap (encoding); - } else - f->char_map = NULL; + const char *encoding = ConvertFontNameToEncoding(f->x_name); + + f->char_map = DviFindMap(encoding); + } + else + f->char_map = NULL; /* * force requery of fonts */ @@ -279,83 +280,82 @@ InstallFont (DviWidget dw, int position, const char *dvi_name, const char *x_nam } static const char * -MapDviNameToXName (DviWidget dw, const char *dvi_name) +MapDviNameToXName(DviWidget dw, const char *dvi_name) { - DviFontMap *fm; - - for (fm = dw->dvi.font_map; fm; fm=fm->next) - if (!strcmp (fm->dvi_name, dvi_name)) - return fm->x_name; + DviFontMap *fm; + + for (fm = dw->dvi.font_map; fm; fm = fm->next) + if (!strcmp(fm->dvi_name, dvi_name)) + return fm->x_name; ++dvi_name; - for (fm = dw->dvi.font_map; fm; fm=fm->next) - if (!strcmp (fm->dvi_name, "R")) - return fm->x_name; + for (fm = dw->dvi.font_map; fm; fm = fm->next) + if (!strcmp(fm->dvi_name, "R")) + return fm->x_name; if (dw->dvi.font_map->x_name) - return dw->dvi.font_map->x_name; + return dw->dvi.font_map->x_name; return "-*-*-*-*-*-*-*-*-*-*-*-*-iso8859-1"; } - void -ParseFontMap (DviWidget dw) +ParseFontMap(DviWidget dw) { - char *m; - DviFontMap *fm; + char *m; + DviFontMap *fm; if (dw->dvi.font_map) - DestroyFontMap (dw->dvi.font_map); + DestroyFontMap(dw->dvi.font_map); fm = NULL; m = dw->dvi.font_map_string; while (*m) { - char dvi_name[1024]; - char x_name[2048]; - - char *s = m; - while (*m && !isspace (*m)) - ++m; - strncpy (dvi_name, s, m-s); - dvi_name[m-s] = '\0'; - while (isspace (*m)) - ++m; - s = m; - while (*m && *m != '\n') - ++m; - strncpy (x_name, s, m-s); - x_name[m-s] = '\0'; - - DviFontMap *new = (DviFontMap *) XtMalloc (sizeof *new); - new->x_name = savestr (x_name); - new->dvi_name = savestr (dvi_name); - new->next = fm; - fm = new; - ++m; + char dvi_name[1024]; + char x_name[2048]; + char *s = m; + + while (*m && !isspace(*m)) + ++m; + strncpy(dvi_name, s, m - s); + dvi_name[m - s] = '\0'; + while (isspace(*m)) + ++m; + s = m; + while (*m && *m != '\n') + ++m; + strncpy(x_name, s, m - s); + x_name[m - s] = '\0'; + + DviFontMap *new = (DviFontMap *) XtMalloc(sizeof *new); + new->x_name = savestr(x_name); + new->dvi_name = savestr(dvi_name); + new->next = fm; + fm = new; + ++m; } dw->dvi.font_map = fm; } void -DestroyFontMap (DviFontMap *font_map) +DestroyFontMap(DviFontMap *font_map) { - DviFontMap *next; + DviFontMap *next; for (; font_map; font_map = next) { - next = font_map->next; - if (font_map->x_name) - XtFree (font_map->x_name); - if (font_map->dvi_name) - XtFree (font_map->dvi_name); - XtFree ((char *) font_map); + next = font_map->next; + if (font_map->x_name) + XtFree(font_map->x_name); + if (font_map->dvi_name) + XtFree(font_map->dvi_name); + XtFree((char *) font_map); } } -/*ARGSUSED*/ -void -SetFontPosition (DviWidget dw, int position, const char *dvi_name, const char *extra) + /*ARGSUSED*/ void +SetFontPosition(DviWidget dw, int position, const char *dvi_name, + const char *extra) { - const char *x_name; + const char *x_name; - x_name = MapDviNameToXName (dw, dvi_name); - (void) InstallFont (dw, position, dvi_name, x_name); + x_name = MapDviNameToXName(dw, dvi_name); + (void) InstallFont(dw, position, dvi_name, x_name); } #ifdef USE_XFT @@ -363,74 +363,71 @@ XftFont * #else XFontStruct * #endif -QueryFont (DviWidget dw, int position, int size) +QueryFont(DviWidget dw, int position, int size) { - DviFontList *f; - DviFontSizeList *fs; + DviFontList *f; + DviFontSizeList *fs; - f = LookupFontByPosition (dw, position); + f = LookupFontByPosition(dw, position); if (!f) - return dw->dvi.default_font; + return dw->dvi.default_font; if (!f->initialized) { - f->sizes = InstallFontSizes (dw, f->x_name, &f->scalable); - f->initialized = TRUE; + f->sizes = InstallFontSizes(dw, f->x_name, &f->scalable); + f->initialized = TRUE; } - fs = LookupFontSizeBySize (dw, f, size); + fs = LookupFontSizeBySize(dw, f, size); if (!fs) - return dw->dvi.default_font; + return dw->dvi.default_font; if (!fs->font) { - if (fs->x_name) - { + if (fs->x_name) { #ifdef USE_XFT - XftPattern *pat; - XftPattern *match; - XftResult result; - - pat = XftXlfdParse (fs->x_name, False, False); - XftPatternAddBool (pat, XFT_CORE, fs->core); - match = XftFontMatch (XtDisplay (dw), - XScreenNumberOfScreen(dw->core.screen), - pat, &result); - XftPatternDestroy (pat); - if (match) - { - fs->font = XftFontOpenPattern (XtDisplay (dw), - match); - if (!fs->font) - XftPatternDestroy (match); - } - else - fs->font = 0; + XftPattern *pat; + XftPattern *match; + XftResult result; + + pat = XftXlfdParse(fs->x_name, False, False); + XftPatternAddBool(pat, XFT_CORE, fs->core); + match = XftFontMatch(XtDisplay(dw), + XScreenNumberOfScreen(dw->core.screen), + pat, &result); + XftPatternDestroy(pat); + if (match) { + fs->font = XftFontOpenPattern(XtDisplay(dw), match); + if (!fs->font) + XftPatternDestroy(match); + } + else + fs->font = 0; #else - fs->font = XLoadQueryFont (XtDisplay (dw), fs->x_name); + fs->font = XLoadQueryFont(XtDisplay(dw), fs->x_name); #endif - } - if (!fs->font) - fs->font = dw->dvi.default_font; + } + if (!fs->font) + fs->font = dw->dvi.default_font; } return fs->font; } DviCharNameMap * -QueryFontMap (DviWidget dw, int position) +QueryFontMap(DviWidget dw, int position) { - DviFontList *f; + DviFontList *f; - f = LookupFontByPosition (dw, position); - if (f) - return f->char_map; - else - return NULL; + f = LookupFontByPosition(dw, position); + if (f) + return f->char_map; + else + return NULL; } unsigned char * -DviCharIsLigature (DviCharNameMap *map, const char *name) +DviCharIsLigature(DviCharNameMap *map, const char *name) { for (int i = 0; i < DVI_MAX_LIGATURES; i++) { - if (!map->ligatures[i][0]) - break; - if (!strcmp (name, map->ligatures[i][0])) - return (unsigned char *) map->ligatures[i][1]; + if (!map->ligatures[i][0]) + break; + if (!strcmp(name, map->ligatures[i][0])) + return (unsigned char *) map->ligatures[i][1]; } return NULL; } @@ -1,4 +1,3 @@ - #include <X11/Xos.h> #include <X11/IntrinsicP.h> #include <X11/StringDefs.h> @@ -9,15 +8,13 @@ int DviGetAndPut(DviWidget dw, int *cp) { - if (dw->dvi.ungot) - { - dw->dvi.ungot = 0; - *cp = getc (dw->dvi.file); + if (dw->dvi.ungot) { + dw->dvi.ungot = 0; + *cp = getc(dw->dvi.file); } - else - { - *cp = getc (dw->dvi.file); - putc (*cp, dw->dvi.tmpFile); + else { + *cp = getc(dw->dvi.file); + putc(*cp, dw->dvi.tmpFile); } return *cp; } @@ -25,54 +22,56 @@ DviGetAndPut(DviWidget dw, int *cp) char * GetLine(DviWidget dw, char *Buffer, int Length) { - int i = 0, c; - char *p = Buffer; + int i = 0, c; + char *p = Buffer; - Length--; /* Save room for final NULL */ + Length--; /* Save room for final NULL */ - while ((!p || i < Length) && DviGetC (dw, &c) != EOF && c != '\n') - if (p) - *p++ = c; - if (c == '\n') - DviUngetC(dw, c); - if (p) - *p = '\0'; - return (Buffer); + while ((!p || i < Length) && DviGetC(dw, &c) != EOF && c != '\n') { + if (p) + *p++ = c; + } + if (c == '\n') + DviUngetC(dw, c); + if (p) + *p = '\0'; + return (Buffer); } char * GetWord(DviWidget dw, char *Buffer, int Length) { - int i = 0, c; - char *p = Buffer; + int i = 0, c; + char *p = Buffer; - Length--; /* Save room for final NULL */ - while (DviGetC(dw, &c) != EOF && isspace(c)) - ; - if (c != EOF) - DviUngetC(dw, c); - while (i < Length && DviGetC(dw, &c) != EOF && !isspace(c)) - if (p) - *p++ = c; - if (c != EOF) - DviUngetC(dw, c); - if (p) - *p = '\0'; - return (Buffer); + Length--; /* Save room for final NULL */ + while (DviGetC(dw, &c) != EOF && isspace(c)) + ; + if (c != EOF) + DviUngetC(dw, c); + while (i < Length && DviGetC(dw, &c) != EOF && !isspace(c)) { + if (p) + *p++ = c; + } + if (c != EOF) + DviUngetC(dw, c); + if (p) + *p = '\0'; + return (Buffer); } int GetNumber(DviWidget dw) { - int i = 0, c; + int i = 0, c; - while (DviGetC(dw, &c) != EOF && isspace(c)) - ; - if (c != EOF) - DviUngetC(dw, c); - while (DviGetC(dw, &c) != EOF && isdigit(c)) - i = i*10 + c - '0'; - if (c != EOF) - DviUngetC(dw, c); - return (i); + while (DviGetC(dw, &c) != EOF && isspace(c)) + ; + if (c != EOF) + DviUngetC(dw, c); + while (DviGetC(dw, &c) != EOF && isdigit(c)) + i = i * 10 + c - '0'; + if (c != EOF) + DviUngetC(dw, c); + return (i); } @@ -12,68 +12,69 @@ #include "DviP.h" static DviFileMap * -MapPageNumberToFileMap (DviWidget dw, int number) +MapPageNumberToFileMap(DviWidget dw, int number) { - DviFileMap *m; + DviFileMap *m; - for (m = dw->dvi.file_map; m; m=m->next) - if (m->page_number == number) - break; - return m; + for (m = dw->dvi.file_map; m; m = m->next) { + if (m->page_number == number) + break; + } + return m; } void -DestroyFileMap (DviFileMap *m) +DestroyFileMap(DviFileMap *m) { - DviFileMap *next; + DviFileMap *next; - for (; m; m = next) { - next = m->next; - XtFree ((char *) m); - } + for (; m; m = next) { + next = m->next; + XtFree((char *) m); + } } void -ForgetPagePositions (DviWidget dw) +ForgetPagePositions(DviWidget dw) { - DestroyFileMap (dw->dvi.file_map); - dw->dvi.file_map = NULL; + DestroyFileMap(dw->dvi.file_map); + dw->dvi.file_map = NULL; } void RememberPagePosition(DviWidget dw, int number) { - DviFileMap *m; + DviFileMap *m; - if (!(m = MapPageNumberToFileMap (dw, number))) { - m = (DviFileMap *) XtMalloc (sizeof *m); - m->page_number = number; - m->next = dw->dvi.file_map; - dw->dvi.file_map = m; - } - if (dw->dvi.tmpFile) - m->position = ftell (dw->dvi.tmpFile); - else - m->position = ftell (dw->dvi.file); + if (!(m = MapPageNumberToFileMap(dw, number))) { + m = (DviFileMap *) XtMalloc(sizeof *m); + m->page_number = number; + m->next = dw->dvi.file_map; + dw->dvi.file_map = m; + } + if (dw->dvi.tmpFile) + m->position = ftell(dw->dvi.tmpFile); + else + m->position = ftell(dw->dvi.file); } long -SearchPagePosition (DviWidget dw, int number) +SearchPagePosition(DviWidget dw, int number) { - DviFileMap *m; + DviFileMap *m; - if (!(m = MapPageNumberToFileMap (dw, number))) - return -1; - return m->position; + if (!(m = MapPageNumberToFileMap(dw, number))) + return -1; + return m->position; } void FileSeek(DviWidget dw, long position) { - if (dw->dvi.tmpFile) { - dw->dvi.readingTmp = 1; - fseek (dw->dvi.tmpFile, position, SEEK_SET); - } else - fseek (dw->dvi.file, position, SEEK_SET); + if (dw->dvi.tmpFile) { + dw->dvi.readingTmp = 1; + fseek(dw->dvi.tmpFile, position, SEEK_SET); + } + else + fseek(dw->dvi.file, position, SEEK_SET); } - @@ -49,12 +49,11 @@ static void pop_env(DviWidget dw); #ifdef USE_XFT static int -charWidth (DviWidget dw, XftFont *font, char c) +charWidth(DviWidget dw, XftFont *font, char c) { - XGlyphInfo extents; + XGlyphInfo extents; - XftTextExtents8 (XtDisplay (dw), font, - (unsigned char *) &c, 1, &extents); + XftTextExtents8(XtDisplay(dw), font, (unsigned char *) &c, 1, &extents); return extents.xOff; } #else @@ -65,398 +64,398 @@ charWidth (DviWidget dw, XftFont *font, char c) (fi)->max_bounds.width\ ) #endif - + int ParseInput(DviWidget dw) { - int n, k; - int c; - char Buffer[BUFSIZ]; - int NextPage; - int prevFont; - int otherc; - unsigned char tc; + int n, k; + int c; + char Buffer[BUFSIZ]; + int NextPage; + int prevFont; + int otherc; + unsigned char tc; + + /* + * make sure some state exists + */ - /* - * make sure some state exists - */ + if (!dw->dvi.state) + push_env(dw); + for (;;) { + switch (DviGetC(dw, &c)) { + case '\n': + break; + case ' ': /* when input is text */ + case 0: /* occasional noise creeps in */ + break; + case '{': /* push down current environment */ + push_env(dw); + break; + case '}': + pop_env(dw); + break; + /* + * two motion digits plus a character + */ + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + HorizontalMove(dw, (c - '0') * 10 + DviGetC(dw, &otherc) - '0'); + /* fall through */ + case 'c': /* single ascii character */ + (void) DviGetC(dw, &c); + if (c == ' ') + break; + tc = c; + PutCharacters(dw, &tc, 1); + break; + case 'C': + GetWord(dw, Buffer, BUFSIZ); + { + DviCharNameMap *map; + int i; + unsigned char *ligature; - if (!dw->dvi.state) - push_env (dw); - for (;;) { - switch (DviGetC(dw, &c)) { - case '\n': - break; - case ' ': /* when input is text */ - case 0: /* occasional noise creeps in */ - break; - case '{': /* push down current environment */ - push_env(dw); - break; - case '}': - pop_env(dw); - break; - /* - * two motion digits plus a character - */ - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - HorizontalMove(dw, (c-'0')*10 + - DviGetC(dw,&otherc)-'0'); - /* fall through */ - case 'c': /* single ascii character */ - (void) DviGetC(dw,&c); - if (c == ' ') - break; - tc = c; - PutCharacters (dw, &tc, 1); - break; - case 'C': - GetWord(dw, Buffer, BUFSIZ); - { - DviCharNameMap *map; - int i; - unsigned char *ligature; - - c = -1; - map = QueryFontMap (dw, dw->dvi.state->font_number); - if (map) - { - c = DviCharIndex (map, Buffer); - if (c == -1) - { - ligature = DviCharIsLigature (map, Buffer); - if (ligature) { - i = strlen ((char *) ligature); - PutCharacters (dw, ligature, i); - break; - } - } - } - prevFont = -1; - if (c == -1) { - for (i = 1; (map = QueryFontMap (dw, i)); i++) - if (map->special) - if ((c = DviCharIndex (map, Buffer)) != -1) { - prevFont = dw->dvi.state->font_number; - dw->dvi.state->font_number = i; - break; - } - } - if (c != -1) - { - tc = c; - PutCharacters (dw, &tc, 1); - } - if (prevFont != -1) - dw->dvi.state->font_number = prevFont; - } - break; - case 'D': /* draw function */ - GetLine(dw, Buffer, BUFSIZ); - ParseDrawFunction(dw, Buffer); - break; - case 's': /* ignore fractional sizes */ - n = GetNumber(dw); - if (!dw->dvi.size_scale) - { - static const int guesses[] = { 1, 4, 100, 1000, 1 }; - int i; + c = -1; + map = QueryFontMap(dw, dw->dvi.state->font_number); + if (map) { + c = DviCharIndex(map, Buffer); + if (c == -1) { + ligature = DviCharIsLigature(map, Buffer); + if (ligature) { + i = strlen((char *) ligature); + PutCharacters(dw, ligature, i); + break; + } + } + } + prevFont = -1; + if (c == -1) { + for (i = 1; (map = QueryFontMap(dw, i)); i++) { + if (map->special) { + if ((c = DviCharIndex(map, Buffer)) != -1) { + prevFont = dw->dvi.state->font_number; + dw->dvi.state->font_number = i; + break; + } + } + } + } + if (c != -1) { + tc = c; + PutCharacters(dw, &tc, 1); + } + if (prevFont != -1) + dw->dvi.state->font_number = prevFont; + } + break; + case 'D': /* draw function */ + GetLine(dw, Buffer, BUFSIZ); + ParseDrawFunction(dw, Buffer); + break; + case 's': /* ignore fractional sizes */ + n = GetNumber(dw); + if (!dw->dvi.size_scale) { + static const int guesses[] = { 1, 4, 100, 1000, 1 }; + int i; - for (i = 0; i < 4; i++) - if (8 <= n/guesses[i] && n/guesses[i] <= 24) - { - break; - } - dw->dvi.size_scale = guesses[i]; - } - dw->dvi.state->font_size = n; - dw->dvi.state->line_width = n * (dw->dvi.device_resolution / - (720 * dw->dvi.size_scale)); - break; - case 'f': - n = GetNumber(dw); - dw->dvi.state->font_number = n; - break; - case 'H': /* absolute horizontal motion */ - k = GetNumber(dw); - HorizontalGoto(dw, k); - break; - case 'h': /* relative horizontal motion */ - k = GetNumber(dw); - HorizontalMove(dw, k); - break; - case 'w': /* word space */ - break; - case 'V': - n = GetNumber(dw); - VerticalGoto(dw, n); - break; - case 'v': - n = GetNumber(dw); - VerticalMove(dw, n); - break; - case 'P': /* new spread */ - break; - case 'p': /* new page */ - (void) GetNumber(dw); - NextPage = dw->dvi.current_page + 1; - RememberPagePosition(dw, NextPage); - FlushCharCache (dw); - return(NextPage); - case 'n': /* end of line */ - GetNumber(dw); - GetNumber(dw); - HorizontalGoto(dw, 0); - break; - case '#': /* comment */ - case 'F': /* file info */ - GetLine(dw, NULL, 0); - break; - case 't': /* text */ - GetLine(dw, Buffer, BUFSIZ); - PutCharacters (dw, (unsigned char *)Buffer, - strlen (Buffer)); - dw->dvi.state->x = ToDevice (dw, dw->dvi.cache.x); - break; - case 'x': /* device control */ - ParseDeviceControl(dw); - break; - case EOF: - dw->dvi.last_page = dw->dvi.current_page; - FlushCharCache (dw); - return dw->dvi.current_page; - default: - GetLine (dw, Buffer, BUFSIZ); - fprintf (stderr, "Unknown command %s\n", Buffer); - break; - } - } + for (i = 0; i < 4; i++) { + if (8 <= n / guesses[i] && n / guesses[i] <= 24) { + break; + } + } + dw->dvi.size_scale = guesses[i]; + } + dw->dvi.state->font_size = n; + dw->dvi.state->line_width = n * (dw->dvi.device_resolution / + (720 * dw->dvi.size_scale)); + break; + case 'f': + n = GetNumber(dw); + dw->dvi.state->font_number = n; + break; + case 'H': /* absolute horizontal motion */ + k = GetNumber(dw); + HorizontalGoto(dw, k); + break; + case 'h': /* relative horizontal motion */ + k = GetNumber(dw); + HorizontalMove(dw, k); + break; + case 'w': /* word space */ + break; + case 'V': + n = GetNumber(dw); + VerticalGoto(dw, n); + break; + case 'v': + n = GetNumber(dw); + VerticalMove(dw, n); + break; + case 'P': /* new spread */ + break; + case 'p': /* new page */ + (void) GetNumber(dw); + NextPage = dw->dvi.current_page + 1; + RememberPagePosition(dw, NextPage); + FlushCharCache(dw); + return (NextPage); + case 'n': /* end of line */ + GetNumber(dw); + GetNumber(dw); + HorizontalGoto(dw, 0); + break; + case '#': /* comment */ + case 'F': /* file info */ + GetLine(dw, NULL, 0); + break; + case 't': /* text */ + GetLine(dw, Buffer, BUFSIZ); + PutCharacters(dw, (unsigned char *) Buffer, strlen(Buffer)); + dw->dvi.state->x = ToDevice(dw, dw->dvi.cache.x); + break; + case 'x': /* device control */ + ParseDeviceControl(dw); + break; + case EOF: + dw->dvi.last_page = dw->dvi.current_page; + FlushCharCache(dw); + return dw->dvi.current_page; + default: + GetLine(dw, Buffer, BUFSIZ); + fprintf(stderr, "Unknown command %s\n", Buffer); + break; + } + } } static void push_env(DviWidget dw) { - DviState *new; + DviState *new; - new = (DviState *) XtMalloc (sizeof (*new)); - if (dw->dvi.state) - *new = *(dw->dvi.state); - else { - new->font_size = 10 * dw->dvi.size_scale; - new->font_number = 1; - new->line_style = 0; - new->line_width = 10; - new->x = 0; - new->y = 0; - } - new->next = dw->dvi.state; - dw->dvi.state = new; + new = (DviState *) XtMalloc(sizeof(*new)); + if (dw->dvi.state) + *new = *(dw->dvi.state); + else { + new->font_size = 10 * dw->dvi.size_scale; + new->font_number = 1; + new->line_style = 0; + new->line_width = 10; + new->x = 0; + new->y = 0; + } + new->next = dw->dvi.state; + dw->dvi.state = new; } static void pop_env(DviWidget dw) { - DviState *old; + DviState *old; - old = dw->dvi.state; - dw->dvi.state = old->next; - XtFree ((char *) old); + old = dw->dvi.state; + dw->dvi.state = old->next; + XtFree((char *) old); } static void -InitTypesetter (DviWidget dw) +InitTypesetter(DviWidget dw) { - while (dw->dvi.state) - pop_env (dw); - dw->dvi.size_scale = dw->dvi.size_scale_set; - push_env (dw); - FlushCharCache (dw); + while (dw->dvi.state) + pop_env(dw); + dw->dvi.size_scale = dw->dvi.size_scale_set; + push_env(dw); + FlushCharCache(dw); } static void -SetFont (DviWidget dw) +SetFont(DviWidget dw) { dw->dvi.cache.font_size = dw->dvi.state->font_size; dw->dvi.cache.font_number = dw->dvi.state->font_number; - dw->dvi.cache.font = QueryFont (dw, - dw->dvi.cache.font_number, - dw->dvi.cache.font_size); + dw->dvi.cache.font = QueryFont(dw, + dw->dvi.cache.font_number, + dw->dvi.cache.font_size); } static void -PutCharacters (DviWidget dw, unsigned char *src, int len) +PutCharacters(DviWidget dw, unsigned char *src, int len) { - int xx, yx; - int fx, fy; - char *dst; - int c; + int xx, yx; + int fx, fy; + char *dst; + int c; xx = ToX(dw, dw->dvi.state->x); yx = ToX(dw, dw->dvi.state->y); - fy = FontSizeInPixels (dw, dw->dvi.state->font_size); + fy = FontSizeInPixels(dw, dw->dvi.state->font_size); fx = fy * len; /* * quick and dirty extents calculation: */ if (yx + fy >= dw->dvi.extents.y1 && - yx - fy <= dw->dvi.extents.y2 && - xx + fx >= dw->dvi.extents.x1 && - xx - fx <= dw->dvi.extents.x2) - { + yx - fy <= dw->dvi.extents.y2 && + xx + fx >= dw->dvi.extents.x1 && xx - fx <= dw->dvi.extents.x2) { #ifdef USE_XFT - XftFont *font; - DviTextItem *text; + XftFont *font; + DviTextItem *text; #else - register XFontStruct *font; - register XTextItem *text; + register XFontStruct *font; + register XTextItem *text; #endif - if (!dw->dvi.display_enable) - return; + if (!dw->dvi.display_enable) + return; - if (yx != dw->dvi.cache.y || - dw->dvi.cache.char_index + len > DVI_CHAR_CACHE_SIZE) - FlushCharCache (dw); - /* - * load a new font, if the current block is not empty, - * step to the next. - */ - if (dw->dvi.cache.font_size != dw->dvi.state->font_size || - dw->dvi.cache.font_number != dw->dvi.state->font_number) - { - SetFont (dw); - if (dw->dvi.cache.cache[dw->dvi.cache.index].nchars != 0) { - ++dw->dvi.cache.index; - if (dw->dvi.cache.index >= dw->dvi.cache.max) - FlushCharCache (dw); - dw->dvi.cache.cache[dw->dvi.cache.index].nchars = 0; - } - } - if (xx != dw->dvi.cache.x) { - if (dw->dvi.cache.cache[dw->dvi.cache.index].nchars != 0) { - ++dw->dvi.cache.index; - if (dw->dvi.cache.index >= dw->dvi.cache.max) - FlushCharCache (dw); - dw->dvi.cache.cache[dw->dvi.cache.index].nchars = 0; - } - } - if (!dw->dvi.cache.font) - SetFont (dw); - text = &dw->dvi.cache.cache[dw->dvi.cache.index]; - font = dw->dvi.cache.font; - dst = &dw->dvi.cache.char_cache[dw->dvi.cache.char_index]; - if (text->nchars == 0) { - text->chars = dst; + if (yx != dw->dvi.cache.y || + dw->dvi.cache.char_index + len > DVI_CHAR_CACHE_SIZE) + FlushCharCache(dw); + /* + * load a new font, if the current block is not empty, + * step to the next. + */ + if (dw->dvi.cache.font_size != dw->dvi.state->font_size || + dw->dvi.cache.font_number != dw->dvi.state->font_number) { + SetFont(dw); + if (dw->dvi.cache.cache[dw->dvi.cache.index].nchars != 0) { + ++dw->dvi.cache.index; + if (dw->dvi.cache.index >= dw->dvi.cache.max) + FlushCharCache(dw); + dw->dvi.cache.cache[dw->dvi.cache.index].nchars = 0; + } + } + if (xx != dw->dvi.cache.x) { + if (dw->dvi.cache.cache[dw->dvi.cache.index].nchars != 0) { + ++dw->dvi.cache.index; + if (dw->dvi.cache.index >= dw->dvi.cache.max) + FlushCharCache(dw); + dw->dvi.cache.cache[dw->dvi.cache.index].nchars = 0; + } + } + if (!dw->dvi.cache.font) + SetFont(dw); + text = &dw->dvi.cache.cache[dw->dvi.cache.index]; + font = dw->dvi.cache.font; + dst = &dw->dvi.cache.char_cache[dw->dvi.cache.char_index]; + if (text->nchars == 0) { + text->chars = dst; #ifdef USE_XFT - text->x = xx; + text->x = xx; #else - text->delta = xx - dw->dvi.cache.x; + text->delta = xx - dw->dvi.cache.x; #endif #ifdef USE_XFT - text->font = font; + text->font = font; #endif - if (font != dw->dvi.font) { + if (font != dw->dvi.font) { #ifndef USE_XFT - text->font = font->fid; + text->font = font->fid; #endif - dw->dvi.font = font; - } + dw->dvi.font = font; + } #ifndef USE_XFT - else - text->font = None; + else + text->font = None; #endif - dw->dvi.cache.x = xx; - } - dw->dvi.cache.char_index += len; - text->nchars += len; - while (len--) - { - c = *src++; - *dst++ = c; - if (font) - dw->dvi.cache.x += charWidth(dw,font,c); - } + dw->dvi.cache.x = xx; + } + dw->dvi.cache.char_index += len; + text->nchars += len; + while (len--) { + c = *src++; + *dst++ = c; + if (font) + dw->dvi.cache.x += charWidth(dw, font, c); + } } } static void ParseDrawFunction(DviWidget dw, char *buf) { - int n, m, n1, m1; + int n, m, n1, m1; - SetGCForDraw (dw); + SetGCForDraw(dw); switch (buf[0]) { - case 'l': /* draw a line */ - sscanf(buf+1, "%d %d", &n, &m); - DrawLine(dw, n, m); - break; - case 'c': /* circle */ - sscanf(buf+1, "%d", &n); - DrawCircle(dw, n); - break; - case 'e': /* ellipse */ - sscanf(buf+1, "%d %d", &m, &n); - DrawEllipse(dw, m, n); - break; - case 'a': /* arc */ - sscanf(buf+1, "%d %d %d %d", &n, &m, &n1, &m1); - DrawArc(dw, n, m, n1, m1); - break; - case '~': /* wiggly line */ - DrawSpline(dw, buf+1,1); - break; - case 't': /* line width */ - sscanf(buf+1, "%d", &n); - dw->dvi.state->line_width = n; - break; - case 's': /* line style */ - sscanf(buf+1, "%d", &n); - /* XXX */ - break; + case 'l': /* draw a line */ + sscanf(buf + 1, "%d %d", &n, &m); + DrawLine(dw, n, m); + break; + case 'c': /* circle */ + sscanf(buf + 1, "%d", &n); + DrawCircle(dw, n); + break; + case 'e': /* ellipse */ + sscanf(buf + 1, "%d %d", &m, &n); + DrawEllipse(dw, m, n); + break; + case 'a': /* arc */ + sscanf(buf + 1, "%d %d %d %d", &n, &m, &n1, &m1); + DrawArc(dw, n, m, n1, m1); + break; + case '~': /* wiggly line */ + DrawSpline(dw, buf + 1, 1); + break; + case 't': /* line width */ + sscanf(buf + 1, "%d", &n); + dw->dvi.state->line_width = n; + break; + case 's': /* line style */ + sscanf(buf + 1, "%d", &n); + /* XXX */ + break; default: - /* warning("unknown drawing function %s", buf); */ - break; + /* warning("unknown drawing function %s", buf); */ + break; } -} +} extern int LastPage, CurrentPage; static void -ParseDeviceControl(DviWidget dw) /* Parse the x commands */ -{ +ParseDeviceControl(DviWidget dw) +{ /* Parse the x commands */ char str[20], str1[50]; int c, n; - GetWord (dw, str, 20); - switch (str[0]) { /* crude for now */ - case 'T': /* output device */ - GetWord(dw, str, 20); - break; - case 'i': /* initialize */ - InitTypesetter (dw); - break; - case 't': /* trailer */ - break; - case 'p': /* pause -- can restart */ - break; - case 's': /* stop */ - return; - case 'r': /* resolution when prepared */ - SetDeviceResolution (dw, GetNumber (dw)); - break; - case 'f': /* font used */ - n = GetNumber(dw); - GetWord(dw, str, 20); - GetLine(dw, str1, 50); - SetFontPosition(dw, n, str, str1); - break; - case 'H': /* char height */ - break; - case 'S': /* slant */ - break; + GetWord(dw, str, 20); + switch (str[0]) { /* crude for now */ + case 'T': /* output device */ + GetWord(dw, str, 20); + break; + case 'i': /* initialize */ + InitTypesetter(dw); + break; + case 't': /* trailer */ + break; + case 'p': /* pause -- can restart */ + break; + case 's': /* stop */ + return; + case 'r': /* resolution when prepared */ + SetDeviceResolution(dw, GetNumber(dw)); + break; + case 'f': /* font used */ + n = GetNumber(dw); + GetWord(dw, str, 20); + GetLine(dw, str1, 50); + SetFontPosition(dw, n, str, str1); + break; + case 'H': /* char height */ + break; + case 'S': /* slant */ + break; } - while (DviGetC(dw,&c) != '\n') /* skip rest of input line */ - if (c == EOF) - return; + while (DviGetC(dw, &c) != '\n') /* skip rest of input line */ + if (c == EOF) + return; } @@ -63,14 +63,14 @@ from the X Consortium. pass over the remaining options after XtParseCommand is let loose. */ static XrmOptionDescRec options[] = { -{"-page", "*dvi.pageNumber", XrmoptionSepArg, NULL}, -{"-backingStore", "*dvi.backingStore", XrmoptionSepArg, NULL}, -{"-noPolyText", "*dvi.noPolyText", XrmoptionNoArg, "TRUE"}, -{"-resolution", "*dvi.screenResolution",XrmoptionSepArg, NULL}, + {"-page", "*dvi.pageNumber", XrmoptionSepArg, NULL}, + {"-backingStore", "*dvi.backingStore", XrmoptionSepArg, NULL}, + {"-noPolyText", "*dvi.noPolyText", XrmoptionNoArg, "TRUE"}, + {"-resolution", "*dvi.screenResolution", XrmoptionSepArg, NULL}, }; -static char current_file_name[1024]; -static FILE *current_file; +static char current_file_name[1024]; +static FILE *current_file; static void MakePrompt(Widget, const char *, void (*)(char *), char *); @@ -81,73 +81,74 @@ static void MakePrompt(Widget, const char *, void (*)(char *), char *); static void Syntax(const char *call) { - (void) printf ("Usage: %s [-fg <color>] [-bg <color>]\n%s\n", call, - " [-bd <color>] [-bw <pixels>] [-help]\n" - " [-display displayname] [-geometry geom]\n" - " [-page <page-number>] [-backing <backing-store>]\n" - " [-resolution <screen-resolution>]\n"); + (void) printf("Usage: %s [-fg <color>] [-bg <color>]\n%s\n", call, + " [-bd <color>] [-bw <pixels>] [-help]\n" + " [-display displayname] [-geometry geom]\n" + " [-page <page-number>] [-backing <backing-store>]\n" + " [-resolution <screen-resolution>]\n"); exit(1); } -static void NewResolution (char *resString); -static void NewFile (char *name); -static void DisplayPageNumber (void); -static void VisitFile (char *name, Boolean resetPage); -static Widget toplevel, paned, porthole, dvi; -static Widget popupMenu; -static Widget menuBar; -static Widget fileMenuButton, fileMenu; -static Widget pageNumber; - -static void NextPage(Widget entry, XtPointer name, XtPointer data); -static void PreviousPage(Widget entry, XtPointer name, XtPointer data); -static void SetResolution(Widget entry, XtPointer name, XtPointer data); -static void OpenFile(Widget entry, XtPointer name, XtPointer data); -static void RevisitFile(Widget entry, XtPointer name, XtPointer data); -static void Quit(Widget entry, XtPointer closure, XtPointer data); +static void NewResolution(char *resString); +static void NewFile(char *name); +static void DisplayPageNumber(void); +static void VisitFile(char *name, Boolean resetPage); + +static Widget toplevel, paned, porthole, dvi; +static Widget popupMenu; +static Widget menuBar; +static Widget fileMenuButton, fileMenu; +static Widget pageNumber; + +static void NextPage(Widget entry, XtPointer name, XtPointer data); +static void PreviousPage(Widget entry, XtPointer name, XtPointer data); +static void SetResolution(Widget entry, XtPointer name, XtPointer data); +static void OpenFile(Widget entry, XtPointer name, XtPointer data); +static void RevisitFile(Widget entry, XtPointer name, XtPointer data); +static void Quit(Widget entry, XtPointer closure, XtPointer data); struct menuEntry { - char *name; - void (*function)(Widget entry, XtPointer name, XtPointer data); + char *name; + void (*function)(Widget entry, XtPointer name, XtPointer data); }; static struct menuEntry popupMenuEntries[] = { - { "nextPage", NextPage }, - { "previousPage", PreviousPage }, - { "setResolution", SetResolution }, - { "openFile", OpenFile }, - { "revisitFile", RevisitFile }, - { "quit", Quit } + {"nextPage", NextPage}, + {"previousPage", PreviousPage}, + {"setResolution", SetResolution}, + {"openFile", OpenFile}, + {"revisitFile", RevisitFile}, + {"quit", Quit} }; static struct menuEntry fileMenuEntries[] = { - { "openFile", OpenFile }, - { "revisitFile", RevisitFile }, - { "setResolution", SetResolution }, - { "quit", Quit } + {"openFile", OpenFile}, + {"revisitFile", RevisitFile}, + {"setResolution", SetResolution}, + {"quit", Quit} }; -static void NextPageAction(Widget, XEvent *, String *, Cardinal *); -static void PreviousPageAction(Widget, XEvent *, String *, Cardinal *); -static void SetResolutionAction(Widget, XEvent *, String *, Cardinal *); -static void OpenFileAction(Widget, XEvent *, String *, Cardinal *); -static void RevisitFileAction(Widget, XEvent *, String *, Cardinal *); -static void QuitAction(Widget, XEvent *, String *, Cardinal *); -static void AcceptAction(Widget, XEvent *, String *, Cardinal *); -static void CancelAction(Widget, XEvent *, String *, Cardinal *); -static void UpdatePageNumber(Widget, XEvent *, String *, Cardinal *); -static void Noop(Widget, XEvent *, String *, Cardinal *); +static void NextPageAction(Widget, XEvent *, String *, Cardinal *); +static void PreviousPageAction(Widget, XEvent *, String *, Cardinal *); +static void SetResolutionAction(Widget, XEvent *, String *, Cardinal *); +static void OpenFileAction(Widget, XEvent *, String *, Cardinal *); +static void RevisitFileAction(Widget, XEvent *, String *, Cardinal *); +static void QuitAction(Widget, XEvent *, String *, Cardinal *); +static void AcceptAction(Widget, XEvent *, String *, Cardinal *); +static void CancelAction(Widget, XEvent *, String *, Cardinal *); +static void UpdatePageNumber(Widget, XEvent *, String *, Cardinal *); +static void Noop(Widget, XEvent *, String *, Cardinal *); static XtActionsRec xditview_actions[] = { - { "NextPage", NextPageAction }, - { "PreviousPage", PreviousPageAction }, - { "SetResolution", SetResolutionAction }, - { "OpenFile", OpenFileAction }, - { "Quit", QuitAction }, - { "Accept", AcceptAction }, - { "Cancel", CancelAction }, - { "SetPageNumber", UpdatePageNumber }, - { "Noop", Noop } + {"NextPage", NextPageAction}, + {"PreviousPage", PreviousPageAction}, + {"SetResolution", SetResolutionAction}, + {"OpenFile", OpenFileAction}, + {"Quit", QuitAction}, + {"Accept", AcceptAction}, + {"Cancel", CancelAction}, + {"SetPageNumber", UpdatePageNumber}, + {"Noop", Noop} }; static Atom wm_delete_window; @@ -156,177 +157,179 @@ static Atom wm_delete_window; int main(int argc, char **argv) { - char *file_name = NULL; + char * file_name = NULL; XtAppContext xtcontext; - Arg topLevelArgs[2]; + Arg topLevelArgs[2]; Widget entry; XtSetLanguageProc(NULL, (XtLanguageProc) NULL, NULL); toplevel = XtAppInitialize(&xtcontext, "Xditview", - options, XtNumber (options), - &argc, argv, NULL, NULL, 0); + options, XtNumber(options), + &argc, argv, NULL, NULL, 0); if (argc > 2) - Syntax(argv[0]); + Syntax(argv[0]); - XtAppAddActions(xtcontext, xditview_actions, XtNumber (xditview_actions)); + XtAppAddActions(xtcontext, xditview_actions, XtNumber(xditview_actions)); XtOverrideTranslations - (toplevel, XtParseTranslationTable ("<Message>WM_PROTOCOLS: Quit()")); - - XtSetArg (topLevelArgs[0], XtNiconPixmap, - XCreateBitmapFromData (XtDisplay (toplevel), - XtScreen(toplevel)->root, - (char *) xdit_bits, - xdit_width, xdit_height)); - - XtSetArg (topLevelArgs[1], XtNiconMask, - XCreateBitmapFromData (XtDisplay (toplevel), - XtScreen(toplevel)->root, - (char *) xdit_mask_bits, - xdit_mask_width, xdit_mask_height)); - XtSetValues (toplevel, topLevelArgs, 2); + (toplevel, XtParseTranslationTable("<Message>WM_PROTOCOLS: Quit()")); + + XtSetArg(topLevelArgs[0], XtNiconPixmap, + XCreateBitmapFromData(XtDisplay(toplevel), + XtScreen(toplevel)->root, + (char *) xdit_bits, + xdit_width, xdit_height)); + + XtSetArg(topLevelArgs[1], XtNiconMask, + XCreateBitmapFromData(XtDisplay(toplevel), + XtScreen(toplevel)->root, + (char *) xdit_mask_bits, + xdit_mask_width, xdit_mask_height)); + XtSetValues(toplevel, topLevelArgs, 2); if (argc > 1) - file_name = argv[1]; + file_name = argv[1]; /* * create the popup menu and insert the entries */ - popupMenu = XtCreatePopupShell ("popupMenu", simpleMenuWidgetClass, toplevel, - NULL, 0); - for (Cardinal i = 0; i < XtNumber (popupMenuEntries); i++) { - entry = XtCreateManagedWidget(popupMenuEntries[i].name, - smeBSBObjectClass, popupMenu, - NULL, (Cardinal) 0); - XtAddCallback(entry, XtNcallback, popupMenuEntries[i].function, NULL); + popupMenu = XtCreatePopupShell("popupMenu", simpleMenuWidgetClass, toplevel, + NULL, 0); + for (Cardinal i = 0; i < XtNumber(popupMenuEntries); i++) { + entry = XtCreateManagedWidget(popupMenuEntries[i].name, + smeBSBObjectClass, popupMenu, + NULL, (Cardinal) 0); + XtAddCallback(entry, XtNcallback, popupMenuEntries[i].function, NULL); } paned = XtCreateManagedWidget("paned", panedWidgetClass, toplevel, - NULL, (Cardinal) 0); - menuBar = XtCreateManagedWidget ("menuBar", boxWidgetClass, paned, NULL, 0); - - fileMenuButton = XtCreateManagedWidget ("fileMenuButton", menuButtonWidgetClass, - menuBar, NULL, (Cardinal) 0); - fileMenu = XtCreatePopupShell ("fileMenu", simpleMenuWidgetClass, - fileMenuButton, NULL, (Cardinal) 0); - for (Cardinal i = 0; i < XtNumber (fileMenuEntries); i++) { - entry = XtCreateManagedWidget(fileMenuEntries[i].name, - smeBSBObjectClass, fileMenu, - NULL, (Cardinal) 0); - XtAddCallback (entry, XtNcallback, fileMenuEntries[i].function, NULL); + NULL, (Cardinal) 0); + menuBar = XtCreateManagedWidget("menuBar", boxWidgetClass, paned, NULL, 0); + + fileMenuButton = + XtCreateManagedWidget("fileMenuButton", menuButtonWidgetClass, menuBar, + NULL, (Cardinal) 0); + fileMenu = + XtCreatePopupShell("fileMenu", simpleMenuWidgetClass, fileMenuButton, + NULL, (Cardinal) 0); + for (Cardinal i = 0; i < XtNumber(fileMenuEntries); i++) { + entry = XtCreateManagedWidget(fileMenuEntries[i].name, + smeBSBObjectClass, fileMenu, + NULL, (Cardinal) 0); + XtAddCallback(entry, XtNcallback, fileMenuEntries[i].function, NULL); } - (void) XtCreateManagedWidget ("prevButton", commandWidgetClass, - menuBar, NULL, (Cardinal) 0); + (void) XtCreateManagedWidget("prevButton", commandWidgetClass, + menuBar, NULL, (Cardinal) 0); pageNumber = XtCreateManagedWidget("pageNumber", asciiTextWidgetClass, - menuBar, NULL, (Cardinal) 0); - - (void) XtCreateManagedWidget ("nextButton", commandWidgetClass, - menuBar, NULL, (Cardinal) 0); - - porthole = XtCreateManagedWidget ("viewport", viewportWidgetClass, - paned, NULL, 0); - dvi = XtCreateManagedWidget ("dvi", dviWidgetClass, porthole, NULL, 0); + menuBar, NULL, (Cardinal) 0); + + (void) XtCreateManagedWidget("nextButton", commandWidgetClass, + menuBar, NULL, (Cardinal) 0); + + porthole = XtCreateManagedWidget("viewport", viewportWidgetClass, + paned, NULL, 0); + dvi = XtCreateManagedWidget("dvi", dviWidgetClass, porthole, NULL, 0); if (file_name) - VisitFile (file_name, FALSE); - XtRealizeWidget (toplevel); + VisitFile(file_name, FALSE); + XtRealizeWidget(toplevel); wm_delete_window = XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW", - False); - (void) XSetWMProtocols (XtDisplay(toplevel), XtWindow(toplevel), - &wm_delete_window, 1); + False); + (void) XSetWMProtocols(XtDisplay(toplevel), XtWindow(toplevel), + &wm_delete_window, 1); XtAppMainLoop(xtcontext); return 0; } static void -DisplayPageNumber (void) +DisplayPageNumber(void) { - Arg arg[2]; - int actual_number, last_page; - XawTextBlock text; - int length; - char value[128]; - char *cur; - - XtSetArg (arg[0], XtNpageNumber, &actual_number); - XtSetArg (arg[1], XtNlastPageNumber, &last_page); - XtGetValues (dvi, arg, 2); + Arg arg[2]; + int actual_number, last_page; + XawTextBlock text; + int length; + char value[128]; + char * cur; + + XtSetArg(arg[0], XtNpageNumber, &actual_number); + XtSetArg(arg[1], XtNlastPageNumber, &last_page); + XtGetValues(dvi, arg, 2); if (actual_number == 0) - snprintf (value, sizeof(value), "<none>"); + snprintf(value, sizeof(value), "<none>"); else if (last_page > 0) - snprintf (value, sizeof(value), "%d of %d", actual_number, last_page); + snprintf(value, sizeof(value), "%d of %d", actual_number, last_page); else - snprintf (value, sizeof(value), "%d", actual_number); + snprintf(value, sizeof(value), "%d", actual_number); text.firstPos = 0; - text.length = strlen (value); + text.length = strlen(value); text.ptr = value; text.format = FMT8BIT; - XtSetArg (arg[0], XtNstring, &cur); - XtGetValues (XawTextGetSource (pageNumber), arg, 1); - length = strlen (cur); - XawTextReplace (pageNumber, 0, length, &text); + XtSetArg(arg[0], XtNstring, &cur); + XtGetValues(XawTextGetSource(pageNumber), arg, 1); + length = strlen(cur); + XawTextReplace(pageNumber, 0, length, &text); } static void -SetPageNumber (int number) +SetPageNumber(int number) { - Arg arg[1]; + Arg arg[1]; - XtSetArg (arg[0], XtNpageNumber, number); - XtSetValues (dvi, arg, 1); - DisplayPageNumber (); + XtSetArg(arg[0], XtNpageNumber, number); + XtSetValues(dvi, arg, 1); + DisplayPageNumber(); } static void -UpdatePageNumber (Widget w, XEvent *xev, String *s, Cardinal *c) +UpdatePageNumber(Widget w, XEvent *xev, String *s, Cardinal *c) { - char *string; - Arg arg[1]; + char *string; + Arg arg[1]; - XtSetArg (arg[0], XtNstring, &string); - XtGetValues (XawTextGetSource(pageNumber), arg, 1); - SetPageNumber (atoi(string)); + XtSetArg(arg[0], XtNstring, &string); + XtGetValues(XawTextGetSource(pageNumber), arg, 1); + SetPageNumber(atoi(string)); } static void NewResolution(char *resString) { - int res; - Arg arg[1]; - - res = atoi (resString); + int res; + Arg arg[1]; + + res = atoi(resString); if (res <= 0) - return; - XtSetArg (arg[0], XtNscreenResolution, res); - XtSetValues (dvi, arg, 1); + return; + XtSetArg(arg[0], XtNscreenResolution, res); + XtSetValues(dvi, arg, 1); } static void -VisitFile (char *name, Boolean resetPage) +VisitFile(char *name, Boolean resetPage) { - Arg arg[3]; - char *n; - FILE *new_file; + Arg arg[3]; + char *n; + FILE *new_file; Boolean seek = 0; - int i; + int i; if (current_file) { - if (!strcmp (current_file_name, "-")) - ; - else if (current_file_name[0] == '|') - pclose (current_file); - else - fclose (current_file); + if (!strcmp(current_file_name, "-")) + ; + else if (current_file_name[0] == '|') + pclose(current_file); + else + fclose(current_file); } - if (!strcmp (name, "-")) - new_file = stdin; + if (!strcmp(name, "-")) + new_file = stdin; else if (name[0] == '|') - new_file = popen (name+1, "r"); + new_file = popen(name + 1, "r"); else { struct stat stbuf; - new_file = fopen (name, "r"); + new_file = fopen(name, "r"); if (!new_file) { perror(name); @@ -338,186 +341,188 @@ VisitFile (char *name, Boolean resetPage) fclose(new_file); return; } - if (! S_ISREG(stbuf.st_mode)){ + if (!S_ISREG(stbuf.st_mode)) { fprintf(stderr, "%s is not a regular file.\n", name); fclose(new_file); return; } - seek = 1; + seek = 1; } if (!new_file) { - /* XXX display error message */ - return; + /* XXX display error message */ + return; } i = 0; - XtSetArg (arg[i], XtNfile, new_file); i++; - XtSetArg (arg[i], XtNseek, seek); i++; + XtSetArg(arg[i], XtNfile, new_file); + i++; + XtSetArg(arg[i], XtNseek, seek); + i++; if (resetPage) { - XtSetArg (arg[i], XtNpageNumber, 1); i++; + XtSetArg(arg[i], XtNpageNumber, 1); + i++; } - XtSetValues (dvi, arg, i); - XtSetArg (arg[0], XtNtitle, name); - if (name[0] != '/' && (n = strrchr (name, '/'))) - n = n + 1; + XtSetValues(dvi, arg, i); + XtSetArg(arg[0], XtNtitle, name); + if (name[0] != '/' && (n = strrchr(name, '/'))) + n = n + 1; else - n = name; - XtSetArg (arg[1], XtNiconName, n); - XtSetValues (toplevel, arg, 2); - strcpy (current_file_name, name); + n = name; + XtSetArg(arg[1], XtNiconName, n); + XtSetValues(toplevel, arg, 2); + strcpy(current_file_name, name); current_file = new_file; - DisplayPageNumber (); + DisplayPageNumber(); } static void -NewFile (char *name) +NewFile(char *name) { - VisitFile (name, TRUE); + VisitFile(name, TRUE); } static char fileBuf[1024]; static char resolutionBuf[1024]; static void -ResetMenuEntry (Widget entry) +ResetMenuEntry(Widget entry) { - Arg arg[1]; + Arg arg[1]; - XtSetArg (arg[0], XtNpopupOnEntry, entry); - XtSetValues (XtParent(entry) , arg, (Cardinal) 1); + XtSetArg(arg[0], XtNpopupOnEntry, entry); + XtSetValues(XtParent(entry), arg, (Cardinal) 1); } /*ARGSUSED*/ static void -NextPage (Widget entry, XtPointer name, XtPointer data) +NextPage(Widget entry, XtPointer name, XtPointer data) { NextPageAction(entry, NULL, NULL, NULL); - ResetMenuEntry (entry); + ResetMenuEntry(entry); } static void -NextPageAction (Widget w, XEvent *xev, String *s, Cardinal *c) +NextPageAction(Widget w, XEvent *xev, String *s, Cardinal *c) { - Arg args[1]; - int number; + Arg args[1]; + int number; - XtSetArg (args[0], XtNpageNumber, &number); - XtGetValues (dvi, args, 1); - SetPageNumber (number+1); + XtSetArg(args[0], XtNpageNumber, &number); + XtGetValues(dvi, args, 1); + SetPageNumber(number + 1); } /*ARGSUSED*/ static void -PreviousPage (Widget entry, XtPointer name, XtPointer data) +PreviousPage(Widget entry, XtPointer name, XtPointer data) { - PreviousPageAction (entry, NULL, NULL, NULL); - ResetMenuEntry (entry); + PreviousPageAction(entry, NULL, NULL, NULL); + ResetMenuEntry(entry); } static void -PreviousPageAction (Widget w, XEvent *xev, String *s, Cardinal *c) +PreviousPageAction(Widget w, XEvent *xev, String *s, Cardinal *c) { - Arg args[1]; - int number; + Arg args[1]; + int number; - XtSetArg (args[0], XtNpageNumber, &number); - XtGetValues (dvi, args, 1); - SetPageNumber (number-1); + XtSetArg(args[0], XtNpageNumber, &number); + XtGetValues(dvi, args, 1); + SetPageNumber(number - 1); } /*ARGSUSED*/ static void -SetResolution (Widget entry, XtPointer name, XtPointer data) +SetResolution(Widget entry, XtPointer name, XtPointer data) { - SetResolutionAction (entry, NULL, NULL, NULL); - ResetMenuEntry (entry); + SetResolutionAction(entry, NULL, NULL, NULL); + ResetMenuEntry(entry); } static void -SetResolutionAction (Widget w, XEvent *xev, String *s, Cardinal *c) +SetResolutionAction(Widget w, XEvent *xev, String *s, Cardinal *c) { - Arg args[1]; - int cur; + Arg args[1]; + int cur; - XtSetArg (args[0], XtNscreenResolution, &cur); - XtGetValues (dvi, args, 1); - snprintf (resolutionBuf, sizeof(resolutionBuf), "%d", cur); - MakePrompt (toplevel, "Screen resolution:", NewResolution, resolutionBuf); + XtSetArg(args[0], XtNscreenResolution, &cur); + XtGetValues(dvi, args, 1); + snprintf(resolutionBuf, sizeof(resolutionBuf), "%d", cur); + MakePrompt(toplevel, "Screen resolution:", NewResolution, resolutionBuf); } /*ARGSUSED*/ static void -OpenFile (Widget entry, XtPointer name, XtPointer data) +OpenFile(Widget entry, XtPointer name, XtPointer data) { - OpenFileAction (entry, NULL, NULL, NULL); - ResetMenuEntry (entry); + OpenFileAction(entry, NULL, NULL, NULL); + ResetMenuEntry(entry); } static void -OpenFileAction (Widget w, XEvent *xev, String *s, Cardinal *c) +OpenFileAction(Widget w, XEvent *xev, String *s, Cardinal *c) { if (current_file_name[0]) - strcpy (fileBuf, current_file_name); + strcpy(fileBuf, current_file_name); else - fileBuf[0] = '\0'; - MakePrompt (toplevel, "File to open:", NewFile, fileBuf); + fileBuf[0] = '\0'; + MakePrompt(toplevel, "File to open:", NewFile, fileBuf); } /*ARGSUSED*/ static void -RevisitFile (Widget entry, XtPointer name, XtPointer data) +RevisitFile(Widget entry, XtPointer name, XtPointer data) { - RevisitFileAction (entry, NULL, NULL, NULL); - ResetMenuEntry (entry); + RevisitFileAction(entry, NULL, NULL, NULL); + ResetMenuEntry(entry); } static void -RevisitFileAction (Widget w, XEvent *xev, String *s, Cardinal *c) +RevisitFileAction(Widget w, XEvent *xev, String *s, Cardinal *c) { if (current_file_name[0]) - VisitFile (current_file_name, FALSE); + VisitFile(current_file_name, FALSE); } /*ARGSUSED*/ static void -Quit (Widget entry, XtPointer closure, XtPointer data) +Quit(Widget entry, XtPointer closure, XtPointer data) { - QuitAction (entry, NULL, NULL, NULL); + QuitAction(entry, NULL, NULL, NULL); } static void -QuitAction (Widget w, XEvent *xev, String *s, Cardinal *c) +QuitAction(Widget w, XEvent *xev, String *s, Cardinal *c) { - exit (0); + exit(0); } static Widget promptShell, promptDialog; static void (*promptfunction)(char *); /* ARGSUSED */ -static -void CancelAction (Widget widget, XEvent *event, - String *params, Cardinal *num_params) +static void +CancelAction(Widget widget, XEvent *event, + String *params, Cardinal *num_params) { if (promptShell) { - XtSetKeyboardFocus(toplevel, (Widget) None); - XtDestroyWidget(promptShell); - promptShell = (Widget) 0; + XtSetKeyboardFocus(toplevel, (Widget) None); + XtDestroyWidget(promptShell); + promptShell = (Widget) 0; } } - /* ARGSUSED */ -static -void AcceptAction (Widget widget, XEvent *event, - String *params, Cardinal *num_params) +static void +AcceptAction(Widget widget, XEvent *event, + String *params, Cardinal *num_params) { - (*promptfunction)(XawDialogGetValueString(promptDialog)); - CancelAction (widget, event, params, num_params); + (*promptfunction) (XawDialogGetValueString(promptDialog)); + CancelAction(widget, event, params, num_params); } -static -void Noop (Widget w, XEvent *xev, String *s, Cardinal *c) +static void +Noop(Widget w, XEvent *xev, String *s, Cardinal *c) { } @@ -525,55 +530,56 @@ static void MakePrompt(Widget centerw, const char *prompt, void (*func)(char *), char *def) { static Arg dialogArgs[] = { - {XtNlabel, (XtArgVal) 0}, - {XtNvalue, (XtArgVal) 0}, + {XtNlabel,(XtArgVal) 0}, + {XtNvalue,(XtArgVal) 0}, }; Arg valueArgs[1]; Arg centerArgs[2]; - Position source_x, source_y; - Position dest_x, dest_y; + Position source_x, source_y; + Position dest_x, dest_y; Dimension center_width, center_height; Dimension prompt_width, prompt_height; - Widget valueWidget; - - CancelAction ((Widget)NULL, (XEvent *) 0, (String *) 0, (Cardinal *) 0); - promptShell = XtCreatePopupShell ("promptShell", transientShellWidgetClass, - toplevel, NULL, (Cardinal) 0); - dialogArgs[0].value = (XtArgVal)prompt; - dialogArgs[1].value = (XtArgVal)def; - promptDialog = XtCreateManagedWidget( "promptDialog", dialogWidgetClass, - promptShell, dialogArgs, XtNumber (dialogArgs)); + Widget valueWidget; + + CancelAction((Widget) NULL, (XEvent *) 0, (String *) 0, (Cardinal *) 0); + promptShell = XtCreatePopupShell("promptShell", transientShellWidgetClass, + toplevel, NULL, (Cardinal) 0); + dialogArgs[0].value = (XtArgVal) prompt; + dialogArgs[1].value = (XtArgVal) def; + promptDialog = XtCreateManagedWidget("promptDialog", dialogWidgetClass, + promptShell, dialogArgs, + XtNumber(dialogArgs)); XawDialogAddButton(promptDialog, "accept", NULL, NULL); XawDialogAddButton(promptDialog, "cancel", NULL, NULL); - valueWidget = XtNameToWidget (promptDialog, "value"); + valueWidget = XtNameToWidget(promptDialog, "value"); if (valueWidget) { - XtSetArg (valueArgs[0], XtNresizable, TRUE); - XtSetValues (valueWidget, valueArgs, 1); - /* - * as resizable isn't set until just above, the - * default value will be displayed incorrectly. - * rectify the situation by resetting the values - */ - XtSetValues (promptDialog, dialogArgs, XtNumber (dialogArgs)); + XtSetArg(valueArgs[0], XtNresizable, TRUE); + XtSetValues(valueWidget, valueArgs, 1); + /* + * as resizable isn't set until just above, the + * default value will be displayed incorrectly. + * rectify the situation by resetting the values + */ + XtSetValues(promptDialog, dialogArgs, XtNumber(dialogArgs)); } - XtSetKeyboardFocus (promptDialog, valueWidget); - XtSetKeyboardFocus (toplevel, valueWidget); - XtRealizeWidget (promptShell); + XtSetKeyboardFocus(promptDialog, valueWidget); + XtSetKeyboardFocus(toplevel, valueWidget); + XtRealizeWidget(promptShell); /* * place the widget in the center of the "parent" */ - XtSetArg (centerArgs[0], XtNwidth, ¢er_width); - XtSetArg (centerArgs[1], XtNheight, ¢er_height); - XtGetValues (centerw, centerArgs, 2); - XtSetArg (centerArgs[0], XtNwidth, &prompt_width); - XtSetArg (centerArgs[1], XtNheight, &prompt_height); - XtGetValues (promptShell, centerArgs, 2); - source_x = (int)(center_width - prompt_width) / 2; - source_y = (int)(center_height - prompt_height) / 3; - XtTranslateCoords (centerw, source_x, source_y, &dest_x, &dest_y); - XtSetArg (centerArgs[0], XtNx, dest_x); - XtSetArg (centerArgs[1], XtNy, dest_y); - XtSetValues (promptShell, centerArgs, 2); + XtSetArg(centerArgs[0], XtNwidth, ¢er_width); + XtSetArg(centerArgs[1], XtNheight, ¢er_height); + XtGetValues(centerw, centerArgs, 2); + XtSetArg(centerArgs[0], XtNwidth, &prompt_width); + XtSetArg(centerArgs[1], XtNheight, &prompt_height); + XtGetValues(promptShell, centerArgs, 2); + source_x = (int) (center_width - prompt_width) / 2; + source_y = (int) (center_height - prompt_height) / 3; + XtTranslateCoords(centerw, source_x, source_y, &dest_x, &dest_y); + XtSetArg(centerArgs[0], XtNx, dest_x); + XtSetArg(centerArgs[1], XtNy, dest_y); + XtSetValues(promptShell, centerArgs, 2); XtMapWidget(promptShell); promptfunction = func; } |