3 * General purpose routines.
11 #include <sys/types.h>
17 int nolist
= 0; /* number of specified ranges */
18 int olist
[50]; /* processing range pairs */
21 * Grab page ranges from str, save them in olist[], and update the
22 * nolist count. Range syntax matches nroff/troff syntax.
24 void out_list(char *str
)
28 while (*str
&& nolist
< sizeof(olist
) - 2) {
29 start
= stop
= str_convert(&str
, 0);
31 if (*str
== '-' && *str
++)
32 stop
= str_convert(&str
, 9999);
34 error(FATAL
, "illegal range %d-%d", start
, stop
);
35 olist
[nolist
++] = start
;
36 olist
[nolist
++] = stop
;
45 * Return ON if num is in the current page range list. Print everything
54 for (i
= 0; i
< nolist
; i
+= 2)
55 if (num
>= olist
[i
] && num
<= olist
[i
+1])
61 * Include the font encoding file selected by name. It's a full
62 * pathname if it begins with /, otherwise append suffix ".enc" and
63 * look for the file in ENCODINGDIR. Missing files are silently
66 void setencoding(char *name
)
76 sprintf(path
, "%s/%s.enc", ENCODINGDIR
, name
);
78 if (cat(path
) == TRUE
)
79 writing
= strncmp(name
, "UTF", 3) == 0;
84 * Grab the next integer from **str and return its value or err if *str
85 * isn't an integer. *str is modified after each digit is read.
87 int str_convert(char **str
, int err
)
93 for (i
= 0; isdigit(**str
); *str
+= 1)
94 i
= 10 * i
+ **str
- '0';
98 /* Signal handler for translators. */
99 void interrupt(int sig
)
101 if (temp_file
!= NULL
)