From 3bc0b01e60a375e4de0035a73e7de0b7c163245a Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Sat, 15 Apr 1989 19:04:30 +0000 Subject: [PATCH] Eliminate case sensitivities in the primitive lookup mechanism. --- v7/src/microcode/findprim.c | 26 ++++++++++++++++++++++++-- v7/src/microcode/primutl.c | 36 ++++++++++++++++++++++++++++-------- v7/src/microcode/version.h | 4 ++-- v8/src/microcode/version.h | 4 ++-- 4 files changed, 56 insertions(+), 14 deletions(-) diff --git a/v7/src/microcode/findprim.c b/v7/src/microcode/findprim.c index 9700c4b81..c1cf80e11 100644 --- a/v7/src/microcode/findprim.c +++ b/v7/src/microcode/findprim.c @@ -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); +} diff --git a/v7/src/microcode/primutl.c b/v7/src/microcode/primutl.c index c7dcc10a1..20a188474 100644 --- a/v7/src/microcode/primutl.c +++ b/v7/src/microcode/primutl.c @@ -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 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) { diff --git a/v7/src/microcode/version.h b/v7/src/microcode/version.h index 23a34dc8b..57f3a96b4 100644 --- a/v7/src/microcode/version.h +++ b/v7/src/microcode/version.h @@ -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 diff --git a/v8/src/microcode/version.h b/v8/src/microcode/version.h index 7fb6dd304..dddf18768 100644 --- a/v8/src/microcode/version.h +++ b/v8/src/microcode/version.h @@ -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 -- 2.25.1