Skip to content

Commit 11e6535

Browse files
committed
* scanpo.c, main.c, misc: implemented a VERSION/N and REVISION/N option to
allow to override the catalog version and revision numbers. This is e.g. the case if the ct/po files don't contain parseable $Id$ specifiers in case git is used as revision control. For these cases the revision can now be specified on the command-line as well.
1 parent 54db5a8 commit 11e6535

19 files changed

+165
-46
lines changed

.gitignore

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1-
.dep_*/
2-
.obj_*/
1+
src/.dep_*/
2+
src/.obj_*/
3+
src/bin_*/
4+
src/locale/*.catalog
5+
release/
6+
/*.lha
7+
/*.readme

ChangeLog

+7-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22
FlexCat Open Source - Changelog
33
-------------------------------
44

5-
$Id$
6-
$URL$
5+
2016-04-27 Jens Maus <[email protected]>
6+
7+
* scanpo.c, main.c, misc: implemented a VERSION/N and REVISION/N option to
8+
allow to override the catalog version and revision numbers. This is e.g.
9+
the case if the ct/po files don't contain parseable $Id$ specifiers in case
10+
git is used as revision control. For these cases the revision can now be
11+
specified on the command-line as well.
712

813
2015-07-12 Thore B�ckelmann <[email protected]>
914

src/FlexCat_cat.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
/****************************************************************
33
4-
This file was created automatically by `FlexCat 2.15'
4+
This file was created automatically by `FlexCat 2.18'
55
from "locale/FlexCat.pot".
66
77
Do NOT edit by hand!
@@ -168,5 +168,7 @@ extern struct FC_String FlexCat_Strings[];
168168
#define _MSG_ERR_ICONV_FAILED 68
169169
#define MSG_ERR_ICONV_OPEN_FAILED (FlexCat_Strings[69].Str)
170170
#define _MSG_ERR_ICONV_OPEN_FAILED 69
171+
#define MSG_ERR_NO_CAT_VERSION (FlexCat_Strings[70].Str)
172+
#define _MSG_ERR_NO_CAT_VERSION 70
171173

172174
#endif

src/FlexCat_cat_other.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
/****************************************************************
33
4-
This file was created automatically by `FlexCat 2.15'
4+
This file was created automatically by `FlexCat 2.18'
55
from "locale/FlexCat.pot".
66
77
Do NOT edit by hand!
@@ -97,5 +97,6 @@ void CloseFlexCatCatalog( void );
9797
#define MSG_ERR_INVALID_CHARS_FOUND FlexCat_Strings[67]
9898
#define MSG_ERR_ICONV_FAILED FlexCat_Strings[68]
9999
#define MSG_ERR_ICONV_OPEN_FAILED FlexCat_Strings[69]
100+
#define MSG_ERR_NO_CAT_VERSION FlexCat_Strings[70]
100101

101102
#endif

src/Makefile

+12-2
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ CC = gcc
124124
STRIP = strip
125125
OBJDUMP = objdump
126126
MAKEINFO= makeinfo
127+
TX = tx
127128

128129
# path definitions
129130
CDUP = /
@@ -519,10 +520,19 @@ FlexCat_cat_other.h: locale/FlexCat.pot sd/Hardcode_h.sd
519520

520521
locale/%.catalog: locale/%.po
521522
@echo " MK $@"
522-
@$(FLEXCAT) POFILE $< CATALOG $@
523+
@$(FLEXCAT) REVISION $(shell git rev-list --all --count $<) POFILE $< CATALOG $@
523524

524-
.IGNORE: $(CATALOGS)
525+
## TRANSIFEX ##########################
526+
527+
.PHONY: txpull
528+
txpull:
529+
@$(TX) pull -a -f
525530

531+
.PHONY: txpush
532+
txpush:
533+
@$(TX) push -t
534+
535+
.IGNORE: $(CATALOGS)
526536
catalogs: $(CATALOGS)
527537

528538
.PHONY: clean

src/createcat.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ void CreateCat(char *CatFile)
260260
name = (char *)"";
261261
}
262262

263-
if(asprintf(&verStr, "%cVER: %s %d.%d(%d.%d.%d)", '$', name, version, revision, day, month, year) != -1)
263+
if(asprintf(&verStr, "%cVER: %s %d.%d (%d.%d.%d)", '$', name, version, revision, day, month, year) != -1)
264264
{
265265
verChunk.ID = MAKE_ID('F', 'V', 'E', 'R');
266266
verChunk.ID = SwapLong(verChunk.ID);

src/createct.c

+27-7
Original file line numberDiff line numberDiff line change
@@ -118,19 +118,39 @@ void CreateCTFile(char *NewCTFile)
118118
t = localtime(&tim);
119119
strftime(dateStr, 12, "%d.%m.%Y", t);
120120

121-
if(CatVersion != 0L)
121+
if(CatVersion != -1)
122122
{
123-
if(BaseName != NULL)
124-
fprintf(fp, "## version %cVER: %s.catalog %d.<rev> (%s)\n", '$', BaseName, CatVersion, dateStr);
123+
if(CatRevision != -1)
124+
{
125+
if(BaseName != NULL)
126+
fprintf(fp, "## version %cVER: %s.catalog %d.%d (%s)\n", '$', BaseName, CatVersion, CatRevision, dateStr);
127+
else
128+
fprintf(fp, "## version %cVER: <name>.catalog %d.%d (%s)\n", '$', CatVersion, CatRevision, dateStr);
129+
}
125130
else
126-
fprintf(fp, "## version %cVER: <name>.catalog %d.<rev> (%s)\n", '$', CatVersion, dateStr);
131+
{
132+
if(BaseName != NULL)
133+
fprintf(fp, "## version %cVER: %s.catalog %d.<rev> (%s)\n", '$', BaseName, CatVersion, dateStr);
134+
else
135+
fprintf(fp, "## version %cVER: <name>.catalog %d.<rev> (%s)\n", '$', CatVersion, dateStr);
136+
}
127137
}
128138
else
129139
{
130-
if(BaseName != NULL)
131-
fprintf(fp, "## version %cVER: %s.catalog <ver>.0 (%s)\n", '$', BaseName, dateStr);
140+
if(CatRevision != -1)
141+
{
142+
if(BaseName != NULL)
143+
fprintf(fp, "## version %cVER: %s.catalog <ver>.%d (%s)\n", '$', BaseName, CatRevision, dateStr);
144+
else
145+
fprintf(fp, "## version %cVER: <name>.catalog <ver>.%d (%s)\n", '$', dateStr, CatRevision);
146+
}
132147
else
133-
fprintf(fp, "## version %cVER: <name>.catalog <ver>.0 (%s)\n", '$', dateStr);
148+
{
149+
if(BaseName != NULL)
150+
fprintf(fp, "## version %cVER: %s.catalog <ver>.<rev> (%s)\n", '$', BaseName, dateStr);
151+
else
152+
fprintf(fp, "## version %cVER: <name>.catalog <ver>.<rev> (%s)\n", '$', dateStr);
153+
}
134154
}
135155

136156
free(dateStr);

src/globals.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
/// Globals
2727
char *BaseName = NULL; /* Basename of catalog description */
2828
const char *Language = "english"; /* Language of catalog description */
29-
int CatVersion = 0; /* Version of catalog to be opened */
30-
int CatRevision = 0; /* Revision of catalog to be opened */
29+
int CatVersion = -1; /* Version of catalog to be opened */
30+
int CatRevision = -1; /* Revision of catalog to be opened */
3131
int NumStrings = 0; /* Number of catalog strings */
3232
char *ScanFile; /* File currently scanned */
3333
int ScanLine; /* Line currently scanned */

src/locale.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
/****************************************************************
33
4-
This file was created automatically by `FlexCat 2.15'
4+
This file was created automatically by `FlexCat 2.18'
55
from "locale/FlexCat.pot".
66
77
Do NOT edit by hand!
@@ -19,7 +19,7 @@
1919
struct FC_String FlexCat_Strings[] =
2020
{
2121
{ "Usage:", 0 },
22-
{ " CDFILE Catalog description file to scan\n CTFILE Catalog translation file to scan\n POFILE Catalog translation in PO-style format\n CATALOG Catalog file to create\n NEWCTFILE Catalog translation file to create\n SOURCES Sources to create; must be something like SFILE=SDFILE,\n where SFILE is a source file and SDFILE is a source\n description file\n WARNCTGAPS Warn about identifiers missing in translation\n NOOPTIM Do not skip unchanged strings in translation/description\n FILL Fill missing identifiers with original text\n FLUSH Flush memory after the catalog is created\n NOBEEP No DisplayBeep() on errors and warnings\n QUIET No warnings\n NOLANGTOLOWER Prevent #language name from being lowercased\n NOBUFFEREDIO Disable I/O buffers\n MODIFIED Create catalog only if description/translation have changed\n COPYMSGNEW Copy ***NEW*** markers over from old translation\n OLDMSGNEW Custom marker in old translation\n CODESET Codeset to force in output file (e.g. 'UTF-8')\n NOAUTODATE no operation - kept for compatibility\n NOSPACES no operation - kept for compatibility", 1 },
22+
{ " CDFILE Catalog description file to scan\n CTFILE Catalog translation file to scan\n POFILE Catalog translation in PO-style format\n CATALOG Catalog file to create\n NEWCTFILE Catalog translation file to create\n SOURCES Sources to create; must be something like SFILE=SDFILE,\n where SFILE is a source file and SDFILE is a source\n description file\n WARNCTGAPS Warn about identifiers missing in translation\n NOOPTIM Do not skip unchanged strings in translation/description\n FILL Fill missing identifiers with original text\n FLUSH Flush memory after the catalog is created\n NOBEEP No DisplayBeep() on errors and warnings\n QUIET No warnings\n NOLANGTOLOWER Prevent #language name from being lowercased\n NOBUFFEREDIO Disable I/O buffers\n MODIFIED Create catalog only if description/translation have changed\n COPYMSGNEW Copy ***NEW*** markers over from old translation\n OLDMSGNEW Custom marker in old translation\n CODESET Codeset to force in output file (e.g. 'UTF-8')\n VERSION Force a certain version to be used during catalog generation\n REVISION Force a certain revision to be used during catalog generation\n NOAUTODATE no operation - kept for compatibility\n NOSPACES no operation - kept for compatibility", 1 },
2323
{ "File '%s' is up to date", 2 },
2424
{ "%s, line %d - warning:", 100 },
2525
{ "%s, line %d - ERROR:", 101 },
@@ -88,6 +88,7 @@ struct FC_String FlexCat_Strings[] =
8888
{ "ERROR in CodesetsConvertStr(): %d invalid characters found", 181 },
8989
{ "ERROR in iconv(): %s", 182 },
9090
{ "ERROR in iconv_open(): %s", 183 },
91+
{ "no catalog version information found, using version 0", 184 },
9192
{ NULL, 0 }
9293
};
9394

src/locale/FlexCat.pot

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Translation catalog description file (pot-style)
2-
# $Id$
32
#
43
# version 3
54
msgid ""
@@ -43,9 +42,11 @@ msgid ""
4342
" COPYMSGNEW Copy ***NEW*** markers over from old translation\n"
4443
" OLDMSGNEW Custom marker in old translation\n"
4544
" CODESET Codeset to force in output file (e.g. 'UTF-8')\n"
45+
" VERSION Force a certain version to be used during catalog generation\n"
46+
" REVISION Force a certain revision to be used during catalog generation\n"
4647
" NOAUTODATE no operation - kept for compatibility\n"
4748
" NOSPACES no operation - kept for compatibility"
48-
msgstr " CDFILE Catalog description file to scan\n CTFILE Catalog translation file to scan\n POFILE Catalog translation in PO-style format\n CATALOG Catalog file to create\n NEWCTFILE Catalog translation file to create\n SOURCES Sources to create; must be something like SFILE=SDFILE,\n where SFILE is a source file and SDFILE is a source\n description file\n WARNCTGAPS Warn about identifiers missing in translation\n NOOPTIM Do not skip unchanged strings in translation/description\n FILL Fill missing identifiers with original text\n FLUSH Flush memory after the catalog is created\n NOBEEP No DisplayBeep() on errors and warnings\n QUIET No warnings\n NOLANGTOLOWER Prevent #language name from being lowercased\n NOBUFFEREDIO Disable I/O buffers\n MODIFIED Create catalog only if description/translation have changed\n COPYMSGNEW Copy ***NEW*** markers over from old translation\n OLDMSGNEW Custom marker in old translation\n CODESET Codeset to force in output file (e.g. 'UTF-8')\n NOAUTODATE no operation - kept for compatibility\n NOSPACES no operation - kept for compatibility"
49+
msgstr " CDFILE Catalog description file to scan\n CTFILE Catalog translation file to scan\n POFILE Catalog translation in PO-style format\n CATALOG Catalog file to create\n NEWCTFILE Catalog translation file to create\n SOURCES Sources to create; must be something like SFILE=SDFILE,\n where SFILE is a source file and SDFILE is a source\n description file\n WARNCTGAPS Warn about identifiers missing in translation\n NOOPTIM Do not skip unchanged strings in translation/description\n FILL Fill missing identifiers with original text\n FLUSH Flush memory after the catalog is created\n NOBEEP No DisplayBeep() on errors and warnings\n QUIET No warnings\n NOLANGTOLOWER Prevent #language name from being lowercased\n NOBUFFEREDIO Disable I/O buffers\n MODIFIED Create catalog only if description/translation have changed\n COPYMSGNEW Copy ***NEW*** markers over from old translation\n OLDMSGNEW Custom marker in old translation\n CODESET Codeset to force in output file (e.g. 'UTF-8')\n VERSION Force a certain version to be used during catalog generation\n REVISION Force a certain revision to be used during catalog generation\n NOAUTODATE no operation - kept for compatibility\n NOSPACES no operation - kept for compatibility"
4950

5051
msgctxt "MSG_FILEUPTODATE (2//)"
5152
msgid "File '%s' is up to date"
@@ -335,3 +336,7 @@ msgstr "ERROR in iconv(): %s"
335336
msgctxt "MSG_ERR_ICONV_OPEN_FAILED (183//)"
336337
msgid "ERROR in iconv_open(): %s"
337338
msgstr "ERROR in iconv_open(): %s"
339+
340+
msgctxt "MSG_ERR_NO_CAT_VERSION (184//)"
341+
msgid "no catalog version information found, using version 0"
342+
msgstr "no catalog version information found, using version 0"

src/locale/greek.po

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# Translators:
66
# Anthony I., 2014
77
# Anthony I., 2014
8+
# Anthony I., 2014
89
msgid ""
910
msgstr ""
1011
"Project-Id-Version: FlexCat\n"

src/locale/russian.po

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# version 3
55
# Translators:
66
# Michael Malyshev, 2014
7+
# Michael Malyshev, 2014
78
msgid ""
89
msgstr ""
910
"Project-Id-Version: FlexCat\n"

src/locale_other.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
/****************************************************************
33
4-
This file was created automatically by `FlexCat 2.15'
4+
This file was created automatically by `FlexCat 2.18'
55
from "locale/FlexCat.pot".
66
77
Do NOT edit by hand!
@@ -43,9 +43,9 @@ void OpenFlexCatCatalog( void )
4343
void CloseFlexCatCatalog( void )
4444
{}
4545

46-
const char * FlexCat_Strings[70] = {
46+
const char * FlexCat_Strings[71] = {
4747
"Usage:",
48-
" CDFILE Catalog description file to scan\n CTFILE Catalog translation file to scan\n POFILE Catalog translation in PO-style format\n CATALOG Catalog file to create\n NEWCTFILE Catalog translation file to create\n SOURCES Sources to create; must be something like SFILE=SDFILE,\n where SFILE is a source file and SDFILE is a source\n description file\n WARNCTGAPS Warn about identifiers missing in translation\n NOOPTIM Do not skip unchanged strings in translation/description\n FILL Fill missing identifiers with original text\n FLUSH Flush memory after the catalog is created\n NOBEEP No DisplayBeep() on errors and warnings\n QUIET No warnings\n NOLANGTOLOWER Prevent #language name from being lowercased\n NOBUFFEREDIO Disable I/O buffers\n MODIFIED Create catalog only if description/translation have changed\n COPYMSGNEW Copy ***NEW*** markers over from old translation\n OLDMSGNEW Custom marker in old translation\n CODESET Codeset to force in output file (e.g. 'UTF-8')\n NOAUTODATE no operation - kept for compatibility\n NOSPACES no operation - kept for compatibility",
48+
" CDFILE Catalog description file to scan\n CTFILE Catalog translation file to scan\n POFILE Catalog translation in PO-style format\n CATALOG Catalog file to create\n NEWCTFILE Catalog translation file to create\n SOURCES Sources to create; must be something like SFILE=SDFILE,\n where SFILE is a source file and SDFILE is a source\n description file\n WARNCTGAPS Warn about identifiers missing in translation\n NOOPTIM Do not skip unchanged strings in translation/description\n FILL Fill missing identifiers with original text\n FLUSH Flush memory after the catalog is created\n NOBEEP No DisplayBeep() on errors and warnings\n QUIET No warnings\n NOLANGTOLOWER Prevent #language name from being lowercased\n NOBUFFEREDIO Disable I/O buffers\n MODIFIED Create catalog only if description/translation have changed\n COPYMSGNEW Copy ***NEW*** markers over from old translation\n OLDMSGNEW Custom marker in old translation\n CODESET Codeset to force in output file (e.g. 'UTF-8')\n VERSION Force a certain version to be used during catalog generation\n REVISION Force a certain revision to be used during catalog generation\n NOAUTODATE no operation - kept for compatibility\n NOSPACES no operation - kept for compatibility",
4949
"File '%s' is up to date",
5050
"%s, line %d - warning:",
5151
"%s, line %d - ERROR:",
@@ -113,5 +113,6 @@ const char * FlexCat_Strings[70] = {
113113
"ERROR in CodesetsFind(): unknown destination charset '%s'",
114114
"ERROR in CodesetsConvertStr(): %d invalid characters found",
115115
"ERROR in iconv(): %s",
116-
"ERROR in iconv_open(): %s"
116+
"ERROR in iconv_open(): %s",
117+
"no catalog version information found, using version 0"
117118
};

src/main.c

+48-2
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ int isParam(char *input_string)
5555
return TRUE;
5656
if(Strnicmp(input_string, "codeset=", 8) == 0)
5757
return TRUE;
58+
if(Stricmp(input_string, "version") == 0)
59+
return TRUE;
60+
if(Strnicmp(input_string, "version=", 8) == 0)
61+
return TRUE;
62+
if(Stricmp(input_string, "revision") == 0)
63+
return TRUE;
64+
if(Strnicmp(input_string, "revision=", 8) == 0)
65+
return TRUE;
5866
if(Stricmp(input_string, "nooptim") == 0)
5967
return TRUE;
6068
if(Stricmp(input_string, "fill") == 0)
@@ -210,6 +218,44 @@ int main(int argc, char *argv[])
210218
DestCodeset[0] = '\0';
211219
}
212220
}
221+
else if(Strnicmp(argv[i], "version=", 8) == 0)
222+
{
223+
CatVersion = strtol(argv[i]+8, NULL, 10);
224+
}
225+
else if(Stricmp(argv[i], "version") == 0)
226+
{
227+
if(i == argc - 1)
228+
CatVersion = -1;
229+
else if(i < argc - 1)
230+
{
231+
if(isParam(argv[i + 1]) != TRUE)
232+
{
233+
CatVersion = strtol(argv[i + 1], NULL, 10);
234+
i++;
235+
}
236+
else
237+
CatVersion = -1;
238+
}
239+
}
240+
else if(Strnicmp(argv[i], "revision=", 9) == 0)
241+
{
242+
CatRevision = strtol(argv[i]+9, NULL, 10);
243+
}
244+
else if(Stricmp(argv[i], "revision") == 0)
245+
{
246+
if(i == argc - 1)
247+
CatRevision = -1;
248+
else if(i < argc - 1)
249+
{
250+
if(isParam(argv[i + 1]) != TRUE)
251+
{
252+
CatRevision = strtol(argv[i + 1], NULL, 10);
253+
i++;
254+
}
255+
else
256+
CatRevision = -1;
257+
}
258+
}
213259
else if(Stricmp(argv[i], "nooptim") == 0)
214260
{
215261
NoOptim = TRUE;
@@ -302,7 +348,7 @@ int main(int argc, char *argv[])
302348
// we eiterh scan a CD file or the supplied pot file
303349
if(strstr(cdfile, ".pot") != NULL)
304350
{
305-
if(!ScanPOFile(cdfile))
351+
if(!ScanPOFile(cdfile, FALSE))
306352
MyExit(10);
307353
}
308354
else
@@ -403,7 +449,7 @@ int main(int argc, char *argv[])
403449

404450
if(pofile != NULL)
405451
{
406-
if(!ScanPOFile(pofile))
452+
if(!ScanPOFile(pofile, makecatalog))
407453
MyExit(10);
408454
}
409455

src/readprefs.c

+10-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
*/
2222

