Esempio n. 1
0
//
// returns 1 if the line is a N  but not FF one
//
char check_N_not_FF(const struct dela_entry* d) {
unichar t1[2];
u_strcpy(t1,"N");
unichar t2[3];
u_strcpy(t2,"FF");
return (char)(dic_entry_contain_gram_code(d,t1) && !(dic_entry_contain_gram_code(d,t2)));
}
Esempio n. 2
0
unichar_t *u_GFileNormalize(unichar_t *name) {
    unichar_t *pt, *base, *ppt;

    if ( (pt = uc_strstr(name,"://"))!=NULL ) {
	base = u_strchr(pt+3,'/');
	if ( base==NULL )
return( name );
	++base;
    } else if ( *name=='/' )
	base = name+1;
    else
	base = name;
    for ( pt=base; *pt!='\0'; ) {
	if ( *pt=='/' )
	    u_strcpy(pt,pt+1);
	else if ( uc_strncmp(pt,"./",2)==0 )
	    u_strcpy(pt,pt+2);
	else if ( uc_strncmp(pt,"../",2)==0 ) {
	    for ( ppt=pt-2; ppt>=base && *ppt!='/'; --ppt );
	    ++ppt;
	    if ( ppt>=base ) {
		u_strcpy(ppt,pt+3);
		pt = ppt;
	    } else
		pt += 3;
	} else {
	    while ( *pt!='/' && *pt!='\0' ) ++pt;
	    if ( *pt == '/' ) ++pt;
	}
    }
return( name );
}
Esempio n. 3
0
// Routine to load date qualifier strings from resources. Do not call before AfApp has m_hinst.
void LoadDateQualifiers()
{
	if (g_fDoneDateQual)
		return;

	int i;
	for (i = 0; i < 5; i++)
	{
		StrUni stu(g_rgridDateQual1[i]);
		Assert(stu.Length() < knPrecLen);
		u_strcpy(g_rgchwPrecFull[i], stu.Chars());
		StrAnsi sta(g_rgridDateQual1[i]);
		Assert(sta.Length() < knPrecLen);
		strcpy_s(g_rgchPrecFull[i], sta.Length(), sta.Chars());
	}
	for (i = 0; i < 2; i++)
	{
		StrUni stu(g_rgridDateQual2[i]);
		Assert(stu.Length() < knAdBcLen);
		u_strcpy(g_rgchwBC_ADFull[i], stu.Chars());
		StrAnsi sta(g_rgridDateQual2[i]);
		Assert(stu.Length() < knAdBcLen);
		strcpy_s(g_rgchBC_ADFull[i], sta.Length(), sta.Chars());
	}
	for (i = 0; i < 3; i++)
	{
		StrUni stu(g_rgridDateBlank[i]);
		Assert(stu.Length() < knBlankLen);
		u_strcpy(g_rgchwBlankFull[i], stu.Chars());
		StrAnsi sta(g_rgridDateBlank[i]);
		Assert(stu.Length() < knBlankLen);
		strcpy_s(g_rgchBlankFull[i], sta.Length(), sta.Chars());
	}
	g_fDoneDateQual = true;
}
Esempio n. 4
0
unichar_t* Wordlist_advanceSelectedCharsBy( SplineFont* sf, EncMap *map, unichar_t* txtu, int offset )
{
    unichar_t original_data[ PATH_MAX ];
    static unichar_t ret[ PATH_MAX ];
    int i = 0;

    u_strcpy( original_data, txtu );
    TRACE("Wordlist_advanceSelectedCharsBy(1) %s\n", u_to_c( txtu ));
    WordlistTrimTrailingSingleSlash( txtu );
    WordListLine wll = WordlistEscapedInputStringToParsedData( sf, txtu );

    int selectedCount = WordListLine_countSelected( wll );
    if( !selectedCount )
	wll->isSelected = 1;
    
    memset( ret, 0, sizeof(unichar_t) * PATH_MAX );
    for( i = 0; wll->sc; wll++, i++ )
    {
	SplineChar* sc = wll->sc;
        int element_selected = wll->isSelected;

        if( element_selected )
        {
            int pos = map->backmap[ sc->orig_pos ];
            pos += offset;
            int gid = pos < 0 || pos >= map->enccount ? -2 : map->map[pos];
            if( gid == -2 )
	    {
		// we can't find a glyph at the desired position.
		// so instead of dropping it we just do not perform the operation
		// on this char.
		pos -= offset;
		gid = pos < 0 || pos >= map->enccount ? -2 : map->map[pos];
		if( gid == -2 )
		{
		    // we can't go back manually!
		    u_strcpy( ret, original_data );
		    return ret;
		}
	    }
	    if( gid==-1 || !sf->glyphs[gid] ) 
                sc = SFMakeChar( sf, map, pos );
            else
                sc = sf->glyphs[gid];
        }
        
        
        if( element_selected )
            uc_strcat( ret, "[" );

        /* uc_strcat( ret, "/" ); */
        /* uc_strcat( ret, scarray[i]->name ); */
        uc_strcat( ret, Wordlist_getSCName( sc ));

        if( element_selected )
            uc_strcat( ret, "]" );
    }

    return ret;
}
Esempio n. 5
0
/**
 * Returns 1 if the given dictionary entry is a "V" one that does
 * not have the inflectional code "Y".
 */
