int16_t setart_new (SOBJ * obj, int16_t * pa, uchar code, uchar type) { int16_t posn, stdn; int16_t i; LT * lt; char * pc; uchar c; // Valdemar+Lepik for russian if (!code) goto Ok_setart_new; /* code=0 => nothing to do */ posn = obj->art_minpos; /* curr pos-buf used to construct new pos */ if (posn <= obj->pos_part[obj->pos_part_nmb]) /* obj->pos[] & []pos<-obj */ { /* ? overlapped ? */ #ifdef SYSPR_ERROR PRINTF( /* Yes: */ "\n SYSTEM ERROR (SPELLART.SETPART_NEW): No buf for pos to change !\n"); #endif goto No_setart_new; } posn--; memset (&(obj->pos[posn]),0,sizeof(SPOS)); obj->pos[posn].type_art = obj->type_art; /* it's art pos */ if (code==BLANK) /* blank ? */ { /* Yes: */ obj->pos[posn].type_sp|= (T_BLANK|T_MYBLANK); /* it's blank pos */ obj->pos[posn]. orig.code = BLANK; obj->pos[posn].alt[0].orig.code = BLANK; obj->pos[posn]. lt = (LT *)&(std.stdlt[0]); obj->pos[posn].alt[0].lt = (LT *)&(std.stdlt[0]); for (i=0, lt=(LT *)&(std.stdlt[0]); i<ABCSize; i++,lt++) /* set all possible alts A-Z: */ obj->pos[posn].alt[i].lt = lt; /* all ltrs in std */ } else /* No: certain alternative */ { obj->pos[posn]. orig.code = code; obj->pos[posn].alt[0].orig.code = code; obj->pos[posn]. orig.attr = PROB_ALLOWED; obj->pos[posn].alt[0].orig.attr = PROB_ALLOWED; obj->pos[posn]. type = type; obj->pos[posn].alt[0].type = type; c = code; pc = &c; if (symcode(pc)==_DIG) /* digit ? */ { /* Yes */ obj->pos[posn]. lt = (LT *)&(stddig[c-'0']); obj->pos[posn].alt[0].lt = (LT *)&(stddig[c-'0']); } else { c = _2cap(code); stdn = getstdn(pc); if (std.stdlt[stdn].code == c) /* letter ? */ { /* Yes */ obj->pos[posn]. lt = (LT *)&(std.stdlt[stdn]); obj->pos[posn].alt[0].lt = (LT *)&(std.stdlt[stdn]); } else { #ifdef SYSPR_ERROR PRINTF ( "\n SYSTEM ERROR (SPELLART.SETART_NEW): alt not found in std!!!\n"); #endif goto No_setart_new; } } } obj->part->posn[*pa] = (uchar)posn; (*pa)++; obj->art_minpos = posn ; /* curr pos-buf used to construct new pos */ Ok_setart_new: return (Ok); No_setart_new: return (No); }
int16_t setwrd (SOBJ * obj, LTIMG * wrddef[] ) { int16_t i, pi, ai; SWORD * wrd; LT * lt; LT * wlt; wrd = obj->word->next; /* save ref to the next in part-word list */ memset ( obj->word, 0, sizeof(SWORD) ); obj->word->next = wrd; /* restore ref to the next ... */ memset ( obj->wordchar, 0, MAX_WORD_SIZE ); for (i=0; wrddef[i] ; i++) { obj->wordchar[i] = wrddef[i]->lt->code; /* word as a char-chain */ pi= obj->part->posn[i]; /* position number */ obj->word->pos[i] = &(obj->pos[pi]); /* ref to pos-item of obj */ if (obj->word->pos[i]->type_sp & T_BLANK) /* the pos is BLANK ? */ { /* BLANK => direct access to STD alt-list in obj->pos[]->alt[]: */ ai = getstdn((char *)&(wrddef[i]->lt->code)); /* AL 122892 */ /* was: if (obj->word->pos[i]->alt[ai].lt->code == wrddef[i]->lt->code) obj->word->altn[i] = ai; :was */ wlt = obj->word->pos[i]->alt[ai].lt; if (wlt == NULL) goto mytail1; /* He DOESN'T caught his tail */ if (wlt->code == wrddef[i]->lt->code) obj->word->altn[i] = (uchar)ai; else /* I've caught my tail ! */ { #ifdef SYSPR #ifdef SYSPR_ERROR PRINTF ("\n SYSTEM ERROR (SPELLSET.SETWORD): blank alt not found !!!\n"); #endif #endif return (No); } } else /* NOT BLANK pos, access via displacement: */ { lt =(LT *) &(wrddef[i]->std); lt +=0; ai = wrddef[i]->lt - lt; /* AL 122892 */ /* was: if (obj->word->pos[i]->alt[ai].lt->code == wrddef[i]->lt->code) obj->word->altn[i] = ai; :was */ wlt = obj->word->pos[i]->alt[ai].lt; if (wlt == NULL) goto mytail1; /* He DOESN'T caught his tail */ if (wlt->code == wrddef[i]->lt->code) obj->word->altn[i] = (uchar)ai; else /* I've caught my tail ! */ { mytail1: #ifdef SYSPR #ifdef SYSPR_ERROR PRINTF ("\n SYSTEM ERROR (SPELLSET.SETWORD): alt specified not found !!!\n"); #endif #endif return (No); } } } obj->word->lth=i; obj->wordchar[i]='\0'; return(Ok); }