| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
#include <config.h> |
| 13 |
|
| 14 |
#include <stdio.h> |
| 15 |
#include <string.h> |
| 16 |
#include <stdlib.h> |
| 17 |
#include "internal.h" |
| 18 |
#include "brl_checks.h" |
| 19 |
|
| 20 |
static const char** emph_classes = NULL; |
| 21 |
|
| 22 |
static formtype * |
| 23 |
typeform(const char* class, const char* fromString) |
| 24 |
{ |
| 25 |
int i; |
| 26 |
typeforms kind = plain_text; |
| 27 |
for (i = 0; emph_classes[i]; i++) { |
| 28 |
if (strcmp(class, emph_classes[i]) == 0) { |
| 29 |
switch (i) { |
| 30 |
case 0: kind = italic; break; |
| 31 |
case 1: kind = underline; break; |
| 32 |
case 2: kind = bold; break; |
| 33 |
case 3: kind = emph_4; break; |
| 34 |
case 4: kind = emph_5; break; |
| 35 |
case 5: kind = emph_6; break; |
| 36 |
case 6: kind = emph_7; break; |
| 37 |
case 7: kind = emph_8; break; |
| 38 |
case 8: kind = emph_9; break; |
| 39 |
case 9: kind = emph_10; break; |
| 40 |
default: |
| 41 |
fprintf(stderr, "CODING ERROR\n"); |
| 42 |
exit(1); |
| 43 |
} |
| 44 |
break; |
| 45 |
} |
| 46 |
} |
| 47 |
if (kind == plain_text) |
| 48 |
fprintf(stderr, "Warning: typeform '%s' was not declared\n", class); |
| 49 |
formtype *typeform = calloc(strlen(fromString), sizeof(formtype)); |
| 50 |
update_typeform(fromString, typeform, kind); |
| 51 |
return typeform; |
| 52 |
} |
| 53 |
|
| 54 |
int |
| 55 |
main (int argc, char **argv) |
| 56 |
{ |
| 57 |
int result = 0; |
| 58 |
const char* table; |
| 59 |
static formtype *formtype; |
| 60 |
table = "tests/tables/emphclass/emphclass_invalid_1.utb"; |
| 61 |
if (lou_getTable(table)) { |
| 62 |
fprintf(stderr, "%s should be invalid\n", table); |
| 63 |
return 1; |
| 64 |
} |
| 65 |
table = "tests/tables/emphclass/emphclass_invalid_2.utb"; |
| 66 |
if (lou_getTable(table)) { |
| 67 |
fprintf(stderr, "%s should be invalid\n", table); |
| 68 |
return 1; |
| 69 |
} |
| 70 |
table = "tests/tables/emphclass/emphclass_valid.utb"; |
| 71 |
if (!lou_getTable(table)) { |
| 72 |
fprintf(stderr, "%s should be valid\n", table); |
| 73 |
return 1; |
| 74 |
} |
| 75 |
emph_classes = lou_getEmphClasses(table); |
| 76 |
formtype = typeform("foo", "++++++"); |
| 77 |
result |= check(table, "foobar", "~,foobar", .typeform=formtype); |
| 78 |
if (emph_classes) free(emph_classes); |
| 79 |
free(formtype); |
| 80 |
lou_free(); |
| 81 |
return result; |
| 82 |
} |