[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] pnet/resgen resgen.1, 1.3, 1.4 resgen.c, 1.5, 1.6
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] pnet/resgen resgen.1, 1.3, 1.4 resgen.c, 1.5, 1.6 resgen.h, 1.1, 1.2 resgen_po.c, 1.1, 1.2 resgen_text.c, 1.1, 1.2 |
Date: |
Wed, 29 Oct 2003 12:00:06 +0000 |
Update of /cvsroot/dotgnu-pnet/pnet/resgen
In directory subversions:/tmp/cvs-serv32287/resgen
Modified Files:
resgen.1 resgen.c resgen.h resgen_po.c resgen_text.c
Log Message:
Add the "-l" option to "resgen", which converts Latin-1 into UTF-8.
Index: resgen.1
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/resgen/resgen.1,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** resgen.1 27 Sep 2001 07:26:13 -0000 1.3
--- resgen.1 29 Oct 2003 12:00:04 -0000 1.4
***************
*** 14,18 ****
.\" along with this program; if not, write to the Free Software
.\" Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
! .TH resgen 1 "27 September 2001" "Southern Storm Software" "Portable.NET
Development Tools"
.SH NAME
resgen \- resource generation and conversion utility
--- 14,18 ----
.\" along with this program; if not, write to the Free Software
.\" Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
! .TH resgen 1 "29 October 2003" "Southern Storm Software" "Portable.NET
Development Tools"
.SH NAME
resgen \- resource generation and conversion utility
***************
*** 90,93 ****
--- 90,96 ----
The output format is set to GNU gettext .po resources.
.TP
+ .B \-l, \-\-latin1
+ Interpret text and .po files as Latin-1 rather than UTF-8.
+ .TP
.B \-s, \-\-sort\-names
When writing text resources as output, sort the resources by name.
***************
*** 124,131 ****
are also considered comments.
! Resource string values are assumed to be in the UTF-8 text encoding.
! No other character sets are currently supported. Values can contain
! one of the following escape sequences, which indicate special
! characters:
.TP
\\n
--- 127,134 ----
are also considered comments.
! Resource string values are assumed to be in the UTF-8 text encoding
! unless the \fB-l\fR command-line option is supplied. No other character
! sets are currently supported. Values can contain one of the following
! escape sequences, which indicate special characters:
.TP
\\n
Index: resgen_po.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/resgen/resgen_po.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** resgen_po.c 27 Sep 2001 07:24:46 -0000 1.1
--- resgen_po.c 29 Oct 2003 12:00:04 -0000 1.2
***************
*** 2,6 ****
* resgen_po.c - PO resource loading and writing routines.
*
! * Copyright (C) 2001 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
--- 2,6 ----
* resgen_po.c - PO resource loading and writing routines.
*
! * Copyright (C) 2001, 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
***************
*** 166,170 ****
* Get the next token from a .po input stream.
*/
! static void nextPOToken(POTokenInfo *tokenInfo)
{
int ch;
--- 166,170 ----
* Get the next token from a .po input stream.
*/
! static void nextPOToken(POTokenInfo *tokenInfo, int latin1)
{
int ch;
***************
*** 300,303 ****
--- 300,316 ----
ch = getc(tokenInfo->stream);
}
+ else if(latin1)
+ {
+ /* Convert the latin1 character into UTF-8 */
+ if(ch < 0x80)
+ {
+ PO_ADD_CH(ch);
+ }
+ else
+ {
+ PO_ADD_CH(0xE0 | ((ch >> 6) & 0x3F));
+ PO_ADD_CH(0x80 | (ch & 0x3F));
+ }
+ }
else
{
***************
*** 363,367 ****
* involve appending multiple strings into a single result.
*/
! static char *getPOString(POTokenInfo *tokenInfo, int *len)
{
char *result;
--- 376,380 ----
* involve appending multiple strings into a single result.
*/
! static char *getPOString(POTokenInfo *tokenInfo, int *len, int latin1)
{
char *result;
***************
*** 378,382 ****
/* Collect up any other strings that are appended to the first */
! nextPOToken(tokenInfo);
while(tokenInfo->token == PO_TOKEN_STRING)
{
--- 391,395 ----
/* Collect up any other strings that are appended to the first */
! nextPOToken(tokenInfo, latin1);
while(tokenInfo->token == PO_TOKEN_STRING)
{
***************
*** 396,400 ****
resultLen += tokenInfo->posn;
}
! nextPOToken(tokenInfo);
}
--- 409,413 ----
resultLen += tokenInfo->posn;
}
! nextPOToken(tokenInfo, latin1);
}
***************
*** 404,408 ****
}
! int ILResLoadPO(const char *filename, FILE *stream)
{
POTokenInfo tokenInfo;
--- 417,421 ----
}
! int ILResLoadPO(const char *filename, FILE *stream, int latin1)
{
POTokenInfo tokenInfo;
***************
*** 423,427 ****
tokenInfo.filename = filename;
tokenInfo.linenum = 1;
! nextPOToken(&tokenInfo);
/* Parse strings from the input stream */
--- 436,440 ----
tokenInfo.filename = filename;
tokenInfo.linenum = 1;
! nextPOToken(&tokenInfo, latin1);
/* Parse strings from the input stream */
***************
*** 430,434 ****
{
/* Get the message identifier */
! nextPOToken(&tokenInfo);
if(tokenInfo.token != PO_TOKEN_STRING)
{
--- 443,447 ----
{
/* Get the message identifier */
! nextPOToken(&tokenInfo, latin1);
if(tokenInfo.token != PO_TOKEN_STRING)
{
***************
*** 441,445 ****
break;
}
! msgid = getPOString(&tokenInfo, &msgidLen);
/* Check for the "msgstr" keyword */
--- 454,458 ----
break;
}
! msgid = getPOString(&tokenInfo, &msgidLen, latin1);
/* Check for the "msgstr" keyword */
***************
*** 457,461 ****
/* Get the message string */
! nextPOToken(&tokenInfo);
if(tokenInfo.token != PO_TOKEN_STRING)
{
--- 470,474 ----
/* Get the message string */
! nextPOToken(&tokenInfo, latin1);
if(tokenInfo.token != PO_TOKEN_STRING)
{
***************
*** 470,474 ****
}
linenum = tokenInfo.linenum;
! msgstr = getPOString(&tokenInfo, &msgstrLen);
/* Add a new resource to the global hash table */
--- 483,487 ----
}
linenum = tokenInfo.linenum;
! msgstr = getPOString(&tokenInfo, &msgstrLen, latin1);
/* Add a new resource to the global hash table */
***************
*** 502,506 ****
* Write a quoted string to a .po file.
*/
! static void writePOString(FILE *stream, const char *str, int len)
{
int posn;
--- 515,519 ----
* Write a quoted string to a .po file.
*/
! static void writePOString(FILE *stream, const char *str, int len, int latin1)
{
int posn;
***************
*** 615,618 ****
--- 628,637 ----
needEscape = 0;
}
+ else if(latin1 && ch < 0x0100)
+ {
+ putc((int)ch, stream);
+ ++lineLen;
+ needEscape = 0;
+ }
else if(ch < (unsigned long)0x10000)
{
***************
*** 644,656 ****
* Write a single hash entry to an output stream as .po data.
*/
! static void writePOEntry(FILE *stream, ILResHashEntry *entry)
{
fputs("msgid ", stream);
! writePOString(stream, entry->data, entry->nameLen);
fputs("msgstr ", stream);
! writePOString(stream, entry->data + entry->nameLen, entry->valueLen);
}
! void ILResWritePO(FILE *stream)
{
int hash;
--- 663,676 ----
* Write a single hash entry to an output stream as .po data.
*/
! static void writePOEntry(FILE *stream, ILResHashEntry *entry, int latin1)
{
fputs("msgid ", stream);
! writePOString(stream, entry->data, entry->nameLen, latin1);
fputs("msgstr ", stream);
! writePOString(stream, entry->data + entry->nameLen,
! entry->valueLen, latin1);
}
! void ILResWritePO(FILE *stream, int latin1)
{
int hash;
***************
*** 670,674 ****
putc('\n', stream);
}
! writePOEntry(stream, entry);
entry = entry->next;
}
--- 690,694 ----
putc('\n', stream);
}
! writePOEntry(stream, entry, latin1);
entry = entry->next;
}
***************
*** 676,680 ****
}
! void ILResWriteSortedPO(FILE *stream)
{
ILResHashEntry **table;
--- 696,700 ----
}
! void ILResWriteSortedPO(FILE *stream, int latin1)
{
ILResHashEntry **table;
***************
*** 691,695 ****
putc('\n', stream);
}
! writePOEntry(stream, table[posn]);
}
--- 711,715 ----
putc('\n', stream);
}
! writePOEntry(stream, table[posn], latin1);
}
Index: resgen.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/resgen/resgen.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** resgen.c 1 Dec 2002 18:40:44 -0000 1.5
--- resgen.c 29 Oct 2003 12:00:04 -0000 1.6
***************
*** 2,6 ****
* resgen.c - Resource file generator and reader.
*
! * Copyright (C) 2001 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
--- 2,6 ----
* resgen.c - Resource file generator and reader.
*
! * Copyright (C) 2001, 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
***************
*** 43,46 ****
--- 43,47 ----
{"-P", 'P', 0, 0, 0},
{"-s", 's', 0, 0, 0},
+ {"-l", 'l', 0, 0, 0},
{"-v", 'v', 0, 0, 0},
{"--text-input", 't', 0,
***************
*** 71,74 ****
--- 72,78 ----
"--po-output or -P",
"Write GNU gettext .po resources to the output file."},
+ {"--latin1", 'l', 0,
+ "--latin1 or -l",
+ "Interpret text and .po files as Latin-1 rather than UTF-8."},
{"--sort-names", 's', 0,
"--sort-names or -s",
***************
*** 97,101 ****
static int guessFormat(const char *filename, int isOutput);
static int loadResources(const char *filename, FILE *stream,
! ILContext *context, int
format);
int main(int argc, char *argv[])
--- 101,105 ----
static int guessFormat(const char *filename, int isOutput);
static int loadResources(const char *filename, FILE *stream,
! ILContext *context, int
format, int latin1);
int main(int argc, char *argv[])
***************
*** 104,107 ****
--- 108,112 ----
int inputFormat = FORMAT_GUESS;
int outputFormat = FORMAT_GUESS;
+ int latin1 = 0;
int sortNames = 0;
char *outputFile = 0;
***************
*** 175,178 ****
--- 180,189 ----
break;
+ case 'l':
+ {
+ latin1 = 1;
+ }
+ break;
+
case 's':
{
***************
*** 228,232 ****
currFormat = ((inputFormat != FORMAT_GUESS)
?
inputFormat : FORMAT_TEXT);
! errors |= loadResources("stdin", stdin,
context, currFormat);
sawStdin = 1;
}
--- 239,244 ----
currFormat = ((inputFormat != FORMAT_GUESS)
?
inputFormat : FORMAT_TEXT);
! errors |= loadResources
! ("stdin", stdin, context, currFormat,
latin1);
sawStdin = 1;
}
***************
*** 249,253 ****
currFormat = ((inputFormat != FORMAT_GUESS)
? inputFormat :
guessFormat(argv[1], 0));
! errors |= loadResources(argv[1], file, context,
currFormat);
fclose(file);
}
--- 261,266 ----
currFormat = ((inputFormat != FORMAT_GUESS)
? inputFormat :
guessFormat(argv[1], 0));
! errors |= loadResources
! (argv[1], file, context, currFormat, latin1);
fclose(file);
}
***************
*** 286,294 ****
if(sortNames)
{
! ILResWriteSortedText(stdout);
}
else
{
! ILResWriteText(stdout);
}
}
--- 299,307 ----
if(sortNames)
{
! ILResWriteSortedText(stdout, latin1);
}
else
{
! ILResWriteText(stdout, latin1);
}
}
***************
*** 303,311 ****
if(sortNames)
{
! ILResWriteSortedText(file);
}
else
{
! ILResWriteText(file);
}
fclose(file);
--- 316,324 ----
if(sortNames)
{
! ILResWriteSortedText(file, latin1);
}
else
{
! ILResWriteText(file, latin1);
}
fclose(file);
***************
*** 367,375 ****
if(sortNames)
{
! ILResWriteSortedPO(stdout);
}
else
{
! ILResWritePO(stdout);
}
}
--- 380,388 ----
if(sortNames)
{
! ILResWriteSortedPO(stdout, latin1);
}
else
{
! ILResWritePO(stdout, latin1);
}
}
***************
*** 384,392 ****
if(sortNames)
{
! ILResWriteSortedPO(file);
}
else
{
! ILResWritePO(file);
}
fclose(file);
--- 397,405 ----
if(sortNames)
{
! ILResWriteSortedPO(file, latin1);
}
else
{
! ILResWritePO(file, latin1);
}
fclose(file);
***************
*** 411,415 ****
{
fprintf(stdout, "RESGEN " VERSION " - IL Resource Generation
Utility\n");
! fprintf(stdout, "Copyright (c) 2001 Southern Storm Software, Pty
Ltd.\n");
fprintf(stdout, "\n");
fprintf(stdout, "Usage: %s [options] input ... output\n", progname);
--- 424,428 ----
{
fprintf(stdout, "RESGEN " VERSION " - IL Resource Generation
Utility\n");
! fprintf(stdout, "Copyright (c) 2001, 2003 Southern Storm Software, Pty
Ltd.\n");
fprintf(stdout, "\n");
fprintf(stdout, "Usage: %s [options] input ... output\n", progname);
***************
*** 422,426 ****
printf("RESGEN " VERSION " - IL Resource Generation Utility\n");
! printf("Copyright (c) 2001 Southern Storm Software, Pty Ltd.\n");
printf("\n");
printf("RESGEN comes with ABSOLUTELY NO WARRANTY. This is free
software,\n");
--- 435,439 ----
printf("RESGEN " VERSION " - IL Resource Generation Utility\n");
! printf("Copyright (c) 2001, 2003 Southern Storm Software, Pty Ltd.\n");
printf("\n");
printf("RESGEN comes with ABSOLUTELY NO WARRANTY. This is free
software,\n");
***************
*** 583,587 ****
*/
static int loadResources(const char *filename, FILE *stream,
! ILContext *context, int format)
{
switch(format)
--- 596,600 ----
*/
static int loadResources(const char *filename, FILE *stream,
! ILContext *context, int
format, int latin1)
{
switch(format)
***************
*** 589,593 ****
case FORMAT_TEXT:
{
! return ILResLoadText(filename, stream);
}
/* Not reached */
--- 602,606 ----
case FORMAT_TEXT:
{
! return ILResLoadText(filename, stream, latin1);
}
/* Not reached */
***************
*** 643,647 ****
case FORMAT_PO:
{
! return ILResLoadPO(filename, stream);
}
/* Not reached */
--- 656,660 ----
case FORMAT_PO:
{
! return ILResLoadPO(filename, stream, latin1);
}
/* Not reached */
Index: resgen.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/resgen/resgen.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** resgen.h 27 Sep 2001 07:24:46 -0000 1.1
--- resgen.h 29 Oct 2003 12:00:04 -0000 1.2
***************
*** 2,6 ****
* resgen.h - Internal API's used by "resgen".
*
! * Copyright (C) 2001 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
--- 2,6 ----
* resgen.h - Internal API's used by "resgen".
*
! * Copyright (C) 2001, 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
***************
*** 62,67 ****
* Load the resources in various formats. Returns non-zero on error.
*/
! int ILResLoadText(const char *filename, FILE *stream);
! int ILResLoadPO(const char *filename, FILE *stream);
int ILResLoadBinary(const char *filename, FILE *stream);
int ILResLoadBinaryIL(const char *filename, unsigned char *address,
--- 62,67 ----
* Load the resources in various formats. Returns non-zero on error.
*/
! int ILResLoadText(const char *filename, FILE *stream, int latin1);
! int ILResLoadPO(const char *filename, FILE *stream, int latin1);
int ILResLoadBinary(const char *filename, FILE *stream);
int ILResLoadBinaryIL(const char *filename, unsigned char *address,
***************
*** 72,79 ****
* Write the resources in various formats.
*/
! void ILResWriteText(FILE *stream);
! void ILResWriteSortedText(FILE *stream);
! void ILResWritePO(FILE *stream);
! void ILResWriteSortedPO(FILE *stream);
void ILResWriteBinary(FILE *stream);
void ILResWriteXML(FILE *stream);
--- 72,79 ----
* Write the resources in various formats.
*/
! void ILResWriteText(FILE *stream, int latin1);
! void ILResWriteSortedText(FILE *stream, int latin1);
! void ILResWritePO(FILE *stream, int latin1);
! void ILResWriteSortedPO(FILE *stream, int latin1);
void ILResWriteBinary(FILE *stream);
void ILResWriteXML(FILE *stream);
Index: resgen_text.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/resgen/resgen_text.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** resgen_text.c 27 Sep 2001 07:24:46 -0000 1.1
--- resgen_text.c 29 Oct 2003 12:00:04 -0000 1.2
***************
*** 2,6 ****
* resgen_text.c - Text resource loading and writing routines.
*
! * Copyright (C) 2001 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
--- 2,6 ----
* resgen_text.c - Text resource loading and writing routines.
*
! * Copyright (C) 2001, 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
***************
*** 66,70 ****
* Convert escape sequences within a buffer into real characters.
*/
! static int ConvertEscapes(const char *inbuf, int inlen, char *outbuf)
{
int outlen = 0;
--- 66,71 ----
* Convert escape sequences within a buffer into real characters.
*/
! static int ConvertEscapes(const char *inbuf, int inlen,
! char *outbuf, int latin1)
{
int outlen = 0;
***************
*** 236,239 ****
--- 237,249 ----
}
}
+ else if(latin1 && (*inbuf & 0x80) != 0)
+ {
+ /* Convert a Latin-1 character into UTF-8 */
+ int tempch = ((*inbuf++) & 0xFF);
+ *outbuf++ = (char)(0xE0 | ((tempch >> 6) & 0x3F));
+ *outbuf++ = (char)(0xC0 | (tempch & 0x3F));
+ outlen += 2;
+ --inlen;
+ }
else
{
***************
*** 246,250 ****
}
! int ILResLoadText(const char *filename, FILE *stream)
{
char buffer[4096];
--- 256,260 ----
}
! int ILResLoadText(const char *filename, FILE *stream, int latin1)
{
char buffer[4096];
***************
*** 303,307 ****
/* Convert escape sequences in the value into real characters */
! valueLen = ConvertEscapes(value, valueLen, buffer2);
value = buffer2;
--- 313,317 ----
/* Convert escape sequences in the value into real characters */
! valueLen = ConvertEscapes(value, valueLen, buffer2, latin1);
value = buffer2;
***************
*** 317,321 ****
* Write a single hash entry to an output stream.
*/
! static void writeEntry(FILE *stream, ILResHashEntry *entry)
{
const char *str;
--- 327,331 ----
* Write a single hash entry to an output stream.
*/
! static void writeEntry(FILE *stream, ILResHashEntry *entry, int latin1)
{
const char *str;
***************
*** 363,366 ****
--- 373,382 ----
needEscape = 0;
}
+ else if(latin1 && ch < 0x0100)
+ {
+ /* Convert a UTF-8 character into
Latin-1 */
+ putc((int)ch, stream);
+ needEscape = 0;
+ }
else if(ch < (unsigned long)0x10000)
{
***************
*** 380,384 ****
}
! void ILResWriteText(FILE *stream)
{
int hash;
--- 396,400 ----
}
! void ILResWriteText(FILE *stream, int latin1)
{
int hash;
***************
*** 389,393 ****
while(entry != 0)
{
! writeEntry(stream, entry);
entry = entry->next;
}
--- 405,409 ----
while(entry != 0)
{
! writeEntry(stream, entry, latin1);
entry = entry->next;
}
***************
*** 395,399 ****
}
! void ILResWriteSortedText(FILE *stream)
{
ILResHashEntry **table;
--- 411,415 ----
}
! void ILResWriteSortedText(FILE *stream, int latin1)
{
ILResHashEntry **table;
***************
*** 406,410 ****
for(posn = 0; posn < ILResNumStrings; ++posn)
{
! writeEntry(stream, table[posn]);
}
--- 422,426 ----
for(posn = 0; posn < ILResNumStrings; ++posn)
{
! writeEntry(stream, table[posn], latin1);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] pnet/resgen resgen.1, 1.3, 1.4 resgen.c, 1.5, 1.6 resgen.h, 1.1, 1.2 resgen_po.c, 1.1, 1.2 resgen_text.c, 1.1, 1.2,
Rhys Weatherley <address@hidden> <=