str_rchr.c
author tomas@localhost
Thu, 01 Nov 2007 14:46:11 +0100
changeset 0 c045670f36e9
permissions -rw-r--r--
Imported queue-fix-1.4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     1
#include "str.h"
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     2
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     3
unsigned int str_rchr(s,c)
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     4
register char *s;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     5
int c;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     6
{
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     7
  register char ch;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     8
  register char *t;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     9
  register char *u;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    10
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    11
  ch = c;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    12
  t = s;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    13
  u = 0;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    14
  for (;;) {
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    15
    if (!*t) break; if (*t == ch) u = t; ++t;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    16
    if (!*t) break; if (*t == ch) u = t; ++t;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    17
    if (!*t) break; if (*t == ch) u = t; ++t;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    18
    if (!*t) break; if (*t == ch) u = t; ++t;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    19
  }
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    20
  if (!u) u = t;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    21
  return u - s;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    22
}