--- ratfor-1.0.orig/rat4.c
+++ ratfor-1.0/rat4.c
@@ -31,6 +31,19 @@
  *	- support both && and & for .and.
  *	- support both || and | for .or.
  *
+ * 11-15-95 Emilio Lopes <ecl@if.usp.br> (Search for ECL to see my changes)
+ *      - Option -l now works (was disabled by some reason).
+ *      - Removed from usage message the options that are not yet
+ *        implemented.
+ *      - Added option -?, that shows usage message.
+ *
+ * 06-08-05 Alan Bain <alanb@chiark.greenend.org.uk> (AFRB tags changes)
+ *      - Fixed handling of include file to cope with 
+ *        absence of quotes (as per original ratfor specification)
+ *        so now support include file, include 'file' and include "file"
+ *        syntax.
+ *        
+ *
  */
 
 #include <stdio.h>
@@ -160,7 +173,8 @@
 
 	progname = argv[0];
 
-	while ((c=our_getopt(argc, argv, "Chn:o:6:")) != EOF)
+/* ECL	while ((c=our_getopt(argc, argv, "Chn:l:o:6:")) != EOF) */
+	while ((c=our_getopt(argc, argv, "C?n:l:o:")) != EOF)
 	switch (c) {
 		case 'C':
 			leaveC = YES; /* keep comments in src */
@@ -178,13 +192,17 @@
 		case '6':
 				/* not written yet */
 			break;
+                case '?':                    /* ECL */
+                        ++errflg;
+                        break;
 		default:
 			++errflg;
 	}
 
 	if (errflg) {
 		fprintf(stderr,
-		"usage: %s [-C][-hx][-l n][-o file][-6x] [file...]\n",progname);
+/* ECL		"usage: %s [-C][-hx][-l n][-o file][-6x] [file...]\n",progname); */
+		"usage: %s [-?] [-C] [-l n] [-o file] [file...]\n",progname);
 		exit(1);
 	}
 
@@ -225,7 +243,7 @@
 	install(bdef, deftyp);
 	fcname[0] = EOS;	/* current function name */
 	label = startlab;	/* next generated label */
-	printf("C Output from Public domain Ratfor, version 1.0\n");
+	printf("C Output from Public domain Ratfor, version 1.01\n");
 }
 
 /*
@@ -485,7 +503,7 @@
 				baderr("definition too long.");
 			defn[i++] = c;
 		}
-		while (c != SHARP && c != NEWLINE && c != (S_CHAR)EOF && c != PERCENT);
+		while (c != SHARP && c != NEWLINE && c != EOF && c != PERCENT);
 		if (c == SHARP || c == PERCENT)
 			putbak(c);
 	}
@@ -497,7 +515,7 @@
 		for (i = 0; nlpar >= 0; i++)
 			if (i > defsiz)
 				baderr("definition too long.");
-			else if (ngetch(&defn[i], fd) == (S_CHAR)EOF)
+			else if (ngetch(&defn[i], fd) == EOF)
 				baderr("missing right paren.");
 			else if (defn[i] == LPAREN)
 				nlpar++;
@@ -559,11 +577,19 @@
 				synerr("includes nested too deeply.");
 			else {
 /**/
-				name[i-1]=EOS;
-				infile[level+1] = fopen((char*)&name[2], "r");
-/*WSB 6-25-91
-				infile[level+1] = fopen(name, "r");
-*/
+				/* AFRB 6-7-2005 */
+				if ((name[1] == SQUOTE && name[i-1]==SQUOTE)
+						|| (name[1]==DQUOTE && name[i-1]==DQUOTE)) {
+					/* Truncation to remove quotes */
+					name[i-1]=EOS;
+					infile[level+1] = fopen((char*)&name[2], "r");
+				} else {
+					/* No quote syntax */
+					infile[level+1] = fopen ((char*) &name[1], "r");
+				}
+				/*WSB 6-25-91
+				  infile[level+1] = fopen(name, "r");
+				  */
 				linect[level+1] = 1;
 				if (infile[level+1] == NULL)
 					synerr("can't open include.");
@@ -743,7 +769,7 @@
 	if (lexstr[0] == NEWLINE)
 		linect[level] = linect[level] + 1;
 
-#if defined(CRAY) || defined(GNU)
+#ifdef CRAY
 /* cray cannot compare char and ints, since EOF is an int we check with feof */
 	if (feof(fd)) tok = EOF;
 #endif
@@ -1111,7 +1137,7 @@
 				nlpar++;
 			else if (t == RPAREN)
 				nlpar--;
-			if (t == (S_CHAR)EOF) {
+			if (t == EOF) {
 				pbstr(token);
 				return;
 			}
@@ -1138,13 +1164,12 @@
 			nlpar++;
 		else if (t == RPAREN)
 			nlpar--;
-		if (t == (S_CHAR)EOF) {
+		if (t == EOF) {
 			pbstr(token);
 			break;
 		}
 		if (nlpar >= 0 && t != NEWLINE && t != UNDERLINE) {
-			if ((j + ((int) strlen((char *) (&token[0])))) >=
-				((int) MAXFORSTK))
+			if (j + strlen((char *) (&token[0])) >= MAXFORSTK)
 				baderr("for clause too long.");
 			scopy(token, 0, forstk, j);
 			j = j + strlen((char *) (&token[0]));
@@ -1168,7 +1193,7 @@
 	j = 0;
 	for (i = 1; i < fordep; i++)
 		j = j + strlen((char *) (&forstk[j])) + 1;
-	if (((int) strlen((char *) (&forstk[j]))) > ((int) 0)) {
+	if (strlen((char *) (&forstk[j])) > 0) {
 		outtab();
 		outstr(&forstk[j]);
 		outdon();
