summaryrefslogtreecommitdiff
path: root/fonts/redis/pretex.c
blob: 910b40a7d8a8adb57bfbcd73c7aa1ee021d62fa9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifdef MSDOS
#include "stdio.h"
#else
#include <stdio.h>
#endif
#define TRUE 1
#define FALSE 0
main(argc,argv)
int argc;char *argv[];
{
  int lrmode=TRUE,punct=FALSE,mathmode=FALSE; /* lrmode FALSE for Hebrew */
  int cur,delimiter,j;
  char temp[255];
  FILE *fin,*fout;
  if ( argc ^= 2 ) return;
  fin = fopen(*++argv,"r");
  if ( fin == NULL ) return;
  fout = fopen("hebtext.tex","w");
  if (fout == NULL) return;
  printf("This is PreTeX Version 0.9.\n");
  strcpy(temp,"");

#ifdef VMS
while (feof(fin) == NULL) {
     cur = getc(fin);
#else
while((cur=getc(fin)) != EOF) {
#endif
     if (lrmode) { putc(cur,fout); /* This is L2R text */
                   if (cur == '|') lrmode = TRUE - lrmode; }
     else {
            delimiter = TRUE; punct = TRUE;
            switch(cur) {  /* Scan for delimiter */
            case ' ':  punct=FALSE;break;
            case ',':  break;
            case '.':  break;
            case '\\': punct=FALSE;break; /* TeX's backslash */
            case '\n': punct=FALSE;break; /* New line */
            case '|':  punct=FALSE;break;
            case '$':  punct=FALSE;break;
            case ';':  break;
            case '?':  break;
            case '!':  break;
            case ':':  break;
            case '(':  break;
            case ')':  break;
            case '{':  break;
            case '}':  break;
            case '[':  break;
            case ']':  break;
            case '"':  punct=FALSE;break;
            default: delimiter = FALSE; } /* end Switch */


            if (delimiter) { if (punct) { j=strlen(temp); temp[j++]=cur;
                                         temp[j]=0;cur=' ';}

                                  if (strlen(temp) > 0)
                                  { if (mathmode==FALSE) reverse(temp);
                                    for (j=0; j<strlen(temp); j++)
                                               putc(temp[j],fout);
      if ((cur != '\\') && (cur != '\n')) putc('\n',fout);
                                    strcpy(temp,"");}
                                    if(cur != ' ') putc(cur,fout); /* anyway */
                             if (cur == '|') lrmode = TRUE-lrmode; }
               else {j=strlen(temp);temp[j++]=cur;temp[j]=0;}/*Store*/
      if (cur == '$') mathmode= TRUE - mathmode;
                  } }
fclose(fout);
fclose(fin);
return; } /* End main */

reverse(s)
char s[];{int c,i,j;for(i=0,j=strlen(s)-1;i<j;i++,j--){c=s[i];s[i]=s[j];
s[j]=c;}}