summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* xgettext: fix --version output (#60)HEADmasterPatrycja2022-03-091-1/+1
| | | | "\n" in the printf parameter doesn't expand and the comma gets printed after format string
* build: respect cflags (#58)Ariadne Conill2021-04-141-1/+1
|
* msgfmt: exit(1) if incorrectly usedv0.3.2Max Rees2020-03-241-2/+2
| | | | | This prevents builds from continuing seemingly fine when they are actually not using this version of msgfmt correctly.
* Correct typos in msgfmt.cFelix Yan2020-02-171-2/+2
|
* msgfmt: Allow space between --keyword and its argA. Wilcox2020-02-161-0/+2
| | | | | | | | | | While building mate-panel 1.24.0: make[3]: Entering directory '/usr/src/packages/user/mate-panel/src/mate-panel-1.24.0/libmate-panel-applet' /usr/bin/msgfmt --desktop --keyword Name --keyword Description --template org.mate.panel.TestApplet.mate-panel-applet.desktop.in -d ../po -o org.mate.panel.TestApplet.mate-panel-applet fopen: No such file or directory Fixes: 55a2119d06 ("msgfmt: support keyword, template, output options")
* LICENSE: add parapraph about doc/ licensesrofl0r2020-02-031-0/+4
| | | | closes #52
* msgmerge: avoid printing too long linexhe2020-01-231-6/+21
| | | | | | | | | | | this is the cause of #50. One line is generally short, and [8192] is big enough for our usage. But after cmake invokes msgmerge, lines are joined. So we printf some super long lines into po files. And again, cmake invokes msgfmt to use these updated po files. So we meet these super long lines.
* Makefile: fix install failure if path contains "m4/" string (#49)Giulio Benetti2020-01-191-1/+1
| | | | | | | | | Actually Makefile install recipe substitutes every occurence of "m4/" in file name of the target of the rule($@), in an absolute path there could more than one "m4/" occurence, so install will fail. Let's change $(subst ...) with $(patsubst ...) substituting only last occurence of "m4/" pattern. Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
* msgfmt: support keyword, template, output optionsxhe2019-11-301-0/+6
| | | | | | | follow https://github.com/sabotage-linux/gettext-tiny/issues/47. 'keyword=' is simply ignored. msgfmt will generate the output based on the template file and other sources. so 'template=' is the input file.
* data/Makefile.in: add missing maintainer targetsxhe2019-06-291-11/+42
| | | | | | | | follow https://github.com/sabotage-linux/gettext-tiny/issues/44. Similiar to #43. I do think update-mo is good, though most targets @ismaell requested are just stubs. Since gettext-tiny is not for maintainer.
* autopoint: support dist target to release tarballsxhe2019-06-281-2/+37
| | | | | | | | follow https://github.com/sabotage-linux/gettext-tiny/issues/43. closed https://github.com/sabotage-linux/gettext-tiny/issues/43. though it's not our goal to support releasing, it's not so much code.
* gettext-tiny: Fix format not a string literal error (#41)Vadim Kochan2019-04-061-6/+19
| | | | | | | Add 'format_arg' attribute for the functions which may return string as formatted parameter, otherwise it fails to compile with corresponding compiler checking flag enabled. Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
* xgettext: parse arguments correctlyxhe2019-04-051-2/+1
| | | | | | | | | `*) break` will stop parsing immediately after the first argument is parsed, leaving all other arguments ignored. To prevent shifting arguments more than we have, we should check if there's any argument left. Otherwise, script will exit with `can not shift anymore`.
* msgfmt: missing breakstubmodexhe2019-02-051-1/+2
|
* msgfmt: clean code, prepare to handle other modesxhe2019-02-051-42/+94
| | | | | | msgfmt only focus on po->mo mode(and a stub for .msg). now as we want to generate .desktop and .xml too, i'd like to handle these modes explicitly.
* poparser: not check overflow for msgid_pluralnew_mergexhe2019-01-161-4/+0
| | | | it's allowed to have nplurals=1, but with msgid_plural and msgstr[0]
* poparser: msgid_plural is with nplurals > 2xhe2019-01-161-1/+1
| | | | i made a exactly wrong check there
* msgfmt: enable strict mode with -c argumentxhe2019-01-162-5/+13
| | | | with the -c argument, msgfmt should check po files more strict.
* poparser: default to non-strict modexhe2019-01-162-2/+3
| | | | | | there're many po files in invalid-form, which will not actually trigger segfault or what in most cases. gnu msgfmt chose to ignore these issues without explicit option, so do i.
* poparser: charset str should stop at escape charsxhe2019-01-161-1/+1
| | | | | | | as we will pass raw strings directly at the first stage, we may meet an escaped '\n', e.g. "\\n". because, there's no '\\' in charset strings, we can use '\\' as a terminator to avoid taking useless parts. useless parts will cause a unsupported_charset error.
* poparser: convert codecs at both two stagesxhe2019-01-161-13/+12
| | | | | | | | | following https://github.com/sabotage-linux/gettext-tiny/commit/5539eff5d507c619735156fa9e44e0bcf1436695#diff-9657ea17ae7a6e3b985dc974d613664e. the previous commit did not fix the issue. because the stage one will not copy anything into message_t. so this time, raw strings are directly passed to feed_hdr().
* poparser: add po_error_last to po_error typexhe2019-01-162-1/+2
| | | | | so we can directly get the problem from the return value of msgfmt.c:process().
* poparser: comment may start a new block tooxhe2019-01-161-0/+5
| | | | | | | i assume a block is completely parsed just before next msgid/ctxt. but the reality is comment may start a new block too. and if poparser dont treat comments as the start of new block, those comments will be parsed into as flags of old block.
* poparser: clean msg comment flagsxhe2019-01-161-0/+1
| | | | or the next msg will ineherit flag like PO_FUZZY
* poparser: should check length instead of pointerxhe2019-01-161-1/+1
| | | | | at stage two, it's a buffer allocated by poparser_finish. it will never be a NULL pointer, so may trigger an abort.
* poparser: disable 'first' flag after a msgblockxhe2019-01-161-2/+2
| | | | | | | | | | | there're two points: 1. only disable 'first' flag at parse stage. but i want it same at both two stages when i tried to invoke this flag. 2. disable 'first' flag once after poparser_feed_hdr() was finished. i originally assume it's consistent in the parse process of a whole block. this is causing 'msgstr abort', because there's a syntax check relying on this flag. so now, it keeps consistent in the whole process.
* poparser: enable 'first' flag at both two stagesxhe2019-01-161-0/+1
| | | | | it should be set to true at the beginning of each stage, or we may abort.
* msgfmt: do not return the result of remove()xhe2019-01-161-3/+1
| | | | | | what we want to do is deleting wrong output files. but if remove() is successfully executed, msgfmt will return 0 instead of ret. this badly damaged various cases.
* poparser: avoid 32-bit truncation by unsignedxhe2019-01-161-1/+2
| | | | | | as rofl0r said, unsigned on x86/x64 is 32 bits, and will truncate the len. though the result of sizeof() should just be a very small number( 12), and truncation will not effect the check result.
* poparser: convert codecs at both two stagesxhe2019-01-161-4/+4
| | | | | | as iconv may increase the length of strings, so we may have a larger length at the parse stage than the first stage. that leads to a memory corruption.
* poparser: set correct length after parsing codecsxhe2019-01-161-2/+5
| | | | retval of iconv is not length, we need to calc that length by pointers.
* poparser: return if the buf is too smallxhe2019-01-161-0/+6
| | | | | if line_len, e.g. inputbytes_left is not 0, that means the output buf is large enough.
* poparser: avoid comparisons of different signsxhe2019-01-162-3/+3
|
* poparser: avoid memory corruption by terminatorxhe2019-01-161-1/+1
| | | | we did not add NULL terminator into the length of strings.
* poparser: avoid invalid memory accessxhe2019-01-161-1/+5
| | | | | | | | 1. y-x is larger than the charset string by 8. we should write to [y-x-8] instead. it may lead to a memory corruption. 2. though, i've checked before: the maxiumum length of charset string should be 11. let's avoid meeting a unknown charset, or an invalid one.
* msgfmt&poparser: correct length at str tablexhe2019-01-163-10/+11
| | | | | then length of str table does not include the NULL terminator while translation includes.
* msgfmt: add missing messages count variablexhe2019-01-161-0/+2
|
* msgfmt: add missing '+' operatorxhe2019-01-161-1/+1
|
* poparser: simplified sysdep() morexhe2019-01-163-25/+26
| | | | | | | | this time, msg->sysdep became a total num of cases simply. just invoke sysdep() X times with a third argument from 0 to X-1, and you are done. in short, i move the code of transforming flags to the num of cases from msgfmt.c to poparser.c
* poparser: a more easy-to-understand sysdep()xhe2019-01-163-53/+52
| | | | | | | | | | | | | as rofl0r said, maybe the previous sysdep(), is a bit confusing. so, i modified a new version. this time, msg->sysdep[] became a bit flag msg->sysdep_flag. it can tell which kind of sysdep string occurs. using this infomation, you can tell the total num of cases on your own. assuming that num is X, you can use new sysdep() to deal with every case simply by invoking the function X times with a third argument from 0 to X-1. and you get X different expanded strings.
* msgfmt: skip impossible casesxhe2019-01-161-0/+5
| | | | | mentioned by rofl0r. it's not possible to have a case where lu is both priu32 and 64. we skip the case by adding one.
* poparpser: avoid endless loopxhe2019-01-161-3/+4
| | | | | | | | | | | when a string like 'xx %8' appears, strchr will capture a '%'. but it's not a sysdep string, so variable `x` is not changed. then strchr will repeat this process over and over again. now, we first copy the content before '%'(including '%'), and refer x to the first character after '%'. then we match and replace sysdep strings. or just continue, since x is now behind '%', strchr wont repeat the process again.
* poparser: optimize by saving strlen() resultsxhe2019-01-161-6/+10
|
* poparser: avoid invalid memory accessxhe2019-01-161-1/+1
| | | | | | | mentioned by rofl0r. if y is shorter than strlen(sysdep_str[n]), it may corrupt the memory. we better use strncmp instead.
* msgmerge: pretty the output with breaklinesxhe2019-01-161-0/+2
|
* poparser: not to skip sysdeps other than %<PRIu32>xhe2019-01-161-14/+18
| | | | | | | | | | | follow https://github.com/sabotage-linux/gettext-tiny/issues/39#issuecomment-445036044. it's obvious that, strstr will search for `%<PRIu32>` first, if there's one, then we get there and skip all other sysdep strings before the first `%<PRIu32>`. but what we want is, to search the first sysdep string. so, our new stragegy is to search for `%` instead. such that, we will always match the first sysdep string.
* msgmerge: give enough space for escape()xhe2019-01-161-0/+2
| | | | escape will need up to two times larger space.
* stringescape: add missing escape chars to escape()xhe2019-01-161-4/+14
| | | | | | | | | escape() should handle '\b' and '\a' as well. also, escape() execute some wrong actions. like transform '\?' into '\\\?', which should be '\\?'. specially, we do not need to en/decode ['] into [\\\']. but for safety, still keep that in unescape().
* msgmerge: use the same size as msgfmtxhe2019-01-161-1/+1
| | | | | as the bufer of msgfmt was overflowed before, we better take a bigger buffer for msgmerge, too.
* complete rewrite of poparser, msgmerge/msgfmt portedxhe2019-01-164-629/+669
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | as stated in https://github.com/sabotage-linux/gettext-tiny/issues/39, the old parser is not good enough to handle all the po files. Similiar issues occurred over and over again because our dirty hacks in the project. so, i propose and implement this new parser, which: 1. needs to parse a po file two times. the first time will acquire the maximum width of every entry. the second time will copy the well-prepared contents into struct po_message, and pass it to the callback function. 2. every struct po_message contains all the information of one translation: msgid, msgctxt, msgid_plural, and msgstrs. comments may be added later. the logic of code is quite simple, nothing special need to explain. the special points are: 1. the first time, new parser gives no infomation about what the string is like. neither will the new parser give the exact size(sysdeped), nor you can calculate the exact size on your own. only xxx_len, strlen, sy- sdep in po_message_t is available. xxx_len is the length of the corressponding entry, strlen is almost the same. 2. sysdep present how many cases the string could be expanded to. since you know the length of the original string and the original string is always longer than the converted one, you can get a safe buffer size to work at the second stage. 3. poparser_sysdep(), a function like unescape(), with a bit flag as the third argument. that is, three bits correspond to st_priu32, st_priu64, st_priumax. since there're only up to two cases for every kind of sysdep, you could count from 0 to msg->sysdep-1, and poparser_sysdep will iterate every possible case eventually.