1 /* -*-C-*-
2 
3 Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
4     1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
5     2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Massachusetts
6     Institute of Technology
7 
8 This file is part of MIT/GNU Scheme.
9 
10 MIT/GNU Scheme is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or (at
13 your option) any later version.
14 
15 MIT/GNU Scheme is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 General Public License for more details.
19 
20 You should have received a copy of the GNU General Public License
21 along with MIT/GNU Scheme; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,
23 USA.
24 
25 */
26 
27 /* Program to preprocess assembly files for Intel assembler.  */
28 
29 #include <stdio.h>
30 
31 void
main(unsigned int argc,const char ** argv)32 main (unsigned int argc, const char ** argv)
33 {
34   if ((argc > 1) && ((strcmp ((argv[1]), "pre")) == 0))
35     {
36       /* Convert '#' to ';' and eliminate formfeeds.  */
37       printf("changecom(`;')\n");
38       while (1)
39 	{
40 	  int c = (getchar ());
41 	  switch (c)
42 	    {
43 	    case EOF: exit (0);
44 	    case '#': putchar (';'); break;
45 	    case '\f': break;
46 	    default: putchar (c); break;
47 	    }
48 	}
49     }
50   else
51     {
52       /* Delete blank lines.  */
53       enum state { line_start, line_middle };
54       enum state s = line_start;
55       while (1)
56 	{
57 	  int c = (getchar ());
58 	  if (c == EOF)
59 	    exit (0);
60 	  if (c == '\n')
61 	    {
62 	      if (s == line_middle)
63 		{
64 		  putchar (c);
65 		  s = line_start;
66 		}
67 	    }
68 	  else
69 	    {
70 	      putchar (c);
71 	      s = line_middle;
72 	    }
73 	}
74     }
75 }
76