comparison src/fns.c @ 5126:2a462149bd6a ben-lisp-object

merge
author Ben Wing <ben@xemacs.org>
date Wed, 24 Feb 2010 19:04:27 -0600
parents b5df3737028a c3d372419e09
children a9c41067dd88
comparison
equal deleted inserted replaced
5125:b5df3737028a 5126:2a462149bd6a
4637 /* We needn't multiply allength with MAX_ICHAR_LEN because all the 4637 /* We needn't multiply allength with MAX_ICHAR_LEN because all the
4638 base64 characters will be single-byte. */ 4638 base64 characters will be single-byte. */
4639 encoded = (Ibyte *) MALLOC_OR_ALLOCA (allength); 4639 encoded = (Ibyte *) MALLOC_OR_ALLOCA (allength);
4640 encoded_length = base64_encode_1 (XLSTREAM (input), encoded, 4640 encoded_length = base64_encode_1 (XLSTREAM (input), encoded,
4641 NILP (no_line_break)); 4641 NILP (no_line_break));
4642 if (encoded_length > allength) 4642 assert (encoded_length <= allength);
4643 ABORT ();
4644 Lstream_delete (XLSTREAM (input)); 4643 Lstream_delete (XLSTREAM (input));
4645 4644
4646 /* Now we have encoded the region, so we insert the new contents 4645 /* Now we have encoded the region, so we insert the new contents
4647 and delete the old. (Insert first in order to preserve markers.) */ 4646 and delete the old. (Insert first in order to preserve markers.) */
4648 buffer_insert_raw_string_1 (buf, begv, encoded, encoded_length, 0); 4647 buffer_insert_raw_string_1 (buf, begv, encoded, encoded_length, 0);
4679 4678
4680 input = make_lisp_string_input_stream (string, 0, -1); 4679 input = make_lisp_string_input_stream (string, 0, -1);
4681 encoded = (Ibyte *) MALLOC_OR_ALLOCA (allength); 4680 encoded = (Ibyte *) MALLOC_OR_ALLOCA (allength);
4682 encoded_length = base64_encode_1 (XLSTREAM (input), encoded, 4681 encoded_length = base64_encode_1 (XLSTREAM (input), encoded,
4683 NILP (no_line_break)); 4682 NILP (no_line_break));
4684 if (encoded_length > allength) 4683 assert (encoded_length <= allength);
4685 ABORT ();
4686 Lstream_delete (XLSTREAM (input)); 4684 Lstream_delete (XLSTREAM (input));
4687 result = make_string (encoded, encoded_length); 4685 result = make_string (encoded, encoded_length);
4688 unbind_to (speccount); 4686 unbind_to (speccount);
4689 return result; 4687 return result;
4690 } 4688 }
4712 4710
4713 input = make_lisp_buffer_input_stream (buf, begv, zv, 0); 4711 input = make_lisp_buffer_input_stream (buf, begv, zv, 0);
4714 /* We need to allocate enough room for decoding the text. */ 4712 /* We need to allocate enough room for decoding the text. */
4715 decoded = (Ibyte *) MALLOC_OR_ALLOCA (length * MAX_ICHAR_LEN); 4713 decoded = (Ibyte *) MALLOC_OR_ALLOCA (length * MAX_ICHAR_LEN);
4716 decoded_length = base64_decode_1 (XLSTREAM (input), decoded, &cc_decoded_length); 4714 decoded_length = base64_decode_1 (XLSTREAM (input), decoded, &cc_decoded_length);
4717 if (decoded_length > length * MAX_ICHAR_LEN) 4715 assert (decoded_length <= length * MAX_ICHAR_LEN);
4718 ABORT ();
4719 Lstream_delete (XLSTREAM (input)); 4716 Lstream_delete (XLSTREAM (input));
4720 4717
4721 /* Now we have decoded the region, so we insert the new contents 4718 /* Now we have decoded the region, so we insert the new contents
4722 and delete the old. (Insert first in order to preserve markers.) */ 4719 and delete the old. (Insert first in order to preserve markers.) */
4723 BUF_SET_PT (buf, begv); 4720 BUF_SET_PT (buf, begv);
4753 decoded = (Ibyte *) MALLOC_OR_ALLOCA (length * MAX_ICHAR_LEN); 4750 decoded = (Ibyte *) MALLOC_OR_ALLOCA (length * MAX_ICHAR_LEN);
4754 4751
4755 input = make_lisp_string_input_stream (string, 0, -1); 4752 input = make_lisp_string_input_stream (string, 0, -1);
4756 decoded_length = base64_decode_1 (XLSTREAM (input), decoded, 4753 decoded_length = base64_decode_1 (XLSTREAM (input), decoded,
4757 &cc_decoded_length); 4754 &cc_decoded_length);
4758 if (decoded_length > length * MAX_ICHAR_LEN) 4755 assert (decoded_length <= length * MAX_ICHAR_LEN);
4759 ABORT ();
4760 Lstream_delete (XLSTREAM (input)); 4756 Lstream_delete (XLSTREAM (input));
4761 4757
4762 result = make_string (decoded, decoded_length); 4758 result = make_string (decoded, decoded_length);
4763 unbind_to (speccount); 4759 unbind_to (speccount);
4764 return result; 4760 return result;