char check_V_but_not_Y(struct dela_entry* d) {
unichar t1[2];
u_strcpy(t1,"V");
unichar t2[2];
u_strcpy(t2,"Y");
return dic_entry_contain_gram_code(d,t1) && (!dic_entry_contain_inflectional_code(d,t2));
}
Esempio n. 6
0
/**
 * Returns 1 if the given dictionary entry is a "V:W" one.
 */
char check_VW(const struct dela_entry* d) {
unichar t1[2];
u_strcpy(t1,"V");
unichar t2[2];
u_strcpy(t2,"W");
return dic_entry_contain_gram_code(d,t1) && dic_entry_contain_inflectional_code(d,t2);
}
Esempio n. 7
0
// names for affixes and rules can be choosen individually for each language
// definition in "<language>Compounds.cpp"
// struct _tags TAG and typedef tags declared in .h
// unicode version of names:
struct utags init_utags (tags T)
{
  struct utags UTAG;
  u_strcpy(UTAG.PREFIX, T.PREFIX);
  u_strcpy(UTAG.SUFFIX, T.SUFFIX);
  u_strcpy(UTAG.RULE,   T.RULE);
  return UTAG;
}
struct composition_rule* copy_composition_rule (struct composition_rule* a,
						struct composition_rule* b)
{
  for (int i = 0; i < MAX_NUMBER_OF_COMPOSITION_RULES; i++) {
    u_strcpy(a->before[i].string, b->before[i].string);
    a->before[i].YesNo = b->before[i].YesNo;
    a->before[i].type = b->before[i].type;
    if (a->before[i].string[0] == '\0')
      break;
  }
  for (int i = 0; i < MAX_NUMBER_OF_COMPOSITION_RULES; i++) {
    u_strcpy(a->after[i].string, b->after[i].string);
    a->after[i].YesNo = b->after[i].YesNo;
    a->after[i].type = b->after[i].type;
    if (a->after[i].string[0] == '\0')
      break;
  }
  u_strcpy(a->then.add, b->then.add);
  u_strcpy(a->then.del, b->then.del);
  u_strcpy(a->then.repl, b->then.repl);
  u_strcpy(a->then.substr_act, b->then.substr_act);
  u_strcpy(a->then.substr_next, b->then.substr_next);
  u_strcpy(a->then.undo_substr_act, b->then.undo_substr_act);
  u_strcpy(a->then.undo_substr_next, b->then.undo_substr_next);
  return a;
}
/**
 * This function moves outputs from final nodes to transitions leading to final nodes.
 */
