[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: lynx-dev EBCDIC and HTMLDTD.{c,h} (patch)
From: |
pg |
Subject: |
Re: lynx-dev EBCDIC and HTMLDTD.{c,h} (patch) |
Date: |
Thu, 13 May 1999 12:45:53 -0600 (MDT) |
In a recent note, address@hidden said:
> Date: Tue, 11 May 1999 17:37:37 -0400 (EDT)
>
> We have enough features - but this doesn't sound like one: if you have
> time and the fix is small and easily understood, that's good. But a large
> change would require more testing.
>
Well, 200 lines is hardy small, IMO. The best I can say is the
#ifdefs make it pretty transparent in the ASCII case. If you're
uncomfortable with it, it can sit in the archive; I'll post a
reminder at 2-8-3.dev.1 time.
Thanks,
gil
===================================================================
%%% Created Wed May 12 22:15:26 MDT 1999 by target lynx.patch. %%%
diff -bru orig/lynx2-8-2/WWW/Library/Implementation/HTFile.c
lynx2-8-2/WWW/Library/Implementation/HTFile.c
--- orig/lynx2-8-2/WWW/Library/Implementation/HTFile.c Sat May 8 11:46:28 1999
+++ lynx2-8-2/WWW/Library/Implementation/HTFile.c Wed May 12 18:42:38 1999
@@ -1555,7 +1555,7 @@
{
- HTBTree * bt = HTBTree_new((HTComparer)strcmp);
+ HTBTree * bt = HTBTree_new((HTComparer)AS_cmp);
int num_of_entries = 0; /* lines counter */
_HTProgress (gettext("Reading directory..."));
diff -bru orig/lynx2-8-2/WWW/Library/Implementation/HTMLDTD.c
lynx2-8-2/WWW/Library/Implementation/HTMLDTD.c
--- orig/lynx2-8-2/WWW/Library/Implementation/HTMLDTD.c Fri Apr 23 08:56:35 1999
+++ lynx2-8-2/WWW/Library/Implementation/HTMLDTD.c Tue May 11 16:09:46 1999
@@ -1540,26 +1540,16 @@
{ P("FORM") , form_attr, HTML_FORM_ATTRIBUTES, SGML_MIXED,T_FORM},
{ P("FRAME") , frame_attr, HTML_FRAME_ATTRIBUTES, SGML_EMPTY,T_FRAME},
{ P("FRAMESET"), frameset_attr,HTML_FRAMESET_ATTRIBUTES,
SGML_ELEMENT,T_FRAMESET},
-#ifndef EBCDIC /* S/390 -- gil -- 0177 */
{ P("H1") , h_attr, HTML_H_ATTRIBUTES, SGML_MIXED,T_H1},
{ P("H2") , h_attr, HTML_H_ATTRIBUTES, SGML_MIXED,T_H2},
{ P("H3") , h_attr, HTML_H_ATTRIBUTES, SGML_MIXED,T_H3},
{ P("H4") , h_attr, HTML_H_ATTRIBUTES, SGML_MIXED,T_H4},
{ P("H5") , h_attr, HTML_H_ATTRIBUTES, SGML_MIXED,T_H5},
{ P("H6") , h_attr, HTML_H_ATTRIBUTES, SGML_MIXED,T_H6},
-#endif /* EBCDIC S/390 -- gil -- 0187 */
{ P("HEAD") , gen_attr, HTML_GEN_ATTRIBUTES, SGML_ELEMENT,T_HEAD},
{ P("HR") , hr_attr, HTML_HR_ATTRIBUTES, SGML_EMPTY,T_HR},
{ P("HTML") , gen_attr, HTML_GEN_ATTRIBUTES, SGML_MIXED,T_HTML},
{ P("HY") , gen_attr, HTML_GEN_ATTRIBUTES, SGML_EMPTY,T_HY},
-#ifdef EBCDIC
- { P("H1") , h_attr, HTML_H_ATTRIBUTES, SGML_MIXED,T_H1},
- { P("H2") , h_attr, HTML_H_ATTRIBUTES, SGML_MIXED,T_H2},
- { P("H3") , h_attr, HTML_H_ATTRIBUTES, SGML_MIXED,T_H3},
- { P("H4") , h_attr, HTML_H_ATTRIBUTES, SGML_MIXED,T_H4},
- { P("H5") , h_attr, HTML_H_ATTRIBUTES, SGML_MIXED,T_H5},
- { P("H6") , h_attr, HTML_H_ATTRIBUTES, SGML_MIXED,T_H6},
-#endif /* EBCDIC <heavy sigh> -- gil */
{ P("I") , gen_attr, HTML_GEN_ATTRIBUTES, SGML_MIXED,T_I},
{ P("IFRAME") , iframe_attr, HTML_IFRAME_ATTRIBUTES, SGML_MIXED,T_IFRAME},
{ P("IMG") , img_attr, HTML_IMG_ATTRIBUTES, SGML_EMPTY,T_IMG},
diff -bru orig/lynx2-8-2/WWW/Library/Implementation/HTPlain.c
lynx2-8-2/WWW/Library/Implementation/HTPlain.c
--- orig/lynx2-8-2/WWW/Library/Implementation/HTPlain.c Wed Mar 17 20:17:11 1999
+++ lynx2-8-2/WWW/Library/Implementation/HTPlain.c Wed May 12 09:10:48 1999
@@ -167,7 +167,7 @@
diff < 0 ? (low = i+1) : (high = i)) {
/* Binary search */
i = (low + (high-low)/2);
- diff = strncmp(HTML_dtd.entity_names[i], name, len);
+ diff = AS_ncmp(HTML_dtd.entity_names[i], name, len);
if (diff == 0) {
HText_appendText(me->text,
LYCharSets[me->outUCLYhndl][i]);
diff -bru orig/lynx2-8-2/WWW/Library/Implementation/HTString.c
lynx2-8-2/WWW/Library/Implementation/HTString.c
--- orig/lynx2-8-2/WWW/Library/Implementation/HTString.c Sat May 8
11:46:28 1999
+++ lynx2-8-2/WWW/Library/Implementation/HTString.c Wed May 12 18:48:20 1999
@@ -122,6 +122,65 @@
}
#endif /* VM */
+#ifdef NOT_ASCII
+
+/* Case-insensitive with ASCII collating sequence
+** ----------------
+*/
+PUBLIC int AS_casecomp ARGS2(
+ CONST char*, p,
+ CONST char*, q)
+{
+ int diff;
+
+ for ( ; ; p++, q++) {
+ if (!(*p && *q))
+ return ((unsigned char) *p - (unsigned char) *q);
+ diff = TOASCII(TOLOWER(*p))
+ - TOASCII(TOLOWER(*q));
+ if (diff)
+ return diff;
+ }
+ /*NOTREACHED*/
+}
+
+
+/* With count limit and ASCII collating sequence
+** ----------------
+** AS_cmp uses n == -1 to compare indefinite length.
+*/
+PUBLIC int AS_ncmp ARGS3(
+ CONST char *, p,
+ CONST char *, q,
+ unsigned int, n)
+{
+ CONST char *a = p;
+ int diff;
+
+ for ( ; (p-a) < n; p++, q++) {
+ if (!(*p && *q))
+ return ((unsigned char) *p - (unsigned char) *q);
+ diff = TOASCII(*p)
+ - TOASCII(*q);
+ if (diff)
+ return diff;
+ }
+ return 0; /* Match up to n characters */
+}
+
+
+/* With ASCII collating sequence
+** ----------------
+*/
+PUBLIC int AS_cmp ARGS2(
+ CONST char *, p,
+ CONST char *, q)
+{
+ return( AS_ncmp( p, q, -1 ) );
+}
+#endif /* NOT_ASCII */
+
+
/* Allocate a new copy of a string, and returns it
*/
PUBLIC char * HTSACopy ARGS2(
diff -bru orig/lynx2-8-2/WWW/Library/Implementation/HTString.h
lynx2-8-2/WWW/Library/Implementation/HTString.h
--- orig/lynx2-8-2/WWW/Library/Implementation/HTString.h Fri Apr 23
08:56:35 1999
+++ lynx2-8-2/WWW/Library/Implementation/HTString.h Wed May 12 18:56:18 1999
@@ -16,6 +16,22 @@
extern CONST char * HTLibraryVersion; /* String for help screen etc */
/*
+ EBCDIC string comparison using ASCII collating sequence
+*/
+#ifdef NOT_ASCII
+extern int AS_casecomp PARAMS((CONST char *a, CONST char *b));
+extern int AS_ncmp PARAMS((CONST char *a, CONST char *b, unsigned int n));
+#define AS_cmp( a, b ) ( AS_ncmp( ( a ), ( b ), -1 ) )
+extern int AS_cmp PARAMS((CONST char *a, CONST char *b));
+
+#else
+#define AS_casecomp( a, b ) ( strcasecomp( ( a ), ( b ) ) )
+#define AS_ncmp( a, b, c ) ( strncmp( ( a ), ( b ), ( c ) ) )
+#define AS_cmp strcmp
+
+#endif /* NOT_ASCII */
+
+/*
Case-insensitive string comparison
diff -bru orig/lynx2-8-2/WWW/Library/Implementation/SGML.c
lynx2-8-2/WWW/Library/Implementation/SGML.c
--- orig/lynx2-8-2/WWW/Library/Implementation/SGML.c Wed May 5 18:33:59 1999
+++ lynx2-8-2/WWW/Library/Implementation/SGML.c Wed May 12 09:11:29 1999
@@ -1215,7 +1215,7 @@
high > low;
diff < 0 ? (low = i+1) : (high = i)) { /* Binary search */
i = (low + (high-low)/2);
- diff = strcasecomp(dtd->tags[i].name, string); /* Case insensitive */
+ diff = AS_casecomp(dtd->tags[i].name, string); /* Case insensitive */
if (diff == 0) { /* success: found it */
return &dtd->tags[i];
}
diff -bru orig/lynx2-8-2/src/LYCharSets.c lynx2-8-2/src/LYCharSets.c
--- orig/lynx2-8-2/src/LYCharSets.c Fri Apr 23 08:56:35 1999
+++ lynx2-8-2/src/LYCharSets.c Wed May 12 09:43:27 1999
@@ -868,12 +868,6 @@
/*
* Try UC_entity_info unicode_entities[].
*/
-#ifdef NOT_ASCII /* S/390 -- gil -- 1656 */
- for (i = 0; i < number_of_unicode_entities; i++ ) {
- /*
- ** Linear search for NOT_ASCII.
- */
-#else /* NOT_ASCII */
for (low = 0, high = number_of_unicode_entities;
high > low;
diff < 0 ? (low = i+1) : (high = i)) {
@@ -881,15 +875,12 @@
** Binary search.
*/
i = (low + (high-low)/2);
-#endif /* NOT_ASCII S/390 -- gil -- 1662 */
- diff = strcmp(unicode_entities[i].name, name); /* Case sensitive! */
+ diff = AS_cmp(unicode_entities[i].name, name); /* Case sensitive! */
if (diff == 0) {
value = unicode_entities[i].code;
break;
}
}
- /* } NOT_ASCII */
-
return(value);
}