Mercurial > hg > xemacs-beta
comparison src/print.c @ 434:9d177e8d4150 r21-2-25
Import from CVS: tag r21-2-25
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:30:53 +0200 |
parents | 3ecd8885ac67 |
children | 84b14dcb0985 |
comparison
equal
deleted
inserted
replaced
433:892ca416f0fb | 434:9d177e8d4150 |
---|---|
1104 switch (XTYPE (obj)) | 1104 switch (XTYPE (obj)) |
1105 { | 1105 { |
1106 case Lisp_Type_Int_Even: | 1106 case Lisp_Type_Int_Even: |
1107 case Lisp_Type_Int_Odd: | 1107 case Lisp_Type_Int_Odd: |
1108 { | 1108 { |
1109 char buf[24]; | 1109 /* ASCII Decimal representation uses 2.4 times as many bits as |
1110 machine binary. */ | |
1111 char buf[3 * sizeof (EMACS_INT) + 5]; | |
1110 long_to_string (buf, XINT (obj)); | 1112 long_to_string (buf, XINT (obj)); |
1111 write_c_string (buf, printcharfun); | 1113 write_c_string (buf, printcharfun); |
1112 break; | 1114 break; |
1113 } | 1115 } |
1114 | 1116 |
1117 /* God intended that this be #\..., you know. */ | 1119 /* God intended that this be #\..., you know. */ |
1118 char buf[16]; | 1120 char buf[16]; |
1119 Emchar ch = XCHAR (obj); | 1121 Emchar ch = XCHAR (obj); |
1120 char *p = buf; | 1122 char *p = buf; |
1121 *p++ = '?'; | 1123 *p++ = '?'; |
1122 if (ch == '\n') | 1124 if (ch < 32) |
1123 *p++ = '\\', *p++ = 'n'; | 1125 { |
1124 else if (ch == '\r') | 1126 *p++ = '\\'; |
1125 *p++ = '\\', *p++ = 'r'; | 1127 switch (ch) |
1126 else if (ch == '\t') | 1128 { |
1127 *p++ = '\\', *p++ = 't'; | 1129 case '\t': *p++ = 't'; break; |
1128 else if (ch < 32) | 1130 case '\n': *p++ = 'n'; break; |
1131 case '\r': *p++ = 'r'; break; | |
1132 default: | |
1133 *p++ = '^'; | |
1134 *p++ = ch + 64; | |
1135 if ((ch + 64) == '\\') | |
1136 *p++ = '\\'; | |
1137 break; | |
1138 } | |
1139 } | |
1140 else if (ch < 127) | |
1141 { | |
1142 /* syntactically special characters should be escaped. */ | |
1143 switch (ch) | |
1144 { | |
1145 case ' ': | |
1146 case '"': | |
1147 case '#': | |
1148 case '\'': | |
1149 case '(': | |
1150 case ')': | |
1151 case ',': | |
1152 case '.': | |
1153 case ';': | |
1154 case '?': | |
1155 case '[': | |
1156 case '\\': | |
1157 case ']': | |
1158 case '`': | |
1159 *p++ = '\\'; | |
1160 } | |
1161 *p++ = ch; | |
1162 } | |
1163 else if (ch == 127) | |
1164 { | |
1165 *p++ = '\\', *p++ = '^', *p++ = '?'; | |
1166 } | |
1167 else if (ch < 160) | |
1129 { | 1168 { |
1130 *p++ = '\\', *p++ = '^'; | 1169 *p++ = '\\', *p++ = '^'; |
1131 *p++ = ch + 64; | 1170 p += set_charptr_emchar ((Bufbyte *) p, ch + 64); |
1132 if ((ch + 64) == '\\') | |
1133 *p++ = '\\'; | |
1134 } | 1171 } |
1135 else if (ch == 127) | 1172 else |
1136 *p++ = '\\', *p++ = '^', *p++ = '?'; | |
1137 else if (ch >= 128 && ch < 160) | |
1138 { | 1173 { |
1139 *p++ = '\\', *p++ = '^'; | 1174 p += set_charptr_emchar ((Bufbyte *) p, ch); |
1140 p += set_charptr_emchar ((Bufbyte *)p, ch + 64); | |
1141 } | 1175 } |
1142 else if (ch < 127 | 1176 |
1143 && !isdigit (ch) | 1177 output_string (printcharfun, (Bufbyte *) buf, Qnil, 0, p - buf); |
1144 && !isalpha (ch) | 1178 |
1145 && ch != '^') /* must not backslash this or it will | |
1146 be interpreted as the start of a | |
1147 control char */ | |
1148 *p++ = '\\', *p++ = ch; | |
1149 else | |
1150 p += set_charptr_emchar ((Bufbyte *)p, ch); | |
1151 output_string (printcharfun, (Bufbyte *)buf, Qnil, 0, p - buf); | |
1152 break; | 1179 break; |
1153 } | 1180 } |
1154 | 1181 |
1155 case Lisp_Type_Record: | 1182 case Lisp_Type_Record: |
1156 { | 1183 { |