static void subsequential_to_normal_transducer(struct dictionary_node* root,
		struct dictionary_node* node,
		struct string_hash* inf_codes,
		int pos,unichar* z,
		Ustring* normalizedOutput) {
struct dictionary_node_transition* tmp=node->trans;
int prefix_set=0;
Ustring* prefix=new_Ustring();
while (tmp!=NULL) {
	z[pos]=tmp->letter;
	z[pos+1]='\0';
	subsequential_to_normal_transducer(root,tmp->node,inf_codes,pos+1,z,normalizedOutput);
	/* First, if the destination state is final, we place its output on the output
	 * of the current transition */

	if (tmp->node->single_INF_code_list!=NULL) {
		//error("<%S>: output=<%S>\n",z,normalizedOutput->str);
		tmp->output=u_strdup(inf_codes->value[tmp->node->INF_code]);
	}
	if (normalizedOutput->len!=0) {
		/* Then, we add the normalized output obtained recursively, if any */
		//error("<%S>: moving normalized output <%S>\n",z,normalizedOutput->str);
		if (tmp->output==NULL) {
			tmp->output=u_strdup(normalizedOutput->str);
		} else {
			tmp->output=(unichar*)realloc(tmp->output,sizeof(unichar)*(1+normalizedOutput->len+u_strlen(tmp->output)));
		}
	}
	if (!prefix_set) {
		prefix_set=1;
		u_strcpy(prefix,tmp->output);
	} else {
		get_longest_common_prefix(prefix,tmp->output);
	}
	tmp=tmp->next;
}
if (node==root || node->single_INF_code_list!=NULL) {
	/* If we are in the initial state or a final one, we let the transitions as they are, since
	 * their outputs can not move more to the left */
	z[pos]='\0';
	free_Ustring(prefix);
	empty(normalizedOutput);
	return;
}
tmp=node->trans;
while (tmp!=NULL) {
	//error("prefix removal: <%S> => ",tmp->output);
	remove_prefix(prefix->len,tmp->output);
	//error("<%S>\n",tmp->output);
	tmp=tmp->next;
}
z[pos]='\0';
u_strcpy(normalizedOutput,prefix);
free_Ustring(prefix);
}
Esempio n. 10
0
/**
 * Allocates, initializes and returns a new corpus_entry structure.
 */
struct corpus_entry* new_corpus_entry(const unichar* line){
struct corpus_entry* entry = (corpus_entry*)malloc(sizeof(corpus_entry));
if(entry == NULL){
	fatal_alloc_error("compute_corpus_entry");
}
/* we fill corpus entry with information extracted from the corpus line*/
int pos = u_strrchr(line,'/');
if(pos == -1){
	fatal_error("Wrong format for line %S\n",line);
}
entry->word = (unichar*)malloc(sizeof(unichar)*(pos+1));
if(entry->word == NULL){
	fatal_alloc_error("compute_corpus_entry");
}
unichar* tmp = u_strcpy_sized(entry->word,pos+1,line);
u_strcat(tmp,"\0");

int code_pos = u_strrchr(line,':');
/* there are no morphological codes associated to this entry */
if(code_pos == -1){
	entry->pos_code = (unichar*)malloc(sizeof(unichar)*(u_strlen(line)-pos));
	if(entry->pos_code == NULL){
		fatal_alloc_error("new_corpus_entry");
	}
	u_strcpy(entry->pos_code,&line[pos+1]);
	entry->overall_codes = u_strdup(entry->pos_code);
}
else{
	entry->pos_code = (unichar*)malloc(sizeof(unichar)*(code_pos-pos));
	if(entry->pos_code == NULL){
		fatal_alloc_error("new_corpus_entry");
	}
	entry->overall_codes = (unichar*)malloc(sizeof(unichar)*(u_strlen(line)-pos));
	if(entry->overall_codes == NULL){
		fatal_alloc_error("new_corpus_entry");
	}
	unichar* tmp2 = u_strcpy_sized(entry->pos_code,code_pos-pos,&line[pos+1]);
	u_strcat(tmp2,"\0");
	u_strcpy(entry->overall_codes,&line[pos+1]);
}
/* if the token is not annotated in the corpus, we put "UNK" */
if(u_strlen(entry->pos_code) == 0){
	free(entry->pos_code);
	free(entry->overall_codes);
	entry->pos_code = u_strdup("UNK");
	entry->overall_codes = u_strdup("UNK");
}
return entry;
}
Esempio n. 11
0
U_CAPI double U_EXPORT2
unum_parseDoubleCurrency(const UNumberFormat* fmt,
                         const UChar* text,
                         int32_t textLength,
                         int32_t* parsePos, /* 0 = start */
                         UChar* currency,
                         UErrorCode* status) {
    double doubleVal = 0.0;
    currency[0] = 0;
    if (U_FAILURE(*status)) {
        return doubleVal;
    }
    const UnicodeString src((UBool)(textLength == -1), text, textLength);
    ParsePosition pp;
    if (parsePos != NULL) {
        pp.setIndex(*parsePos);
    }
    *status = U_PARSE_ERROR; // assume failure, reset if succeed
    LocalPointer<CurrencyAmount> currAmt(((const NumberFormat*)fmt)->parseCurrency(src, pp));
    if (pp.getErrorIndex() != -1) {
        if (parsePos != NULL) {
            *parsePos = pp.getErrorIndex();
        }
    } else {
        if (parsePos != NULL) {
            *parsePos = pp.getIndex();
        }
        if (pp.getIndex() > 0) {
            *status = U_ZERO_ERROR;
            u_strcpy(currency, currAmt->getISOCurrency());
            doubleVal = currAmt->getNumber().getDouble(*status);
        }
    }
    return doubleVal;
}
Esempio n. 12
0
/**
 * Loads the initial keyword list from a tok_by_freq.txt file,
 * and turns all those tokens in a list whose primary key is the
 * lower case token:
 * The/20 THE/2 the/50 => the->(The/20 THE/2 the/50)
 */
