Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

v47i123: viz - make invisible characters visible; od on steroids, Patch01

7 views
Skip to first unread message

Will Deich

unread,
Apr 12, 1995, 3:00:00 AM4/12/95
to
Submitted-by: WDe...@nfra.nl (Will Deich)
Posting-number: Volume 47, Issue 123
Archive-name: viz/patch01
Environment: UNIX
Patch-To: viz: Volume 47, Issue 104-106

System: viz version 1.1
Patch #: 01
Priority: HIGH
Subject: Supply missing dep.h file.
Subject: Correct man page.
Subject: Improve error messages.
From: Will Deich <wde...@nfra.nl>

Description:
Supply missing dep.h file. The system-dependent file
dep.h was left out of the shar file.

The man page had one moderately important error (it said that
the comment character was `!' instead of `#'), and some minor
errors.

The cryptic yacc-generated error messages have been supplemented
to indicate exactly what part of a format string contains the error.

Fix: From rn, say "| patch -N -d DIR", where DIR is your viz source
directory. Outside of rn, say "cd DIR; patch -N <thisarticle".
If you don't have the patch program, apply the following by hand,
or get patch (version 2.0, latest patchlevel).

After patching:
Edit dep.h
make
make install

If patch indicates that patchlevel (in version.h) is the wrong
version, you may need to apply one or more previous patches,
or the patch may already have been applied. See the version.h
file to find out what has or has not been applied. In any event,
don't continue with the patch.

*** viz-1.1.0/version.h Wed Mar 29 14:26:55 1995
--- viz-1.1.1/version.h Wed Mar 29 14:27:13 1995
***************
*** 1,2 ****
#define Version "1.1"
! #define Patchlevel "0"
--- 1,2 ----
#define Version "1.1"
! #define Patchlevel "1"

*** viz-1.1.0/Makefile Wed Mar 29 14:26:46 1995
--- viz-1.1.1/Makefile Wed Mar 29 14:27:03 1995
***************
*** 28,34 ****
#######
# CFLAGS
# Always keep $(DEFS) and $(SIZES) in CFLAGS
! CFLAGS = $(DEFS) $(SIZES)

#######
# LDFLAGS,LDLIBS
--- 28,34 ----
#######
# CFLAGS
# Always keep $(DEFS) and $(SIZES) in CFLAGS
! CFLAGS = -O $(DEFS) $(SIZES)

#######
# LDFLAGS,LDLIBS
***************
*** 42,55 ****
####################################################################

VIZOBJS = viz.o vizgrammar.o lists.o loadfile.o viz_decode.o
! VIZ_H = viz.h translate.h string.h memory.h version.h
VIZSRC = viz.c vizgrammar.y lists.c loadfile.c viz_decode.c
VIZSRC_C = viz.c vizgrammar.c lists.c loadfile.c viz_decode.c

INVIZOBJS = inviz.o strtou.o strtod.o inviz_text.o inviz_num.o
INVIZSRC = inviz.c strtou.c strtod.c inviz_text.c inviz_num.c

! ALL = README INSTALL Artistic Copying Makefile viz.1 inviz.1 $(VIZSRC) $(INVIZSRC) $(VIZ_H)

all: viz inviz

--- 42,55 ----
####################################################################

VIZOBJS = viz.o vizgrammar.o lists.o loadfile.o viz_decode.o
! VIZ_H = viz.h dep.h translate.h string.h memory.h version.h
VIZSRC = viz.c vizgrammar.y lists.c loadfile.c viz_decode.c
VIZSRC_C = viz.c vizgrammar.c lists.c loadfile.c viz_decode.c

INVIZOBJS = inviz.o strtou.o strtod.o inviz_text.o inviz_num.o
INVIZSRC = inviz.c strtou.c strtod.c inviz_text.c inviz_num.c

! ALL = README INSTALL Artistic Copying WhatsNew Makefile viz.1 inviz.1 $(VIZSRC) $(INVIZSRC) $(VIZ_H)

all: viz inviz

***************
*** 89,96 ****
$(CC) $(CFLAGS) -c inviz_num.c

install: viz inviz
! cp viz $(DESTDIR) && chmod 755 $(DESTDIR)/viz
! cp inviz $(DESTDIR) && chmod 755 $(DESTDIR)/inviz
cp viz.1 $(MANDIR)/viz.$(MANEXT) && \
chmod 644 $(MANDIR)/viz.$(MANEXT)
cp inviz.1 $(MANDIR)/inviz.$(MANEXT) && \
--- 89,96 ----
$(CC) $(CFLAGS) -c inviz_num.c

install: viz inviz
! cp viz $(BINDIR) && chmod 755 $(BINDIR)/viz
! cp inviz $(BINDIR) && chmod 755 $(BINDIR)/inviz
cp viz.1 $(MANDIR)/viz.$(MANEXT) && \
chmod 644 $(MANDIR)/viz.$(MANEXT)
cp inviz.1 $(MANDIR)/inviz.$(MANEXT) && \

*** viz-1.1.0/WhatsNew Thu Jan 1 01:00:00 1970
--- viz-1.1.1/WhatsNew Wed Mar 29 14:27:03 1995
***************
*** 0 ****
--- 1,11 ----
+ -------------------
+ What's new for version 1.1.1:
+
+ A. error messages: added information about the position in a format at
+ which an error occurred.
+
+ B. The shar file was missing dep.h.
+
+ C. Corrected the man page (it said "!" marked a comment; it's really "#").
+
+ D. Corrected the makefile.

*** viz-1.1.0/dep.h Thu Jan 1 01:00:00 1970
--- viz-1.1.1/dep.h Wed Mar 29 14:27:12 1995
***************
*** 0 ****
--- 1,57 ----
+ #ifdef __STDC__
+ #include <limits.h>
+ #endif
+
+ /* LONG_MAX is the largest allowed long. Ideally, its value is larger
+ * than the largest filesize that can be handled.
+ */
+ #ifndef LONG_MAX
+ #define LONG_MAX (2147483647L)
+ #endif
+
+ /* -- Put the sizes of shorts, ints, and longs here. (The sizeof operator
+ * isn't sufficient because we need to use L_XXXX in the argument to a
+ * #if expression.)
+ */
+ #ifndef L_SHORT
+ #define L_SHORT 2
+ #endif
+ #ifndef L_INT
+ #define L_INT 4
+ #endif
+ #ifndef L_LONG
+ #define L_LONG 4
+ #endif
+
+
+ /* aligned(type) should evaluate to 1 if the pointer p is properly aligned
+ * for data of type "type", where type is one of 'C' (char),
+ * 'Z' (zero-terminated string), 'S' (short), 'I' (int), 'L' (long),
+ * 'F' (float), or 'D' (double); it should evaluate to 0 otherwise.
+
+ * It is used to decide if each datum in the input buffer is properly aligned --
+ * if not, we have to copy it to an aligned boundary before interpreting it.
+
+ * The default macro will work on most but not all machines. It will work
+ * properly if (a) all data sizes are powers of 2; (b) the architecture
+ * uses byte address, not word address; and (c) after casting the
+ * address to unsigned long, the alignment is indicated by the low-order bits.
+ * This is not guaranteed to be true on all architectures, however, so you may
+ * need to adjust the definition.
+
+ * This default macro requires alignment of each datum on a boundary that's
+ * a multiple of its own size. It is unnecessarily restrictive for some
+ * architectures (e.g. some architectures allow 4-byte quantities to start
+ * on any 2-byte boundary).
+ */
+
+ #ifndef aligned
+ #define aligned(type, p) ( \
+ (type) == 'C' ? 1 : \
+ (type) == 'Z' ? 1 : \
+ (type) == 'S' ? !( (unsigned long) (p) & (sizeof(short)-1) ) : \
+ (type) == 'I' ? !( (unsigned long) (p) & (sizeof(int)-1) ) : \
+ (type) == 'L' ? !( (unsigned long) (p) & (sizeof(long)-1) ) : \
+ (type) == 'F' ? !( (unsigned long) (p) & (sizeof(float)-1) ) : \
+ /* assume 'D' */ !( (unsigned long) (p) & (sizeof(double)-1) ) )
+ #endif

*** viz-1.1.0/viz.1 Wed Mar 29 14:26:47 1995
--- viz-1.1.1/viz.1 Wed Mar 29 14:27:05 1995
***************
*** 490,505 ****
wherever the string is encountered). The special meaning of \fB$\fP
may be escaped by preceding it with a backslash.
.SS Input Comments
! All text from an exclamation point (\fB!\fP) through a newline is considered
a comment about the format, and is ignored (it's not put into the
output stream, either). This allows you to comment long format files.
For instance, a format file could contain
.in +.5i
.nf
.B
! I~ >n\ \ \ \ !Read the number of bytes into register n
.B
! $n/F\ \ \ \ \ ! convert to a number of floats
.fi
.in -.5i
(See the section on \fBRegisters\fP.)
--- 490,505 ----
wherever the string is encountered). The special meaning of \fB$\fP
may be escaped by preceding it with a backslash.
.SS Input Comments
! All text from a sharp (\fB#\fP) through a newline is considered
a comment about the format, and is ignored (it's not put into the
output stream, either). This allows you to comment long format files.
For instance, a format file could contain
.in +.5i
.nf
.B
! I~ >n\ \ \ \ # Read the number of bytes into register n
.B
! $n/F\ \ \ \ \ # Convert to a number of floats
.fi
.in -.5i
(See the section on \fBRegisters\fP.)

*** viz-1.1.0/viz.c Wed Mar 29 14:26:50 1995
--- viz-1.1.1/viz.c Wed Mar 29 14:27:08 1995
***************
*** 52,59 ****
#include "memory.h"
#include <errno.h>

#include "viz.h"
- #include "version.h"

extern errno;
extern int sys_nerr;
--- 52,59 ----
#include "memory.h"
#include <errno.h>

+ #define VIZ_MAIN
#include "viz.h"

extern errno;
extern int sys_nerr;
***************
*** 65,71 ****
extern char *optarg;

char *prog;
! char *fmttext = "a"; /* Default format */
int show_list = 0; /* show the format list */
int debug = 0; /* ==list + show the creation of the list */
int show_type = 0; /* use \# T to show data type */
--- 65,78 ----
extern char *optarg;

char *prog;
! struct Format Fmt = {
! "a", /* Default format */
! NULL, /* input text */
! 0, /* format is not from a file */
! 0, /* current line number in format */
! NULL, /* ptr to start of curr line */
! NULL}; /* ptr to 1 past last item */
!
int show_list = 0; /* show the format list */
int debug = 0; /* ==list + show the creation of the list */
int show_type = 0; /* use \# T to show data type */
***************
*** 346,352 ****
prog);
exit(1);
}
! fmttext = optarg;
fmt_done = 1;
break;
case 'F':
--- 353,359 ----
prog);
exit(1);
}
! Fmt.text = optarg;
fmt_done = 1;
break;
case 'F':
***************
*** 356,364 ****
prog);
exit(1);
}
! fmttext = loadfile(optarg);
fmt_done = 1;
! if (fmttext == NULL) {
(void) fprintf(stderr,
"%s: Failed to load format from `%s' -- ",
prog, optarg);
--- 363,372 ----
prog);
exit(1);
}
! Fmt.file = 1;
! Fmt.text = loadfile(optarg);
fmt_done = 1;
! if (Fmt.text == NULL) {
(void) fprintf(stderr,
"%s: Failed to load format from `%s' -- ",
prog, optarg);

*** viz-1.1.0/viz.h Wed Mar 29 14:26:55 1995
--- viz-1.1.1/viz.h Wed Mar 29 14:27:12 1995
***************
*** 1,11 ****
! /* Dep.h handles the system dependencies */
#include "dep.h"

extern long count_reg[256];
extern int process_to_eof;
extern int debug;
extern char *prog;
! extern char *fmttext;

#define UPTO_EOF -1000 /* Code for '$' used as a number; must not be -255..0,
* because those are the codes for the $x registers.
--- 1,24 ----
! /* System dependencies */
#include "dep.h"

+ struct Format {
+ char *text; /* The input format text */
+ char *p; /* For walking through the input. */
+ int file; /* !0 means format comes from file */
+ int linenum; /* current line number in format list */
+ char *line; /* pointer to start of current line */
+ char *item; /* pointer to one past last item */
+ };
+
extern long count_reg[256];
extern int process_to_eof;
extern int debug;
extern char *prog;
!
! #ifndef VIZ_MAIN
! extern struct Format Fmt;
! #endif
!

#define UPTO_EOF -1000 /* Code for '$' used as a number; must not be -255..0,
* because those are the codes for the $x registers.

*** viz-1.1.0/vizgrammar.y Wed Mar 29 14:26:52 1995
--- viz-1.1.1/vizgrammar.y Wed Mar 29 14:27:09 1995
***************
*** 171,182 ****
--- 171,184 ----
$$ = $1;
$$->count = 1;
$$->next = NIL;
+ Fmt.item = Fmt.p;
}
| count iounion
{
$$ = $2;
$$->count = $1;
$$->next = NIL;
+ Fmt.item = Fmt.p;
}
;

