chiark / gitweb /
new lstrcmp, thiswordstrcmp
authorian <ian>
Tue, 31 May 2005 23:34:23 +0000 (23:34 +0000)
committerian <ian>
Tue, 31 May 2005 23:34:23 +0000 (23:34 +0000)
hostside/client.c
hostside/hostside.h

index 81c0b7fb5588703e82d8e6c2ad2cddf8676b48b2..22e1c0c1432f8e723f262f01274557f7f6b9a0f3 100644 (file)
@@ -71,12 +71,21 @@ int ps_needhextoend(ParseState *ps, Byte *d, int *remain_io) {
   return 1;
 }
 
+int lstrstrcmp(const char *a, int la, const char *b) {
+  int lb= strlen(b);
+  if (la != lb) return 1;
+  return memcmp(a,b,la);
+}
+
+int thiswordstrcmp(ParseState *ps, const char *b) {
+  return lstrstrcmp(ps->thisword, ps->lthisword, b);
+}
+
 const CmdInfo *ps_lookup(ParseState *ps, const CmdInfo *inf) {
   for (;
        inf->name;
        inf++)
-    if (ps->lthisword == strlen(inf->name) &&
-       !memcmp(ps->thisword, inf->name, ps->lthisword))
+    if (!thiswordstrcmp(ps,inf->name))
       return inf;
   return 0;
 }
index 867a8e4556178cdecd827b51eeef6406b8accfdc..62dd211bd36ce41a4f2227b64efc3d1f157b9b56 100644 (file)
@@ -92,6 +92,9 @@ struct CmdInfo {
   int xarg;
 };
 
+int lstrstrcmp(const char *a, int la, const char *b);
+int thiswordstrcmp(ParseState *ps, const char *b);
+
 int ps_word(ParseState *ps);
 int ps_needword(ParseState *ps);
 int ps_needhextoend(ParseState *ps, Byte *dbuf, int *len_io);