struct string_hash_ptr* load_tokens_by_freq(char* name,VersatileEncodingConfig* vec) {
U_FILE* f=u_fopen(vec,name,U_READ);
if (f==NULL) return NULL;
Ustring* line=new_Ustring(128);
Ustring* lower=new_Ustring(128);
struct string_hash_ptr* res=new_string_hash_ptr(1024);
int val,pos;
/* We skip the first line of the file, containing the number
 * of tokens
 */
if (EOF==readline(line,f)) {
	fatal_error("Invalid empty file %s\n",name);
}
while (EOF!=readline(line,f)) {
	if (1!=u_sscanf(line->str,"%d%n",&val,&pos)) {
		fatal_error("Invalid line in file %s:\n%S\n",name,line->str);
	}
	u_strcpy(lower,line->str+pos);
	u_tolower(lower->str);
	int index=get_value_index(lower->str,res,INSERT_IF_NEEDED,NULL);
	if (index==-1) {
		fatal_error("Internal error in load_tokens_by_freq\n");
	}
	KeyWord* value=(KeyWord*)res->value[index];
	res->value[index]=new_KeyWord(val,line->str+pos,value);
}
free_Ustring(line);
free_Ustring(lower);
u_fclose(f);
return res;
}
Esempio n. 13
0
/**
 * Loads a compound word file, adding each word to the keywords.
 */
