11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
-
+
|
* man2tcl ?fileName?
*
* Copyright (c) 1995 Sun Microsystems, Inc.
*
* 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.11 2007/01/19 08:17:35 mistachkin Exp $
* RCS: @(#) $Id: man2tcl.c,v 1.11.2.1 2007/10/27 04:11:51 dgp Exp $
*/
static char sccsid[] = "@(#) man2tcl.c 1.3 95/08/12 17:34:08";
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
|
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
|
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
|
+
+
+
+
+
+
+
+
+
+
|
} else if (*p == 'e') {
PRINT(("text \\\\\n"));
p++;
} else if (*p == '.') {
PRINT(("text .\n"));
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",
lineNumber);
status = 1;
} else {
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", ch));
while(*p&&*p!='\'') p++;
} else if (*p != 0) {
PRINT(("char {\\%c}\n", *p));
p++;
}
}
}
PRINT(("newline\n"));
|
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
|
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
|
{
if (count == 0) {
PRINT(("{}"));
return;
}
for ( ; count > 0; string++, count--) {
switch (*string) {
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 '$': case '[': case '{': case ' ': case ';':
case '"': case '\t':
PRINTC('\\');
default:
PRINTC(*string);
}
}
}
|