diff --git a/client/X11/generate_argument_docbook.c b/client/X11/generate_argument_docbook.c
index 2f143d4c8..86fabd964 100644
--- a/client/X11/generate_argument_docbook.c
+++ b/client/X11/generate_argument_docbook.c
@@ -9,10 +9,10 @@
* the argument struct. */
#include "../common/cmdline.c"
-LPSTR tr_esc_str(LPCSTR arg)
+LPSTR tr_esc_str(LPCSTR arg, bool format)
{
LPSTR tmp = NULL;
- size_t cs = 0, x, ds;
+ size_t cs = 0, x, ds, len;
size_t s;
if(NULL == arg)
return NULL;
@@ -36,30 +36,34 @@ LPSTR tr_esc_str(LPCSTR arg)
switch(arg[x])
{
case '<':
- ds += 3;
+ len = format ? 13 : 4;
+ ds += len - 1;
tmp = (LPSTR)realloc(tmp, ds * sizeof(CHAR));
if(NULL == tmp)
{
WLog_ERR(TAG, "Could not reallocate string buffer.");
exit(-3);
}
- tmp[cs++] = '&';
- tmp[cs++] = 'l';
- tmp[cs++] = 't';
- tmp[cs++] = ';';
+ if (format)
+ strncpy (&tmp[cs], "", len);
+ else
+ strncpy (&tmp[cs], "<", len);
+ cs += len;
break;
case '>':
- ds += 3;
+ len = format ? 14 : 4;
+ ds += len - 1;
tmp = (LPSTR)realloc(tmp, ds * sizeof(CHAR));
if(NULL == tmp)
{
WLog_ERR(TAG, "Could not reallocate string buffer.");
exit(-4);
}
- tmp[cs++] = '&';
- tmp[cs++] = 'g';
- tmp[cs++] = 't';
- tmp[cs++] = ';';
+ if (format)
+ strncpy (&tmp[cs], "", len);
+ else
+ strncpy (&tmp[cs], "<", len);
+ cs += len;
break;
case '\'':
ds += 5;
@@ -142,27 +146,47 @@ int main(int argc, char *argv[])
for(x=0; xName);
- char *format = tr_esc_str(arg->Format);
- char *text = tr_esc_str((LPSTR) arg->Text);
+ char *name = tr_esc_str((LPSTR) arg->Name, FALSE);
+ char *format = tr_esc_str(arg->Format, TRUE);
+ char *text = tr_esc_str((LPSTR) arg->Text, FALSE);
fprintf(fp, "\t\t\t\n");
- fprintf(fp, "\t\t\t\t", name);
- if ((arg->Flags == COMMAND_LINE_VALUE_REQUIRED) && format)
- fprintf(fp, " %s\n", format);
+ fprintf(fp, "\t\t\t\t", name);
+
+ if (format)
+ {
+ if (arg->Flags == COMMAND_LINE_VALUE_OPTIONAL)
+ fprintf(fp, "[");
+ fprintf(fp, ":%s", format);
+ if (arg->Flags == COMMAND_LINE_VALUE_OPTIONAL)
+ fprintf(fp, "]");
+ }
+
fprintf(fp, "\n");
- if (format || text)
+ if (text)
{
fprintf(fp, "\t\t\t\t\n");
- fprintf(fp, "\t\t\t\t\t%s\n", format ? format : "");
+ fprintf(fp, "\t\t\t\t\t");
+
if (text)
- {
- if (format)
- fprintf(fp, " - ");
fprintf(fp, "%s", text);
+
+ if (arg->Flags == COMMAND_LINE_VALUE_BOOL)
+ fprintf(fp, " (default:%s)", arg->Default ? "on" : "off");
+ else if (arg->Default)
+ {
+ char *value = tr_esc_str((LPSTR) arg->Default, FALSE);
+ fprintf(fp, " (default:%s)", value);
+ free (value);
}
+
fprintf(fp, "\n");
fprintf(fp, "\t\t\t\t\n");
}