void load_compound_words(char* name,VersatileEncodingConfig* vec,
		struct string_hash_ptr* keywords) {
U_FILE* f=u_fopen(vec,name,U_READ);
if (f==NULL) return;
Ustring* line=new_Ustring(256);
Ustring* lower=new_Ustring(256);
while (EOF!=readline(line,f)) {
	if (line->str[0]=='{') {
		/* We skip tags */
		continue;
	}
	u_strcpy(lower,line->str);
	u_tolower(lower->str);
	int index=get_value_index(lower->str,keywords,INSERT_IF_NEEDED,NULL);
	if (index==-1) {
		fatal_error("Internal error in load_tokens_by_freq\n");
	}
	KeyWord* value=(KeyWord*)keywords->value[index];
	add_keyword(&value,line->str,1);
	keywords->value[index]=value;
}
free_Ustring(line);
free_Ustring(lower);
u_fclose(f);
}
Esempio n. 14
0
const UChar *ZNStringPool::get(const UChar *s, UErrorCode &status) {
    const UChar *pooledString;
    if (U_FAILURE(status)) {
        return &EmptyString;
    }

    pooledString = static_cast<UChar *>(uhash_get(fHash, s));
    if (pooledString != NULL) {
        return pooledString;
    }

    int32_t length = u_strlen(s);
    int32_t remainingLength = POOL_CHUNK_SIZE - fChunks->fLimit;
    if (remainingLength <= length) {
        U_ASSERT(length < POOL_CHUNK_SIZE);
        if (length >= POOL_CHUNK_SIZE) {
            status = U_INTERNAL_PROGRAM_ERROR;
            return &EmptyString;
        }
        ZNStringPoolChunk *oldChunk = fChunks;
        fChunks = new ZNStringPoolChunk;
        if (fChunks == NULL) {
            status = U_MEMORY_ALLOCATION_ERROR;
            return &EmptyString;
        }
        fChunks->fNext = oldChunk;
    }
    
    UChar *destString = &fChunks->fStrings[fChunks->fLimit];
    u_strcpy(destString, s);
    fChunks->fLimit += (length + 1);
    uhash_put(fHash, destString, destString, &status);
    return destString;
}        
Esempio n. 15
0
void save_pattern (pattern* patterns, bool YesNo, unichar type, const unichar* patt)
{
  patterns->YesNo   = YesNo;
  patterns->type    = type;
  patterns->string[0] = '\0';
  u_strcpy(patterns->string, patt);
}
Esempio n. 16
0
 UINT64 *Uint64Comp::u_strdup(UINT64 *s) {
     int length = u_strlen(s) + 1;
     UINT64 *result = (UINT64*)malloc(length*sizeof(UINT64));
     if (result == (UINT64*)0){return (UINT64*)0;}
     u_strcpy(result, s);
     return result;
 }
Esempio n. 17
0
static void demo_C_Unicode_strings() {
    printf("\n* demo_C_Unicode_strings() --------- ***\n\n");

    static const UChar text[]={ 0x41, 0x42, 0x43, 0 };          /* "ABC" */
    static const UChar appendText[]={ 0x61, 0x62, 0x63, 0 };    /* "abc" */
    static const UChar cmpText[]={ 0x61, 0x53, 0x73, 0x43, 0 }; /* "aSsC" */
    UChar buffer[32];
    int32_t compare;
    int32_t length=u_strlen(text); /* length=3 */

    /* simple ANSI C-style functions */
    buffer[0]=0;                    /* empty, NUL-terminated string */
    u_strncat(buffer, text, 1);     /* append just n=1 character ('A') */
    u_strcat(buffer, appendText);   /* buffer=="Aabc" */
    length=u_strlen(buffer);        /* length=4 */
    printUString("should be \"Aabc\": ", buffer, -1);

    /* bitwise comparing buffer with text */
    compare=u_strcmp(buffer, text);
    if(compare<=0) {
        printf("String comparison error, expected \"Aabc\" > \"ABC\"\n");
    }

    /* Build "A<sharp s>C" in the buffer... */
    u_strcpy(buffer, text);
    buffer[1]=0xdf; /* sharp s, case-compares equal to "ss" */
    printUString("should be \"A<sharp s>C\": ", buffer, -1);

    /* Compare two strings case-insensitively using full case folding */
    compare=u_strcasecmp(buffer, cmpText, U_FOLD_CASE_DEFAULT);
    if(compare!=0) {
        printf("String case insensitive comparison error, expected \"AbC\" to be equal to \"ABC\"\n");
    }
}
Esempio n. 18
0
UChar *
make_alphabet(const UChar *source)
{
    UChar *dest;
    int sourcelen = u_strlen(source);
    int x, y;

    dest = safe_calloc(sourcelen + 1, sizeof(UChar));

    u_strcpy(dest, source);

    /* Very simple ripple sort as these are very short strings */
    /* No advantage in using qsort() or similar */
    for (x = 0; x < sourcelen - 1; x++) {
        for (y = x + 1; y < sourcelen ; y++) {
            if (dest[x] > dest[y]) {
                UChar temp;

                temp = dest[x];
                dest[x] = dest[y];
                dest[y] = temp;
            }
        }
    }

    x = y = 0;
    while (dest[x]) {
        if (dest[x] != dest[y])
            dest[++y] = dest[x];
        x++;
    }
    dest[++y] = dest[x];
    return dest;
}
Esempio n. 19
0
/**
 * This function loads concordance lines from 'f1' and/or 'f2' and prints them to
 * 'output' in the given color.
 */
