a99  V32.6
allegro Windows Hauptprogramm
 Alle Klassen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
aicompar.cpp
gehe zur Dokumentation dieser Datei
1 // aicompar.cpp : 2 Indexeintr. vergleichen, ident. f. .c und .cpp
2 // 1991 / 1995 / 1995-05-23
3 // Copyright 2011 Universitätsbibliothek Braunschweig, more see bottom
4 
5 
6 #include "includes.h" // einige Konventionen
7 #include "ai-const.h" // allg. Konstanten
8 #include "aisetup.h" // allg. Einstellungen
9 #include "aierrors.h" // Fehlernummern
10 #include "aistruc.h" // Strukturen
11 #include "aideclar.h" // Funktionsdeklarationen
12 
13 extern unsigned char *svTable; // Sortierwerttabelle (i-Befehl in IndexParam)
14  // s. exet2.c(pp)
15 
16 // ------------------------------------
17 // Vergleich mit der Sortierwerttabelle (i-Werte in den Indexparam.)
18 
19 int ai_scmpar(unsigned char *a, unsigned char *b)
20 {
21  int j=0;
22  int i=strlen((char*)a);
23  while(j++<i && (*a++ == *b++)) ;
24  if(j>i) if(*a++ == *b++) return 0; /* equal */
25  i=(int)svTable[*--a] - (int)svTable[*--b];
26  return i;
27 }
28 
29 
30 /* -----------------
31  Vergleichsroutine ohne Sortierwerttabelle
32 
33  Rueckgabewert ist < 0 wenn *val1 < *val2
34  = 0 *val1 = *val2
35  > 0 *val1 > *val2
36 */
37 SHORT compar(CHAR *val1, CHAR *val2, aiINDX *aixf)
38 {
39  SHORT i;
40  SHORT kylgth;
41  kylgth = aixf->kylgth;
42  i = 0;
43  while(i++ < kylgth && *val1++ == *val2++) ;
44  if(i<kylgth-3)
45  kylgth = (int)svTable[*--val1] - (int)svTable[*--val2];
46  else
47  kylgth = (int)(*--val1) - (int)(*--val2);
48  if(kylgth > 0)
49  return(i);
50  else if(kylgth < 0)
51  return(-i);
52  else
53  return(0);
54 }
55 
56 
57 
58 /*
59  Copyright 2011 Universitätsbibliothek Braunschweig
60 
61  Licensed under the Apache License, Version 2.0 (the "License");
62  you may not use this file except in compliance with the License.
63  You may obtain a copy of the License at
64 
65  http://www.apache.org/licenses/LICENSE-2.0
66 
67  Unless required by applicable law or agreed to in writing, software
68  distributed under the License is distributed on an "AS IS" BASIS,
69  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
70  See the License for the specific language governing permissions and
71  limitations under the License.
72 */
73