| 1 |
/* |
| 2 |
* Copyright (c) 2013-2022 the xdvik development team |
| 3 |
* |
| 4 |
* Permission is hereby granted, free of charge, to any person obtaining a copy |
| 5 |
* of this software and associated documentation files (the "Software"), to |
| 6 |
* deal in the Software without restriction, including without limitation the |
| 7 |
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 8 |
* sell copies of the Software, and to permit persons to whom the Software is |
| 9 |
* furnished to do so, subject to the following conditions: |
| 10 |
* |
| 11 |
* The above copyright notice and this permission notice shall be included in |
| 12 |
* all copies or substantial portions of the Software. |
| 13 |
* |
| 14 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 15 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 17 |
* PAUL VOJTA OR ANY OTHER AUTHOR OF THIS SOFTWARE BE LIABLE FOR ANY CLAIM, |
| 18 |
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 19 |
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR |
| 20 |
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 21 |
* |
| 22 |
*/ |
| 23 |
|
| 24 |
#include "xdvi-config.h" |
| 25 |
|
| 26 |
#include <locale.h> |
| 27 |
|
| 28 |
#include <X11/Intrinsic.h> |
| 29 |
|
| 30 |
#include "kpathsea/proginit.h" |
| 31 |
#include "kpathsea/expand.h" |
| 32 |
|
| 33 |
#include "xdvi.h" |
| 34 |
#include "util.h" |
| 35 |
#include "x_util.h" |
| 36 |
#include "sfSelFile.h" |
| 37 |
#include "my-snprintf.h" |
| 38 |
#include "dvi-init.h" |
| 39 |
#include "filehist.h" |
| 40 |
#include "mag.h" |
| 41 |
#include "message-window.h" |
| 42 |
|
| 43 |
#if FREETYPE |
| 44 |
# include <ft2build.h> |
| 45 |
# include FT_FREETYPE_H |
| 46 |
#endif |
| 47 |
|
| 48 |
#define STRINGIFY(x) #x |
| 49 |
#define TOSTRING(x) STRINGIFY(x) |
| 50 |
#ifndef XDVI_KPSE_PROG_NAME |
| 51 |
#define XDVI_KPSE_PROG_NAME xdvi |
| 52 |
#endif |
| 53 |
static const char *xdvi_kpse_prog_name = TOSTRING(XDVI_KPSE_PROG_NAME); |
| 54 |
#undef STRINGIFY |
| 55 |
#undef TOSTRING |
| 56 |
|
| 57 |
static char XtRBool3[] = "Bool3"; /* resource for Bool3 */ |
| 58 |
|
| 59 |
/* get these before setting `application_resources' */ |
| 60 |
static XtResource xdvirc_resources[] = { |
| 61 |
{"noInitFile", "NoInitFile", XtRBoolean, sizeof(Boolean), |
| 62 |
XtOffsetOf(struct x_resources, no_init_file), XtRString, "false"}, |
| 63 |
}; |
| 64 |
|
| 65 |
|
| 66 |
static XrmOptionDescRec options[] = { |
| 67 |
{"-q", ".noInitFile", XrmoptionNoArg, (XPointer)"on" }, |
| 68 |
{"+q", ".noInitFile", XrmoptionNoArg, (XPointer)"off" }, |
| 69 |
{"-geometry", ".geometry", XrmoptionSepArg, (XPointer)NULL }, |
| 70 |
#ifdef MOTIF |
| 71 |
/* to make `-font' and `-fn' options work, make them an alias for `fontList' */ |
| 72 |
{ "-font", "*fontList", XrmoptionSepArg, (XPointer)NULL }, |
| 73 |
{ "-fn", "*fontList", XrmoptionSepArg, (XPointer)NULL }, |
| 74 |
#endif |
| 75 |
{"-s", ".shrinkFactor", XrmoptionSepArg, (XPointer)NULL }, |
| 76 |
#ifndef VMS |
| 77 |
{"-S", ".densityPercent", XrmoptionSepArg, (XPointer)NULL }, |
| 78 |
#endif |
| 79 |
{"-density", ".densityPercent", XrmoptionSepArg, (XPointer)NULL }, |
| 80 |
{"-noomega", ".omega", XrmoptionNoArg, (XPointer)"off" }, |
| 81 |
{"+noomega", ".omega", XrmoptionNoArg, (XPointer)"on" }, |
| 82 |
#if COLOR |
| 83 |
{"-nocolor", ".color", XrmoptionNoArg, (XPointer)"off" }, |
| 84 |
{"+nocolor", ".color", XrmoptionNoArg, (XPointer)"on" }, |
| 85 |
#endif |
| 86 |
#ifdef GREY |
| 87 |
{"-nogrey", ".grey", XrmoptionNoArg, (XPointer)"off" }, |
| 88 |
{"+nogrey", ".grey", XrmoptionNoArg, (XPointer)"on" }, |
| 89 |
{"-gamma", ".gamma", XrmoptionSepArg, (XPointer)NULL }, |
| 90 |
{"-nomatchinverted",".matchInverted", XrmoptionNoArg, (XPointer)"off" }, |
| 91 |
{"+nomatchinverted",".matchInverted", XrmoptionNoArg, (XPointer)"on" }, |
| 92 |
/* {"-invertedfactor", ".invertedFactor", XrmoptionSepArg, (XPointer)NULL }, */ |
| 93 |
{"-install", ".install", XrmoptionNoArg, (XPointer)"on" }, |
| 94 |
{"-noinstall", ".install", XrmoptionNoArg, (XPointer)"off" }, |
| 95 |
#endif |
| 96 |
{"-rulecolor", ".ruleColor", XrmoptionSepArg, (XPointer)NULL }, |
| 97 |
{"-p", ".pixelsPerInch", XrmoptionSepArg, (XPointer)NULL }, |
| 98 |
{"-margins", ".Margin", XrmoptionSepArg, (XPointer)NULL }, |
| 99 |
{"-sidemargin", ".sideMargin", XrmoptionSepArg, (XPointer)NULL }, |
| 100 |
{"-topmargin", ".topMargin", XrmoptionSepArg, (XPointer)NULL }, |
| 101 |
{"-offsets", ".Offset", XrmoptionSepArg, (XPointer)NULL }, |
| 102 |
{"-xoffset", ".xOffset", XrmoptionSepArg, (XPointer)NULL }, |
| 103 |
{"-yoffset", ".yOffset", XrmoptionSepArg, (XPointer)NULL }, |
| 104 |
{"-paper", ".paper", XrmoptionSepArg, (XPointer)NULL }, |
| 105 |
{"-altfont", ".altFont", XrmoptionSepArg, (XPointer)NULL }, |
| 106 |
#ifdef MKTEXPK |
| 107 |
{"-nomakepk", ".makePk", XrmoptionNoArg, (XPointer)"off" }, |
| 108 |
{"+nomakepk", ".makePk", XrmoptionNoArg, (XPointer)"on" }, |
| 109 |
#endif |
| 110 |
{"-mfmode", ".mfMode", XrmoptionSepArg, (XPointer)NULL }, |
| 111 |
{"-editor", ".editor", XrmoptionSepArg, (XPointer)NULL }, |
| 112 |
#if FREETYPE |
| 113 |
{"-notype1fonts", ".type1", XrmoptionNoArg, (XPointer)"off" }, |
| 114 |
{"+notype1fonts", ".type1", XrmoptionNoArg, (XPointer)"on" }, |
| 115 |
#endif |
| 116 |
#if HAVE_XI21 |
| 117 |
{"-noxi2scrolling", ".xi2Scrolling", XrmoptionNoArg, (XPointer)"off"}, |
| 118 |
{"+noxi2scrolling", ".xi2Scrolling", XrmoptionNoArg, (XPointer)"on"}, |
| 119 |
#endif |
| 120 |
{"-sourceposition", ".sourcePosition", XrmoptionSepArg, (XPointer)NULL }, |
| 121 |
{"-findstring", ".findString", XrmoptionSepArg, (XPointer)NULL }, |
| 122 |
{"-text-encoding", ".textEncoding", XrmoptionSepArg, (XPointer)NULL }, |
| 123 |
{"-unique", ".unique", XrmoptionNoArg, (XPointer)"on" }, |
| 124 |
{"+unique", ".unique", XrmoptionNoArg, (XPointer)"off" }, |
| 125 |
{"-nofork", ".fork", XrmoptionNoArg, (XPointer)"off" }, |
| 126 |
{"+nofork", ".fork", XrmoptionNoArg, (XPointer)"on" }, |
| 127 |
#ifdef RGB_ANTI_ALIASING |
| 128 |
{"-subpixels", ".subPixels", XrmoptionSepArg, (XPointer)NULL }, |
| 129 |
#endif |
| 130 |
{"-l", ".listFonts", XrmoptionNoArg, (XPointer)"on" }, |
| 131 |
{"+l", ".listFonts", XrmoptionNoArg, (XPointer)"off" }, |
| 132 |
{"-watchfile", ".watchFile", XrmoptionSepArg, (XPointer)NULL }, |
| 133 |
{"-expertmode", ".expertMode", XrmoptionSepArg, (XPointer)NULL }, |
| 134 |
{"-expert", ".expert", XrmoptionNoArg, (XPointer)"on" }, |
| 135 |
{"+expert", ".expert", XrmoptionNoArg, (XPointer)"off" }, |
| 136 |
{"+statusline", ".statusline", XrmoptionNoArg, (XPointer)"off" }, |
| 137 |
{"-statusline", ".statusline", XrmoptionNoArg, (XPointer)"on" }, |
| 138 |
{"+useTeXpages", ".useTeXPages", XrmoptionNoArg, (XPointer)"off" }, |
| 139 |
{"-useTeXpages", ".useTeXPages", XrmoptionNoArg, (XPointer)"on" }, |
| 140 |
{"-mgs", ".magnifierSize1", XrmoptionSepArg, (XPointer)NULL }, |
| 141 |
{"-mgs1", ".magnifierSize1", XrmoptionSepArg, (XPointer)NULL }, |
| 142 |
{"-mgs2", ".magnifierSize2", XrmoptionSepArg, (XPointer)NULL }, |
| 143 |
{"-mgs3", ".magnifierSize3", XrmoptionSepArg, (XPointer)NULL }, |
| 144 |
{"-mgs4", ".magnifierSize4", XrmoptionSepArg, (XPointer)NULL }, |
| 145 |
{"-mgs5", ".magnifierSize5", XrmoptionSepArg, (XPointer)NULL }, |
| 146 |
{"-warnspecials", ".warnSpecials", XrmoptionNoArg, (XPointer)"on" }, |
| 147 |
{"+warnspecials", ".warnSpecials", XrmoptionNoArg, (XPointer)"off" }, |
| 148 |
{"-hush", ".Hush", XrmoptionNoArg, (XPointer)"on" }, |
| 149 |
{"+hush", ".Hush", XrmoptionNoArg, (XPointer)"off" }, |
| 150 |
{"-hushchars", ".hushLostChars", XrmoptionNoArg, (XPointer)"on" }, |
| 151 |
{"+hushchars", ".hushLostChars", XrmoptionNoArg, (XPointer)"off" }, |
| 152 |
{"-hushchecksums", ".hushChecksums", XrmoptionNoArg, (XPointer)"on" }, |
| 153 |
{"+hushchecksums", ".hushChecksums", XrmoptionNoArg, (XPointer)"off" }, |
| 154 |
{"-hushstdout", ".hushStdout", XrmoptionNoArg, (XPointer)"on" }, |
| 155 |
{"+hushstdout", ".hushStdout", XrmoptionNoArg, (XPointer)"off" }, |
| 156 |
{"-hushbell", ".hushBell", XrmoptionNoArg, (XPointer)"on" }, |
| 157 |
{"+hushbell", ".hushBell", XrmoptionNoArg, (XPointer)"off" }, |
| 158 |
{"-safer", ".safer", XrmoptionNoArg, (XPointer)"on" }, |
| 159 |
{"+safer", ".safer", XrmoptionNoArg, (XPointer)"off" }, |
| 160 |
{"-fg", ".foreground", XrmoptionSepArg, (XPointer)NULL }, |
| 161 |
{"-foreground", ".foreground", XrmoptionSepArg, (XPointer)NULL }, |
| 162 |
{"-bg", ".background", XrmoptionSepArg, (XPointer)NULL }, |
| 163 |
{"-background", ".background", XrmoptionSepArg, (XPointer)NULL }, |
| 164 |
{"-hl", ".highlight", XrmoptionSepArg, (XPointer)NULL }, |
| 165 |
{"-cr", ".cursorColor", XrmoptionSepArg, (XPointer)NULL }, |
| 166 |
{"-icongeometry", ".iconGeometry", XrmoptionSepArg, (XPointer)NULL }, |
| 167 |
{"-keep", ".keepPosition", XrmoptionNoArg, (XPointer)"on" }, |
| 168 |
{"+keep", ".keepPosition", XrmoptionNoArg, (XPointer)"off" }, |
| 169 |
{"-copy", ".copy", XrmoptionNoArg, (XPointer)"on" }, |
| 170 |
{"+copy", ".copy", XrmoptionNoArg, (XPointer)"off" }, |
| 171 |
{"-thorough", ".thorough", XrmoptionNoArg, (XPointer)"on" }, |
| 172 |
{"+thorough", ".thorough", XrmoptionNoArg, (XPointer)"off" }, |
| 173 |
{"-fullscreen", ".fullscreen", XrmoptionNoArg, (XPointer)"on" }, |
| 174 |
{"+fullscreen", ".fullscreen", XrmoptionNoArg, (XPointer)"off" }, |
| 175 |
{"-pause", ".pause", XrmoptionNoArg, (XPointer)"on" }, |
| 176 |
{"+pause", ".pause", XrmoptionNoArg, (XPointer)"off" }, |
| 177 |
{"-pausespecial", ".pauseSpecial", XrmoptionSepArg, (XPointer)NULL }, |
| 178 |
{"-wheelunit", ".wheelUnit", XrmoptionSepArg, (XPointer)NULL }, |
| 179 |
{"-mousemode", ".mouseMode", XrmoptionSepArg, (XPointer)NULL }, |
| 180 |
#ifdef PS |
| 181 |
{"-postscript", ".postscript", XrmoptionSepArg, (XPointer)NULL }, |
| 182 |
{"-allowshell", ".allowShell", XrmoptionNoArg, (XPointer)"on" }, |
| 183 |
{"+allowshell", ".allowShell", XrmoptionNoArg, (XPointer)"off" }, |
| 184 |
# ifdef PS_DPS |
| 185 |
{"-nodps", ".dps", XrmoptionNoArg, (XPointer)"off" }, |
| 186 |
{"+nodps", ".dps", XrmoptionNoArg, (XPointer)"on" }, |
| 187 |
# endif |
| 188 |
# ifdef PS_NEWS |
| 189 |
{"-nonews", ".news", XrmoptionNoArg, (XPointer)"off" }, |
| 190 |
{"+nonews", ".news", XrmoptionNoArg, (XPointer)"on" }, |
| 191 |
# endif |
| 192 |
# ifdef PS_GS |
| 193 |
{"-noghostscript", ".ghostscript", XrmoptionNoArg, (XPointer)"off" }, |
| 194 |
{"+noghostscript", ".ghostscript", XrmoptionNoArg, (XPointer)"on" }, |
| 195 |
{"-nogssafer", ".gsSafer", XrmoptionNoArg, (XPointer)"off" }, |
| 196 |
{"+nogssafer", ".gsSafer", XrmoptionNoArg, (XPointer)"on" }, |
| 197 |
{"-gsalpha", ".gsAlpha", XrmoptionNoArg, (XPointer)"on" }, |
| 198 |
{"+gsalpha", ".gsAlpha", XrmoptionNoArg, (XPointer)"off" }, |
| 199 |
{"-interpreter", ".interpreter", XrmoptionSepArg, (XPointer)NULL }, |
| 200 |
{"-gspalette", ".palette", XrmoptionSepArg, (XPointer)NULL }, |
| 201 |
# endif |
| 202 |
# ifdef MAGICK |
| 203 |
{"-magick", ".ImageMagick", XrmoptionNoArg, (XPointer)"on" }, |
| 204 |
{"+magick", ".ImageMagick", XrmoptionNoArg, (XPointer)"off" }, |
| 205 |
{"-magick_cache", ".MagickCache", XrmoptionSepArg, (XPointer)NULL }, |
| 206 |
# endif |
| 207 |
#endif /* PS */ |
| 208 |
{"-noscan", ".prescan", XrmoptionNoArg, (XPointer)"off" }, |
| 209 |
{"+noscan", ".prescan", XrmoptionNoArg, (XPointer)"on" }, |
| 210 |
{"-notempfile", ".tempFile", XrmoptionNoArg, (XPointer)"off" }, |
| 211 |
{"+notempfile", ".tempFile", XrmoptionNoArg, (XPointer)"on" }, |
| 212 |
{"-dvipspath", ".dvipsPath", XrmoptionSepArg, (XPointer)NULL }, |
| 213 |
{"-ps2pdfpath", ".ps2pdfPath", XrmoptionSepArg, (XPointer)NULL }, |
| 214 |
{"-debug", ".debugLevel", XrmoptionSepArg, (XPointer)NULL }, |
| 215 |
{"-linkstyle", ".linkStyle", XrmoptionSepArg, (XPointer)NULL }, |
| 216 |
{"-linkcolor", ".linkColor", XrmoptionSepArg, (XPointer)NULL }, |
| 217 |
{"-visitedlinkcolor",".visitedLinkColor", XrmoptionSepArg, (XPointer)NULL }, |
| 218 |
{"-browser", ".wwwBrowser", XrmoptionSepArg, (XPointer)NULL }, |
| 219 |
{"-anchorposition", ".anchorPosition", XrmoptionSepArg, (XPointer)NULL }, |
| 220 |
}; |
| 221 |
|
| 222 |
/* |
| 223 |
* Data for options processing. |
| 224 |
*/ |
| 225 |
static const char SILENT[] = " "; /* flag value for usage() */ |
| 226 |
static const char SUBST[] = "x"; /* another flag value */ |
| 227 |
static const char USAGESTR_END_MARKER[] = "__USAGE_END_MARKER__"; /* end marker */ |
| 228 |
|
| 229 |
/* Here, list usage values for options that have `XrmoptionSepArg' set. |
| 230 |
TODO: what does the `^' stand for? |
| 231 |
*/ |
| 232 |
static const char *usagestr[] = { |
| 233 |
/* geometry */ SILENT, |
| 234 |
#ifdef MOTIF |
| 235 |
/* font */ SILENT, |
| 236 |
/* f */ SILENT, |
| 237 |
#endif |
| 238 |
/* shrinkFactor */ "shrink", |
| 239 |
#ifndef VMS |
| 240 |
/* S */ "density", |
| 241 |
/* density */ SILENT, |
| 242 |
#else |
| 243 |
/* density */ "density", |
| 244 |
#endif |
| 245 |
#ifdef GREY |
| 246 |
/* gamma */ "float", |
| 247 |
#endif |
| 248 |
/* rulecolor */ "color", |
| 249 |
/* p */ "pixels", |
| 250 |
/* margins */ "dimen", |
| 251 |
/* sidemargin */ "dimen", |
| 252 |
/* topmargin */ "dimen", |
| 253 |
/* offsets */ "dimen", |
| 254 |
/* xoffset */ "dimen", |
| 255 |
/* yoffset */ "dimen", |
| 256 |
/* paper */ "papertype", |
| 257 |
/* altfont */ "font", |
| 258 |
/* mfmode */ "mode-def", |
| 259 |
/* editor */ "editor", |
| 260 |
/* sourceposition */ "linenumber[ ]*filename", |
| 261 |
/* findstring */ "string", |
| 262 |
/* textencoding */ "charset", |
| 263 |
#ifdef RGB_ANTI_ALIASING |
| 264 |
/* subpixels */ "{rgb,bgr}[ i1 i2 i3]", |
| 265 |
#endif |
| 266 |
/* rv */ "^-l", "-rv", |
| 267 |
/* watchfile */ "secs", |
| 268 |
/* expertmode */ "flag", |
| 269 |
/* mgs */ SUBST, |
| 270 |
/* mgs1 */ SILENT, |
| 271 |
/* mgs2 */ SILENT, |
| 272 |
/* mgs3 */ SILENT, |
| 273 |
/* mgs4 */ SILENT, |
| 274 |
/* mgs5 */ SILENT, |
| 275 |
/* fg */ "color", |
| 276 |
/* foreground */ SILENT, |
| 277 |
/* bg */ "color", |
| 278 |
/* background */ SILENT, |
| 279 |
/* hl */ "color", |
| 280 |
/* cr */ "color", |
| 281 |
#ifndef VMS |
| 282 |
/* display */ "^-cr", "-display <host:display>", |
| 283 |
#else |
| 284 |
/* display */ "^-cr", "-display <host::display>", |
| 285 |
#endif |
| 286 |
/* geometry */ "^-cr", "-geometry <geometry>", |
| 287 |
/* icongeometry */ "geometry", |
| 288 |
/* iconic */ "^-icongeometry", "-iconic", |
| 289 |
/* font */ "^-icongeometry", "-font <font>", |
| 290 |
/* pausespecial */ "string", |
| 291 |
/* wheelunit */ "pixels", |
| 292 |
/* mousemode */ "0|1|2", |
| 293 |
#ifdef PS |
| 294 |
/* postscript */ "0|1|2", |
| 295 |
# ifdef PS_GS |
| 296 |
/* interpreter */ "path", |
| 297 |
/* gspalette */ "monochrome|grayscale|color", |
| 298 |
# endif |
| 299 |
# ifdef MAGICK |
| 300 |
/* magick_cache */ "size[k|K|m|M|g|G]", |
| 301 |
# endif |
| 302 |
#endif |
| 303 |
/* dvipspath */ "path", |
| 304 |
/* ps2pdfpath */ "path", |
| 305 |
/* debug */ "bitmask|string[,string ...]", |
| 306 |
/* linkstyle */ "0|1|2|3", |
| 307 |
/* linkcolor */ "color", |
| 308 |
/* visitedlinkcolor */ "color", |
| 309 |
/* browser */ "WWWbrowser", |
| 310 |
/* anchorposition */ "anchor", |
| 311 |
/* [end marker] */ USAGESTR_END_MARKER |
| 312 |
}; |
| 313 |
|
| 314 |
static const char *SUBST_VAL[] = { "-mgs[n] <size>" }; |
| 315 |
|
| 316 |
static int |
| 317 |
compare_strings(const void *s, const void *t) |
| 318 |
{ |
| 319 |
const char *const *ss = (const char *const *)s; |
| 320 |
const char *const *tt = (const char *const *)t; |
| 321 |
|
| 322 |
return memicmp(*ss, *tt, strlen(*tt) + 1); /* also check for final 0 */ |
| 323 |
} |
| 324 |
|
| 325 |
static void |
| 326 |
usage(int exitval) |
| 327 |
{ |
| 328 |
XrmOptionDescRec *opt; |
| 329 |
const char **usageptr = usagestr; |
| 330 |
const char **sv = SUBST_VAL; |
| 331 |
const char *str1; |
| 332 |
const char *str2; |
| 333 |
const char *sorted_options[XtNumber(options)]; |
| 334 |
char buf[256]; |
| 335 |
char *s; |
| 336 |
int col, n; |
| 337 |
size_t nopt = 0, k; |
| 338 |
|
| 339 |
for (opt = options; opt < options + XtNumber(options); ++opt) { |
| 340 |
str1 = opt->option; |
| 341 |
if (*str1 != '-') |
| 342 |
continue; |
| 343 |
|
| 344 |
ASSERT(*usageptr != USAGESTR_END_MARKER, "Too few elements in usageptr[]"); |
| 345 |
|
| 346 |
str2 = NULL; |
| 347 |
if (opt->argKind != XrmoptionNoArg) { |
| 348 |
str2 = *usageptr++; |
| 349 |
if (str2 == SILENT) |
| 350 |
continue; |
| 351 |
if (str2 == SUBST) { |
| 352 |
str1 = *sv++; |
| 353 |
str2 = NULL; |
| 354 |
} |
| 355 |
} |
| 356 |
#if 0 |
| 357 |
fprintf(stderr, "str1: %s, str2: %s\n", str1, str2); |
| 358 |
#endif |
| 359 |
for (;;) { |
| 360 |
if (str2 == NULL) |
| 361 |
sprintf(buf, "[%.80s]", str1); |
| 362 |
else |
| 363 |
sprintf(buf, "[%.80s <%.80s>]", str1, str2); |
| 364 |
|
| 365 |
/* fprintf(stderr, "number of options: %d; len of usagestr: %d\n", */ |
| 366 |
/* XtNumber(options), XtNumber(usagestr)); */ |
| 367 |
ASSERT(nopt < XtNumber(options), "index out of range"); |
| 368 |
/* fprintf(stderr, "sorted: %d=%s\n", nopt, buf); */ |
| 369 |
sorted_options[nopt++] = xstrdup(buf); |
| 370 |
|
| 371 |
if (**usageptr != '^' || strcmp(*usageptr + 1, opt->option) != 0) |
| 372 |
break; |
| 373 |
++usageptr; |
| 374 |
str1 = *usageptr++; |
| 375 |
str2 = NULL; |
| 376 |
} |
| 377 |
} |
| 378 |
|
| 379 |
ASSERT(*usageptr == USAGESTR_END_MARKER, "Too many elements in usageptr[]"); |
| 380 |
|
| 381 |
/* fprintf(stderr, "elems in sorted options: %d\n", nopt); */ |
| 382 |
qsort((void*)sorted_options, |
| 383 |
nopt, |
| 384 |
sizeof(sorted_options[0]), |
| 385 |
compare_strings); |
| 386 |
|
| 387 |
s = xstrdup("Usage: "); |
| 388 |
s = xstrcat(s, XDVI_PROGNAME); /* use `xdvi' here, not `xdvik' or `xdvi-xaw.bin' or ... */ |
| 389 |
s = xstrcat(s, " [+[<page>]] [-h | --help] [-v | --version] [-license]"); |
| 390 |
|
| 391 |
col = strlen(s); |
| 392 |
fputs(s, stdout); |
| 393 |
|
| 394 |
for (k = 0; k < nopt; ++k) { |
| 395 |
n = strlen(sorted_options[k]); |
| 396 |
if (col + n < 80) |
| 397 |
putc(' ', stdout); |
| 398 |
else { |
| 399 |
fputs("\n\t", stdout); |
| 400 |
col = 8 - 1; |
| 401 |
} |
| 402 |
fputs(sorted_options[k], stdout); |
| 403 |
col += n + 1; |
| 404 |
} |
| 405 |
|
| 406 |
/* put this in an extra line, to emphasize that it must come last */ |
| 407 |
fputs("\n\t[dvi_file]\n", stdout); |
| 408 |
|
| 409 |
xdvi_exit(exitval); |
| 410 |
} |
| 411 |
|
| 412 |
|
| 413 |
static void |
| 414 |
display_bug_reporting_info(void) |
| 415 |
{ |
| 416 |
printf("Please send bug reports, feature requests etc. to one of:\n" |
| 417 |
" http://sourceforge.net/tracker/?group_id=23164&atid=377580\n" |
| 418 |
" [email protected] (http://tug.org/mailman/listinfo/tex-k)\n\n" |
| 419 |
"\n"); |
| 420 |
} |
| 421 |
|
| 422 |
static void |
| 423 |
display_licensing_info(void) |
| 424 |
{ |
| 425 |
fputs("Licenses: X Consortium license, GNU Library General Public\n" |
| 426 |
"License, GNU General Public License (use option `-license'\n" |
| 427 |
"for more details). There is NO WARRANTY of anything.\n\n", stdout); |
| 428 |
} |
| 429 |
|
| 430 |
static void |
| 431 |
display_long_licensing_info(void) |
| 432 |
{ |
| 433 |
fputs("The major parts of Xdvik are licensed under the X Consortium license.\n" |
| 434 |
"Parts (encoding.c) are licensed under the GNU General Public License.\n" |
| 435 |
"Xdvik uses the following libraries:\n" |
| 436 |
"- The kpathsea library, licensed in part under the GNU General Public\n" |
| 437 |
" License, in part under the GNU Library General Public License.\n" |
| 438 |
"- FreeType2, licensed under the GNU General Public License.\n" |
| 439 |
"There is NO WARRANTY of anything.\n\n", stdout); |
| 440 |
} |
| 441 |
|
| 442 |
static char * |
| 443 |
is_good_dvi_file(const char *filename, Boolean from_history) |
| 444 |
{ |
| 445 |
static char canonical_path[MAXPATHLEN + 1]; |
| 446 |
Boolean tried_dvi_extension = False; |
| 447 |
/* following allocates real_filename */ |
| 448 |
char *real_filename = find_dvi_file(filename, &tried_dvi_extension, from_history); |
| 449 |
char *ret; |
| 450 |
FILE *f = NULL; |
| 451 |
dviErrFlagT errflag; |
| 452 |
|
| 453 |
if (real_filename == NULL) |
| 454 |
return NULL; |
| 455 |
|
| 456 |
if ((ret = REALPATH(real_filename, canonical_path)) == NULL) { |
| 457 |
/* REALPATH failed, use real_filename */ |
| 458 |
size_t n = strlen(real_filename); |
| 459 |
if (n >= MAXPATHLEN) { |
| 460 |
n = MAXPATHLEN - 1; |
| 461 |
} |
| 462 |
|
| 463 |
memcpy(canonical_path, real_filename, n); |
| 464 |
canonical_path[n] = '\0'; |
| 465 |
ret = canonical_path; |
| 466 |
} |
| 467 |
free(real_filename); |
| 468 |
|
| 469 |
/* check for correct DVI files */ |
| 470 |
if ((f = XFOPEN(ret, OPEN_MODE)) != NULL) { |
| 471 |
TRACE_EVENTS((stderr, "watching: new file opened successfully.")); |
| 472 |
if (process_preamble(f, &errflag) |
| 473 |
&& find_postamble(f, &errflag) |
| 474 |
&& read_postamble(f, &errflag, False |
| 475 |
#if DELAYED_MKTEXPK |
| 476 |
, False |
| 477 |
#endif |
| 478 |
)) { |
| 479 |
fclose(f); |
| 480 |
return ret; |
| 481 |
} |
| 482 |
fclose(f); |
| 483 |
if (!from_history) |
| 484 |
XDVI_FATAL((stderr, "%s: %s.", filename, get_dvi_error(errflag))); |
| 485 |
return NULL; |
| 486 |
} |
| 487 |
else { |
| 488 |
if (!from_history) |
| 489 |
XDVI_FATAL((stderr, "Could not open `%s': %s.", filename, strerror(errno))); |
| 490 |
return NULL; |
| 491 |
} |
| 492 |
} |
| 493 |
|
| 494 |
|
| 495 |
static char * |
| 496 |
get_filename_from_history(int *pageno) |
| 497 |
{ |
| 498 |
size_t i; |
| 499 |
/* loop through history, trying to get a good file */ |
| 500 |
for (i = 0; i < file_history_size(); i++) { |
| 501 |
char *ret, *test; |
| 502 |
|
| 503 |
if ((test = file_history_get_elem(i, pageno)) == NULL) |
| 504 |
return NULL; |
| 505 |
TRACE_FILES((stderr, "HISTORY %lu: |%s|", (unsigned long)i, test)); |
| 506 |
if ((ret = is_good_dvi_file(test, True)) != NULL) { |
| 507 |
TRACE_FILES((stderr, "SUCCESS: |%s|", test)); |
| 508 |
return ret; |
| 509 |
} |
| 510 |
} |
| 511 |
return NULL; |
| 512 |
} |
| 513 |
|
| 514 |
static void |
| 515 |
warn_about_prerelease_versions(void) |
| 516 |
{ |
| 517 |
int unstable_version = 0; |
| 518 |
if (strstr(XDVI_VERSION_INFO, "-cvs") != NULL) |
| 519 |
unstable_version = 1; |
| 520 |
else if (strstr(XDVI_VERSION_INFO, "-beta") != NULL) |
| 521 |
unstable_version = 2; |
| 522 |
|
| 523 |
if (unstable_version > 0) { |
| 524 |
printf("\n**********************************************************************\n"); |
| 525 |
printf("%s version %s,\n%s version.\n\n", XDVIK_PROGNAME, XDVI_VERSION_INFO, |
| 526 |
unstable_version == 1 ? "an unstable development" : "a beta testing"); |
| 527 |
printf("Want a stable version instead?\n" |
| 528 |
" -> please visit one of:\n" |
| 529 |
" http://xdvi.sourceforge.net/cvs-upgrade.html\n" |
| 530 |
" http://sourceforge.net/project/showfiles.php?group_id=23164\n\n" |
| 531 |
"Found a bug?\n" |
| 532 |
" -> please report it to:\n" |
| 533 |
" http://sourceforge.net/tracker/?group_id=23164&atid=377580\n\n" |
| 534 |
"Thanks for your support!\n"); |
| 535 |
printf("**********************************************************************\n"); |
| 536 |
} |
| 537 |
} |
| 538 |
|
| 539 |
/* |
| 540 |
Initialize internal data (most of them global ...) according to the values |
| 541 |
of resources/command-line arguments, warning user about illegal values |
| 542 |
etc. |
| 543 |
*/ |
| 544 |
static void |
| 545 |
init_check_resources(void) |
| 546 |
{ |
| 547 |
size_t i; |
| 548 |
|
| 549 |
if (resource.mfmode != NULL) { |
| 550 |
char *p; |
| 551 |
|
| 552 |
p = strrchr(resource.mfmode, ':'); |
| 553 |
if (p != NULL) { |
| 554 |
unsigned int len; |
| 555 |
char *p1; |
| 556 |
|
| 557 |
++p; |
| 558 |
len = p - resource.mfmode; |
| 559 |
p1 = xmalloc(len); |
| 560 |
memcpy(p1, resource.mfmode, len - 1); |
| 561 |
p1[len - 1] = '\0'; |
| 562 |
resource.mfmode = p1; |
| 563 |
resource.pixels_per_inch = atoi(p); |
| 564 |
} |
| 565 |
} |
| 566 |
if (currwin.shrinkfactor < 0) { |
| 567 |
XDVI_ERROR((stderr, "Invalid shrink factor: %d.", currwin.shrinkfactor)); |
| 568 |
usage(EXIT_FAILURE); |
| 569 |
} |
| 570 |
if (resource.density <= 0) { |
| 571 |
XDVI_ERROR((stderr, "Invalid shrink density: %d.", resource.density)); |
| 572 |
usage(EXIT_FAILURE); |
| 573 |
} |
| 574 |
if (resource.pixels_per_inch <= 0) { |
| 575 |
XDVI_ERROR((stderr, "Invalid dpi value: %d.", resource.pixels_per_inch)); |
| 576 |
usage(EXIT_FAILURE); |
| 577 |
} |
| 578 |
if (resource.link_style < 0 || resource.link_style > 3) { |
| 579 |
XDVI_ERROR((stderr, "Unrecognized value %d for resource \"linkstyle\" (valid range is 0 - 3); assuming 3.", |
| 580 |
resource.link_style)); |
| 581 |
resource.link_style = 3; |
| 582 |
} |
| 583 |
if (currwin.shrinkfactor > 1) { |
| 584 |
mane.shrinkfactor = currwin.shrinkfactor; /* otherwise it's 1 */ |
| 585 |
} |
| 586 |
|
| 587 |
#ifdef RGB_ANTI_ALIASING |
| 588 |
#warning Note: RGB Anti-aliasing enabled |
| 589 |
/* subpixel rendering */ |
| 590 |
resource.subpixel_order = SUBPIXEL_NONE; |
| 591 |
if (resource.sub_pixels != NULL) { |
| 592 |
int sum; |
| 593 |
|
| 594 |
if (memicmp(resource.sub_pixels, "rgb", 3) == 0) |
| 595 |
resource.subpixel_order = SUBPIXEL_RGB; |
| 596 |
else if (memicmp(resource.sub_pixels, "bgr", 3) == 0) |
| 597 |
resource.subpixel_order = SUBPIXEL_BGR; |
| 598 |
else if (memicmp(resource.sub_pixels, "none", 3) == 0) |
| 599 |
resource.subpixel_order = SUBPIXEL_NONE; |
| 600 |
else { |
| 601 |
XDVI_ERROR((stderr, |
| 602 |
"Unrecognized value \"%s\" for resource subpixels\n" |
| 603 |
"(possible values are: \"rgb\" or \"bgr\").", |
| 604 |
resource.sub_pixels)); |
| 605 |
xdvi_exit(EXIT_FAILURE); |
| 606 |
} |
| 607 |
/* get the energy distribution */ |
| 608 |
if (resource.subpixel_order == SUBPIXEL_RGB || resource.subpixel_order == SUBPIXEL_BGR) { |
| 609 |
const char *ptr = resource.sub_pixels + 3; |
| 610 |
while (isspace(*ptr)) |
| 611 |
ptr++; |
| 612 |
fprintf(stderr, "ptr: |%s|\n", ptr); |
| 613 |
resource.subpixel_energy[0] = 33.333; |
| 614 |
resource.subpixel_energy[1] = 33.333; |
| 615 |
resource.subpixel_energy[2] = 0.0; |
| 616 |
if (*ptr != '\0') { |
| 617 |
if (sscanf(ptr, "%f %f %f", |
| 618 |
&(resource.subpixel_energy[0]), |
| 619 |
&(resource.subpixel_energy[1]), |
| 620 |
&(resource.subpixel_energy[2])) |
| 621 |
!= 3) { |
| 622 |
XDVI_ERROR((stderr, |
| 623 |
"Illegal color mask `%s' for resource subpixels (should be: `n n n')\n", |
| 624 |
ptr)); |
| 625 |
} |
| 626 |
} |
| 627 |
|
| 628 |
sum = (int)(resource.subpixel_energy[0] + |
| 629 |
2 * resource.subpixel_energy[1] + |
| 630 |
2 * resource.subpixel_energy[2]); |
| 631 |
if (sum < 99 || sum > 100) { |
| 632 |
XDVI_WARNING((stderr, "energy values %f + 2 * %f + 2 * %f don't sum up to 100%%!\n", |
| 633 |
resource.subpixel_energy[0], resource.subpixel_energy[1], resource.subpixel_energy[2])); |
| 634 |
exit(1); |
| 635 |
} |
| 636 |
|
| 637 |
resource.subpixel_energy[0] /= 100.0; |
| 638 |
resource.subpixel_energy[1] /= 100.0; |
| 639 |
resource.subpixel_energy[2] /= 100.0; |
| 640 |
fprintf(stderr, "subpixel order: %s = %d; [%f %f %f]\n", |
| 641 |
resource.sub_pixels, resource.subpixel_order, |
| 642 |
resource.subpixel_energy[0], resource.subpixel_energy[1], resource.subpixel_energy[2]); |
| 643 |
} |
| 644 |
} |
| 645 |
#endif |
| 646 |
|
| 647 |
/* margins */ |
| 648 |
if (resource.sidemargin) |
| 649 |
resource.sidemargin_int = atopix(resource.sidemargin); |
| 650 |
if (resource.topmargin) |
| 651 |
resource.topmargin_int = atopix(resource.topmargin); |
| 652 |
resource.xoffset_int = resource.xoffset ? atopix_signed(resource.xoffset) |
| 653 |
: resource.pixels_per_inch; |
| 654 |
resource.yoffset_int = resource.yoffset ? atopix_signed(resource.yoffset) |
| 655 |
: resource.pixels_per_inch; |
| 656 |
|
| 657 |
/* paper type */ |
| 658 |
if (!set_paper_type(resource.paper)) { |
| 659 |
const char **p; |
| 660 |
char *helpmsg = xstrdup("Possible paper types are:\n "); |
| 661 |
const char **paper_types = get_paper_types(); |
| 662 |
for (p = paper_types; p < paper_types + get_paper_types_size(); p += 2) { |
| 663 |
if (**p == '\0') { /* next line of list */ |
| 664 |
helpmsg = xstrcat(helpmsg, "\n "); |
| 665 |
} |
| 666 |
else { |
| 667 |
helpmsg = xstrcat(helpmsg, *p); |
| 668 |
helpmsg = xstrcat(helpmsg, " "); |
| 669 |
} |
| 670 |
} |
| 671 |
helpmsg = xstrcat(helpmsg, |
| 672 |
"\n(the names ending with `r' are `rotated' or `landscape' variants).\n" |
| 673 |
"Alternatively, you can specify the dimensions as `WIDTHxHEIGHT', followed " |
| 674 |
"by a dimension unit (one of: pt pc in bp cm mm dd cc sp)."); |
| 675 |
/* also dump it to stderr ... */ |
| 676 |
fprintf(stderr, |
| 677 |
"Unrecognized value `%s' for paper type option; using %s instead.\n%s\n", |
| 678 |
resource.paper, DEFAULT_PAPER, helpmsg); |
| 679 |
|
| 680 |
popup_message(globals.widgets.top_level, |
| 681 |
MSG_WARN, helpmsg, |
| 682 |
"Unrecognized value `%s' for paper type option; using a4 instead.", resource.paper); |
| 683 |
set_paper_type(DEFAULT_PAPER); |
| 684 |
} |
| 685 |
|
| 686 |
/* magnifier sizes */ |
| 687 |
for (i = 0; i < get_magglass_items(); ++i) { |
| 688 |
if (resource.mg_arg[i] != NULL) { |
| 689 |
char *s; |
| 690 |
|
| 691 |
int n = atoi(resource.mg_arg[i]); |
| 692 |
set_magglass_widht(i, n); |
| 693 |
set_magglass_height(i, n); |
| 694 |
s = strchr(resource.mg_arg[i], 'x'); |
| 695 |
if (s != NULL) { |
| 696 |
set_magglass_height(i, atoi(s + 1)); |
| 697 |
if (get_magglass_height(i) <= 0) |
| 698 |
set_magglass_widht(i, 0); |
| 699 |
} |
| 700 |
} |
| 701 |
} |
| 702 |
|
| 703 |
#ifdef PS |
| 704 |
if (resource.safer) { |
| 705 |
resource.allow_shell = False; |
| 706 |
# ifdef PS_GS |
| 707 |
resource.gs_safer = True; |
| 708 |
# endif /* PS_GS */ |
| 709 |
} |
| 710 |
# ifdef PS_GS |
| 711 |
{ |
| 712 |
const char *CGMcgm = "CGMcgm"; |
| 713 |
const char *cgmp; |
| 714 |
|
| 715 |
cgmp = strchr(CGMcgm, resource.gs_palette[0]); |
| 716 |
if (cgmp == NULL) |
| 717 |
XDVI_FATAL((stderr, "Invalid value %s for gs palette option", resource.gs_palette)); |
| 718 |
if (cgmp >= CGMcgm + 3) { |
| 719 |
static char gsp[] = "x"; |
| 720 |
|
| 721 |
gsp[0] = *(cgmp - 3); |
| 722 |
resource.gs_palette = gsp; |
| 723 |
} |
| 724 |
} |
| 725 |
# endif /* PS_GS */ |
| 726 |
#endif /* PS */ |
| 727 |
|
| 728 |
/* The old `-expert' flag overrides resource.expert_mode, `+expert' (or not |
| 729 |
setting it) just uses expert_mode. |
| 730 |
*/ |
| 731 |
if (resource.expert) |
| 732 |
resource.expert_mode = XPRT_SHOW_NONE; |
| 733 |
/* fprintf(stderr, "++++++++ initializing resource.expert_mode: %d\n", resource.expert_mode); */ |
| 734 |
update_expert_mode(); |
| 735 |
|
| 736 |
if (resource.hush) { |
| 737 |
resource.hush_chars = resource.hush_chk = resource.hush_stdout = resource.hush_bell = True; |
| 738 |
} |
| 739 |
} |
| 740 |
|
| 741 |
/* |
| 742 |
a custom error handler that makes it easier to catch X errors in the debugger |
| 743 |
(by setting a breakpoint to this function, plus using the -sync option). |
| 744 |
Also, Motif sometimes gives non-fatal errors that we want to ignore ... |
| 745 |
*/ |
| 746 |
static int |
| 747 |
x_error_handler(Display *display, XErrorEvent *error) |
| 748 |
{ |
| 749 |
char buf[1024], req_buf[1024]; |
| 750 |
|
| 751 |
if (error->request_code < 128) { |
| 752 |
char num[LENGTH_OF_INT]; |
| 753 |
sprintf(num, "%d", error->request_code); |
| 754 |
XGetErrorDatabaseText(display, "XRequest", num, "", req_buf, 1024); |
| 755 |
} |
| 756 |
else { |
| 757 |
req_buf[0] = '\0'; |
| 758 |
} |
| 759 |
|
| 760 |
XGetErrorText(display, error->error_code, buf, sizeof buf); |
| 761 |
/* XtCloseDisplay(DISP); */ |
| 762 |
if (error->error_code == BadWindow |
| 763 |
|| error->error_code == BadPixmap |
| 764 |
|| error->error_code == BadCursor |
| 765 |
|| error->error_code == BadFont |
| 766 |
|| error->error_code == BadDrawable |
| 767 |
|| error->error_code == BadColor |
| 768 |
|| error->error_code == BadGC |
| 769 |
|| error->error_code == BadIDChoice |
| 770 |
|| error->error_code == BadValue |
| 771 |
|| error->error_code == BadAtom) { |
| 772 |
XDVI_WARNING((stderr, "X protocol error: %s\n X Request %d (%s), Value=0x%x.", |
| 773 |
buf, error->request_code, req_buf, (unsigned int)error->resourceid)); |
| 774 |
} |
| 775 |
else { |
| 776 |
XDVI_WARNING((stderr, "X protocol error: %s\n X Request %d (%s).", |
| 777 |
buf, error->request_code, req_buf)); |
| 778 |
} |
| 779 |
return 0; |
| 780 |
} |
| 781 |
|
| 782 |
static void |
| 783 |
display_version_info(void) |
| 784 |
{ |
| 785 |
printf("%s version %s ", XDVIK_PROGNAME, XDVI_VERSION); |
| 786 |
#ifdef MOTIF |
| 787 |
printf("(%s, runtime version %d.%d)\n", |
| 788 |
/* XmVERSION, XmREVISION, XmUPDATE_LEVEL, */ |
| 789 |
XmVERSION_STRING, |
| 790 |
xmUseVersion / 1000, xmUseVersion % 1000); |
| 791 |
#else |
| 792 |
printf("%s\n", XDVI_GUI); |
| 793 |
#endif |
| 794 |
#if FREETYPE |
| 795 |
printf("Libraries: %s, freetype version %d.%d.%d\n", |
| 796 |
kpathsea_version_string, FREETYPE_MAJOR, FREETYPE_MINOR, FREETYPE_PATCH); |
| 797 |
#else |
| 798 |
printf("Libraries: %s\n", kpathsea_version_string); |
| 799 |
#endif |
| 800 |
} |
| 801 |
|
| 802 |
|
| 803 |
static void |
| 804 |
check_early_arguments(int argc, char **argv) |
| 805 |
{ |
| 806 |
/* This checks arguments that need to work before the X machinery is |
| 807 |
* started (e.g. if no display is available, or for information that is |
| 808 |
* needed before the X defaults are evaluated), so the `options' structure |
| 809 |
* can't be used for them. |
| 810 |
* |
| 811 |
* We need to loop through all arguments in case xdvi is aliased, |
| 812 |
* or called via a shell script (like in teTeX) that adds things |
| 813 |
* like `-name' at the beginning of the arglist. |
| 814 |
*/ |
| 815 |
int i; |
| 816 |
Boolean install_err_handler = True; |
| 817 |
|
| 818 |
for (i = 1; i < argc; i++) { |
| 819 |
if (strcmp(argv[i], "-help") == 0 |
| 820 |
|| strcmp(argv[i], "-h") == 0 |
| 821 |
|| strcmp(argv[i], "+help") == 0 |
| 822 |
|| strcmp(argv[i], "--help") == 0) { |
| 823 |
printf("%s version %s\n", XDVIK_PROGNAME, XDVI_VERSION_INFO); |
| 824 |
printf("A DVI file previewer for the X window system.\n\n"); |
| 825 |
display_licensing_info(); |
| 826 |
display_bug_reporting_info(); |
| 827 |
usage(0); |
| 828 |
} |
| 829 |
else if (strcmp(argv[i], "-license") == 0) { |
| 830 |
display_long_licensing_info(); |
| 831 |
xdvi_exit(EXIT_SUCCESS); |
| 832 |
} |
| 833 |
else if (strcmp(argv[i], "--version") == 0 |
| 834 |
|| strcmp(argv[i], "-version") == 0 |
| 835 |
|| strcmp(argv[i], "-v") == 0) { |
| 836 |
display_version_info(); |
| 837 |
xdvi_exit(EXIT_SUCCESS); |
| 838 |
} |
| 839 |
else if (strcmp(argv[i], "--default-xerr-handler") == 0) { /* hook to disable custom handler */ |
| 840 |
install_err_handler = False; |
| 841 |
} |
| 842 |
} |
| 843 |
|
| 844 |
if (install_err_handler) { |
| 845 |
(void)XSetErrorHandler(x_error_handler); |
| 846 |
} |
| 847 |
} |
| 848 |
|
| 849 |
/* initialize global variables with default values. */ |
| 850 |
static void |
| 851 |
init_globals(void) { |
| 852 |
globals.program_name = NULL; |
| 853 |
globals.dvi_name = NULL; |
| 854 |
globals.cwd = xgetcwd(); |
| 855 |
globals.orig_locale = NULL; |
| 856 |
globals.debug = 0L; |
| 857 |
globals.pageno_correct = 1; |
| 858 |
|
| 859 |
globals.curr_paper = NULL; |
| 860 |
globals.curr_editor = NULL; |
| 861 |
globals.curr_browser = NULL; |
| 862 |
|
| 863 |
globals.ev.flags = EV_IDLE; |
| 864 |
globals.ev.ctr = 0; |
| 865 |
|
| 866 |
globals.pausing.num = 0; |
| 867 |
globals.pausing.num_save = NULL; |
| 868 |
globals.pausing.flag = False; |
| 869 |
|
| 870 |
globals.win_expose.min_x = 0; |
| 871 |
globals.win_expose.max_x = 0; |
| 872 |
globals.win_expose.min_y = 0; |
| 873 |
globals.win_expose.max_y = 0; |
| 874 |
|
| 875 |
globals.gc.rule = NULL; |
| 876 |
globals.gc.fore = NULL; |
| 877 |
globals.gc.inverted = NULL; |
| 878 |
globals.gc.high = NULL; |
| 879 |
globals.gc.linkcolor = NULL; |
| 880 |
globals.gc.visited_linkcolor = NULL; |
| 881 |
globals.gc.fore2 = NULL; |
| 882 |
globals.gc.fore2_bak = NULL; |
| 883 |
globals.gc.fore2_bak1 = NULL; |
| 884 |
globals.gc.copy = NULL; |
| 885 |
globals.gc.ruler = NULL; |
| 886 |
|
| 887 |
globals.gc.do_copy = False; |
| 888 |
|
| 889 |
globals.cursor.flags = 0; |
| 890 |
|
| 891 |
globals.src.fwd_box_page = -1; /* -1 means no box */ |
| 892 |
globals.src.fwd_string = NULL; |
| 893 |
|
| 894 |
globals.widgets.top_level = 0; |
| 895 |
globals.widgets.draw_widget = 0; |
| 896 |
globals.widgets.draw_background = 0; |
| 897 |
globals.widgets.clip_widget = 0; |
| 898 |
globals.widgets.x_bar = 0; |
| 899 |
globals.widgets.y_bar = 0; |
| 900 |
#ifdef MOTIF |
| 901 |
globals.widgets.main_window = 0; |
| 902 |
globals.widgets.main_row = 0; |
| 903 |
globals.widgets.tool_bar = 0; |
| 904 |
globals.widgets.top_row = 0; |
| 905 |
globals.widgets.menu_bar = 0; |
| 906 |
#else |
| 907 |
globals.widgets.vport_widget = 0; |
| 908 |
globals.widgets.form_widget = 0; |
| 909 |
globals.widgets.paned = 0; |
| 910 |
#endif |
| 911 |
|
| 912 |
globals.page.w = 0; |
| 913 |
globals.page.h = 0; |
| 914 |
globals.page.unshrunk_w = 0; |
| 915 |
globals.page.unshrunk_h = 0; |
| 916 |
|
| 917 |
globals.dvi_file.dirname = NULL; |
| 918 |
globals.dvi_file.dirlen = 0; |
| 919 |
globals.dvi_file.bak_fp = NULL; |
| 920 |
globals.dvi_file.time = 0; |
| 921 |
|
| 922 |
#if defined(LESSTIF_VERSION) |
| 923 |
globals.broken_motif_event_handling = True; |
| 924 |
#elif defined(MOTIF) /* was: && XmVersion <= 1002 - better use runtime information:*/ |
| 925 |
if (xmUseVersion <= 1002) |
| 926 |
globals.broken_motif_event_handling = True; |
| 927 |
else |
| 928 |
globals.broken_motif_event_handling = False; |
| 929 |
#else |
| 930 |
globals.broken_motif_event_handling = False; |
| 931 |
#endif |
| 932 |
|
| 933 |
} |
| 934 |
|
| 935 |
|
| 936 |
#ifdef GREY |
| 937 |
/* |
| 938 |
* Convert string to yes/no/maybe. Adapted from the X toolkit. |
| 939 |
*/ |
| 940 |
|
| 941 |
static Boolean |
| 942 |
XdviCvtStringToBool3(Display *dpy, |
| 943 |
XrmValuePtr args, Cardinal *num_args, |
| 944 |
XrmValuePtr fromVal, XrmValuePtr toVal, |
| 945 |
XtPointer *closure_ret) |
| 946 |
{ |
| 947 |
String str = (String) fromVal->addr; |
| 948 |
static Bool3 value; |
| 949 |
|
| 950 |
UNUSED(args); |
| 951 |
UNUSED(num_args); |
| 952 |
UNUSED(closure_ret); |
| 953 |
|
| 954 |
if (memicmp(str, "true", 5) == 0 |
| 955 |
|| memicmp(str, "yes", 4) == 0 |
| 956 |
|| memicmp(str, "on", 3) == 0 || memicmp(str, "1", 2) == 0) |
| 957 |
value = True; |
| 958 |
|
| 959 |
else if (memicmp(str, "false", 6) == 0 |
| 960 |
|| memicmp(str, "no", 3) == 0 |
| 961 |
|| memicmp(str, "off", 4) == 0 || memicmp(str, "0", 2) == 0) |
| 962 |
value = False; |
| 963 |
|
| 964 |
else if (memicmp(str, "maybe", 6) == 0) |
| 965 |
value = Maybe; |
| 966 |
|
| 967 |
else { |
| 968 |
XtDisplayStringConversionWarning(dpy, str, XtRBoolean); |
| 969 |
return False; |
| 970 |
} |
| 971 |
|
| 972 |
if (toVal->addr != NULL) { |
| 973 |
if (toVal->size < sizeof(Bool3)) { |
| 974 |
toVal->size = sizeof(Bool3); |
| 975 |
return False; |
| 976 |
} |
| 977 |
*(Bool3 *) (toVal->addr) = value; |
| 978 |
} |
| 979 |
else |
| 980 |
toVal->addr = (XPointer) & value; |
| 981 |
|
| 982 |
toVal->size = sizeof(Bool3); |
| 983 |
return True; |
| 984 |
} |
| 985 |
#endif |
| 986 |
|
| 987 |
/* |
| 988 |
************************************************************ |
| 989 |
************************************************************ |
| 990 |
main routine |
| 991 |
************************************************************ |
| 992 |
************************************************************ |
| 993 |
*/ |
| 994 |
|
| 995 |
int |
| 996 |
main(int argc, char **argv) |
| 997 |
{ |
| 998 |
int i; |
| 999 |
static struct startup_info info; |
| 1000 |
const char *file_name = NULL; |
| 1001 |
const char *file_name2 = NULL; |
| 1002 |
|
| 1003 |
/* Hack to have command-line options override ~/.xdvirc stuff: |
| 1004 |
* Parse and merge them again from argv_bak, a copy of the command-line options, |
| 1005 |
* via XrmParseCommand(). I think the only alternative would be to merge in all |
| 1006 |
* resources manually instead of using XtInitialize(), similar to what's done in gv, |
| 1007 |
* but that looks like too much trouble. |
| 1008 |
*/ |
| 1009 |
#define COMMANDLINE_OVERRIDE_HACK 1 |
| 1010 |
|
| 1011 |
#if COMMANDLINE_OVERRIDE_HACK |
| 1012 |
int argc_bak; |
| 1013 |
char **argv_bak; |
| 1014 |
#endif |
| 1015 |
|
| 1016 |
setup_signal_handlers(True); /* catch USR1 early */ |
| 1017 |
|
| 1018 |
info.file_idx = 0; |
| 1019 |
info.page_arg = NULL; |
| 1020 |
|
| 1021 |
/* BEGIN_TIMER_LOOP; */ |
| 1022 |
|
| 1023 |
init_globals(); |
| 1024 |
|
| 1025 |
/* |
| 1026 |
* Step 1: Process command-line options and resources. |
| 1027 |
*/ |
| 1028 |
|
| 1029 |
globals.program_name = xstrdup(argv[0]); |
| 1030 |
{ /* get filename from program_name if it contains a path */ |
| 1031 |
char sep; |
| 1032 |
char *ptr; |
| 1033 |
#ifdef VMS |
| 1034 |
sep = ']'; |
| 1035 |
#else |
| 1036 |
sep = '/'; |
| 1037 |
#endif |
| 1038 |
if ((ptr = strrchr(globals.program_name, sep)) != NULL) { |
| 1039 |
globals.program_name = ++ptr; |
| 1040 |
} |
| 1041 |
#ifdef VMS |
| 1042 |
if ((ptr = strchr(globals.program_name, '.')) != NULL) |
| 1043 |
*ptr = '\0'; |
| 1044 |
#endif |
| 1045 |
} |
| 1046 |
|
| 1047 |
#if COMMANDLINE_OVERRIDE_HACK |
| 1048 |
/* create a copy of argv[] */ |
| 1049 |
argc_bak = argc; |
| 1050 |
argv_bak = xmalloc((1 + argc_bak) * sizeof *argv_bak); |
| 1051 |
for (i = 0; i < argc_bak; i++) { |
| 1052 |
argv_bak[i] = xstrdup(argv[i]); |
| 1053 |
} |
| 1054 |
argv_bak[i] = NULL; |
| 1055 |
#endif |
| 1056 |
|
| 1057 |
/* |
| 1058 |
Arguments that need to be checked early, like `help', `version' and `sync'. |
| 1059 |
The former don't even require an X connection. |
| 1060 |
*/ |
| 1061 |
check_early_arguments(argc, argv); |
| 1062 |
|
| 1063 |
warn_about_prerelease_versions(); |
| 1064 |
|
| 1065 |
/* We need to set up SIGALRM before calling XtAppAddTimeOut() (inside sfSelFile, or |
| 1066 |
called from XtInitialize() in Motif), otherwise we'll die with the error message |
| 1067 |
`Alarm clock'. However, we mustn't install SIGPOLL before the forking is done |
| 1068 |
below, otherwise xdvi may hang forever waiting for input. So the signal handler setup |
| 1069 |
is split in 2 parts: setup_sigalarm(), and setup_signal_handlers() below. |
| 1070 |
*/ |
| 1071 |
setup_sigalarm(); |
| 1072 |
|
| 1073 |
/* get the debug value (if any) from the environment |
| 1074 |
(it's too early to get it from the command line) */ |
| 1075 |
globals.debug = parse_debugging_option(getenv("XDVIDEBUG")); |
| 1076 |
|
| 1077 |
/* to make input of non-latin characters work */ |
| 1078 |
XtSetLanguageProc(NULL, (XtLanguageProc)NULL, NULL); |
| 1079 |
|
| 1080 |
globals.widgets.top_level = XtInitialize(globals.program_name, "XDvi", options, XtNumber(options), |
| 1081 |
&argc, argv); |
| 1082 |
|
| 1083 |
globals.app = XtWidgetToApplicationContext(globals.widgets.top_level); |
| 1084 |
|
| 1085 |
XtAppAddActions(globals.app, get_actions(), get_num_actions()); |
| 1086 |
|
| 1087 |
/* create_magnifier(); */ |
| 1088 |
|
| 1089 |
if ((globals.orig_locale = setlocale(LC_ALL, "")) != NULL) |
| 1090 |
globals.orig_locale = xstrdup(globals.orig_locale); /* note: never free'd */ |
| 1091 |
else /* fallback */ |
| 1092 |
globals.orig_locale = xstrdup(setlocale(LC_ALL, NULL)); |
| 1093 |
|
| 1094 |
/* Override LC_NUMERIC, otherwise sscanf(), strtod() etc. won't work for floats |
| 1095 |
inside specials for locales like LANG=de_DE which uses `,' instead of `.' as |
| 1096 |
decimal separator. (Strangely, using |
| 1097 |
LC_CTYPE | LC_COLLATE |
| 1098 |
doesn't work?) |
| 1099 |
Regression: |
| 1100 |
xdvik/regression/special-pics/pictest.dvi |
| 1101 |
*/ |
| 1102 |
setlocale(LC_NUMERIC, "C"); |
| 1103 |
|
| 1104 |
/* at this point, all known options will have been consumed; so the |
| 1105 |
only ones remaining should be: +pageno, and the dvi name. Exit with |
| 1106 |
usage message if this is not the case. The convention is that the last |
| 1107 |
argument is always treated as filename (even if it starts with '-'), |
| 1108 |
so we throw an error if there's more than one unknown argument at the end. |
| 1109 |
*/ |
| 1110 |
for (i = 1; i < argc; i++) { /* skip argv[0] */ |
| 1111 |
if (*(argv[i]) == '+') { |
| 1112 |
if (info.page_arg != NULL) { |
| 1113 |
XDVI_ERROR((stderr, "Unrecognized option `%s'.", argv[i])); |
| 1114 |
usage(EXIT_FAILURE); |
| 1115 |
} |
| 1116 |
else { |
| 1117 |
info.page_arg = argv[i] + 1; |
| 1118 |
} |
| 1119 |
} |
| 1120 |
else if (file_name == NULL) { |
| 1121 |
file_name = xstrdup(argv[i]); /* leaks, but never mind ... */ |
| 1122 |
} |
| 1123 |
else { |
| 1124 |
/* we had already seen a filename */ |
| 1125 |
XDVI_ERROR((stderr, "Unrecognized option `%s'.", argv[i - 1])); /* safe because we started at argv[1] */ |
| 1126 |
usage(EXIT_FAILURE); |
| 1127 |
} |
| 1128 |
} |
| 1129 |
|
| 1130 |
DISP = XtDisplay(globals.widgets.top_level); |
| 1131 |
SCRN = XtScreen(globals.widgets.top_level); |
| 1132 |
|
| 1133 |
#ifdef GREY |
| 1134 |
XtSetTypeConverter(XtRString, XtRBool3, XdviCvtStringToBool3, |
| 1135 |
NULL, 0, XtCacheNone, NULL); |
| 1136 |
#endif |
| 1137 |
|
| 1138 |
#ifdef MOTIF |
| 1139 |
/* we'll take care of that ourselves */ |
| 1140 |
XtVaSetValues(globals.widgets.top_level, XmNdeleteResponse, XmDO_NOTHING, NULL); |
| 1141 |
|
| 1142 |
{ |
| 1143 |
/* Hack to work around #884290 (drag&drop freezes file selector, see comment |
| 1144 |
in xm_filesel.c): Disable drag&drop altogether (we don't need it). |
| 1145 |
Could also be done via Xdefaults as follows: |
| 1146 |
XDvi*dragInitiatorProtocolStyle: XmDRAG_NONE |
| 1147 |
XDvi*dragReceiverProtocolStyle: XmDRAG_NONE |
| 1148 |
*/ |
| 1149 |
Widget display = XmGetXmDisplay(DISP); |
| 1150 |
XtVaSetValues(display, |
| 1151 |
XmNdragInitiatorProtocolStyle, XmDRAG_NONE, |
| 1152 |
XmNdragReceiverProtocolStyle, XmDRAG_NONE, |
| 1153 |
NULL); |
| 1154 |
} |
| 1155 |
#else |
| 1156 |
G_accels_cr = XtParseAcceleratorTable("<Key>Return:set()notify()unset()\n" |
| 1157 |
"<Key>q:set()notify()unset()\n" |
| 1158 |
"<Key>Escape: set()notify()unset()"); |
| 1159 |
#endif |
| 1160 |
|
| 1161 |
/* get the no_init_file resource first: This needs to be done |
| 1162 |
* before the call to XtGetApplicationResources() below, which populates |
| 1163 |
* the `resource' struct with the actual application resources (which |
| 1164 |
* may be merged from ~/.xdvirc). */ |
| 1165 |
XtGetApplicationResources(globals.widgets.top_level, (XtPointer)&resource, |
| 1166 |
xdvirc_resources, XtNumber(xdvirc_resources), |
| 1167 |
(ArgList)NULL, 0); |
| 1168 |
|
| 1169 |
if (!resource.no_init_file) { /* Read user preferences from ~/.xdvirc. */ |
| 1170 |
read_user_preferences(globals.widgets.top_level, ".xdvirc"); |
| 1171 |
} |
| 1172 |
|
| 1173 |
#if COMMANDLINE_OVERRIDE_HACK /* see above */ |
| 1174 |
{ |
| 1175 |
XrmDatabase cmdline_db = XrmGetDatabase(DISP); |
| 1176 |
XrmParseCommand(&cmdline_db, options, XtNumber(options), |
| 1177 |
"xdvi", &argc_bak, argv_bak); |
| 1178 |
|
| 1179 |
for (i = 0; i < argc_bak; i++) { |
| 1180 |
free(argv_bak[i]); |
| 1181 |
} |
| 1182 |
free(argv_bak); |
| 1183 |
argc_bak = 0; |
| 1184 |
} |
| 1185 |
#endif /* COMMANDLINE_OVERRIDE_HACK */ |
| 1186 |
|
| 1187 |
load_app_resources(False); |
| 1188 |
|
| 1189 |
/* musn't do this, 0 is 'fit to window' (bug #1454648) */ |
| 1190 |
/* if (resource.shrinkfactor == 0) /\* protect against division by 0 *\/ */ |
| 1191 |
/* resource.shrinkfactor = 1; */ |
| 1192 |
currwin.shrinkfactor = resource.shrinkfactor; |
| 1193 |
globals.curr_use_color = resource.use_color; |
| 1194 |
globals.curr_gamma = resource.gamma; |
| 1195 |
globals.curr_paper = xstrdup(resource.paper); /* never free()d */ |
| 1196 |
globals.curr_editor = NULL; |
| 1197 |
globals.curr_browser = NULL; |
| 1198 |
globals.curr_mode = NO_MODE_ACTIVE; |
| 1199 |
|
| 1200 |
/* Initialize `globals.debug' as early as possible. Note: earlier |
| 1201 |
* calls to TRACE_* or tests for `if (globals.debug)' will only work if the |
| 1202 |
* XDVIDEBUG environment variable is set! |
| 1203 |
*/ |
| 1204 |
globals.debug |= parse_debugging_option(resource.debug_arg); |
| 1205 |
kpathsea_debug = globals.debug / DBG_STAT; |
| 1206 |
|
| 1207 |
if (globals.debug) |
| 1208 |
fprintf(stderr, "KPATHSEA_DEBUG = %d\n", kpathsea_debug); |
| 1209 |
|
| 1210 |
kpse_init_prog("XDVI", resource.pixels_per_inch, resource.mfmode, resource.alt_font); |
| 1211 |
|
| 1212 |
TRACE_FILES((stderr, "Initializing kpathsearch with program name '%s'", |
| 1213 |
xdvi_kpse_prog_name)); |
| 1214 |
kpse_set_program_name(argv[0], xdvi_kpse_prog_name); |
| 1215 |
|
| 1216 |
if (globals.debug & DBG_EXPAND) { |
| 1217 |
const char *texmfcnf = kpse_path_expand("$TEXMFCNF"); |
| 1218 |
const char *texmfmain = kpse_path_expand("$TEXMFMAIN"); |
| 1219 |
fprintf(stderr, "\n%s:%d: KPATHSEA variables:\n", __FILE__, __LINE__); |
| 1220 |
fprintf(stderr, "%s:%d: SELFAUTOLOC=\"%s\"\n", __FILE__, __LINE__, getenv("SELFAUTOLOC")); |
| 1221 |
fprintf(stderr, "%s:%d: SELFAUTODIR=\"%s\"\n", __FILE__, __LINE__, getenv("SELFAUTODIR")); |
| 1222 |
fprintf(stderr, "%s:%d: SELFAUTOPARENT=\"%s\"\n", __FILE__, __LINE__, getenv("SELFAUTOPARENT")); |
| 1223 |
fprintf(stderr, "%s:%d: TEXMFCNF=\"%s\"\n", __FILE__, __LINE__, texmfcnf); |
| 1224 |
fprintf(stderr, "%s:%d: TEXMFMAIN=\"%s\"\n\n", __FILE__, __LINE__, texmfmain); |
| 1225 |
} |
| 1226 |
|
| 1227 |
if (resource.regression) { |
| 1228 |
/* currently it just turns on everything; what we'd like here is |
| 1229 |
output that's usable for automatic diffs (e.g. independent |
| 1230 |
of window manager state) */ |
| 1231 |
globals.debug = DBG_ALL; |
| 1232 |
} |
| 1233 |
|
| 1234 |
/* Check early for whether to pass off to a different xdvi process |
| 1235 |
* (-sourceposition argument for reverse source special lookup). |
| 1236 |
*/ |
| 1237 |
property_initialize(); |
| 1238 |
|
| 1239 |
#if 0 /* def RGB_ANTI_ALIASING */ |
| 1240 |
/* error checking and setting of resources according to command line arguments */ |
| 1241 |
if (resource.sub_pixels != NULL && memicmp(resource.sub_pixels, "unknown", 4) == 0) { |
| 1242 |
#ifdef __GNUC__ |
| 1243 |
#warning TODO: implement callbacks |
| 1244 |
#endif |
| 1245 |
choice_dialog_sized(globals.widgets.top_level, |
| 1246 |
MSG_QUESTION, |
| 1247 |
SIZE_MEDIUM, |
| 1248 |
NULL, |
| 1249 |
#ifndef MOTIF |
| 1250 |
NULL, /* TODO: xaw ret_action_str */ |
| 1251 |
#endif |
| 1252 |
NULL, NULL, /* pre callback */ |
| 1253 |
"Enable", NULL, NULL, |
| 1254 |
"Disable", NULL, NULL, |
| 1255 |
"This version of xdvi can optimize the anti-aliased font display " |
| 1256 |
"when running on an LCD monitor, such as a notebook screen or a TFT flat screen." |
| 1257 |
"\n\n" |
| 1258 |
"If you are using such a monitor, click `Enable' to enable optimized display; otherwise click `Disable'." |
| 1259 |
"\n\n" |
| 1260 |
"You can change this setting later via the Menu `Options -> Anti-Aliasing'."); |
| 1261 |
/* enter event loop */ |
| 1262 |
do_pages(); |
| 1263 |
} |
| 1264 |
else { |
| 1265 |
#endif |
| 1266 |
init_check_resources(); |
| 1267 |
|
| 1268 |
TRACE_FILES((stderr, "file history: |%s|", resource.file_history)); |
| 1269 |
file_history_init(); |
| 1270 |
|
| 1271 |
#if !DELAYED_MKTEXPK |
| 1272 |
/* Notify users that fonts might be created. This is just a hack |
| 1273 |
and no replacement for true asynchronous font creation since it |
| 1274 |
doesn't give details (is just invoked if startup takes somewhat |
| 1275 |
longer) and freezes during font creation. |
| 1276 |
*/ |
| 1277 |
/* register_font_popup(); */ |
| 1278 |
#endif |
| 1279 |
|
| 1280 |
if (file_name == NULL) { /* no filename argument */ |
| 1281 |
|
| 1282 |
if (resource.no_file_arg_use_history) { |
| 1283 |
static char buf[LENGTH_OF_INT]; /* so that we can pass its address */ |
| 1284 |
int pageno; |
| 1285 |
if ((file_name = get_filename_from_history(&pageno)) != NULL) { |
| 1286 |
SNPRINTF(buf, LENGTH_OF_INT, "%d", pageno + 1); /* pageno is 0-based */ |
| 1287 |
info.page_arg = buf; |
| 1288 |
} |
| 1289 |
} |
| 1290 |
|
| 1291 |
TRACE_FILES((stderr, "got from history: |%s|", file_name)); |
| 1292 |
|
| 1293 |
if (file_name != NULL) { |
| 1294 |
run_dvi_file(file_name, &info); |
| 1295 |
} |
| 1296 |
else { /* get filename from file selector */ |
| 1297 |
/* static so that we can pass its address */ |
| 1298 |
static struct filesel_callback cb = { |
| 1299 |
NULL, NULL, "Xdvi: Open file", "Open file:", "OK", "Cancel", |
| 1300 |
NULL, "*.dvi", True, True, NULL, NULL |
| 1301 |
}; |
| 1302 |
cb.func_ptr = run_dvi_file; |
| 1303 |
cb.data = &info; |
| 1304 |
cb.browse_fname = xt_strdup(globals.cwd); |
| 1305 |
|
| 1306 |
if (cb.shell == NULL) |
| 1307 |
cb.shell = XsraSelFile(globals.widgets.top_level, &cb); |
| 1308 |
XsraSelFilePopup(&cb); |
| 1309 |
/* enter event loop */ |
| 1310 |
do_pages(); |
| 1311 |
} |
| 1312 |
} |
| 1313 |
else if ((file_name2 = is_good_dvi_file(file_name, False)) != NULL) { |
| 1314 |
run_dvi_file(file_name2, &info); |
| 1315 |
} |
| 1316 |
#if 0 /* def RGB_ANTI_ALIASING */ |
| 1317 |
} |
| 1318 |
#endif |
| 1319 |
/* notreached */ |
| 1320 |
return 0; |
| 1321 |
} |