void print_diff_matches(U_FILE* output,U_FILE* f1,U_FILE* f2,const char* color,
        unichar* match1,unichar* match2) {
unichar left1[MAX_CONTEXT_IN_UNITS];
unichar middle1[MAX_CONTEXT_IN_UNITS];
unichar right1[MAX_CONTEXT_IN_UNITS];
unichar indices1[MAX_CONTEXT_IN_UNITS];
unichar left2[MAX_CONTEXT_IN_UNITS];
unichar middle2[MAX_CONTEXT_IN_UNITS];
unichar right2[MAX_CONTEXT_IN_UNITS];
unichar indices2[MAX_CONTEXT_IN_UNITS];
if (f1!=NULL) {
   read_concordance_line(f1,left1,middle1,right1,indices1,match1==NULL?0:u_strlen(match1));
}
if (f2!=NULL) {
   read_concordance_line(f2,left2,middle2,right2,indices2,match2==NULL?0:u_strlen(match2));
}
if (match1!=NULL) u_strcpy(middle1,match1);
if (match2!=NULL) u_strcpy(middle2,match2);
if (!strcmp(color,RED)) {
    /* If we have one match included in the another, we want to align
     * them. We do that by adjusting their left contexts */
    int pos1,pos2;
    u_sscanf(indices1,"%d",&pos1);
    u_sscanf(indices2,"%d",&pos2);
    if (pos1<pos2) {
        adjust(left1,left2,middle1,pos2-pos1);
    } else if (pos1>pos2) {
        adjust(left2,left1,middle2,pos1-pos2);
    } /*  Nothing to adjust if pos1==pos2 */
}
/* We print the line from the first file, if needed */
u_fprintf(output,"<tr><td nowrap bgcolor=\"#FFE4C4\"><font color=\"%s\">",color);
if (f1!=NULL) {
   u_fprintf(output,"%HS<a href=\"%S\" style=\"color:%s\">%HS</a>%HS",left1,indices1,color,middle1,right1);
} else {
    u_fprintf(output,"&nbsp;");
}
u_fprintf(output,"</font></td></tr>\n");
u_fprintf(output,"<tr><td nowrap bgcolor=\"#90EE90\"><font color=\"%s\">",color);
/* We print the line from the second file, if needed */
if (f2!=NULL) {
   u_fprintf(output,"%HS<a href=\"%S\" style=\"color:%s\">%HS</a>%HS",left2,indices2,color,middle2,right2);
} else {
    u_fprintf(output,"&nbsp;");
}
u_fprintf(output,"</font></td></tr>\n");
}
Esempio n. 20
0
/**
 * This function parses a DELAF line and stores in the appropriate parameters
 * the inflected form, the lemma and the codes. If there is no lemma, it takes
 * the value of the inflected form. All these strings are unprotected:
 *
 * "3\,14,.PI" => inflected="3,14" lemma="3,14" codes="PI"
 */
