naev 0.11.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"

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()

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

Definition at line 240 of file msgcat.c.

◆ evalbinop()

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

Definition at line 283 of file msgcat.c.

◆ evalexpr()

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

Definition at line 307 of file msgcat.c.

◆ evalprim()

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

Definition at line 213 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 59 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 130 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 101 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 169 of file msgcat.c.

◆ msgcat_plural_eval()

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

Definition at line 325 of file msgcat.c.

◆ parseop()

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

Definition at line 261 of file msgcat.c.

◆ skipspace()

static const char * skipspace ( const char * s)
static

Definition at line 205 of file msgcat.c.

◆ swapc()

static uint32_t swapc ( uint32_t x,
int c )
inlinestatic

Definition at line 125 of file msgcat.c.