aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c73
1 files changed, 14 insertions, 59 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 0aa7fc3f805..8e4e1bec2ec 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -865,20 +865,23 @@ make_uninit_string (length)
865} 865}
866 866
867/* Return a newly created vector or string with specified arguments as 867/* Return a newly created vector or string with specified arguments as
868 elements. If all the arguments are characters, make a string; 868 elements. If all the arguments are characters that can fit
869 otherwise, make a vector. Any number of arguments, even zero 869 in a string of events, make a string; otherwise, make a vector.
870 arguments, are allowed. */ 870
871 Any number of arguments, even zero arguments, are allowed. */
871 872
872Lisp_Object 873Lisp_Object
873make_array (nargs, args) 874make_event_array (nargs, args)
874 register int nargs; 875 register int nargs;
875 Lisp_Object *args; 876 Lisp_Object *args;
876{ 877{
877 int i; 878 int i;
878 879
879 for (i = 0; i < nargs; i++) 880 for (i = 0; i < nargs; i++)
881 /* The things that fit in a string
882 are characters that are in 0...127 after discarding the meta bit. */
880 if (XTYPE (args[i]) != Lisp_Int 883 if (XTYPE (args[i]) != Lisp_Int
881 || (unsigned) XINT (args[i]) >= 0400) 884 || (XUINT (args[i]) & ~CHAR_META) >= 0200)
882 return Fvector (nargs, args); 885 return Fvector (nargs, args);
883 886
884 /* Since the loop exited, we know that all the things in it are 887 /* Since the loop exited, we know that all the things in it are
@@ -887,63 +890,17 @@ make_array (nargs, args)
887 Lisp_Object result = Fmake_string (nargs, make_number (0)); 890 Lisp_Object result = Fmake_string (nargs, make_number (0));
888 891
889 for (i = 0; i < nargs; i++) 892 for (i = 0; i < nargs; i++)
890 XSTRING (result)->data[i] = XINT (args[i]); 893 {
894 XSTRING (result)->data[i] = XINT (args[i]);
895 /* Move the meta bit to the right place for a string char. */
896 if (XINT (args[i]) & CHAR_META)
897 XSTRING (result)->data[i] |= 0x80;
898 }
891 899
892 return result; 900 return result;
893 } 901 }
894} 902}
895 903
896/* Allocation of ropes. */
897
898/* Note: the user cannot manipulate ropes portably by referring
899 to the chars of the string, because combining two chars to make a GLYPH
900 depends on endianness. */
901
902DEFUN ("make-rope", Fmake_rope, Smake_rope, 0, MANY, 0,
903 "Return a newly created rope containing the arguments of this function.\n\
904A rope is a string, except that its contents will be treated as an\n\
905array of glyphs, where a glyph is an integer type that may be larger\n\
906than a character. Emacs is normally configured to use 8-bit glyphs,\n\
907so ropes are normally no different from strings. But Emacs may be\n\
908configured to use 16-bit glyphs, to allow the use of larger fonts.\n\
909\n\
910Each argument (which must be an integer) specifies one glyph, whatever\n\
911size glyphs may be.\n\
912\n\
913See variable `buffer-display-table' for the uses of ropes.")
914 (nargs, args)
915 register int nargs;
916 Lisp_Object *args;
917{
918 register int i;
919 register Lisp_Object val;
920 register GLYPH *p;
921
922 val = make_uninit_string (nargs * sizeof (GLYPH));
923
924 p = (GLYPH *) XSTRING (val)->data;
925 for (i = 0; i < nargs; i++)
926 {
927 CHECK_NUMBER (args[i], i);
928 p[i] = XFASTINT (args[i]);
929 }
930 return val;
931}
932
933DEFUN ("rope-elt", Frope_elt, Srope_elt, 2, 2, 0,
934 "Return an element of rope R at index N.\n\
935A rope is a string in which each pair of bytes is considered an element.\n\
936See variable `buffer-display-table' for the uses of ropes.")
937 (r, n)
938 Lisp_Object r, n;
939{
940 CHECK_STRING (r, 0);
941 CHECK_NUMBER (n, 1);
942 if ((XSTRING (r)->size / sizeof (GLYPH)) <= XINT (n) || XINT (n) < 0)
943 args_out_of_range (r, n);
944 return ((GLYPH *) XSTRING (r)->data)[XFASTINT (n)];
945}
946
947/* Pure storage management. */ 904/* Pure storage management. */
948 905
949/* Must get an error if pure storage is full, 906/* Must get an error if pure storage is full,
@@ -2146,8 +2103,6 @@ which includes both saved text and other data.");
2146 defsubr (&Smake_list); 2103 defsubr (&Smake_list);
2147 defsubr (&Smake_vector); 2104 defsubr (&Smake_vector);
2148 defsubr (&Smake_string); 2105 defsubr (&Smake_string);
2149 defsubr (&Smake_rope);
2150 defsubr (&Srope_elt);
2151 defsubr (&Smake_symbol); 2106 defsubr (&Smake_symbol);
2152 defsubr (&Smake_marker); 2107 defsubr (&Smake_marker);
2153 defsubr (&Spurecopy); 2108 defsubr (&Spurecopy);