root/lang.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. mlesccpy
  2. mlescinsert

   1 /*
   2  *   Compound Text word statistics and search report
   3  *
   4  *   lang.c : ESC sequence copy & insert, language set, separator check 
   5  *
   6  *                                           Copyright(c) isao yasuda, 1998 
   7  */
   8 static char *rcs_id = "$Id: lang.c,v 1.3 2008/05/04 13:09:06 isao Exp $";
   9 
  10 #include <stdio.h>
  11 #include <string.h>
  12 #include "staslova.h"
  13 #include "table.h"
  14 
  15 void
  16 mlesccpy(void)
  17 {
  18   int c;
  19   unsigned char *escp = text;
  20 
  21   if ((strncmp(text, ESCASCII, 3)) == 0) {
  22     if (*(text+3) == '\n') {
  23       text += 4;
  24       return;
  25     } else {
  26       if (!(lang & JIS)) {
  27         text += 3;
  28         G0 = ASCII;
  29         return;
  30       }
  31     }
  32   } else if ((strncmp(text, ESCASCII ESC88591 "\n", 7)) == 0) {
  33     text += 7;
  34     return;
  35   } else if ((strncmp(text, ESC88591, 3)) == 0) {
  36     if (*(text+3) == '\n') {
  37       text += 4;
  38       return;
  39     } else {
  40       if (!(lang & (LATIN2 | CYRIL | OTHER))) {
  41         text += 3;
  42         G1 = LATIN1;
  43         return;
  44       }
  45     }
  46   } else if ((strncmp(text, ESC88591 ESCASCII "\n", 7)) == 0) {
  47     text += 7;
  48     return;
  49   }
  50 
  51   *wordp++ = *text++;
  52   if ((c = *wordp++ = *text++) == '\x28') {
  53     if ((c = *wordp++ = *text++) == '\x42') {
  54       G0 = ASCII;
  55     } else {
  56       fprintf(stderr, "Unsupported ESC sequence x1B28%X.(mlesccpy)\n", c);
  57       fprintf(stderr, "line no : %d\n", lno);
  58       G0 = ASCII;
  59     }
  60     escfg0 = 1; /* ESC wrote */
  61   } else if (c == '\x24') {
  62     if ((c = *wordp++ = *text++) == '\x28') {
  63       *wordp++ = *text++;
  64       strncpy(kanji_esc_save, escp, 4); 
  65       G0 = JIS;
  66     } else {
  67       fprintf(stderr, "Unsupported ESC sequence x1B24%X.(mlesccpy)\n", c);
  68       fprintf(stderr, "line no : %d\n", lno);
  69       *wordp++ = *text++;
  70       G0 = JIS;
  71     }
  72     escfg0 = 1; /* ESC wrote */
  73   } else if (c  == '\x2D') {
  74       switch (c = *wordp++ = *text++) {
  75       case '\x41' : G1 = LATIN1; break;
  76       case '\x42' : G1 = LATIN2; break;
  77       case '\x4C' : G1 = CYRIL;  break;
  78       default     : G1 = OTHER;  strncpy(esc_save, escp, 3); break;
  79       }
  80       escfg1 = 1; /* ESC wrote */
  81   } else {
  82     fprintf(stderr, "Unsupported ESC sequence x1B%X.(mlesccpy)\n", c);
  83     fprintf(stderr, "line no : %d\n", lno);
  84     *wordp++ = *text++;
  85     strncpy(esc_save, escp, 3);
  86     G1 = OTHER;
  87     escfg1 = 1; /* ESC wrote */
  88   }
  89 }
  90 
  91 void
  92 mlescinsert(int mode)
  93 {
  94   if (mode == IN) { /* mode == IN */
  95     if (*text < (unsigned char) '\xA0') {
  96       if (G0 == JIS) {
  97         sprintf(wordp, "%s", kanji_esc_save);
  98         wordp += 4;
  99       }
 100     } else {
 101       switch (G1) {
 102       case LATIN2 : sprintf(wordp, ESC88592); wordp += 3; break;
 103       case CYRIL  : sprintf(wordp, ESC88595); wordp += 3; break;
 104       case OTHER  : sprintf(wordp, "%s", esc_save); wordp += 3; break;
 105       default     : break;
 106       }
 107     }
 108   } else { /* mode == OUT */
 109     if ((lang == (BASE | ASCII)) || (lang == (BASE | LATIN1)) ||\
 110         (lang == (BASE | ASCII | LATIN1)))
 111       return;
 112     if (G0 == JIS) {
 113       sprintf(wordp, ESCASCII);
 114       wordp += 3;
 115       }
 116     if (G1 != LATIN1)
 117       if (lang & (LATIN2 | CYRIL | OTHER)) {
 118         sprintf(wordp, ESC88591);
 119         wordp += 3;
 120       }
 121   }
 122 }
 123 
 124 
 125 
 126 
 127 
 128 
 129 

/* [previous][next][first][last][top][bottom][index][help] */