Blame view
tools/lia_ltbox/lia_ne_v2.2/src/decapital.c
3.37 KB
f34231730 add lia_ne + crf+... |
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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> /* ................................................................ */ #define TailleLigne 8000 #define True 1 #define False 0 void ERREUR(char *ch1, char *ch2) { fprintf(stderr, "ERREUR : %s %s ", ch1, ch2); exit(0); } /* ................................................................ */ /* ................................................................ */ #define IF_NUMBER(a) (((a)>='0')&&((a)<='9')) int if_capital(char c) { if ((c >= 'A') && (c <= 'Z')) return True; if ( (c == 'É') || (c == 'À') || (c == 'È') || (c == 'Ù') || (c == 'Â') || (c == 'Ê') || (c == 'Î') || (c == 'Ô') || (c == 'Û') || (c == 'Ä') || (c == 'Ë') || (c == 'Ï') || (c == 'Ö') || (c == 'Ü') || (c == 'Ç') ) return True; return False; } int if_lettre(char c) { if ((c >= 'A') && (c <= 'Z')) return True; if ((c >= 'a') && (c <= 'z')) return True; if ( (c == 'É') || (c == 'À') || (c == 'È') || (c == 'Ù') || (c == 'Â') || (c == 'Ê') || (c == 'Î') || (c == 'Ô') || (c == 'Û') || (c == 'Ä') || (c == 'Ë') || (c == 'Ï') || (c == 'Ö') || (c == 'Ü') || (c == 'Ç') || (c == 'é') || (c == 'à') || (c == 'è') || (c == 'ù') || (c == 'â') || (c == 'ê') || (c == 'î') || (c == 'ô') || (c == 'û') || (c == 'ä') || (c == 'ë') || (c == 'ï') || (c == 'ö') || (c == 'ü') || (c == 'ç') ) return True; return False; } char decapital(char c) { if ((c >= 'A') && (c <= 'Z')) return (c + ('a' - 'A')); if (c == 'É') return 'é'; if (c == 'À') return 'à'; if (c == 'È') return 'è'; if (c == 'Ù') return 'ù'; if (c == 'Â') return 'â'; if (c == 'Ê') return 'ê'; if (c == 'Î') return 'î'; if (c == 'Ô') return 'ô'; if (c == 'Û') return 'û'; if (c == 'Ä') return 'ä'; if (c == 'Ë') return 'ë'; if (c == 'Ï') return 'ï'; if (c == 'Ö') return 'ö'; if (c == 'Ü') return 'ü'; if (c == 'Ç') return 'ç'; return c; } char * decapital_string(char *pt) { int i; for (i = 0; pt[i]; i++) pt[i] = decapital(pt[i]); return pt; } int at_least_one(char *pt) { int i; for (i = 0; (pt[i]) && ((pt[i] < 'A') || (pt[i] > 'Z')); i++); return (pt[i] ? True : False); } /* ................................................................ */ int if_zarbi(char *pt, int *mixt) { int zarb; for (*mixt = False, zarb = False; *pt; pt++) if (((*pt) != '_') && ((*pt) != '\'') && ((*pt) != '\\') && ((*pt) != '/') && ((*pt) != '+') && ((*pt) != '!') && (!if_lettre(*pt)) && (!(IF_NUMBER((*pt))))) zarb = True; else *mixt = True; return zarb; } /* ................................................................ */ int main(int argc, char **argv) { char ch[TailleLigne]; int nb; /* if (argc>1) for(nb=1;nb<argc;nb++) if (!strcmp(argv[nb],"-XXXX")) { if (nb+1==argc) ERREUR("an option must follow option:",argv[nb]); XXXX } else if (!strcmp(argv[nb],"-h")) { fprintf(stderr,"Syntax: %s [-h] ",argv[0]); exit(0); } else ERREUR("unknown option:",argv[nb]); */ for (nb = 0; fgets(ch, TailleLigne, stdin); nb++) { printf("%s", decapital_string(ch)); } exit(0); } |