aboutsummaryrefslogtreecommitdiffstats
path: root/z39.c
diff options
context:
space:
mode:
authorJeffrey H. Kingston <jeff@it.usyd.edu.au>2010-09-14 20:37:45 +0000
committerJeffrey H. Kingston <jeff@it.usyd.edu.au>2010-09-14 20:37:45 +0000
commitc89f0bc2209f7f98695e6b94fbac316c84fbf9d4 (patch)
tree456d506bd18edd3b768eaffa8f70ae93565682e4 /z39.c
parent7db8921aac3a0e1223af269ec7092bdd91a7c7a2 (diff)
downloadlout-c89f0bc2209f7f98695e6b94fbac316c84fbf9d4.tar.gz
Lout 3.25.
git-svn-id: http://svn.savannah.nongnu.org/svn/lout/trunk@19 9365b830-b601-4143-9ba8-b4a8e2c3339c
Diffstat (limited to 'z39.c')
-rw-r--r--z39.c40
1 files changed, 32 insertions, 8 deletions
diff --git a/z39.c b/z39.c
index 0558c8a..09528f2 100644
--- a/z39.c
+++ b/z39.c
@@ -1,7 +1,7 @@
/*@z39.c:String Handler:AsciiToFull(), StringEqual(), etc.@*******************/
/* */
-/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.24) */
-/* COPYRIGHT (C) 1991, 2000 Jeffrey H. Kingston */
+/* THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.25) */
+/* COPYRIGHT (C) 1991, 2001 Jeffrey H. Kingston */
/* */
/* Jeffrey H. Kingston (jeff@cs.usyd.edu.au) */
/* Basser Department of Computer Science */
@@ -79,23 +79,36 @@ int strcollcmp(char *a, char *b)
*** */
int strcollcmp(char *a, char *b)
-{ char a1[100], b1[100];
+{ char a1[100], a2[100], a3[100], b1[100], b2[100], b3[100];
int order;
- sscanf(a, "%[^\t]", a1);
- sscanf(b, "%[^\t]", b1);
+ a1[0] = a2[0] = a3[0] = '\0';
+ sscanf(a, "%[^\t]\t%[^\t]\t%[^\t]", a1, a2, a3);
+ b1[0] = b2[0] = b3[0] = '\0';
+ sscanf(b, "%[^\t]\t%[^\t]\t%[^\t]", b1, b2, b3);
order = strcoll(a1, b1);
if( order == 0 )
- order = strcmp(a, b); /* disambiguate with strcmp */
- debug3(DBS, D, "strcollcmp(\"%s<tab>\", \"%s<tab>\") = %d", a1, b1, order)
+ {
+ order = strcoll(a2, b2);
+ if( order == 0 )
+ {
+ order = strcoll(a3, b3);
+ if( order == 0 )
+ order = strcmp(a, b); /* disambiguate with strcmp */
+ }
+ }
+ debug7(DBS, D, "strcollcmp(\"%s<tab>%s<tab>%s\", \"%s<tab>%s<tab>%s\") = %d",
+ a1, a2, a3, b1, b2, b3, order);
return order;
}
/*@::StringBeginsWith(), StringContains(), StringInt(), StringFiveInt()@******/
/* */
/* BOOLEAN StringBeginsWith(str, pattern) */
+/* BOOLEAN StringBeginsWithWord(str, pattern) */
/* BOOLEAN StringEndsWith(str, pattern) */
/* */
-/* Check whether str begins with or ends with pattern. */
+/* Check whether str begins with or ends with pattern; in the case of */
+/* StringBeginsWithWord there may not be a letter after the pattern. */
/* */
/*****************************************************************************/
@@ -108,6 +121,17 @@ BOOLEAN StringBeginsWith(FULL_CHAR *str, FULL_CHAR *pattern)
return (*pp == '\0');
} /* end StringBeginsWith */
+#define is_letter(c) (((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && (c) <= 'Z'))
+
+BOOLEAN StringBeginsWithWord(FULL_CHAR *str, FULL_CHAR *pattern)
+{ FULL_CHAR *sp, *pp;
+ sp = str; pp = pattern;
+ while( *sp != '\0' && *pp != '\0' )
+ { if( *sp++ != *pp++ ) return FALSE;
+ }
+ return (*pp == '\0' && !is_letter(*sp));
+} /* end StringBeginsWithWord */
+
BOOLEAN StringEndsWith(FULL_CHAR *str, FULL_CHAR *pattern)
{ FULL_CHAR *sp, *pp; int slen, plen;