将Fortran程序转化成大写[cwp]

我是代码的搬运工

/* Copyright (c) Colorado School of Mines, 2011.*/
/* All rights reserved.                       */


/*********************** self documentation **********************/
/*
 * UPFORT - change Fortran programs to upper case, preserving strings
 *
 * Usage:   upfort < infile.f > outfile.f
 *
 * Reverse of: downfort
 *
 */
/**************** end self doc ********************************/

/*
 * Author: Brian Sumner
 */

#include "cwp.h"
#include <ctype.h>

int
main()
{

	register int c;
	while ((c = getchar()) != EOF) {
		if (c=='\n') putchar(c);
		else if (c=='*' || c=='C' || c=='c' || c=='D') {
			putchar(c);
			while((c = getchar()) != '\n') putchar(c);
			putchar(c);
		} else {
			putchar(c);
			while ((c = getchar()) != '\n') {
				if (c != '\'') putchar(islower(c) ? toupper(c)
								  : c);
				else {
					putchar(c);
					if ((c = getchar()) != '(') {
						putchar(c);
						while((c = getchar()) != '\'')
							putchar(c);
						putchar(c);
					} else {
						putchar(c);
						while((c = getchar()) != '\'')
				 			putchar(islower(c)
								 ? toupper(c)
								 : c);
						putchar(c);
					}
				}
			}
			putchar(c);
		}
	}
	fclose(stdout);
	return EXIT_SUCCESS;
}

 

相关推荐
©️2020 CSDN 皮肤主题: 酷酷鲨 设计师:CSDN官方博客 返回首页