Rev 8123 | Rev 8185 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8123 | Rev 8149 | ||
---|---|---|---|
Line 75... | Line 75... | ||
75 | } mod[MAX_MODULES]; |
75 | } mod[MAX_MODULES]; |
76 | int modcnt; |
76 | int modcnt; |
77 | 77 | ||
78 | char *mlist; |
78 | char *mlist; |
79 | 79 | ||
80 | /* |
- | |
81 | void *xmalloc(size_t n) |
- | |
82 | { |
- | |
83 | void *p; |
- | |
84 | p=malloc(n); |
- | |
85 | if(p==NULL) { |
- | |
86 | printf("Malloc failure.\n"); |
- | |
87 | exit(1); |
- | |
88 | } |
- | |
89 | return p; |
- | |
90 | } |
- | |
91 | */ |
- | |
92 | - | ||
93 | /* |
- | |
94 | char *acctab="çéèêëúùûüáàâäãóòôöõíìïîñýÿÇÉÈÊËÚÙÛÜÁÀÂÃÄÓÒÔÖÕÍÌÏÎÑÝ", |
- | |
95 | *deatab="ceeeeuuuuaaaaaoooooiiiinyyCEEEEUUUUAAAAAOOOOOIIIINY"; |
- | |
96 | */ |
- | |
97 | /* fold known accented letters to unaccented, other strange characters to space |
80 | /* fold known accented letters to unaccented, other strange characters to space |
98 | * apostrophe is among the exceptions to be kept (important for multi-word expressions) |
81 | * apostrophe is among the exceptions to be kept (important for multi-word expressions) |
99 | */ |
82 | */ |
100 | void deaccent2(char *p) |
83 | void deaccent2(char *p) |
101 | { |
84 | { |
102 | char *sp; |
85 | char *sp; |
103 | char *v; |
86 | char *v; |
104 | for(sp=p;*sp;sp++) { |
87 | for(sp=p;*sp;sp++) { |
105 | if(*sp<0 && (v=strchr(acctab,*sp))!=NULL) |
88 | if(*sp<0 && (v=strchr(acctab,*sp))!=NULL) |
106 | *sp=*(deatab+(v-acctab)); |
89 | *sp=*(deatab+(v-acctab)); |
107 | if(!isalnum(*sp) && strchr(",.&$+*",*sp)==0) *sp=' '; |
90 | if(!isalnum(*sp) && strchr(",.&$+*",*sp)==0) *sp=' '; |
108 | else *sp=tolower(*sp); |
91 | else *sp=tolower(*sp); |
109 | } |
92 | } |
110 | } |
93 | } |
111 | 94 | ||
112 | /* translate everything non-alphanumeric into space */ |
95 | /* translate everything non-alphanumeric into space */ |
113 | void towords(char *p) |
96 | void towords(char *p) |
114 | { |
97 | { |
115 | char *pp; |
98 | char *pp; |
116 | for(pp=p;*pp;pp++) if(!isalnum(*pp) && strchr("&$+*",*pp)==0) *pp=' '; |
99 | for(pp=p;*pp;pp++) if(!isalnum(*pp) && strchr("&$+*",*pp)==0) *pp=' '; |
117 | } |
100 | } |
118 | 101 | ||
119 | /* Points to the end of the word */ |
- | |
120 | /* |
- | |
121 | char *find_word_end(char *p) |
- | |
122 | { |
- | |
123 | int i; |
- | |
124 | for(i=0;!isspace(*p) && *p!=0 && i<MAX_LINELEN; p++,i++); |
- | |
125 | return p; |
- | |
126 | } |
- | |
127 | */ |
- | |
128 | /* Strips leading spaces */ |
- | |
129 | /* |
- | |
130 | char *find_word_start(char *p) |
- | |
131 | { |
- | |
132 | int i; |
- | |
133 | for(i=0; isspace(*p) && i<MAX_LINELEN; p++,i++); |
- | |
134 | return p; |
- | |
135 | } |
- | |
136 | */ |
- | |
137 | /* Find first occurrence of word */ |
102 | /* Find first occurrence of word */ |
138 | char *wordchr2(char *p, char *w) |
103 | char *wordchr2(char *p, char *w) |
139 | { |
104 | { |
140 | char *r; |
105 | char *r; |
141 | 106 | ||
142 | for(r=strstr(p,w);r!=NULL && |
107 | for(r=strstr(p,w);r!=NULL && |
143 | ( (r>p && !isspace(*(r-1))) || (!isspace(*(r+strlen(w))) && *(r+strlen(w))!=0) ); |
108 | ( (r>p && !isspace(*(r-1))) || (!isspace(*(r+strlen(w))) && *(r+strlen(w))!=0) ); |
144 | r=strstr(r+1,w)); |
109 | r=strstr(r+1,w)); |
145 | return r; |
110 | return r; |
146 | } |
111 | } |
147 | 112 | ||
148 | /* find a variable in a string (math expression). |
- | |
149 | * Returns the pointer or NULL. |
- | |
150 | */ |
- | |
151 | /*char *varchr(char *p, char *v) |
- | |
152 | { |
- | |
153 | char *pp; int n=strlen(v); |
- | |
154 | for(pp=strstr(p,v); pp!=NULL; pp=strstr(pp+1,v)) { |
- | |
155 | if((pp==p || !isalnum(*(pp-1))) && |
- | |
156 | (!isalnum(*(pp+n)) || *(pp+n)==0)) break; |
- | |
157 | } |
- | |
158 | return pp; |
- | |
159 | } |
- | |
160 | */ |
- | |
161 | /* strip trailing spaces; return string end. */ |
113 | /* strip trailing spaces; return string end. */ |
162 | char *strip_trailing_spaces2(char *p) |
114 | char *strip_trailing_spaces2(char *p) |
163 | { |
115 | { |
164 | char *pp; |
116 | char *pp; |
165 | if(*p==0) return p; |
117 | if(*p==0) return p; |