summaryrefslogtreecommitdiff
path: root/indexing/makeindexk/scanid.c
diff options
context:
space:
mode:
Diffstat (limited to 'indexing/makeindexk/scanid.c')
-rw-r--r--indexing/makeindexk/scanid.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/indexing/makeindexk/scanid.c b/indexing/makeindexk/scanid.c
index aea5272d47..b9cc6492e0 100644
--- a/indexing/makeindexk/scanid.c
+++ b/indexing/makeindexk/scanid.c
@@ -418,6 +418,39 @@ static int
scan_no(char no[], int npg[], short *count, short *type)
{
int i = 1;
+ static int type_guess[PAGEFIELD_MAX] =
+ {EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY};
+
+ /* heuristic detection if a letter is Roman or Alpha ::
+ "IVX" as roman number since I=1, V=5, X=10 are quite small
+ "LCDM" as alphabet since L=50, C=100, D=100, M=1000 are quite large */
+ if (isdigit((unsigned char)no[0])) {
+ type_guess[*count] = ARAB;
+ } else if (IS_ROMAN_LOWER(no[0]) && IS_ALPHA_LOWER(no[0])
+ && strchr(page_prec,ROMAN_LOWER) && strchr(page_prec,ALPHA_LOWER)) {
+ if (strspn(no,"ivxlcdm")==1 /* ambiguous */
+ && type_guess[*count] != ROML && type_guess[*count] != ALPL) {
+ type_guess[*count] = strspn(no,"ivx")==1 ? ROML : ALPL;
+ }
+ if (strspn(no,"ivxlcdm")>1) type_guess[*count] = ROML;
+ } else if (IS_ROMAN_UPPER(no[0]) && IS_ALPHA_UPPER(no[0])
+ && strchr(page_prec,ROMAN_UPPER) && strchr(page_prec,ALPHA_UPPER)) {
+ if (strspn(no,"IVXLCDM")==1 /* ambiguous */
+ && type_guess[*count] != ROMU && type_guess[*count] != ALPU) {
+ type_guess[*count] = strspn(no,"IVX")==1 ? ROMU : ALPU;
+ }
+ if (strspn(no,"IVXLCDM")>1) type_guess[*count] = ROMU;
+ } else if (IS_ROMAN_LOWER(no[0]) && strchr(page_prec,ROMAN_LOWER)) {
+ type_guess[*count] = ROML;
+ } else if (IS_ROMAN_UPPER(no[0]) && strchr(page_prec,ROMAN_UPPER)) {
+ type_guess[*count] = ROMU;
+ } else if (IS_ALPHA_LOWER(no[0]) && strchr(page_prec,ALPHA_LOWER)) {
+ type_guess[*count] = ALPL;
+ } else if (IS_ALPHA_UPPER(no[0]) && strchr(page_prec,ALPHA_UPPER)) {
+ type_guess[*count] = ALPU;
+ } else {
+ type_guess[*count] = EMPTY;
+ }
if (isdigit((unsigned char)no[0])) {
*type = ARAB;
@@ -425,13 +458,13 @@ scan_no(char no[], int npg[], short *count, short *type)
return (FALSE);
/* simple heuristic to determine if a letter is Roman or Alpha */
} else if (IS_ROMAN_LOWER(no[0]) && strchr(page_prec,ROMAN_LOWER) &&
- (!strchr(page_prec,ALPHA_LOWER) || (!IS_COMPOSITOR))) {
+ (!strchr(page_prec,ALPHA_LOWER) || type_guess[*count] == ROML) ) {
*type = ROML;
if (!scan_roman_lower(no, npg, count))
return (FALSE);
/* simple heuristic to determine if a letter is Roman or Alpha */
} else if (IS_ROMAN_UPPER(no[0]) && strchr(page_prec,ROMAN_UPPER) &&
- (!strchr(page_prec,ALPHA_UPPER) || (!IS_COMPOSITOR))) {
+ (!strchr(page_prec,ALPHA_UPPER) || type_guess[*count] == ROMU) ) {
*type = ROMU;
if (!scan_roman_upper(no, npg, count))
return (FALSE);