Subversion Repositories wimsdev

Rev

Rev 8185 | Rev 8898 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8185 Rev 8863
Line 42... Line 42...
42
int entrycount;
42
int entrycount;
43
 
43
 
44
int nocase=0, hassuffix=0, leaveline=0;
44
int nocase=0, hassuffix=0, leaveline=0;
45
int entrycount, ocount;
45
int entrycount, ocount;
46
 
46
 
47
/* strip trailing spaces; return string end. */
-
 
48
char *strip_trailing_spaces2(char *p)
-
 
49
{
-
 
50
    char *pp;
-
 
51
    if(*p==0) return p;
-
 
52
    for(pp=p+strlen(p)-1; pp>=p && isspace(*pp); *(pp--)=0);
-
 
53
    return pp;
-
 
54
}
-
 
55
 
-
 
56
int compare(const void *s1, const void *s2)
47
int compare(const void *s1, const void *s2)
57
{
48
{
58
    const struct entry *p1, *p2;
49
    const struct entry *p1, *p2;
59
    p1=s1; p2=s2;
50
    p1=s1; p2=s2;
60
    if(nocase) return strcasecmp(p1->original,p2->original);
51
    if(nocase) return strcasecmp(p1->original,p2->original);
61
    else return strcmp(p1->original,p2->original);
52
    else return strcmp(p1->original,p2->original);
62
}
53
}
63
 
54
 
64
void sortdic(void)
55
void sortdic(void)
65
{
56
{
66
    qsort(entry,entrycount,sizeof(entry[0]),compare);
57
    qsort(entry,entrycount,sizeof(entry[0]),compare);
67
}
-
 
68
 
-
 
69
/* modify a string. Bufferlen must be at least MAX_LINELEN */
-
 
70
void string_modify3(char *start, char *bad_beg, char *bad_end, char *good,...)
-
 
71
{
-
 
72
    char buf[MAX_LINELEN+1];
-
 
73
    va_list vp;
-
 
74
 
-
 
75
    va_start(vp,good);
-
 
76
    vsnprintf(buf,sizeof(buf),good,vp); va_end(vp);
-
 
77
    if(strlen(start)-(bad_end-bad_beg)+strlen(buf)>=MAX_LINELEN)
-
 
78
      return; /* this is an error situation. */
-
 
79
    strcat(buf,bad_end);
-
 
80
    ovlstrcpy(bad_beg,buf);
-
 
81
}
58
}
82
 
59
 
83
/* change all spaces into ' ', and collapse multiple occurences */
60
/* change all spaces into ' ', and collapse multiple occurences */
84
void singlespace2(char *p)
61
void singlespace2(char *p)
85
{
62
{