comparison src/lread.c @ 2018:7c970ef8949d

(read_escape): Handle M-, C- and S- for new convention. (read1): Move the meta bit to the right place for a string.
author Richard M. Stallman <rms@gnu.org>
date Fri, 05 Mar 1993 23:57:00 +0000
parents bcc34323a475
children 258362f03d90
comparison
equal deleted inserted replaced
2017:ffa43acb7de7 2018:7c970ef8949d
764 { 764 {
765 case 'a': 765 case 'a':
766 return '\007'; 766 return '\007';
767 case 'b': 767 case 'b':
768 return '\b'; 768 return '\b';
769 case 'd':
770 return 0177;
769 case 'e': 771 case 'e':
770 return 033; 772 return 033;
771 case 'f': 773 case 'f':
772 return '\f'; 774 return '\f';
773 case 'n': 775 case 'n':
786 if (c != '-') 788 if (c != '-')
787 error ("Invalid escape character syntax"); 789 error ("Invalid escape character syntax");
788 c = READCHAR; 790 c = READCHAR;
789 if (c == '\\') 791 if (c == '\\')
790 c = read_escape (readcharfun); 792 c = read_escape (readcharfun);
791 return c | 0200; 793 return c | CHAR_META;
794
795 case 'S':
796 c = READCHAR;
797 if (c != '-')
798 error ("Invalid escape character syntax");
799 c = READCHAR;
800 if (c == '\\')
801 c = read_escape (readcharfun);
802 return c | CHAR_SHIFT;
792 803
793 case 'C': 804 case 'C':
794 c = READCHAR; 805 c = READCHAR;
795 if (c != '-') 806 if (c != '-')
796 error ("Invalid escape character syntax"); 807 error ("Invalid escape character syntax");
797 case '^': 808 case '^':
798 c = READCHAR; 809 c = READCHAR;
799 if (c == '\\') 810 if (c == '\\')
800 c = read_escape (readcharfun); 811 c = read_escape (readcharfun);
801 if (c == '?') 812 if ((c & 0177) == '?')
802 return 0177; 813 return 0177 | c;
814 /* ASCII control chars are made from letters (both cases),
815 as well as the non-letters within 0100...0137. */
816 else if ((c & 0137) >= 0101 && (c & 0137) <= 0132)
817 return (c & (037 | ~0177));
818 else if ((c & 0177) >= 0100 && (c & 0177) <= 0137)
819 return (c & (037 | ~0177));
803 else 820 else
804 return (c & (0200 | 037)); 821 return c | CHAR_CTL;
805 822
806 case '0': 823 case '0':
807 case '1': 824 case '1':
808 case '2': 825 case '2':
809 case '3': 826 case '3':
987 end = read_buffer + read_buffer_size; 1004 end = read_buffer + read_buffer_size;
988 } 1005 }
989 if (c == '\\') 1006 if (c == '\\')
990 c = read_escape (readcharfun); 1007 c = read_escape (readcharfun);
991 /* c is -1 if \ newline has just been seen */ 1008 /* c is -1 if \ newline has just been seen */
992 if (c < 0) 1009 if (c == -1)
993 { 1010 {
994 if (p == read_buffer) 1011 if (p == read_buffer)
995 cancel = 1; 1012 cancel = 1;
996 } 1013 }
1014 else if (c & CHAR_META)
1015 /* Move the meta bit to the right place for a string. */
1016 *p++ = (c & ~CHAR_META) | 0x80;
997 else 1017 else
998 *p++ = c; 1018 *p++ = c;
999 } 1019 }
1000 if (c < 0) return Fsignal (Qend_of_file, Qnil); 1020 if (c < 0) return Fsignal (Qend_of_file, Qnil);
1001 1021