Eliminate case sensitivities in the primitive lookup mechanism.
authorChris Hanson <org/chris-hanson/cph>
Sat, 15 Apr 1989 19:04:30 +0000 (19:04 +0000)
committerChris Hanson <org/chris-hanson/cph>
Sat, 15 Apr 1989 19:04:30 +0000 (19:04 +0000)
v7/src/microcode/findprim.c
v7/src/microcode/primutl.c
v7/src/microcode/version.h
v8/src/microcode/version.h

index 9700c4b81b7b344cfde8d11e883e05ffc5be9891..c1cf80e11cc9061b04b558ca7aae59b00022396f 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/findprim.c,v 9.36 1989/02/19 20:02:52 jinx Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/findprim.c,v 9.37 1989/04/15 19:04:16 cph Exp $
 
 Copyright (c) 1987, 1988, 1989 Massachusetts Institute of Technology
 
@@ -210,6 +210,7 @@ TOKEN_PROCESSOR scan ();
 boolean whitespace ();
 int compare_descriptors ();
 int read_index ();
+int strcmp_ci ();
 pseudo_void create_alternate_entry ();
 pseudo_void create_builtin_entry ();
 pseudo_void create_normal_entry ();
@@ -1196,7 +1197,7 @@ compare_descriptors (d1, d2)
 
   dprintf ("comparing \"%s\"", (d1 -> scheme_name));
   dprintf(" and \"%s\".\n", (d2 -> scheme_name));
-  value = (strcmp ((d1 -> scheme_name), (d2 -> scheme_name)));
+  value = (strcmp_ci ((d1 -> scheme_name), (d2 -> scheme_name)));
   if (value > 0)
     return (1);
   else if (value < 0)
@@ -1204,3 +1205,24 @@ compare_descriptors (d1, d2)
   else
     return (0);
 }
+
+int
+strcmp_ci (s1, s2)
+     fast char * s1;
+     fast char * s2;
+{
+  int length1 = (strlen (s1));
+  int length2 = (strlen (s2));
+  fast int length = ((length1 < length2) ? length1 : length2);
+
+  while ((length--) > 0)
+    {
+      fast int c1 = (*s1++);
+      fast int c2 = (*s2++);
+      if (islower (c1)) c1 = (_toupper (c1));
+      if (islower (c2)) c2 = (_toupper (c2));
+      if (c1 < c2) return (-1);
+      if (c1 > c2) return (1);
+    }
+  return (length1 - length2);
+}
index c7dcc10a16c8d49443d1737520748fc21b353322..20a188474520a8e5c89647e04666e962ddcabf70 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-Copyright (c) 1988 Massachusetts Institute of Technology
+Copyright (c) 1988, 1989 Massachusetts Institute of Technology
 
 This material was developed by the Scheme project at the Massachusetts
 Institute of Technology, Department of Electrical Engineering and
@@ -30,7 +30,7 @@ Technology nor of any adaptation thereof in any advertising,
 promotional, or sales literature without prior written consent from
 MIT in each case. */
 
-/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/primutl.c,v 9.46 1988/08/15 20:53:13 cph Exp $
+/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/primutl.c,v 9.47 1989/04/15 19:04:24 cph Exp $
  *
  * This file contains the support routines for mapping primitive names
  * to numbers within the microcode.  Primitives are written in C
@@ -42,12 +42,34 @@ MIT in each case. */
 
 #include "scheme.h"
 #include "prims.h"
+#include <ctype.h>
 \f
 Pointer Undefined_Primitives = NIL;
 Pointer Undefined_Primitives_Arity = NIL;
 
 /* Common utilities. */
 
+static int
+strcmp_ci (s1, s2)
+     fast char * s1;
+     fast char * s2;
+{
+  int length1 = (strlen (s1));
+  int length2 = (strlen (s2));
+  fast int length = ((length1 < length2) ? length1 : length2);
+
+  while ((length--) > 0)
+    {
+      fast int c1 = (*s1++);
+      fast int c2 = (*s2++);
+      if (islower (c1)) c1 = (_toupper (c1));
+      if (islower (c2)) c2 = (_toupper (c2));
+      if (c1 < c2) return (-1);
+      if (c1 > c2) return (1);
+    }
+  return (length1 - length2);
+}
+
 struct primitive_alias
   {
     char *alias;
@@ -67,7 +89,7 @@ primitive_alias_to_name (alias)
   alias_end = (alias_ptr + N_ALIASES);
   while (alias_ptr < alias_end)
     {
-      if ((strcmp (alias, (alias_ptr -> alias))) == 0)
+      if ((strcmp_ci (alias, (alias_ptr -> alias))) == 0)
        return (alias_ptr -> name);
       alias_ptr += 1;
     }
@@ -122,7 +144,6 @@ primitive_name_to_code(name, table, size)
      fast char *table[];
      int size;
 {
-  extern int strcmp();
   fast int low, high, middle, result;
 
   name = (primitive_alias_to_name (name));
@@ -132,7 +153,7 @@ primitive_name_to_code(name, table, size)
   while(low < high)
   {
     middle = ((low + high) / 2);
-    result = strcmp(name, table[middle]);
+    result = strcmp_ci(name, table[middle]);
     if (result < 0)
     {
       high = (middle - 1);
@@ -151,7 +172,7 @@ primitive_name_to_code(name, table, size)
      If division were to round up, we would have to use high.
    */
 
-  if (strcmp(name, table[low]) == 0)
+  if (strcmp_ci(name, table[low]) == 0)
   {
     return ((long) low);
   }
@@ -335,7 +356,6 @@ search_for_primitive(scheme_name, c_name, intern_p, allow_p, arity)
      Boolean intern_p, allow_p;
      int arity;
 {
-  extern int strcmp();
   long i, Max, old_arity;
   Pointer *Next;
 
@@ -373,7 +393,7 @@ search_for_primitive(scheme_name, c_name, intern_p, allow_p, arity)
       Pointer temp;
 
       temp = *Next++;
-      if (strcmp(c_name, Scheme_String_To_C_String(temp)) == 0)
+      if (strcmp_ci(c_name, Scheme_String_To_C_String(temp)) == 0)
       {
        if (arity != UNKNOWN_PRIMITIVE_ARITY)
        {
index 23a34dc8ba3073c1c62b8d19ffd270e2bf2d001f..57f3a96b429e5cbe105f96a2617e846719340ebe 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/version.h,v 10.71 1989/04/15 01:16:36 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/version.h,v 10.72 1989/04/15 19:04:30 cph Exp $
 
 Copyright (c) 1988, 1989 Massachusetts Institute of Technology
 
@@ -46,7 +46,7 @@ MIT in each case. */
 #define VERSION                10
 #endif
 #ifndef SUBVERSION
-#define SUBVERSION     71
+#define SUBVERSION     72
 #endif
 
 #ifndef UCODE_TABLES_FILENAME
index 7fb6dd30460d56bee92ac1bb2567022a84d39137..dddf18768ac807cd931a8aaac31bfae3ff2cdd59 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/version.h,v 10.71 1989/04/15 01:16:36 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/version.h,v 10.72 1989/04/15 19:04:30 cph Exp $
 
 Copyright (c) 1988, 1989 Massachusetts Institute of Technology
 
@@ -46,7 +46,7 @@ MIT in each case. */
 #define VERSION                10
 #endif
 #ifndef SUBVERSION
-#define SUBVERSION     71
+#define SUBVERSION     72
 #endif
 
 #ifndef UCODE_TABLES_FILENAME