void tokenize_DELA_line_into_3_parts(const unichar* line,unichar* inflected,unichar* lemma,unichar* codes) {
int i,j;
if (line==NULL) return;
/* We read the inflected form */
i=0;
j=0;
while (line[i]!='\0' && line[i]!=',') {
   if (line[i]=='\\') {
      /* We unprotect chars */
      i++;
      if (line[i]=='\0') {
         error("***Dictionary error: incorrect line\n%S\n",line);
         return;
      }
   }
   inflected[j++]=line[i++];
}
inflected[j]='\0';
if (line[i]=='\0') {
   error("***Dictionary error: incorrect line\n%S\n",line);
   return;
}
/* We read the lemma */
i++;
j=0;
while (line[i]!='\0' && line[i]!='.') {
   if (line[i]=='\\') {
      i++;
      if (line[i]=='\0') {
         error("***Dictionary error: incorrect line\n%S\n",line);
         return;
      }
   }
   lemma[j++]=line[i++];
}
lemma[j]='\0';
if (j==0) {
   /* If the lemma is not specified, we copy the inflected form */
   u_strcpy(lemma,inflected);
}
if (line[i]=='\0') {
   error("***Dictionary error: incorrect line\n%S\n",line);
   return;
}
/* We read the remaining part of the line */
i++;
j=0;
while (line[i]!='\0') {
   if (line[i]=='\\') {
      i++;
      if (line[i]=='\0') {
         error("***Dictionary error: incorrect line\n%S\n",line);
         return;
      }
   }
   codes[j++]=line[i++];
}
codes[j]='\0';
}
Esempio n. 21
0
bool Wordlist_selectionsEqual( unichar_t* s1, unichar_t* s2 )
{
    static unichar_t s1stripped[ PATH_MAX ];
    static unichar_t s2stripped[ PATH_MAX ];
    int s1HasSelection = 0;
    int s2HasSelection = 0;

    u_strcpy( s1stripped, Wordlist_selectionStringOnly( s1, &s1HasSelection ));
    u_strcpy( s2stripped, Wordlist_selectionStringOnly( s2, &s2HasSelection ));

    if( s1HasSelection && !s2HasSelection )
	return false;
    if( !s1HasSelection && s2HasSelection )
	return false;

    return !u_strcmp( s1stripped, s2stripped );
}
Esempio n. 22
0
/**
 * Returns 1 if the line is a valid right "A" component.
 */
char check_A_right_component(unichar* s) {
/* We produce an artifical dictionary entry with the given INF code,
 * and then, we tokenize it in order to get grammatical and inflectional
 * codes in a structured way. */
unichar temp[2000];
u_strcpy(temp,"x,");
u_strcat(temp,s);
struct dela_entry* d=tokenize_DELAF_line(temp,0);
unichar t1[2];
u_strcpy(t1,"A");
unichar t2[4];
u_strcpy(t2,"sie");
char res=dic_entry_contain_gram_code(d,t1) && !dic_entry_contain_inflectional_code(d,t2);
/* We free the artifical dictionary entry */
free_dela_entry(d);
return res;
}
Esempio n. 23
0
void LEXIC_trans_write(Elag_fst_file_out * fstf, int to) {

  unichar label[8];
  int idx;

  u_strcpy(label, "<MOT>");

  idx=get_value_index(label,fstf->labels);

  u_fprintf(fstf->f, "%d %d ", idx, to);

  u_strcpy(label, "<!MOT>");

  idx=get_value_index(label,fstf->labels);

  u_fprintf(fstf->f, "%d %d ", idx, to);
}
Esempio n. 24
0
CurrencyUnit& CurrencyUnit::operator=(const CurrencyUnit& other) {
    if (this == &other) {
        return *this;
    }
    MeasureUnit::operator=(other);
    u_strcpy(isoCode, other.isoCode);
    return *this;
}
Esempio n. 25
0
/**
 * Copies src into fst, and then appends the nth first chars of middle.
 */
