changeset 7674:947d24fefd9e

(Freplace_match): Improve capitalization heuristics.
author Karl Heuer <kwzh@gnu.org>
date Wed, 25 May 1994 03:59:06 +0000
parents 6ad64419ba08
children 4767bfeb097d
files src/search.c
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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;
     }