[net.nlang.greek] a program to write greek with

kyrimis@tilt.FUN (Kriton Kyrimis) (01/29/85)

Geia-xara se oloys!
  Eimai o Kritwnas (Kyrimis), sto Princeton, kai molis ematha gia to net, kai
ti einai to net.nlang.greek poy moy eixe anaferei o Xristos Papadimitrioy sthn
Ellada.
  To keimenaki ayto exei dyo skopoys:
  1- (To mantepsate) Na dw an mporw na steilw news.
  2- Na proteinw kati gia to thema twn frangolevantinikwn, sta opoia einai
     grammena ta mhnymata twn news, kai ypothetw olh h hlektronikh
     allhlografia metaksy twn Ellhnwn:
       H protash einai aplh: na standardaroyme thn antistoixhsh twn ellhnikwn
     grammatwn sto latiniko plhktrologio, wste meta na mporoyme "eykola" na ta
     typwsoyme san Ellhnika me kapoio filtro.
       H antistoixia poy moy erxetai amesws sto noy einai ayth thw ellhnikhw
     grafommhxanhw: 
	A=alpha, B=beta, G=gamma, D=delta, E=epsilon, Z=zeta, H=eta, U=theta,
	I=iota, K=kapa, L=lambda, M=mu, N=nu, J=xi, O=omikron, P=pi, R=rho,
	S=sigma, T=tau, Y=upsilon, F=fi, X=chi, C=psi, V=omega
	(to idio kai gia ta peza, me epipleon w=teliko sigma)
       Ean apofasisoyme na yiothethsoyme kati tetoio, mporoyme na
     xrhsimopoihsoyme to parakatw filtro, poy xrhsimopoiei to mathimatiko
     character set toy troff (h' vtroff, analoga me to poia apoxrwsh toy
     trexete). To programma exei kai diafora epi pleon features, poy
     perigrafontai sthn epikefalida toy. O logos poy xrhsimopoiei to
     mathimatiko character set kai oxi ta ellhnika tou UNIX, einai oti ayta
     einai poly mikra (toylaxiston sto BSD UNIX).
       An to programma ayto ftasei sto "eyry koino" kai, an yparxei
     endiaferon, mporw na steilw se deyterh fash ena ellhniko font gia ton
     versatec printer/plotter, poy to eftiaksa sta plaisia enos graphics
     course, gia na apallagoyme apo to filtro ( to font exei antistoixhsh
     ellhnikhs grafomhxanhs kai einai isomegethes me to 10 pt. roman font tou
     UNIX, kai epomenws pio eyanagnwsto - to mathimatiko, opws tha
     diapistwsete, den einai apolyta ikanopoihtiko).
        Arketa sas zalisa. Akoloythei to programma, kai ena mikro test gi' ayto.

					Kales doyleies!

-----------------TEST---------------------------------------
typwste me greek <test | vtroff -ms
h'
greek <test | troff -ms
analoga me to systhma sas
---------KOPSTE EDW GIA TO TEST-----------------------------
.LP
.nf
Ellhniko alfabhto:
abgdezhuiklmnjoprswtyfxcv
ABGDEZHUIKLMNJOPRS TYFXCV
Latiniko Alfabhto:
\abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ\

Kalh' ty'xh!
-----------------------TELOS TOY TEST------------------------

-----------------------PROGRAMMA-----------------------------
metafraste me cc greek.c -O -o greek
------------------KOPSTE EDW GIA TO PROGRAMMA----------------

#include <stdio.h>

#define TRUE -1
#define FALSE 0
#define NEWLINE '\n'
#define TAB '\t'

