#include "ObjProGen/cpyrght_exe.h"
#include <stdio.h>
#include <ctype.h>
#include <string.h>
void main()
{
	int last_char = '\n' ;
	int this_char ;
	int in_comment = 0 ;
	int in_command = 0 ;
	int in_special = 0 ;
	char buf[4096];
	char * pt = 0 ;
	int bracket_count = 0 ;
	const char * exclude[] = {"DppNm", "section","subsection","subsubsection",
		"paragraph","item",0};
	
	while((this_char = fgetc(stdin))>0) {
		if (this_char == '\n') in_comment = 0 ;
		else if (this_char == '%' && last_char == '\n') in_comment = 1 ;
		// we only check for comments at the beginning because we dont
		// want to worry about verbatim text
		if (!in_comment) {
			if (in_command) if (this_char != '{') *pt++ = this_char ;
			else {
				*pt = '\0' ;
				int do_exclude = 0 ;
				for (const char ** ck = exclude; *ck; ck++) if(!strcmp(*ck,buf)) {
					do_exclude = 1 ;
					break ;
				}
				if (!do_exclude) bracket_count = 1 ;
				in_command = 0 ;
			} else if (bracket_count) if (this_char == '{') bracket_count++;
			else if (this_char == '}') bracket_count-- ;
	
			if (!bracket_count) if (this_char == '\\') {
				in_command = 1;
				pt = buf ;
			} else if(!isalnum(this_char)) in_command = 0 ;
			if (!in_command && !bracket_count) if (isupper(this_char) && islower(last_char)) {
				fputc('\\',stdout);
				fputc('-',stdout);
			}
		} // end not in comment
		fputc(last_char=this_char,stdout);
	}
}
