Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

docs

  • Loading branch information...
commit a6c62ee027f25932435a60fb0f7a844204bf4001 1 parent d9a2ee9
@tj authored
Showing with 40 additions and 27 deletions.
  1. +36 −27 src/parser.c
  2. +4 −0 src/parser.leg
View
63 src/parser.c
@@ -976,49 +976,58 @@ YY_PARSE(void) YY_NAME(parse_free)(CDESCENT *G)
#endif
-void yyerror(struct _CDESCENT *G, char *message)
-{
+void
+yyerror(struct _CDESCENT *G, char *message) {
fprintf(stderr, "%s:%d: %s", filename, lineNumber, message);
if (G->text[0]) fprintf(stderr, " near token '%s'", G->text);
- if (G->pos < G->limit || !feof(input))
- {
- G->buf[G->limit]= '\0';
- fprintf(stderr, " before text \"");
- while (G->pos < G->limit)
- {
- if ('\n' == G->buf[G->pos] || '\r' == G->buf[G->pos]) break;
- fputc(G->buf[G->pos++], stderr);
- }
- if (G->pos == G->limit)
- {
- int c;
- while (EOF != (c= fgetc(input)) && '\n' != c && '\r' != c)
- fputc(c, stderr);
- }
- fputc('\"', stderr);
+ if (G->pos < G->limit || !feof(input)) {
+ G->buf[G->limit]= '\0';
+ fprintf(stderr, " before text \"");
+
+ while (G->pos < G->limit) {
+ if ('\n' == G->buf[G->pos] || '\r' == G->buf[G->pos]) break;
+ fputc(G->buf[G->pos++], stderr);
+ }
+
+ if (G->pos == G->limit) {
+ int c;
+ while (EOF != (c= fgetc(input)) && '\n' != c && '\r' != c)
+ fputc(c, stderr);
}
+
+ fputc('\"', stderr);
+ }
+
fprintf(stderr, "\n");
exit(1);
}
-void makeHeader(char *text)
-{
- Header *header= (Header *)malloc(sizeof(Header));
- header->text= strdup(text);
- header->next= headers;
- headers= header;
+void
+makeHeader(char *text) {
+ Header *header = (Header *)malloc(sizeof(Header));
+ header->text = strdup(text);
+ header->next = headers;
+ headers = header;
}
-void makeTrailer(char *text)
-{
- trailer= strdup(text);
+void
+makeTrailer(char *text) {
+ trailer = strdup(text);
}
+/*
+ * Output cDescent version.
+ */
+
static void
version() {
printf("%s\n", CDESCENT_VERSION);
}
+/*
+ * Output usage information.
+ */
+
static void
usage(char *name) {
fprintf(stderr,
View
4 src/parser.leg
@@ -218,6 +218,10 @@ usage(char *name) {
exit(1);
}
+/*
+ * Parse arguments.
+ */
+
int
main(int argc, char **argv) {
CDESCENT *G;
Please sign in to comment.
Something went wrong with that request. Please try again.