1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <X11/Xos.h>
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#include <stdio.h>
#include <ctype.h>
#include "DviP.h"
int
DviGetAndPut(DviWidget dw, int *cp)
{
if (dw->dvi.ungot) {
dw->dvi.ungot = 0;
*cp = getc(dw->dvi.file);
}
else {
*cp = getc(dw->dvi.file);
putc(*cp, dw->dvi.tmpFile);
}
return *cp;
}
char *
GetLine(DviWidget dw, char *Buffer, int Length)
{
int i = 0, c;
char *p = Buffer;
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);
}
char *
GetWord(DviWidget dw, char *Buffer, int Length)
{
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);
}
int
GetNumber(DviWidget dw)
{
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);
}
|