main()	/* Converts a text from Latin alphabet to Greek, using the math */
	/* special character set. Text is entered using the greek */
	/* typewriter convention. Accents are entered by entering a single */
	/* quote after the accented character. Latin characters are entered */
	/* between two backslashes. A backslash is specified as "\\", though */
	/* in order for it to be printed, one must specify two backslashes, */
	/* i.e. type "\\\\". troff commands may be embedded in the text. */

	/* Author: Kriton Kyrimis */
{
  int count,	/* number of current character in line */
      troff,	/* flag: are we processing a troff command? */
      greek,	/* flag: are we processing greek text? */
      back;	/* counts # of backslashes encountered */
  char c;	/* current character */

  greek = TRUE;	/* start in greek mode */
  troff = FALSE;	/* start in regular text mode (not troff commands) */
  count = 0;		/* we are at the begining of a line */
  while (c != EOF ){		/* while the file is not empty */
    c = fgetc(stdin);		/* read next character */
    if (c == EOF)		/* if EOF is reached, stop */
      continue;
    count++;			/* one more character has been read */
    if (c == NEWLINE){	/* if char was newline */
      printf("%c",c);		/* print it */
      count = 0;		/* we're back at the begining of line */
      troff = FALSE;		/* we don't know if line is troff cmd */
      continue;
    }
    if (c == '\\'){			/* if char was "\" */
      back++;				/* one more "\" found */
      greek = ~greek;			/* complement greek mode */
      if (back == 2){			/* if it was second consecutive */
					/* backslash */
	back = 0;			/* ignore them, */
	printf("\\");			/* output a backslash */
	continue;			/* and go read next char */
	}else
	continue;			/* go read next char */
    }
    if (c != '\\' && back == 1)		/* if char is not "\" */
      back = 0;				/* forget previous "\" */
    if (count == 1 && c == '.')		/* if line's first char is "." */
      troff = TRUE;			/* then line is troff cmd */
    if (troff)				/* if processing troff cmd */
      if (c != ' ' && c != NEWLINE && c != TAB){
					/* and char is not white space */
	printf("%c",c);			/* print char */
	continue;			/* and go read next one */
      }
    else{
      printf("%c",c);			/* else print char */
      troff = FALSE;			/* troff cmd ended */
      continue;
    }
    if (!greek){			/* if processing latin text */
      printf("%c",c);			/* output char */
      continue;				/* and go read next one */
    }
    switch (c){			/* map greek keyboard into */
				/* UNIX character set */
      case 'w':			/* w maps to terminal sigma */
	printf("\\(ts");	/* output terminal sigma sequence */
	break;
      case '\'':		/* ' is an acute accent */
	printf("\b\\(aa");	/* backspace & print accent sequence */
	break;
      case 'c':			/* c maps to psi */
	printf("\\(*q");	/* print psi sequence */
	break;
      case 'C':			/* same for capital C */
	printf("\\(*Q");
	break;
      case 'h':			/* h maps to eta */
	printf("\\(*y");	/* print eta sequence */
	break;
      case 'H':			/* same for capital H */
	printf("\\(*Y");
	break;
      case 'j':			/* j maps to xi */
	printf("\\(*c");	/* print xi sequence */
	break;
      case 'J':			/* same for capital J */
	printf("\\(*C");
	break;
      case 'u':			/* u maps to theta */
	printf("\\(*h");	/* print theta sequence */
	break;
      case 'U':			/* same for capital U */
	printf("\\(*H");
	break;
      case 'y':			/* y maps to upsilon */
	printf("\\(*u");	/* print upsilon sequence */
	break;
      case 'Y':			/* same for capital Y */
	printf("\\(*U");
	break;
      case 'v':			/* v maps to omega */
	printf("\\(*w");	/* print omega sequence */
	break;
      case 'V':			/* same for capital V */
	printf("\\(*W");
	break;
      default:
	if (( c >= 'a' && c <= 'z' && c != 'q')
	 || ( c >= 'A' && c <= 'Z' && c != 'Q' && c != 'W')){
				/* if character is a letter */
	  printf("\\(*%c",c);	/* print letter sequence */
	  break;
	}else
	  printf("%c",c);	/* else print the character */
    }
  }
}