***************
*** 395,400 ****
--- 397,403 ----
(void) fprintf(stderr,
"%s: input size `%c' and output format `%c' cannot go together.\n",
prog, $$.iospec.ichar, $$.iospec.ochar);
+ yyerror("");
YYERROR;
}
}
***************
*** 405,410 ****
--- 408,414 ----
(void) fprintf(stderr,
"%s: input size `%c' and output format `%c' cannot go together.\n",
prog, $$.iospec.ichar, $$.iospec.ochar);
+ yyerror("");
YYERROR;
}
}
***************
*** 415,420 ****
--- 419,425 ----
(void) fprintf(stderr,
"%s: input size `%c' and output format `%c' cannot go together.\n",
prog, $$.iospec.ichar, $$.iospec.ochar);
+ yyerror("");
YYERROR;
}
}
***************
*** 444,493 ****
yyerror(s)
char *s;
{
! (void) fprintf(stderr, "%s: %s\n", prog, s);
}

yylex()
{
- static char *p=NULL; /* for walking through format list */
static char *tmpbuf; /* temporary storage for copyout text */

char *b;

! if (p == NULL) {
! p = fmttext;
! tmpbuf = malloc((unsigned) strlen(fmttext));
if (tmpbuf == NULL) {
(void) fprintf(stderr,
"%s: Can't malloc buffer space in yylex().\n", prog);
exit(1);
}
/* Eat leading whitespace */
! eatws1: while (isspace(*p))
! p++;
! if (*p == '#') {
/* Comment embedded in format; discard text through newline */
! while (*p && *p != '\n')
! p++;
goto eatws1;
}
/* If the first non-whitespace character is a digit,
* then the count is specified; don't process to eof.
*/
! if ( isdigit(*p) )
process_to_eof = 0;
else
process_to_eof = 1;
}

/* Eat whitespace */
! eatws2: while (isspace(*p))
! p++;

! if (*p == '#') {
/* Comment embedded in format; discard text through newline */
! while (*p && *p != '\n')
! p++;
goto eatws2;
}

--- 449,534 ----
yyerror(s)
char *s;
{
! if (s && *s)
! (void) fprintf(stderr, "%s: %s", prog, s);
! if (Fmt.p) {
! int n0, n1, n2;
! char *nl = strchr(Fmt.line, '\n');
! if (Fmt.file) {
! n0 = Fmt.item - Fmt.line;
! n1 = ((nl <= Fmt.p) ? nl : Fmt.p + 1) - Fmt.item;
! n2 = nl ? (nl - Fmt.line - n1 - n0) : 0;
! if (Fmt.item && Fmt.line)
! fprintf(stderr, " at line %d:\n\t%.*s >>>%.*s<<< %.*s\n",
! Fmt.linenum, n0, Fmt.line, n1, Fmt.item,
! n2, (nl < Fmt.p) ? nl : Fmt.p+1);
! else
! fprintf(stderr, " at line %d.\n", Fmt.linenum);
! } else {
! if (Fmt.item)
! fprintf(stderr, "\n%.*s >>>%.*s<<< %s\n",
! Fmt.item - Fmt.text, Fmt.text,
! Fmt.p + 1 - Fmt.item, Fmt.item,
! Fmt.p+1);
! else
! putc('\n', stderr);
! }
! }
! }
!
! /* Save our current location (assumes we are at a newline) */
! void
! mark_line() {
! Fmt.linenum++;
! Fmt.line = Fmt.item = Fmt.p;
}

yylex()
{
static char *tmpbuf; /* temporary storage for copyout text */

char *b;
+ char c;

! if (Fmt.p == NULL) {
! Fmt.p = Fmt.item = Fmt.line = Fmt.text;
! Fmt.linenum = 1;
! tmpbuf = malloc((unsigned) strlen(Fmt.text));
if (tmpbuf == NULL) {
(void) fprintf(stderr,
"%s: Can't malloc buffer space in yylex().\n", prog);
exit(1);
}
/* Eat leading whitespace */
! eatws1: while (isspace(*Fmt.p)) {
! if (*Fmt.p++ == '\n')
! mark_line();
! }
! if (*Fmt.p == '#') {
/* Comment embedded in format; discard text through newline */
! while (*Fmt.p && *Fmt.p != '\n')
! Fmt.p++;
goto eatws1;
}
/* If the first non-whitespace character is a digit,
* then the count is specified; don't process to eof.
*/
! if ( isdigit(*Fmt.p) )
process_to_eof = 0;
else
process_to_eof = 1;
}

/* Eat whitespace */
! eatws2: while (isspace(*Fmt.p)) {
! if (*Fmt.p++ == '\n')
! mark_line();
! }

! if (*Fmt.p == '#') {
/* Comment embedded in format; discard text through newline */
! while (*Fmt.p && *Fmt.p != '\n')
! Fmt.p++;
goto eatws2;
}

***************
*** 502,511 ****
*/
{
#define ifname(longname, shortname) \
! if (strncmp(p, longname, sizeof(longname)-1) == 0 && \
! !isalpha(*(p+sizeof(longname)-1))) { \
! p += sizeof(longname) - 2; \
! *p = shortname; \
}

ifname("char", 'C')
--- 543,552 ----
*/
{
#define ifname(longname, shortname) \
! if (strncmp(Fmt.p, longname, sizeof(longname)-1) == 0 && \
! !isalpha(*(Fmt.p+sizeof(longname)-1))) { \
! Fmt.p += sizeof(longname) - 2; \
! c = shortname; \
}

ifname("char", 'C')
***************
*** 517,529 ****
else ifname("double", 'D')
else ifname("seek", '!')
else ifname("print", 'P')

}
if (debug)
! fprintf(stderr, "(dbg) fmt = `%s'\n", p);

/* Now check for usual forms */
! switch (*p) {
case '\0':
return 0;
break;
--- 558,572 ----
else ifname("double", 'D')
else ifname("seek", '!')
else ifname("print", 'P')
+ else
+ c = *Fmt.p;

}
if (debug)
! fprintf(stderr, "(dbg) fmt = `%s'\n", Fmt.p);

/* Now check for usual forms */
! switch (c) {
case '\0':
return 0;
break;
***************
*** 540,551 ****
/* require count base to be 10; if we allow strtol to interpret
* hex, we'll have to interpret 10a (10 ascii) as count=266.
*/
! yylval.lval = strtol(p, &b, 10);
! if (b == p) {
fprintf(stderr, "%s: severe error: strtol(\"%s\",...) failed\n");
exit(1);
}
! p = b;
return NUMBER;
break;
case 'C':
--- 583,594 ----
/* require count base to be 10; if we allow strtol to interpret
* hex, we'll have to interpret 10a (10 ascii) as count=266.
*/
! yylval.lval = strtol(Fmt.p, &b, 10);
! if (b == Fmt.p) {
fprintf(stderr, "%s: severe error: strtol(\"%s\",...) failed\n");
exit(1);
}
! Fmt.p = b;
return NUMBER;
break;
case 'C':
***************
*** 555,561 ****
case 'F':
case 'D':
case 'Z':
! yylval.ival = *p++;
return INCHAR;
break;
case '~':
--- 598,605 ----
case 'F':
case 'D':
case 'Z':
! yylval.ival = c;
! *Fmt.p++;
return INCHAR;
break;
case '~':
***************
*** 568,590 ****
case 'x':
case 'f':
case 'g':
! yylval.ival = *p++;
return OUTCHAR;
break;
case 'h':
yylval.ival = 'x';
! p++;
return OUTCHAR;
break;
case '[':
! for (b = tmpbuf, p++; *p && *p != ']'; ) {
! if (*p == '\\' && *(p+1) == ']')
! { *b++ = *++p; p++; }
else
! *b++ = *p++;
}
! if (*p++ != ']') {
! (void) fprintf(stderr, "%s: Unterminated comment.\n", prog);
return LEXERROR;
}
*b = '\0';
--- 612,638 ----
case 'x':
case 'f':
case 'g':
! yylval.ival = *Fmt.p++;
return OUTCHAR;
break;
case 'h':
yylval.ival = 'x';
! Fmt.p++;
return OUTCHAR;
break;
case '[':
! for (b = tmpbuf, Fmt.p++; *Fmt.p && *Fmt.p != ']'; ) {
! if (*Fmt.p == '\n') {
! (void) fprintf(stderr, "%s: Unterminated output comment.\n", prog);
! return LEXERROR;
! }
! if (*Fmt.p == '\\' && *(Fmt.p+1) == ']')
! { *b++ = *++Fmt.p; Fmt.p++; }
else
! *b++ = *Fmt.p++;
}
! if (*Fmt.p++ != ']') {
! (void) fprintf(stderr, "%s: Unterminated output comment.\n", prog);
return LEXERROR;
}
*b = '\0';
***************
*** 596,634 ****
return COPYOUT;
break;
case ';':
! ++p;
return NEWLINE;
break;
case '\\':
! ++p;
! switch (*p) {
case 'n':
! ++p;
return NEWLINE;
break;
default:
(void) fprintf(stderr, "%s: unrecognized backslash sequence.\n");
}
case 'n':
! ++p;
return NEWLINE;
break;
case '(':
case ')':
! return (*p++);
break;
case '!':
! ++p;
return SEEK;
break;
case '$':
! yylval.ival = *++p;
! if (*p == '\0') {
(void) fprintf(stderr,
"%s: `$' cannot end the format.\n", prog);
return LEXERROR;
}
! p++;
if (yylval.ival == '$')
return EOF_COUNT; /* $$ is special: a count that means up-to-eof */

--- 644,682 ----
return COPYOUT;
break;
case ';':
! ++Fmt.p;
return NEWLINE;
break;
case '\\':
! ++Fmt.p;
! switch (*Fmt.p) {
case 'n':
! ++Fmt.p;
return NEWLINE;
break;
default:
(void) fprintf(stderr, "%s: unrecognized backslash sequence.\n");
}
case 'n':
! ++Fmt.p;
return NEWLINE;
break;
case '(':
case ')':
! return (*Fmt.p++);
break;
case '!':
! ++Fmt.p;
return SEEK;
break;
case '$':
! yylval.ival = *++Fmt.p;
! if (*Fmt.p == '\0') {
(void) fprintf(stderr,
"%s: `$' cannot end the format.\n", prog);
return LEXERROR;
}
! Fmt.p++;
if (yylval.ival == '$')
return EOF_COUNT; /* $$ is special: a count that means up-to-eof */

***************
*** 639,651 ****
return REG;
break;
case '>':
! yylval.ival = *++p;
! if (*p == '\0') {
(void) fprintf(stderr,
"%s: `>' must precede a register character.\n", prog);
return LEXERROR;
}
! p++;
return STORE;
break;
case '+':
--- 687,699 ----
return REG;
break;
case '>':
! yylval.ival = *++Fmt.p;
! if (*Fmt.p == '\0') {
(void) fprintf(stderr,
"%s: `>' must precede a register character.\n", prog);
return LEXERROR;
}
! Fmt.p++;
return STORE;
break;
case '+':
***************
*** 654,688 ****
case '/':
case '%':
case '=':
! yylval.ival = *p++;
return MATHOP;
break;
case '?':
case ':':
/* Used to form tests */
! return *p++;
break;
case 'P':
! yylval.ival = *p++;
return U_MATHOP;
break;
case '"':
/* User-entered format. Terminate it at '"'. */
! p++;
! for (b = tmpbuf; *p && *p != '"'; )
! *b++ = *p++;
! if (*p == '\0') {
(void) fprintf(stderr, "%s: Unterminated printf-fmt.\n", prog);
return LEXERROR;
}
*b = '\0';
! p++;
yylval.sval = tmpbuf;
return PCTSTRING;
break;
default:
! (void) fprintf(stderr,
! "%s: Invalid character `%c' in format.\n", prog, *p);
return LEXERROR;
}
/* NOTREACHED */
--- 702,742 ----
case '/':
case '%':
case '=':
! yylval.ival = *Fmt.p++;
return MATHOP;
break;
case '?':
case ':':
/* Used to form tests */
! return *Fmt.p++;
break;
case 'P':
! yylval.ival = *Fmt.p++;
return U_MATHOP;
break;
case '"':
/* User-entered format. Terminate it at '"'. */
! for (b = tmpbuf, Fmt.p++; *Fmt.p && *Fmt.p != '"'; ) {
! if (*Fmt.p == '\n') {
! (void) fprintf(stderr, "%s: Unterminated printf-fmt.\n", prog);
! return LEXERROR;
! }
! if (*Fmt.p == '\\' && *(Fmt.p+1) == '"')
! { *b++ = *++Fmt.p; Fmt.p++; }
! else
! *b++ = *Fmt.p++;
! }
! if (*Fmt.p++ != '"') {
(void) fprintf(stderr, "%s: Unterminated printf-fmt.\n", prog);
return LEXERROR;
}
*b = '\0';
! Fmt.p++;
yylval.sval = tmpbuf;
return PCTSTRING;
break;
default:
! fprintf(stderr, "%s: Invalid character `%c' in format\n", prog, *Fmt.p);
return LEXERROR;
}
/* NOTREACHED */

exit 0 # Just in case...

0 new messages