freebsd-ports/www/quickie/files/freebsd.h
Renato Botelho 29ce428a7c Quickie is a small footprint, fast C++ Wiki engine; hence the name.
The fundamental insight for this engine is that wiki pages are read far
more often than they are modified. Thus, the generated HTML can be
cached. It follows that the main code path will check that the .html
file exists and simply copy it to stdout in the vast majority of cases.

The .html file generated from each .wiki file is about the same size as
the .wiki file itself, so there will be no particular I/O advantage,
but there is a huge CPU advantage, and a significant memory footprint
advantage, and since I want to run a wiki on a geriatric 20MB 33MHz 386
machine, this is a good thing.

    Online demo: http://quickie.sourceforge.net/cgi-bin/quickie

WWW: http://quickie.sourceforge.net/

PR:		ports/97376
Submitted by:	Shaun Amott <shaun@inerd.com>
2006-05-17 13:48:19 +00:00

44 lines
762 B
C

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
int
strverscmp(const char *s1, const char *s2);
int
strverscmp(const char *s1, const char *s2)
{
static const char *digits = "0123456789";
int ret;
long n1, n2;
size_t p1, p2;
do {
p1 = strcspn(s1, digits);
p2 = strcspn(s2, digits);
/* Different prefix */
if ((ret = strncmp(s1, s2, p1)) != 0)
return ret;
s1 += p1;
s2 += p2;
n1 = strtol(s1, NULL, 10);
n2 = strtol(s2, NULL, 10);
if (n1 < n2)
return -1;
else if (n1 > n2)
return 1;
/* Numbers are equal or not present, try with next ones. */
p1 = strspn(s1, digits);
p2 = strspn(s2, digits);
s1 += p1;
s2 += p2;
} while (p1 == p2 && p1 != 0 && p1 != 0);
return strcmp(s1, s2);
}