Mercurial > emacs
comparison src/process.c @ 18585:64184009811b
(send_process): Make buf and temp_buf `unsigned char *'.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 04 Jul 1997 02:01:31 +0000 |
parents | c9470cd6de93 |
children | 5deb269b970f |
comparison
equal
deleted
inserted
replaced
18584:aea386116817 | 18585:64184009811b |
---|---|
2939 being encoded. Should we store them in a buffer to prepend them to | 2939 being encoded. Should we store them in a buffer to prepend them to |
2940 the data send later? */ | 2940 the data send later? */ |
2941 | 2941 |
2942 send_process (proc, buf, len, object) | 2942 send_process (proc, buf, len, object) |
2943 volatile Lisp_Object proc; | 2943 volatile Lisp_Object proc; |
2944 char *buf; | 2944 unsigned char *buf; |
2945 int len; | 2945 int len; |
2946 Lisp_Object object; | 2946 Lisp_Object object; |
2947 { | 2947 { |
2948 /* Use volatile to protect variables from being clobbered by longjmp. */ | 2948 /* Use volatile to protect variables from being clobbered by longjmp. */ |
2949 int rv; | 2949 int rv; |
2968 coding = proc_encode_coding_system[XINT (XPROCESS (proc)->outfd)]; | 2968 coding = proc_encode_coding_system[XINT (XPROCESS (proc)->outfd)]; |
2969 if (CODING_REQUIRE_CONVERSION (coding)) | 2969 if (CODING_REQUIRE_CONVERSION (coding)) |
2970 { | 2970 { |
2971 int require = encoding_buffer_size (coding, len); | 2971 int require = encoding_buffer_size (coding, len); |
2972 int offset, dummy; | 2972 int offset, dummy; |
2973 char *temp_buf = NULL; | 2973 unsigned char *temp_buf = NULL; |
2974 | 2974 |
2975 /* Remember the offset of data because a string or a buffer may | 2975 /* Remember the offset of data because a string or a buffer may |
2976 be relocated. Setting OFFSET to -1 means we don't have to | 2976 be relocated. Setting OFFSET to -1 means we don't have to |
2977 care relocation. */ | 2977 care relocation. */ |
2978 offset = (BUFFERP (object) | 2978 offset = (BUFFERP (object) |
2979 ? BUF_PTR_CHAR_POS (XBUFFER (object), (unsigned char *) buf) | 2979 ? BUF_PTR_CHAR_POS (XBUFFER (object), buf) |
2980 : (STRINGP (object) | 2980 : (STRINGP (object) |
2981 ? offset = buf - (char *) XSTRING (object)->data | 2981 ? offset = buf - XSTRING (object)->data |
2982 : -1)); | 2982 : -1)); |
2983 | 2983 |
2984 if (coding->carryover_size > 0) | 2984 if (coding->carryover_size > 0) |
2985 { | 2985 { |
2986 temp_buf = (char *) xmalloc (len + coding->carryover_size); | 2986 temp_buf = (unsigned char *) xmalloc (len + coding->carryover_size); |
2987 | 2987 |
2988 if (offset >= 0) | 2988 if (offset >= 0) |
2989 { | 2989 { |
2990 if (BUFFERP (object)) | 2990 if (BUFFERP (object)) |
2991 buf = (char *) BUF_CHAR_ADDRESS (XBUFFER (object), offset); | 2991 buf = BUF_CHAR_ADDRESS (XBUFFER (object), offset); |
2992 else if (STRINGP (object)) | 2992 else if (STRINGP (object)) |
2993 buf = offset + (char *) XSTRING (object)->data; | 2993 buf = offset + XSTRING (object)->data; |
2994 /* Now we don't have to care relocation. */ | 2994 /* Now we don't have to care relocation. */ |
2995 offset = -1; | 2995 offset = -1; |
2996 } | 2996 } |
2997 bcopy (coding->carryover, temp_buf, coding->carryover_size); | 2997 bcopy (coding->carryover, temp_buf, coding->carryover_size); |
2998 bcopy (buf, temp_buf + coding->carryover_size, len); | 2998 bcopy (buf, temp_buf + coding->carryover_size, len); |
3004 XPROCESS (proc)->encoding_buf = make_uninit_string (require); | 3004 XPROCESS (proc)->encoding_buf = make_uninit_string (require); |
3005 | 3005 |
3006 if (offset >= 0) | 3006 if (offset >= 0) |
3007 { | 3007 { |
3008 if (BUFFERP (object)) | 3008 if (BUFFERP (object)) |
3009 buf = (char *) BUF_CHAR_ADDRESS (XBUFFER (object), offset); | 3009 buf = BUF_CHAR_ADDRESS (XBUFFER (object), offset); |
3010 else if (STRINGP (object)) | 3010 else if (STRINGP (object)) |
3011 buf = offset + (char *) XSTRING (object)->data; | 3011 buf = offset + XSTRING (object)->data; |
3012 } | 3012 } |
3013 } | 3013 } |
3014 object = XPROCESS (proc)->encoding_buf; | 3014 object = XPROCESS (proc)->encoding_buf; |
3015 len = encode_coding (coding, buf, XSTRING (object)->data, | 3015 len = encode_coding (coding, buf, XSTRING (object)->data, |
3016 len, XSTRING (object)->size, &dummy); | 3016 len, XSTRING (object)->size, &dummy); |
3057 It may not be correct for the first iteration | 3057 It may not be correct for the first iteration |
3058 if a partial line was sent in a separate send_process call. | 3058 if a partial line was sent in a separate send_process call. |
3059 If that proves worth handling, we need to save linepos | 3059 If that proves worth handling, we need to save linepos |
3060 in the process object. */ | 3060 in the process object. */ |
3061 int linepos = 0; | 3061 int linepos = 0; |
3062 char *ptr = buf; | 3062 unsigned char *ptr = buf; |
3063 char *end = buf + len; | 3063 unsigned char *end = buf + len; |
3064 | 3064 |
3065 /* Scan through this text for a line that is too long. */ | 3065 /* Scan through this text for a line that is too long. */ |
3066 while (ptr != end && linepos < pty_max_bytes) | 3066 while (ptr != end && linepos < pty_max_bytes) |
3067 { | 3067 { |
3068 if (*ptr == '\n') | 3068 if (*ptr == '\n') |
3101 int offset; | 3101 int offset; |
3102 | 3102 |
3103 /* Running filters might relocate buffers or strings. | 3103 /* Running filters might relocate buffers or strings. |
3104 Arrange to relocate BUF. */ | 3104 Arrange to relocate BUF. */ |
3105 if (BUFFERP (object)) | 3105 if (BUFFERP (object)) |
3106 offset = BUF_PTR_CHAR_POS (XBUFFER (object), | 3106 offset = BUF_PTR_CHAR_POS (XBUFFER (object), buf); |
3107 (unsigned char *) buf); | |
3108 else if (STRINGP (object)) | 3107 else if (STRINGP (object)) |
3109 offset = buf - (char *) XSTRING (object)->data; | 3108 offset = buf - XSTRING (object)->data; |
3110 | 3109 |
3111 XSETFASTINT (zero, 0); | 3110 XSETFASTINT (zero, 0); |
3112 #ifdef EMACS_HAS_USECS | 3111 #ifdef EMACS_HAS_USECS |
3113 wait_reading_process_input (0, 20000, zero, 0); | 3112 wait_reading_process_input (0, 20000, zero, 0); |
3114 #else | 3113 #else |
3115 wait_reading_process_input (1, 0, zero, 0); | 3114 wait_reading_process_input (1, 0, zero, 0); |
3116 #endif | 3115 #endif |
3117 | 3116 |
3118 if (BUFFERP (object)) | 3117 if (BUFFERP (object)) |
3119 buf = (char *) BUF_CHAR_ADDRESS (XBUFFER (object), offset); | 3118 buf = BUF_CHAR_ADDRESS (XBUFFER (object), offset); |
3120 else if (STRINGP (object)) | 3119 else if (STRINGP (object)) |
3121 buf = offset + (char *) XSTRING (object)->data; | 3120 buf = offset + XSTRING (object)->data; |
3122 | 3121 |
3123 rv = 0; | 3122 rv = 0; |
3124 } | 3123 } |
3125 else | 3124 else |
3126 /* This is a real error. */ | 3125 /* This is a real error. */ |