mkhaw@teknowledge-vaxc.ARPA (Mike Khaw) (12/21/88)
Enclosed are context diffs to allow less to display 8-bit data using
a "M-" prefix (as "cat" does).
Feed to "patch" ...
<--- cut here --->
*** makefile- Tue Dec 20 14:22:16 1988
--- makefile Tue Dec 20 12:10:02 1988
***************
*** 45,51
# It is normally "-O" but may be, for example, "-g".
OPTIM = -O
! CFLAGS = $(OPTIM)
--- 45,51 -----
# It is normally "-O" but may be, for example, "-g".
OPTIM = -O
! CFLAGS = $(OPTIM) -DDO_META
*** ch.c- Tue Dec 20 14:15:16 1988
--- ch.c Tue Dec 20 14:14:52 1988
***************
*** 178,183
p = &bp->data[bp->datasize];
while (--n >= 0)
{
*--p &= 0177;
if (*p == EOI)
*p = '@';
--- 178,184 -----
p = &bp->data[bp->datasize];
while (--n >= 0)
{
+ #ifndef DO_META
*--p &= 0177;
#endif DO_META
if (*p == EOI)
***************
*** 179,184
while (--n >= 0)
{
*--p &= 0177;
if (*p == EOI)
*p = '@';
}
--- 180,186 -----
{
#ifndef DO_META
*--p &= 0177;
+ #endif DO_META
if (*p == EOI)
*p = '@';
}
*** line.c- Fri Sep 16 16:24:29 1988
--- line.c Tue Dec 20 12:23:55 1988
***************
*** 349,354
* Treat backspace as a control char: output "^H".
*/
NEW_COLUMN(column+2);
*curr++ = ('H' | 0200);
} else
{
--- 349,355 -----
* Treat backspace as a control char: output "^H".
*/
NEW_COLUMN(column+2);
+ #ifndef DO_META
*curr++ = ('H' | 0200);
#else
*curr++ = '\b';
***************
*** 350,355
*/
NEW_COLUMN(column+2);
*curr++ = ('H' | 0200);
} else
{
/*
--- 351,359 -----
NEW_COLUMN(column+2);
#ifndef DO_META
*curr++ = ('H' | 0200);
+ #else
+ *curr++ = '\b';
+ #endif DO_META
} else
{
/*
***************
*** 361,366
return (0);
}
if (control_char(c))
{
/*
--- 365,382 -----
return (0);
}
+ #ifdef DO_META
+ if (meta_char(c))
+ {
+ if (control_char(unmetafy_char(c)))
+ NEW_COLUMN(column+4);
+ else
+ NEW_COLUMN(column+3);
+ *curr++ = c;
+ return (0);
+ }
+ #endif DO_META
+
if (control_char(c))
{
/*
***************
*** 374,379
* 8 bit (e.g. international) character set. }}
*/
NEW_COLUMN(column+2);
*curr++ = (carat_char(c) | 0200);
return (0);
}
--- 390,396 -----
* 8 bit (e.g. international) character set. }}
*/
NEW_COLUMN(column+2);
+ #ifndef DO_META
*curr++ = (carat_char(c) | 0200);
#else
*curr++ = c;
***************
*** 375,380
*/
NEW_COLUMN(column+2);
*curr++ = (carat_char(c) | 0200);
return (0);
}
--- 392,400 -----
NEW_COLUMN(column+2);
#ifndef DO_META
*curr++ = (carat_char(c) | 0200);
+ #else
+ *curr++ = c;
+ #endif DO_META
return (0);
}
*** output.c- Wed Sep 21 12:50:12 1988
--- output.c Tue Dec 20 12:46:34 1988
***************
*** 6,11
public int errmsgs; /* Count of messages displayed by error() */
extern int sigs;
extern int sc_width, sc_height;
extern int ul_width, ue_width;
--- 6,14 -----
public int errmsgs; /* Count of messages displayed by error() */
+ #ifdef DO_META
+ extern int bs_mode;
+ #endif DO_META
extern int sigs;
extern int sc_width, sc_height;
extern int ul_width, ue_width;
***************
*** 70,75
} while ((column % tabstop) != 0);
break;
case '\b':
putbs();
column--;
break;
--- 73,79 -----
} while ((column % tabstop) != 0);
break;
case '\b':
+ #ifndef DO_META
putbs();
column--;
#else
***************
*** 72,77
case '\b':
putbs();
column--;
break;
default:
if (c & 0200)
--- 76,94 -----
#ifndef DO_META
putbs();
column--;
+ #else
+ if (bs_mode == BS_CONTROL)
+ {
+ putchr('^');
+ putchr('H');
+ column += 2;
+ }
+ else
+ {
+ putbs();
+ --column;
+ }
+ #endif DO_META
break;
default:
#ifndef DO_META
***************
*** 74,79
column--;
break;
default:
if (c & 0200)
{
/*
--- 91,97 -----
#endif DO_META
break;
default:
+ #ifndef DO_META
if (c & 0200)
{
/*
***************
*** 89,94
putchr(c);
column++;
}
}
}
if (column < sc_width || !auto_wrap || ignaw)
--- 107,130 -----
putchr(c);
column++;
}
+ #else
+ if (meta_char(c))
+ {
+ putchr('M');
+ putchr('-');
+ column += 2;
+ c = unmetafy_char(c);
+ }
+ if (control_char(c))
+ {
+ putchr('^');
+ ++column;
+ c = carat_char(c);
+ }
+ putchr(c);
+ ++column;
+ #endif DO_META
+ break;
}
}
if (column < sc_width || !auto_wrap || ignaw)
***************
*** 118,123
return ((c == '\177') ? '?' : (c | 0100));
}
static char obuf[1024];
static char *ob = obuf;
--- 154,182 -----
return ((c == '\177') ? '?' : (c | 0100));
}
+ #ifdef DO_META
+ /*
+ * Is a given character a "meta" character?
+ * {{ ASCII DEPENDENT }}
+ */
+ public int
+ meta_char(c)
+ int c;
+ {
+ return (c > 0x7F);
+ }
+
+ /*
+ * strip the high bit from a metafied character
+ * {{ ASCII DEPENDENT }}
+ */
+ public int
+ unmetafy_char(c)
+ int c;
+ {
+ return (c & 0x7F);
+ }
+ #endif DO_META
static char obuf[1024];
static char *ob = obuf;
<--- cut here --->
Mike Khaw
--
internet: mkhaw@teknowledge.arpa
uucp: {uunet|sun|ucbvax|decwrl|ames|hplabs}!mkhaw%teknowledge.arpa
hardcopy: Teknowledge Inc, 1850 Embarcadero Rd, POB 10119, Palo Alto, CA 94303