static void adjust(unichar* src,unichar* dst,unichar* middle,int n) {
u_strcpy(dst,src);
int pos=u_strlen(dst);
for (int i=0;i<n;i++) {
    dst[pos++]=middle[i];
}
dst[pos]='\0';
}
Esempio n. 26
0
unichar_t *u_GFileGetAbsoluteName(unichar_t *name, unichar_t *result, int rsiz) {
    /* result may be the same as name */
    unichar_t buffer[1000];

    if ( ! u_GFileIsAbsolute(name) ) {
	unichar_t *pt, *spt, *rpt, *bpt;

	if ( dirname_[0]=='\0' ) {
	    getcwd(dirname_,sizeof(dirname_));
	}
	uc_strcpy(buffer,dirname_);
	if ( buffer[u_strlen(buffer)-1]!='/' )
	    uc_strcat(buffer,"/");
	u_strcat(buffer,name);
	_u_backslash_to_slash(buffer);

	/* Normalize out any .. */
	spt = rpt = buffer;
	while ( *spt!='\0' ) {
	    if ( *spt=='/' ) ++spt;
	    for ( pt = spt; *pt!='\0' && *pt!='/'; ++pt );
	    if ( pt==spt )	/* Found // in a path spec, reduce to / (we've*/
		u_strcpy(spt,pt); /*  skipped past the :// of the machine name) */
	    else if ( pt==spt+1 && spt[0]=='.' && *pt=='/' )	/* Noop */
		u_strcpy(spt,spt+2);
	    else if ( pt==spt+2 && spt[0]=='.' && spt[1]=='.' ) {
		for ( bpt=spt-2 ; bpt>rpt && *bpt!='/'; --bpt );
		if ( bpt>=rpt && *bpt=='/' ) {
		    u_strcpy(bpt,pt);
		    spt = bpt;
		} else {
		    rpt = pt;
		    spt = pt;
		}
	    } else
		spt = pt;
	}
	name = buffer;
    }
    if (result!=name) {
	u_strncpy(result,name,rsiz);
	result[rsiz-1]='\0';
	_u_backslash_to_slash(result);
    }
return(result);
}
Esempio n. 27
0
//
// returns 1 if the INF code refers to a valid right component, 0 else
//
char check_valid_right_component_for_one_INF_code_german(const unichar* s) {
unichar temp[2000];
u_strcpy(temp,"x,");
u_strcat(temp,s);
struct dela_entry* d=tokenize_DELAF_line(temp,0);
char res=check_N_not_FF(d);
free_dela_entry(d);
return res;
}
Esempio n. 28
0
unichar_t *u_GFileAppendFile(unichar_t *dir,unichar_t *name,int isdir) {
    unichar_t *ret, *pt;

    ret = (unichar_t *) malloc((u_strlen(dir)+u_strlen(name)+3)*sizeof(unichar_t));
    u_strcpy(ret,dir);
    pt = ret+u_strlen(ret);
    if ( pt>ret && pt[-1]!='/' )
	*pt++ = '/';
    u_strcpy(pt,name);
    if ( isdir ) {
	pt += u_strlen(pt);
	if ( pt>ret && pt[-1]!='/' ) {
	    *pt++ = '/';
	    *pt = '\0';
	}
    }
return(ret);
}
Esempio n. 29
0
    TZEnumeration(const char* country) : map(NULL), len(0), pos(0) {
        if (!getOlsonMeta()) {
            return;
        }

        UErrorCode ec = U_ZERO_ERROR;
        UResourceBundle *res = ures_openDirect(0, kZONEINFO, &ec);
        ures_getByKey(res, kREGIONS, res, &ec);
        if (U_SUCCESS(ec) && ures_getType(res) == URES_ARRAY) {
            UChar uCountry[] = {0, 0, 0, 0};
            if (country) {
                u_charsToUChars(country, uCountry, 2);
            } else {
                u_strcpy(uCountry, WORLD);
            }

            // count matches
            int32_t count = 0;
            int32_t i;
            const UChar *region;
            for (i = 0; i < ures_getSize(res); i++) {
                region = ures_getStringByIndex(res, i, NULL, &ec);
                if (U_FAILURE(ec)) {
                    break;
                }
                if (u_strcmp(uCountry, region) == 0) {
                    count++;
                }
            }

            if (count > 0) {
                map = (int32_t*)uprv_malloc(sizeof(int32_t) * count);
                if (map != NULL) {
                    int32_t idx = 0;
                    for (i = 0; i < ures_getSize(res); i++) {
                        region = ures_getStringByIndex(res, i, NULL, &ec);
                        if (U_FAILURE(ec)) {
                            break;
                        }
                        if (u_strcmp(uCountry, region) == 0) {
                            map[idx++] = i;
                        }
                    }
                    if (U_SUCCESS(ec)) {
                        len = count;
                    } else {
                        uprv_free(map);
                        map = NULL;
                    }
                } else {
                    U_DEBUG_TZ_MSG(("Failed to load tz for region %s: %s\n", country, u_errorName(ec)));
                }
            }
        }
        ures_close(res);
    }
Esempio n. 30
0
int check_is_valid_for_one_INF_code(const unichar* t, const unichar* s)
{
  unichar temp[MAX_DICT_LINE_LENGTH];
  u_strcpy(temp,"x,");
  u_strcat(temp,s);
  struct dela_entry* d = tokenize_DELAF_line(temp,0);
  int res = check_is_valid(t, d);
  free_dela_entry(d);
  return res;
}