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 49... Line 49...
49
 
49
 
50
/* Exit without translating anything */
50
/* Exit without translating anything */
51
void escape(void)
51
void escape(void)
52
{
52
{
53
    printf("%s",inpbuf); exit(0);
53
    printf("%s",inpbuf); exit(0);
54
}
-
 
55
 
-
 
56
/* strip trailing spaces; return string end. */
-
 
57
char *strip_trailing_spaces2(char *p)
-
 
58
{
-
 
59
    char *pp;
-
 
60
    if(*p==0) return p;
-
 
61
    for(pp=p+strlen(p)-1; pp>=p && isspace(*pp); *(pp--)=0);
-
 
62
    return pp;
-
 
63
}
54
}
64
 
55
 
65
int compare(int i1, const char *s2)
56
int compare(int i1, const char *s2)
66
{
57
{
67
    int k;
58
    int k;
Line 89... Line 80...
89
      j=i1+(i2-i1)/2;
80
      j=i1+(i2-i1)/2;
90
      k=list[j].original[0]-c; if(k==0) k=compare(j,str);
81
      k=list[j].original[0]-c; if(k==0) k=compare(j,str);
91
      if(k==0) goto more;
82
      if(k==0) goto more;
92
      if(k>0) {i2=j; continue;}
83
      if(k>0) {i2=j; continue;}
93
      if(k<0) {i1=j; continue;}
84
      if(k<0) {i1=j; continue;}
94
    }
85
    }
95
    if(k>0) {j--;k=compare(j,str);}
86
    if(k>0) {j--;k=compare(j,str);}
96
    more:
87
    more:
97
    if((t=list[j].earlier)<0) {
88
    if((t=list[j].earlier)<0) {
98
      if(k==0) return j; else return -1;
89
      if(k==0) return j; else return -1;
99
    }
90
    }
100
    if(compare(t,str)!=0) return -1;
91
    if(compare(t,str)!=0) return -1;
101
    for(j=t1=t,k=0;j<items && list[j].earlier==t1 && (k=compare(j,str))<=0; j++) {
92
    for(j=t1=t,k=0;j<items && list[j].earlier==t1 && (k=compare(j,str))<=0; j++) {
102
      if(k==0) t=j;
93
      if(k==0) t=j;
103
    }
94
    }
104
    return t;
95
    return t;
105
}
-
 
106
 
-
 
107
/* modify a string. Bufferlen must be at least MAX_LINELEN */
-
 
108
void string_modify3(char *start, char *bad_beg, char *bad_end, char *good,...)
-
 
109
{
-
 
110
    char buf[MAX_LINELEN+1];
-
 
111
    va_list vp;
-
 
112
 
-
 
113
    va_start(vp,good);
-
 
114
    vsnprintf(buf,sizeof(buf),good,vp); va_end(vp);
-
 
115
    if(strlen(start)-(bad_end-bad_beg)+strlen(buf)>=2*MAX_LINELEN)
-
 
116
      return; /* this is an error situation. */
-
 
117
    strcat(buf,bad_end);
-
 
118
    ovlstrcpy(bad_beg,buf);
-
 
119
}
96
}
120
 
97
 
121
/* change all spaces into ' ', and collapse multiple occurences */
98
/* change all spaces into ' ', and collapse multiple occurences */
122
void singlespace2(char *p)
99
void singlespace2(char *p)
123
{
100
{