diff options
author | Waldemar Brodkorb <mail@waldemar-brodkorb.de> | 2013-10-03 19:52:47 +0200 |
---|---|---|
committer | Waldemar Brodkorb <mail@waldemar-brodkorb.de> | 2013-10-03 19:52:47 +0200 |
commit | ae8520cfbb9cce8cfe38b00b52f202584ae1fab4 (patch) | |
tree | f03f2553582d3647393f0c1617c74ae0438192ab /package/gettext-tiny/src/src | |
parent | 05a7f514cca7e6858e5f5dd46cecd0c3bd6f9f71 (diff) |
update samba to latest version, use stub gettext-tiny; use utf8 charset by default for vfat
Diffstat (limited to 'package/gettext-tiny/src/src')
-rw-r--r-- | package/gettext-tiny/src/src/StringEscape.c | 111 | ||||
-rw-r--r-- | package/gettext-tiny/src/src/StringEscape.h | 7 | ||||
-rw-r--r-- | package/gettext-tiny/src/src/msgfmt.c | 278 | ||||
-rw-r--r-- | package/gettext-tiny/src/src/msgmerge.c | 222 | ||||
-rw-r--r-- | package/gettext-tiny/src/src/poparser.c | 144 | ||||
-rw-r--r-- | package/gettext-tiny/src/src/poparser.h | 36 | ||||
-rwxr-xr-x | package/gettext-tiny/src/src/xgettext.sh | 112 |
7 files changed, 910 insertions, 0 deletions
diff --git a/package/gettext-tiny/src/src/StringEscape.c b/package/gettext-tiny/src/src/StringEscape.c new file mode 100644 index 000000000..3a9ddd6cb --- /dev/null +++ b/package/gettext-tiny/src/src/StringEscape.c @@ -0,0 +1,111 @@ +#include <stddef.h> + +//FIXME out gets silently truncated if outsize is too small + +size_t escape(char* in, char* out, size_t outsize) { + size_t l = 0; + while(*in && l + 3 < outsize) { + switch(*in) { + case '\n': + *out++ = '\\'; + l++; + *out = 'n'; + break; + case '\r': + *out++ = '\\'; + l++; + *out = 'r'; + break; + case '\t': + *out++ = '\\'; + l++; + *out = 't'; + break; + case '\\': + *out++ = '\\'; + l++; + *out = '\\'; + break; + case '"': + *out++ = '\\'; + l++; + *out = '"'; + break; + case '\v': + *out++ = '\\'; + l++; + *out = '\v'; + break; + case '\?': + *out++ = '\\'; + l++; + *out = '\?'; + break; + case '\f': + *out++ = '\\'; + l++; + *out = '\f'; + break; + default: + *out = *in; + } + in++; + out++; + l++; + } + *out = 0; + return l; +} +#include <assert.h> +#include <stdlib.h> +size_t unescape(char* in, char *out, size_t outsize) { + size_t l = 0; + while(*in && l + 2 < outsize) { + switch (*in) { + case '\\': + ++in; + assert(*in); + switch(*in) { + case 'n': + *out='\n'; + break; + case 'r': + *out='\r'; + break; + case 't': + *out='\t'; + break; + case '\\': + *out='\\'; + break; + case '"': + *out='"'; + break; + case 'v': + *out='\v'; + break; + case '\?': + *out = '\?'; + break; + case 'f': + *out = '\f'; + break; + case '\'': + *out = '\''; + break; + // FIXME add handling of hex and octal + default: + abort(); + } + break; + default: + *out=*in; + } + in++; + out++; + l++; + } + *out = 0; + return l; +} + diff --git a/package/gettext-tiny/src/src/StringEscape.h b/package/gettext-tiny/src/src/StringEscape.h new file mode 100644 index 000000000..fc764821b --- /dev/null +++ b/package/gettext-tiny/src/src/StringEscape.h @@ -0,0 +1,7 @@ +#ifndef STRINGESCAPE_H +#define STRINGESCAPE_H +#include <stddef.h> +size_t escape(char* in, char *out, size_t outsize); +size_t unescape(char* in, char *out, size_t outsize); +//RcB: DEP "StringEscape.c" +#endif diff --git a/package/gettext-tiny/src/src/msgfmt.c b/package/gettext-tiny/src/src/msgfmt.c new file mode 100644 index 000000000..bf5f3430d --- /dev/null +++ b/package/gettext-tiny/src/src/msgfmt.c @@ -0,0 +1,278 @@ +/* msgfmt utility (C) 2012 rofl0r + * released under the MIT license, see LICENSE for details */ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include <assert.h> +#include "poparser.h" + +// in DO_NOTHING mode, we simply write the msgid twice, once for msgid, once for msgstr. +// TODO: maybe make it write "" instead of echoing the msgid. +//#define DO_NOTHING + +__attribute__((noreturn)) +static void syntax(void) { + fprintf(stdout, + "Usage: msgfmt [OPTION] filename.po ...\n"); + exit(1); +} + +__attribute__((noreturn)) +static void version(void) { + fprintf(stdout, + "these are not (GNU gettext-tools) 99.9999.9999\n"); + exit(0); +} + +#define streq(A, B) (!strcmp(A, B)) +#define strstarts(S, W) (memcmp(S, W, sizeof(W) - 1) ? NULL : (S + (sizeof(W) - 1))) + +struct mo_hdr { + unsigned magic; + int rev; + unsigned numstring; + unsigned off_tbl_org; + unsigned off_tbl_trans; + unsigned hash_tbl_size; + unsigned off_tbl_hash; +}; + +/* file layout: + header + strtable (lenghts/offsets) + transtable (lenghts/offsets) + [hashtable] + strings section + translations section */ + +const struct mo_hdr def_hdr = { + 0x950412de, + 0, + 0, + sizeof(struct mo_hdr), + 0, + 0, + 0, +}; + + +// pass 0: collect numbers of strings, calculate size and offsets for tables +// print header +// pass 1: print string table [lengths/offsets] +// pass 2: print translation table [lengths/offsets] +// pass 3: print strings +// pass 4: print translations +enum passes { + pass_first = 0, + pass_collect_sizes = pass_first, + pass_second, + pass_print_string_offsets = pass_second, + pass_print_translation_offsets, + pass_print_strings, + pass_print_translations, + pass_max, +}; + +struct callbackdata { + enum passes pass; + unsigned off; + FILE* out; + unsigned num[pe_maxstr]; + unsigned len[pe_maxstr]; +}; + + +int process_line_callback(struct po_info* info, void* user) { + struct callbackdata *d = (struct callbackdata *) user; + assert(info->type == pe_msgid || info->type == pe_msgstr); + switch(d->pass) { + case pass_collect_sizes: + d->num[info->type] += 1; + d->len[info->type] += info->textlen; + break; + case pass_print_string_offsets: + if(info->type == pe_msgstr) break; + write_offsets: + // print length of current string + fwrite(&info->textlen, sizeof(unsigned), 1, d->out); + // print offset of current string + fwrite(&d->off, sizeof(unsigned), 1, d->out); + d->off += info->textlen + 1; + break; + case pass_print_translation_offsets: +#ifndef DO_NOTHING + if(info->type == pe_msgid) break; +#else + if(info->type != pe_msgid) break; +#endif + goto write_offsets; + case pass_print_strings: + if(info->type == pe_msgstr) break; + write_string: + fwrite(info->text, info->textlen + 1, 1, d->out); + break; + case pass_print_translations: +#ifndef DO_NOTHING + if(info->type == pe_msgid) break; +#else + if(info->type != pe_msgid) break; +#endif + goto write_string; + break; + default: + abort(); + } + return 0; +} + +int process(FILE *in, FILE *out) { + struct mo_hdr mohdr = def_hdr; + char line[4096]; char *lp; + char convbuf[16384]; + + struct callbackdata d = { + .num = { + [pe_msgid] = 0, + [pe_msgstr] = 0, + }, + .len = { + [pe_msgid] = 0, + [pe_msgstr] = 0, + }, + .off = 0, + .out = out, + .pass = pass_first, + }; + + struct po_parser pb, *p = &pb; + int invalid_file = 0; + + mohdr.off_tbl_trans = mohdr.off_tbl_org; + for(d.pass = pass_first; d.pass < pass_max; d.pass++) { + if(d.pass == pass_second) { + // start of second pass: + // check that data gathered in first pass is consistent +#ifndef DO_NOTHING + if(d.num[pe_msgid] != d.num[pe_msgstr]) { + // one should actually abort here, + // but gnu gettext simply writes an empty .mo and returns success. + //abort(); + d.num[pe_msgid] = 0; + invalid_file = 1; + } +#endif + + // calculate header fields from len and num arrays + mohdr.numstring = d.num[pe_msgid]; + mohdr.off_tbl_org = sizeof(struct mo_hdr); + mohdr.off_tbl_trans = mohdr.off_tbl_org + d.num[pe_msgid] * (sizeof(unsigned)*2); + // print header + fwrite(&mohdr, sizeof(mohdr), 1, out); + // set offset startvalue + d.off = mohdr.off_tbl_trans + d.num[pe_msgid] * (sizeof(unsigned)*2); + if(invalid_file) return 0; + } + poparser_init(p, convbuf, sizeof(convbuf), process_line_callback, &d); + + while((lp = fgets(line, sizeof(line), in))) { + poparser_feed_line(p, lp, sizeof(line)); + } + + poparser_finish(p); + + fseek(in, 0, SEEK_SET); + } + return 0; +} + + +void set_file(int out, char* fn, FILE** dest) { + if(streq(fn, "-")) { + *dest = out ? stdout : stdin; + } else { + *dest = fopen(fn, out ? "w" : "r"); + } + if(!*dest) { + perror("fopen"); + exit(1); + } +} + +int main(int argc, char**argv) { + if(argc == 1) syntax(); + int arg = 1; + FILE *out = NULL; + FILE *in = NULL; + int expect_out_fn = 0; + int expect_in_fn = 1; + char* dest; +#define A argv[arg] + for(; arg < argc; arg++) { + if(expect_out_fn) { + set_file(1, A, &out); + expect_out_fn = 0; + } else if(A[0] == '-') { + if(A[1] == '-') { + if( + streq(A+2, "java") || + streq(A+2, "java2") || + streq(A+2, "csharp") || + streq(A+2, "csharp-resources") || + streq(A+2, "tcl") || + streq(A+2, "qt") || + streq(A+2, "strict") || + streq(A+2, "properties-input") || + streq(A+2, "stringtable-input") || + streq(A+2, "use-fuzzy") || + strstarts(A+2, "alignment=") || + streq(A+2, "check") || + streq(A+2, "check-format") || + streq(A+2, "check-header") || + streq(A+2, "check-domain") || + streq(A+2, "check-compatibility") || + streq(A+2, "check-accelerators") || + streq(A+2, "no-hash") || + streq(A+2, "verbose") || + streq(A+2, "statistics") || + strstarts(A+2, "check-accelerators=") || + strstarts(A+2, "resource=") || + strstarts(A+2, "locale=") + + ) { + } else if((dest = strstarts(A+2, "output-file="))) { + set_file(1, dest, &out); + } else if(streq(A+2, "version")) { + version(); + } else if(streq(A+2, "help")) syntax(); + + } else if(streq(A + 1, "o")) { + expect_out_fn = 1; + } else if( + streq(A+1, "j") || + streq(A+1, "r") || + streq(A+1, "l") || + streq(A+1, "P") || + streq(A+1, "f") || + streq(A+1, "a") || + streq(A+1, "c") || + streq(A+1, "C") + ) { + } else if (streq(A+1, "v")) { + version(); + } else if (streq(A+1, "d")) { + // no support for -d at this time + fprintf(stderr, "EINVAL\n"); + exit(1); + } else if (streq(A+1, "h")) syntax(); + } else if (expect_in_fn) { + set_file(0, A, &in); + } + } + if(in == NULL || out == NULL) syntax(); + int ret = process(in, out); + fflush(in); fflush(out); + if(in != stdin) fclose(in); + if(out != stdout) fclose(out); + return ret; +} diff --git a/package/gettext-tiny/src/src/msgmerge.c b/package/gettext-tiny/src/src/msgmerge.c new file mode 100644 index 000000000..977f1686e --- /dev/null +++ b/package/gettext-tiny/src/src/msgmerge.c @@ -0,0 +1,222 @@ +/* msgfmt utility (C) 2012 rofl0r + * released under the MIT license, see LICENSE for details */ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include <assert.h> +#include "poparser.h" +#include "StringEscape.h" + +__attribute__((noreturn)) +static void syntax(void) { + fprintf(stdout, + "Usage: msgmerge [OPTION] def.po ref.pot\n"); + exit(1); +} + +__attribute__((noreturn)) +static void version(void) { + fprintf(stdout, + "these are not (GNU gettext-tools) 99.9999.9999\n"); + exit(0); +} + +#define streq(A, B) (!strcmp(A, B)) +#define strstarts(S, W) (memcmp(S, W, sizeof(W) - 1) ? NULL : (S + (sizeof(W) - 1))) + +struct fiLes { + FILE *out; + /* we can haz 3 different input files: + * the .pot, which is the file containing only the ripped out strings from the program + * (and no translations) + * a .po, which is contains translations and strings made from a previous .pot from that same source file, + * a compendium, which is basically a huge po file containing all sorts of strings (msgid's) and translations (msgstr's) + */ + FILE *po; + FILE *pot; + FILE *compend; +}; + +/* currently we only output input strings as output strings + * i.e. there is no translation lookup at all */ +int process_line_callback(struct po_info* info, void* user) { + char convbuf[8192]; + FILE* out = (FILE*) user; + size_t l; + if(info->type == pe_msgid) { + l = escape(info->text, convbuf, sizeof(convbuf)); + fprintf(out, "msgid \"%s\"\nmsgstr \"%s\"\n", convbuf, convbuf); + } + return 0; +} + +int process(struct fiLes *files, int update, int backup) { + (void) update; (void) backup; + struct po_parser pb, *p = &pb; + char line[4096], conv[8192], *lb; + poparser_init(p, conv, sizeof(conv), process_line_callback, files->out); + while((lb = fgets(line, sizeof(line), files->pot))) { + poparser_feed_line(p, lb, sizeof(line) - (size_t)(lb - line)); + } + poparser_finish(p); + return 0; +} + +void set_file(int out, char* fn, FILE** dest) { + if(streq(fn, "-")) { + *dest = out ? stdout : stdin; + } else { + *dest = fopen(fn, out ? "w" : "r"); + } + if(!*dest) { + perror("fopen"); + exit(1); + } +} + +int getbackuptype(char* str) { + if(!str || !*str || streq(str, "none") || streq(str, "off")) + return 0; + else if(streq(str, "t") || streq(str, "numbered")) + return 1; + else if(streq(str, "nil") || streq(str, "existing")) + return 2; + else if(streq(str, "simple") || streq(str, "never")) + return 3; + else syntax(); +} + +int main(int argc, char**argv) { + if(argc == 1) syntax(); + int arg = 1; + struct expect { + int out; + int po; + int pot; + int compend; + } expect_fn = { + .out = 0, + .po = 1, + .pot = 0, + .compend = 0, + }; + struct fiLes files = {0,0,0,0}; + char* backup_suffix = getenv("SIMPLE_BACKUP_SUFFIX"); + if(!backup_suffix) backup_suffix = "~"; + int update = 0; + int backup = getbackuptype(getenv("VERSION_CONTROL")); + char* dest; + set_file(1, "-", &files.out); +#define A argv[arg] + for(; arg < argc; arg++) { + if(A[0] == '-') { + if(A[1] == '-') { + if( + streq(A+2, "strict") || + streq(A+2, "properties-input") || + streq(A+2, "properties-output") || + streq(A+2, "stringtable-input") || + streq(A+2, "stringtable-output") || + streq(A+2, "no-fuzzy-matching") || + streq(A+2, "multi-domain") || + streq(A+2, "previous") || + streq(A+2, "escape") || + streq(A+2, "no-escape") || + streq(A+2, "force-po") || + streq(A+2, "indent") || + streq(A+2, "add-location") || + streq(A+2, "no-location") || + streq(A+2, "no-wrap") || + streq(A+2, "sort-output") || + streq(A+2, "sort-by-file") || + + strstarts(A+2, "lang=") || + strstarts(A+2, "color") || // can be --color or --color=xxx + strstarts(A+2, "style=") || + strstarts(A+2, "width=") || + + streq(A+2, "verbose") || + streq(A+2, "quiet") || + streq(A+2, "silent") ) { + } else if(streq(A+2, "version")) { + version(); + } else if((dest = strstarts(A+2, "output-file="))) { + set_file(1, dest, &files.out); + } else if((dest = strstarts(A+2, "compendium="))) { + set_file(1, dest, &files.compend); + } else if((dest = strstarts(A+2, "suffix="))) { + backup_suffix = dest; + } else if((dest = strstarts(A+2, "directory="))) { + goto nodir; + } else if((dest = strstarts(A+2, "backup"))) { + if (*dest == '=') + backup = getbackuptype(dest + 1); + else + backup = 0; + } else if(streq(A+2, "update")) { + set_update: + update = 1; + abort(); + } else if(streq(A+2, "help")) syntax(); + + } else if(streq(A + 1, "o")) { + expect_fn.out = 1; + } else if(streq(A + 1, "C")) { + expect_fn.compend = 1; + } else if(streq(A + 1, "U")) { + goto set_update; + } else if( + streq(A+1, "m") || + streq(A+1, "N") || + streq(A+1, "P") || + streq(A+1, "e") || + streq(A+1, "E") || + streq(A+1, "i") || + streq(A+1, "p") || + streq(A+1, "w") || + streq(A+1, "s") || + streq(A+1, "F") || + streq(A+1, "V") || + streq(A+1, "q") + ) { + + } else if (streq(A+1, "v")) { + version(); + } else if (streq(A+1, "D")) { + // no support for -D at this time + nodir: + fprintf(stderr, "EINVAL\n"); + exit(1); + } else if (streq(A+1, "h")) syntax(); + } else if(expect_fn.out) { + set_file(1, A, &files.out); + expect_fn.out = 0; + } else if(expect_fn.compend) { + set_file(1, A, &files.compend); + expect_fn.compend = 0; + } else if(expect_fn.po) { + set_file(0, A, &files.po); + expect_fn.po = 0; + expect_fn.pot = 1; + } else if(expect_fn.pot) { + set_file(0, A, &files.pot); + expect_fn.pot = 0; + } + } + if(!files.out || !files.po || !files.pot) syntax(); + int ret = process(&files, update, backup); + FILE** filearr = (FILE**) &files; + unsigned i; + for (i = 0; i < 4; i++) { + if(filearr[i] != NULL) fflush(filearr[i]); + } + for (i = 0; i < 4; i++) { + if( + filearr[i] != NULL && + filearr[i] != stdout && + filearr[i] != stdin + ) fclose(filearr[i]); + } + return ret; +} diff --git a/package/gettext-tiny/src/src/poparser.c b/package/gettext-tiny/src/src/poparser.c new file mode 100644 index 000000000..e67761305 --- /dev/null +++ b/package/gettext-tiny/src/src/poparser.c @@ -0,0 +1,144 @@ +#include <ctype.h> +#include <assert.h> +#include <stdlib.h> +#include <string.h> +#include "poparser.h" +#include "StringEscape.h" + +#define streq(A, B) (!strcmp(A, B)) +#define strstarts(S, W) (memcmp(S, W, sizeof(W) - 1) ? NULL : (S + (sizeof(W) - 1))) + +static enum po_entry get_type_and_start(char* lp, char* end, size_t *stringstart) { + enum po_entry result_type; + char *x, *y; + size_t start = (size_t) lp; + while(isspace(*lp) && lp < end) lp++; + if(lp[0] == '#') { + inv: + *stringstart = 0; + return pe_invalid; + } + if((y = strstarts(lp, "msg"))) { + if((x = strstarts(y, "id")) && (isspace(*x) || ((x = strstarts(x, "_plural")) && isspace(*x)))) + result_type = pe_msgid; + else if ((x = strstarts(y, "str")) && (isspace(*x) || + (x[0] == '[' && (x[1] == '0' || x[1] == '1') && x[2] == ']' && (x += 3) && isspace(*x)))) + result_type = pe_msgstr; + else + goto inv; + while(isspace(*x) && x < end) x++; + if(*x != '"') abort(); + conv: + *stringstart = ((size_t) x - start) + 1; + } else if(*lp == '"') { + result_type = pe_str; + x = lp; + goto conv; + } else { + goto inv; + } + return result_type; +} + +/* expects a pointer to the first char after a opening " in a string, + * converts the string into convbuf, and returns the length of that string */ +static size_t get_length_and_convert(char* x, char* end, char* convbuf, size_t convbuflen) { + size_t result = 0; + char* e = x + strlen(x); + assert(e > x && e < end && *e == 0); + e--; + while(isspace(*e)) e--; + if(*e != '"') abort(); + *e = 0; + result = unescape(x, convbuf, convbuflen); + return result; +} + + +void poparser_init(struct po_parser *p, char* workbuf, size_t bufsize, poparser_callback cb, void* cbdata) { + p->buf = workbuf; + p->bufsize = bufsize; + p->cb = cb; + p->prev_type = pe_invalid; + p->curr_len = 0; + p->cbdata = cbdata; +} + +enum lineactions { + la_incr, + la_proc, + la_abort, + la_nop, + la_max, +}; + +/* return 0 on success */ +int poparser_feed_line(struct po_parser *p, char* line, size_t buflen) { + char *convbuf = p->buf; + size_t convbuflen = p->bufsize; + size_t strstart; + + static const enum lineactions action_tbl[pe_max][pe_max] = { + // pe_str will never be set as curr_type + [pe_str] = { + [pe_str] = la_abort, + [pe_msgid] = la_abort, + [pe_msgstr] = la_abort, + [pe_invalid] = la_abort, + }, + [pe_msgid] = { + [pe_str] = la_incr, + [pe_msgid] = la_proc, + [pe_msgstr] = la_proc, + [pe_invalid] = la_proc, + }, + [pe_msgstr] = { + [pe_str] = la_incr, + [pe_msgid] = la_proc, + [pe_msgstr] = la_proc, + [pe_invalid] = la_proc, + }, + [pe_invalid] = { + [pe_str] = la_nop, // this can happen when we have msgstr[2] "" ... "foo", since we only parse msgstr[0] and [1] + [pe_msgid] = la_incr, + [pe_msgstr] = la_incr, + [pe_invalid] = la_nop, + }, + }; + + enum po_entry type; + + type = get_type_and_start(line, line + buflen, &strstart); + switch(action_tbl[p->prev_type][type]) { + case la_incr: + assert(type == pe_msgid || type == pe_msgstr || type == pe_str); + p->curr_len += get_length_and_convert(line + strstart, line + buflen, convbuf + p->curr_len, convbuflen - p->curr_len); + break; + case la_proc: + assert(p->prev_type == pe_msgid || p->prev_type == pe_msgstr); + p->info.text = convbuf; + p->info.textlen = p->curr_len; + p->info.type = p->prev_type; + p->cb(&p->info, p->cbdata); + if(type != pe_invalid) + p->curr_len = get_length_and_convert(line + strstart, line + buflen, convbuf, convbuflen); + else + p->curr_len = 0; + break; + case la_nop: + break; + case la_abort: + default: + abort(); + // todo : return error code + } + if(type != pe_str) { + p->prev_type = type; + } + return 0; +} + +int poparser_finish(struct po_parser *p) { + char empty[4] = ""; + return poparser_feed_line(p, empty, sizeof(empty)); +} diff --git a/package/gettext-tiny/src/src/poparser.h b/package/gettext-tiny/src/src/poparser.h new file mode 100644 index 000000000..e29594f35 --- /dev/null +++ b/package/gettext-tiny/src/src/poparser.h @@ -0,0 +1,36 @@ +#ifndef POPARSER_H +#define POPARSER_H +#include <unistd.h> + +enum po_entry { + pe_msgid = 0, + pe_msgstr, + pe_maxstr, + pe_str = pe_maxstr, + pe_invalid, + pe_max, +}; + +struct po_info { + enum po_entry type; + char *text; + size_t textlen; +}; + +typedef int (*poparser_callback)(struct po_info* info, void* user); + +struct po_parser { + struct po_info info; + char *buf; + size_t bufsize; + enum po_entry prev_type; + unsigned curr_len; + poparser_callback cb; + void *cbdata; +}; + +void poparser_init(struct po_parser *p, char* workbuf, size_t bufsize, poparser_callback cb, void* cbdata); +int poparser_feed_line(struct po_parser *p, char* line, size_t buflen); +int poparser_finish(struct po_parser *p); + +#endif diff --git a/package/gettext-tiny/src/src/xgettext.sh b/package/gettext-tiny/src/src/xgettext.sh new file mode 100755 index 000000000..32173556b --- /dev/null +++ b/package/gettext-tiny/src/src/xgettext.sh @@ -0,0 +1,112 @@ +#!/bin/sh + +outputfile= +outputdir=. +domain=messages + +spliteq() { + arg=$1 + echo "${arg#*=}" + #alternatives echo "$arg" | cut -d= -f2- + # or echo "$arg" | sed 's/[^=]*=//' +} + +syntax() { + printf "%s\n" "Usage: xgettext [OPTION] [INPUTFILE]..." + exit 1 +} + +show_version() { + printf "%s\n", "these are not (GNU gettext-tools) 99.9999.9999\n" + exit 0 +} + +while true ; do + case $1 in + #--files-from=*) readfile `spliteq "$1"`;; + #-f) expectfilefrom=1;; + --version) show_version;; + -V) show_version;; + --default-domain=*) domain=`spliteq "$1"` ;; + -d) shift ; domain="$1" ;; + --files-from=*) : ;; + -f) shift ;; + --directory=*) : ;; + -D) shift ;; + -o) shift ; outputfile="$1" ;; + --output=*) outputfile=`spliteq "$1"` ;; + --output-dir=*) outputdir=`spliteq "$1"` ;; + -p) shift ; outputdir=`spliteq "$1"` ;; + --language=*) : ;; + -L) shift ;; + --C) : ;; + --c++) : ;; + --from-code=*) : ;; + --join-existing) : ;; + -j) : ;; + --exclude-file=*) : ;; + -x) shift;; + --add-comments=*) : ;; + -cTAG) shift;; + --add-comments) : ;; + -c) : ;; + --extract-all) : ;; + -a) : ;; + --keyword=*) : ;; + -k*) : ;; + --keyword) : ;; + -k) : ;; + --flag=*) : ;; + --trigraphs) : ;; + -T) : ;; + --qt) : ;; + --kde) : ;; + --boost) : ;; + --debug) : ;; + --color) : ;; + --color=*) : ;; + --style=*) : ;; + --no-escape) : ;; + -e) : ;; + --escape) : ;; + -E) : ;; + --force-po) force=1 ;; + --indent) : ;; + -i) : ;; + --no-location) : ;; + --add-location) : ;; + -n) : ;; + --strict) : ;; + --properties-output) : ;; + --stringtable-output) : ;; + --width=*) : ;; + -w) : ;; + --no-wrap) : ;; + --sort-output) : ;; + -s) : ;; + --sort-by-file) : ;; + -F) : ;; + --omit-header) : ;; + --copyright-holder=*) : ;; + --foreign-user) : ;; + --package-name=*) : ;; + --package-version=*) : ;; + --msgid-bugs-address=*) : ;; + --msgstr-prefix*) : ;; + -m*) : ;; + --msgstr-suffix*) : ;; + -M*) : ;; + --help) syntax ;; + -h) syntax ;; + *) break ;; + esac + shift +done + +[ -z "$outputfile" ] && outputfile=${domain}.po +[ "$outputfile" = "-" ] && exit 0 +if [ ! -z "$outputfile" ] ; then + touch $outputdir/$outputfile +fi + + |