# HG changeset patch # User Karl Heuer # Date 769838346 0 # Node ID 947d24fefd9edec0d8dcee75f90fa63e4a94ab1e # Parent 6ad64419ba0853a2f39350e4b6b9fa1ee9c39912 (Freplace_match): Improve capitalization heuristics. diff -r 6ad64419ba08 -r 947d24fefd9e src/search.c --- a/src/search.c Wed May 25 03:53:30 1994 +0000 +++ b/src/search.c Wed May 25 03:59:06 1994 +0000 @@ -1174,6 +1174,7 @@ register int pos, last; int some_multiletter_word; int some_lowercase; + int some_uppercase; int some_lowercase_initial; register int c, prevc; int inslen; @@ -1205,6 +1206,7 @@ some_multiletter_word = 0; some_lowercase = 0; some_lowercase_initial = 0; + some_uppercase = 0; for (pos = search_regs.start[0]; pos < last; pos++) { @@ -1221,6 +1223,7 @@ } else if (!NOCASEP (c)) { + some_uppercase = 1; if (SYNTAX (prevc) != Sword) ; else @@ -1235,11 +1238,12 @@ if (! some_lowercase && some_multiletter_word) case_action = all_caps; /* Capitalize each word, if the old text has all capitalized words. */ - /* We used to insist on some_multiletter_word here, - but that screwed query replacing x with y, acting on X. - Even what we have now is more strict than what 19.22 had. */ - else if (!some_lowercase_initial) + else if (!some_lowercase_initial && some_multiletter_word) case_action = cap_initial; + else if (!some_lowercase_initial && some_uppercase) + /* Should x -> yz, operating on X, give Yz or YZ? + We'll assume the latter. */ + case_action = all_caps; else case_action = nochange; }