naev 0.12.5
msgcat.c File Reference

Message catalog lookup and plural-form evaluation subroutines. This implementation comes from musl. See below for details and copyright info. More...

#include "msgcat.h"
Include dependency graph for msgcat.c:

Go to the source code of this file.

Data Structures

struct  st

Functions

static uint64_t msgcat_plural_eval (const char *, uint64_t)
static const char * msgcat_mo_lookup (const void *p, size_t size, const char *s)
void msgcat_init (msgcat_t *p, const void *map, size_t map_size)
 Initialize a msgcat_t, given the contents and content-length of a .mo file.
const char * msgcat_ngettext (const msgcat_t *p, const char *msgid1, const char *msgid2, uint64_t n)
 Return a translation, if present, from the given message catalog.
static uint32_t swapc (uint32_t x, int c)
uint32_t msgcat_nstringsFromHeader (const char buf[12])
 Return the number of strings in a message catalog, given its first 12 bytes.
static const char * skipspace (const char *s)
static const char * evalexpr (struct st *st, const char *s, int d)
static const char * evalprim (struct st *st, const char *s, int d)
static int binop (struct st *st, int op, uint64_t left)
static const char * parseop (struct st *st, const char *s)
static const char * evalbinop (struct st *st, const char *s, int minprec, int d)

Detailed Description

Message catalog lookup and plural-form evaluation subroutines. This implementation comes from musl. See below for details and copyright info.

Definition in file msgcat.c.

Function Documentation

◆ binop()

int binop ( struct st * st,
int op,
uint64_t left )
static

Definition at line 237 of file msgcat.c.

◆ evalbinop()

const char * evalbinop ( struct st * st,
const char * s,
int minprec,
int d )
static

Definition at line 280 of file msgcat.c.

◆ evalexpr()

const char * evalexpr ( struct st * st,
const char * s,
int d )
static

Definition at line 304 of file msgcat.c.

◆ evalprim()

const char * evalprim ( struct st * st,
const char * s,
int d )
static

Definition at line 210 of file msgcat.c.

◆ msgcat_init()

void msgcat_init ( msgcat_t * p,
const void * map,
size_t map_size )

Initialize a msgcat_t, given the contents and content-length of a .mo file.

Definition at line 56 of file msgcat.c.

◆ msgcat_mo_lookup()

const char * msgcat_mo_lookup ( const void * p,
size_t size,
const char * s )
static

Definition at line 127 of file msgcat.c.

◆ msgcat_ngettext()

const char * msgcat_ngettext ( const msgcat_t * p,
const char * msgid1,
const char * msgid2,
uint64_t n )

Return a translation, if present, from the given message catalog.

Parameters
pThe message catalog.
msgid1The English singular form.
msgid2The English plural form. (Pass NULL if simply translating msgid1.)
nThe number determining the plural form to use. (Pass 1 if simply translating msgid1.)
Returns
The translation in the message catalog, if it exists, else NULL. (msgid1 is not passed through; the higher-level gettext.c functions handle fallbacks.)

Definition at line 98 of file msgcat.c.

◆ msgcat_nstringsFromHeader()

uint32_t msgcat_nstringsFromHeader ( const char buf[12])

Return the number of strings in a message catalog, given its first 12 bytes.

Definition at line 166 of file msgcat.c.

◆ msgcat_plural_eval()

uint64_t msgcat_plural_eval ( const char * s,
uint64_t n )
static

Definition at line 322 of file msgcat.c.

◆ parseop()

const char * parseop ( struct st * st,
const char * s )
static

Definition at line 258 of file msgcat.c.

◆ skipspace()

const char * skipspace ( const char * s)
static

Definition at line 202 of file msgcat.c.

◆ swapc()

uint32_t swapc ( uint32_t x,
int c )
inlinestatic

Definition at line 122 of file msgcat.c.