#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void t(const char *locale, int canary)
{
    char buf[1024];
    size_t ret;
    int i;

    if (setlocale(LC_ALL, locale) == NULL)
	printf("setlocale(\"%s\") failed\n", locale);
    memset(buf, canary, sizeof(buf)); buf[0] = canary - 1;
    ret = strxfrm(buf + 1, "pg_amop_opc_strategy_index", 58);

    for (i = sizeof(buf) - 1; i >= 0 && buf[i] == canary; --i)
	;
    printf("locale \"%s\": strxfrm returned %d; last modified byte at %d (0x%hhx)\n",
	   locale, (int) ret, i, buf[i]);
}

int main(int argc, char **argv)
{
    system("uname -a");
    t("is_IS.ISO8859-1", 0x7F);
    t("is_IS.ISO8859-1", 0x7E);
    t("", 0x7F);
    return 0;
}
