summaryrefslogtreecommitdiffstats
path: root/tools/man2tcl.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/man2tcl.c')
-rw-r--r--tools/man2tcl.c44
1 files changed, 37 insertions, 7 deletions
diff --git a/tools/man2tcl.c b/tools/man2tcl.c
index aa8dfbc..8e59bea 100644
--- a/tools/man2tcl.c
+++ b/tools/man2tcl.c
@@ -14,13 +14,12 @@
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
- *
- * RCS: @(#) $Id: man2tcl.c,v 1.10 2005/11/04 00:06:49 dkf Exp $
*/
static char sccsid[] = "@(#) man2tcl.c 1.3 95/08/12 17:34:08";
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
@@ -95,7 +94,7 @@ main(
char **argv) /* Values of command-line arguments. */
{
FILE *f;
-#define MAX_LINE_SIZE 1000
+#define MAX_LINE_SIZE 4000
char line[MAX_LINE_SIZE];
char *p;
@@ -135,7 +134,7 @@ main(
}
lineNumber++;
- if ((line[0] == '\'') && (line[1] == '\\') && (line[2] == '\"')) {
+ if (((line[0] == '.') || (line[0] == '\'')) && (line[1] == '\\') && (line[2] == '\"')) {
/*
* This line is a comment. Ignore it.
*/
@@ -196,6 +195,7 @@ DoMacro(
* invocation. */
{
char *p, *end;
+ int quote;
/*
* If there is no macro name, then just skip the whole line.
@@ -233,8 +233,11 @@ DoMacro(
}
QuoteText(p+1, (end-(p+1)));
} else {
- for (end = p+1; (*end != 0) && !isspace(*end); end++) {
- /* Empty loop body. */
+ quote = 0;
+ for (end = p+1; (*end != 0) && (quote || !isspace(*end)); end++) {
+ if (*end == '\'') {
+ quote = !quote;
+ }
}
QuoteText(p, end-p);
}
@@ -328,6 +331,9 @@ DoText(
p++;
} else if (*p == '&') {
p++;
+ } else if (*p == '0') {
+ PRINT(("text { }\n"));
+ p++;
} else if (*p == '(') {
if ((p[1] == 0) || (p[2] == 0)) {
fprintf(stderr, "Bad \\( sequence on line %d.\n",
@@ -337,6 +343,14 @@ DoText(
PRINT(("char {\\(%c%c}\n", p[1], p[2]));
p += 3;
}
+ } else if (*p == 'N' && *(p+1) == '\'') {
+ int ch;
+
+ p += 2;
+ sscanf(p,"%d",&ch);
+ PRINT(("text \\u%04x\n", ch));
+ while(*p&&*p!='\'') p++;
+ p++;
} else if (*p != 0) {
PRINT(("char {\\%c}\n", *p));
p++;
@@ -376,7 +390,23 @@ QuoteText(
}
for ( ; count > 0; string++, count--) {
switch (*string) {
- case '$': case '[': case '{': case ' ': case ';': case '\\':
+ case '\\':
+ if (*(string+1) == 'N' && *(string+2) == '\'') {
+ int ch;
+
+ string += 3;
+ count -= 3;
+ sscanf(string,"%d",&ch);
+ PRINT(("\\u%04x", ch));
+ while(count>0&&*string!='\'') {string++;count--;}
+ continue;
+ } else if (*(string+1) == '0') {
+ PRINT(("\\ "));
+ string++;
+ count--;
+ continue;
+ }
+ case '$': case '[': case '{': case ' ': case ';':
case '"': case '\t':
PRINTC('\\');
default: