Mercurial > emacs
comparison src/search.c @ 8526:2b7b23059f1b
(Freplace_match): Treat caseless initial like a lowercase initial.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 11 Aug 1994 22:57:20 +0000 |
parents | 7d8e0f338e4a |
children | 4f0a475b1fa9 |
comparison
equal
deleted
inserted
replaced
8525:fcc070bca96d | 8526:2b7b23059f1b |
---|---|
1180 enum { nochange, all_caps, cap_initial } case_action; | 1180 enum { nochange, all_caps, cap_initial } case_action; |
1181 register int pos, last; | 1181 register int pos, last; |
1182 int some_multiletter_word; | 1182 int some_multiletter_word; |
1183 int some_lowercase; | 1183 int some_lowercase; |
1184 int some_uppercase; | 1184 int some_uppercase; |
1185 int some_lowercase_initial; | 1185 int some_nonuppercase_initial; |
1186 register int c, prevc; | 1186 register int c, prevc; |
1187 int inslen; | 1187 int inslen; |
1188 | 1188 |
1189 CHECK_STRING (newtext, 0); | 1189 CHECK_STRING (newtext, 0); |
1190 | 1190 |
1210 | 1210 |
1211 /* some_multiletter_word is set nonzero if any original word | 1211 /* some_multiletter_word is set nonzero if any original word |
1212 is more than one letter long. */ | 1212 is more than one letter long. */ |
1213 some_multiletter_word = 0; | 1213 some_multiletter_word = 0; |
1214 some_lowercase = 0; | 1214 some_lowercase = 0; |
1215 some_lowercase_initial = 0; | 1215 some_nonuppercase_initial = 0; |
1216 some_uppercase = 0; | 1216 some_uppercase = 0; |
1217 | 1217 |
1218 for (pos = search_regs.start[0]; pos < last; pos++) | 1218 for (pos = search_regs.start[0]; pos < last; pos++) |
1219 { | 1219 { |
1220 c = FETCH_CHAR (pos); | 1220 c = FETCH_CHAR (pos); |
1222 { | 1222 { |
1223 /* Cannot be all caps if any original char is lower case */ | 1223 /* Cannot be all caps if any original char is lower case */ |
1224 | 1224 |
1225 some_lowercase = 1; | 1225 some_lowercase = 1; |
1226 if (SYNTAX (prevc) != Sword) | 1226 if (SYNTAX (prevc) != Sword) |
1227 some_lowercase_initial = 1; | 1227 some_nonuppercase_initial = 1; |
1228 else | 1228 else |
1229 some_multiletter_word = 1; | 1229 some_multiletter_word = 1; |
1230 } | 1230 } |
1231 else if (!NOCASEP (c)) | 1231 else if (!NOCASEP (c)) |
1232 { | 1232 { |
1234 if (SYNTAX (prevc) != Sword) | 1234 if (SYNTAX (prevc) != Sword) |
1235 ; | 1235 ; |
1236 else | 1236 else |
1237 some_multiletter_word = 1; | 1237 some_multiletter_word = 1; |
1238 } | 1238 } |
1239 else | |
1240 { | |
1241 /* If the initial is a caseless word constituent, | |
1242 treat that like a lowercase initial. */ | |
1243 if (SYNTAX (prevc) != Sword) | |
1244 some_nonuppercase_initial = 1; | |
1245 } | |
1239 | 1246 |
1240 prevc = c; | 1247 prevc = c; |
1241 } | 1248 } |
1242 | 1249 |
1243 /* Convert to all caps if the old text is all caps | 1250 /* Convert to all caps if the old text is all caps |
1244 and has at least one multiletter word. */ | 1251 and has at least one multiletter word. */ |
1245 if (! some_lowercase && some_multiletter_word) | 1252 if (! some_lowercase && some_multiletter_word) |
1246 case_action = all_caps; | 1253 case_action = all_caps; |
1247 /* Capitalize each word, if the old text has all capitalized words. */ | 1254 /* Capitalize each word, if the old text has all capitalized words. */ |
1248 else if (!some_lowercase_initial && some_multiletter_word) | 1255 else if (!some_nonuppercase_initial && some_multiletter_word) |
1249 case_action = cap_initial; | 1256 case_action = cap_initial; |
1250 else if (!some_lowercase_initial && some_uppercase) | 1257 else if (!some_nonuppercase_initial && some_uppercase) |
1251 /* Should x -> yz, operating on X, give Yz or YZ? | 1258 /* Should x -> yz, operating on X, give Yz or YZ? |
1252 We'll assume the latter. */ | 1259 We'll assume the latter. */ |
1253 case_action = all_caps; | 1260 case_action = all_caps; |
1254 else | 1261 else |
1255 case_action = nochange; | 1262 case_action = nochange; |