+ xx1 = *str;
+ if (_nc_strict_bsd) {
+
+ if (isoctal(UChar(xx1))) {
+ int pad = 0;
+ int xx2;
+ int fix = 0;
+
+ if (!isoctal(UChar(str[1])))
+ pad = 2;
+ else if (str[1] && !isoctal(UChar(str[2])))
+ pad = 1;
+
+ /*
+ * Test for "\0", "\00" or "\000" and transform those
+ * into "\200".
+ */
+ if (xx1 == '0'
+ && ((pad == 2) || (str[1] == '0'))
+ && ((pad >= 1) || (str[2] == '0'))) {
+ xx2 = '2';
+ } else {
+ xx2 = '0';
+ pad = 0; /* FIXME - optionally pad to 3 digits */
+ }
+ if (myfix < MAX_TC_FIXUPS) {
+ fix = 3 - pad;
+ fixups[myfix].ch = 0;
+ fixups[myfix].offset = (int) (bufptr
+ - my_string
+ - 1);
+ }
+ while (pad-- > 0) {
+ bufptr = save_char(bufptr, xx2);
+ if (myfix < MAX_TC_FIXUPS) {
+ fixups[myfix].ch <<= 3;
+ fixups[myfix].ch |= (xx2 - '0');
+ }
+ xx2 = '0';
+ }
+ if (myfix < MAX_TC_FIXUPS) {
+ int n;
+ for (n = 0; n < fix; ++n) {
+ fixups[myfix].ch <<= 3;
+ fixups[myfix].ch |= (str[n] - '0');
+ }
+ if (fixups[myfix].ch < 32) {
+ ++myfix;
+ }
+ }
+ } else if (strchr("E\\nrtbf", xx1) == 0) {
+ switch (xx1) {
+ case 'e':
+ xx1 = 'E';
+ break;
+ case 'l':
+ xx1 = 'n';
+ break;
+ case 's':
+ bufptr = save_char(bufptr, '0');
+ bufptr = save_char(bufptr, '4');
+ xx1 = '0';
+ break;
+ case ':':
+ /*
+ * Note: termcap documentation claims that ":"
+ * must be escaped as "\072", however the
+ * documentation is incorrect - read the code.
+ * The replacement does not work reliably,
+ * so the advice is not helpful.
+ */
+ bufptr = save_char(bufptr, '0');
+ bufptr = save_char(bufptr, '7');
+ xx1 = '2';
+ break;
+ default:
+ /* should not happen, but handle this anyway */
+ _nc_SPRINTF(octal, _nc_SLIMIT(sizeof(octal))
+ "%03o", UChar(xx1));
+ bufptr = save_char(bufptr, octal[0]);
+ bufptr = save_char(bufptr, octal[1]);
+ xx1 = octal[2];
+ break;
+ }
+ }
+ } else {
+ if (myfix < MAX_TC_FIXUPS && isoctal(UChar(xx1))) {
+ bool will_fix = TRUE;
+ int n;
+
+ fixups[myfix].ch = 0;
+ fixups[myfix].offset = (int) (bufptr - my_string - 1);
+ for (n = 0; n < 3; ++n) {
+ if (isoctal(str[n])) {
+ octal_fixup(myfix, str[n]);
+ } else {
+ will_fix = FALSE;
+ break;
+ }
+ }
+ if (will_fix && (fixups[myfix].ch < 32))
+ ++myfix;
+ }
+ }
+ bufptr = save_char(bufptr, xx1);