comparison src/lread.c @ 34362:020c1a0abaf6

(read1): Change the way buffers are reallocated to be portable and less obfuscated.
author Gerd Moellmann <gerd@gnu.org>
date Fri, 08 Dec 2000 09:59:34 +0000
parents 32e84d2e9891
children b2ec0cbfd60a
comparison
equal deleted inserted replaced
34361:385981407528 34362:020c1a0abaf6
1 /* Lisp parsing and input streams. 1 /* Lisp parsing and input streams.
2 Copyright (C) 1985, 86, 87, 88, 89, 93, 94, 95, 97, 98, 1999 2 Copyright (C) 1985, 86, 87, 88, 89, 93, 94, 95, 97, 98, 99, 2000
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 4
5 This file is part of GNU Emacs. 5 This file is part of GNU Emacs.
6 6
7 GNU Emacs is free software; you can redistribute it and/or modify 7 GNU Emacs is free software; you can redistribute it and/or modify
2118 while ((c = READCHAR) >= 0 2118 while ((c = READCHAR) >= 0
2119 && c != '\"') 2119 && c != '\"')
2120 { 2120 {
2121 if (end - p < MAX_MULTIBYTE_LENGTH) 2121 if (end - p < MAX_MULTIBYTE_LENGTH)
2122 { 2122 {
2123 char *new = (char *) xrealloc (read_buffer, read_buffer_size *= 2); 2123 int offset = p - read_buffer;
2124 p += new - read_buffer; 2124 read_buffer = (char *) xrealloc (read_buffer,
2125 read_buffer += new - read_buffer; 2125 read_buffer_size *= 2);
2126 p = read_buffer + offset;
2126 end = read_buffer + read_buffer_size; 2127 end = read_buffer + read_buffer_size;
2127 } 2128 }
2128 2129
2129 if (c == '\\') 2130 if (c == '\\')
2130 { 2131 {
2258 || c == '(' || c == ')' 2259 || c == '(' || c == ')'
2259 || c == '[' || c == ']' || c == '#')) 2260 || c == '[' || c == ']' || c == '#'))
2260 { 2261 {
2261 if (end - p < MAX_MULTIBYTE_LENGTH) 2262 if (end - p < MAX_MULTIBYTE_LENGTH)
2262 { 2263 {
2263 char *new = (char *) xrealloc (read_buffer, 2264 int offset = p - read_buffer;
2264 read_buffer_size *= 2); 2265 read_buffer = (char *) xrealloc (read_buffer,
2265 p += new - read_buffer; 2266 read_buffer_size *= 2);
2266 read_buffer += new - read_buffer; 2267 p = read_buffer + offset;
2267 end = read_buffer + read_buffer_size; 2268 end = read_buffer + read_buffer_size;
2268 } 2269 }
2269 2270
2270 if (c == '\\') 2271 if (c == '\\')
2271 { 2272 {
2281 c = READCHAR; 2282 c = READCHAR;
2282 } 2283 }
2283 2284
2284 if (p == end) 2285 if (p == end)
2285 { 2286 {
2286 char *new = (char *) xrealloc (read_buffer, read_buffer_size *= 2); 2287 int offset = p - read_buffer;
2287 p += new - read_buffer; 2288 read_buffer = (char *) xrealloc (read_buffer,
2288 read_buffer += new - read_buffer; 2289 read_buffer_size *= 2);
2289 /* end = read_buffer + read_buffer_size; */ 2290 p = read_buffer + offset;
2291 end = read_buffer + read_buffer_size;
2290 } 2292 }
2291 *p = 0; 2293 *p = 0;
2292 if (c >= 0) 2294 if (c >= 0)
2293 UNREAD (c); 2295 UNREAD (c);
2294 } 2296 }