2323
#include "flexcat.h"
24+
#include "globals.h"
2425

2526
int WarnCTGaps = FALSE; /* Warn for missing symbols in CT file. */
2627
int NoOptim = FALSE; /* Put string into catalog even
@@ -53,7 +54,6 @@ char DestCodeset[MAX_NEW_STR_LEN] = ""; /* To which codeset should w
5354
should automatically find out which codeset
5455
to be used */
5556

56-
5757
char prefs_sddir[MAXPATHLEN] = "\0";
5858

5959
/// ReadPrefs
@@ -87,10 +87,12 @@ char ReadPrefs(void)
8787
OLDMSGNEW,
8888
NOAUTODATE,
8989
NOSPACES,
90+
VERSION,
91+
REVISION,
9092
ARGS_COUNT
9193
};
9294

93-
const char template[] = "SDDIR/K,MSG_NEW/K,CODESET/K,WARNCTGAPS/S,NOOPTIM/S,FILL/S,FLUSH/S,NOBEEP/S,QUIET/S,NOLANGTOLOWER/S,NOBUFFEREDIO/S,MODIFIED/S,COPYMSGNEW/S,OLDMSGNEW/K,NOAUTODATE/S,NOSPACES/S";
95+
const char template[] = "SDDIR/K,MSG_NEW/K,CODESET/K,WARNCTGAPS/S,NOOPTIM/S,FILL/S,FLUSH/S,NOBEEP/S,QUIET/S,NOLANGTOLOWER/S,NOBUFFEREDIO/S,MODIFIED/S,COPYMSGNEW/S,OLDMSGNEW/K,NOAUTODATE/S,NOSPACES/S,VERSION/N,REVISION/N";
9496
LONG Results[ARGS_COUNT] = { 0 };
9597
char *prefs;
9698
struct RDArgs *rda;
@@ -134,6 +136,12 @@ char ReadPrefs(void)
134136
if(Results[OLDMSGNEW])
135137
snprintf(Old_Msg_New, sizeof(Old_Msg_New), "; %s", (char *)Results[OLDMSGNEW]);
136138

139+
if(Results[VERSION])
140+
CatVersion = Results[VERSION];
141+
142+
if(Results[REVISION])
143+
CatRevision = Results[REVISION];
144+
137145
FreeArgs(rdargs);
138146

139147
result = TRUE;

0 commit comments

Comments
 (0)