File: str_start.c

package info (click to toggle)
libowfat 0.28-6
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 4,068 kB
  • sloc: ansic: 12,863; makefile: 16
file content (14 lines) | stat: -rw-r--r-- 424 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include "str.h"

/* str_start returns 1 if the b is a prefix of a, 0 otherwise */
int str_start(const char* a, const char* b) {
  register const char* s=a;
  register const char* t=b;
  for (;;) {
    if (!*t) return 1; if (*s!=*t) break; ++s; ++t;
    if (!*t) return 1; if (*s!=*t) break; ++s; ++t;
    if (!*t) return 1; if (*s!=*t) break; ++s; ++t;
    if (!*t) return 1; if (*s!=*t) break; ++s; ++t;
  }
  return 0;
}